diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile | 4 | ||||
-rwxr-xr-x | tests/parallel-signatures.py | 409 | ||||
-rw-r--r-- | tests/test-aes-key-wrap.c | 2 | ||||
-rw-r--r-- | tests/test-ecdsa.c | 2 | ||||
-rw-r--r-- | tests/test-hash.c | 2 | ||||
-rw-r--r-- | tests/test-hashsig.h | 925 | ||||
-rw-r--r-- | tests/test-pbkdf2.c | 2 | ||||
-rw-r--r-- | tests/test-rpc_hashsig.c | 594 | ||||
-rw-r--r-- | tests/test-rsa.c | 23 | ||||
-rw-r--r-- | tests/test-trng.c | 1 | ||||
-rw-r--r-- | tests/test-xdr.c | 111 | ||||
-rwxr-xr-x | tests/time-keygen.py | 37 |
12 files changed, 2100 insertions, 12 deletions
diff --git a/tests/Makefile b/tests/Makefile index 79cb3ff..d186000 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -45,7 +45,7 @@ CFLAGS ?= -g3 -Wall -fPIC -std=c99 -I${LIBHAL_SRC} -I${LIBTFM_BLD} CORE_TESTS = test-aes-key-wrap test-hash test-pbkdf2 test-ecdsa test-bus test-trng test-rsa test-mkmif SERVER_TESTS = test-rpc_server -CLIENT_TESTS = test-rpc_hash test-rpc_pkey test-rpc_get_version test-rpc_get_random test-rpc_login test-rpc_bighash +CLIENT_TESTS = test-rpc_hash test-rpc_pkey test-rpc_get_version test-rpc_get_random test-rpc_login test-rpc_bighash test-xdr test-rpc_hashsig ALL_TESTS = ${CORE_TESTS} ${SERVER_TESTS} ${CLIENT_TESTS} @@ -78,3 +78,5 @@ ${BIN}: %: %.o ${LIBS} %.o: %.c ${LBHAL_SRC}/*.h ${LIBTFM_BLD}/tfm.h ${CC} ${CFLAGS} -c -o $@ $< + +test-rpc_hashsig.o: test-hashsig.h diff --git a/tests/parallel-signatures.py b/tests/parallel-signatures.py new file mode 100755 index 0000000..006b753 --- /dev/null +++ b/tests/parallel-signatures.py @@ -0,0 +1,409 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016-2018, NORDUnet A/S +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# - Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# +# - Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# - Neither the name of the NORDUnet nor the names of its contributors may +# be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +""" +Test multiple clients and parallel RSA signatures. +""" + +# This was originally going to be a complete asynchronous-capable +# version of cryptech.libhal, but that turned into a yak shaving +# exercise, so refocused on just solving the immediate task at hand, +# to wit, parallel signing tests. + +import os +import sys +import uuid +import xdrlib +import socket +import logging +import datetime +import collections + +import cryptech.libhal + +from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter + +from tornado.gen import Return, coroutine +from tornado.ioloop import IOLoop +from tornado.iostream import IOStream, StreamClosedError +from tornado.queues import Queue + +from Crypto.Util.asn1 import DerSequence, DerNull, DerOctetString +from Crypto.Util.number import inverse +from Crypto.PublicKey import RSA +from Crypto.Cipher.PKCS1_v1_5 import PKCS115_Cipher +from Crypto.Signature.PKCS1_v1_5 import PKCS115_SigScheme +from Crypto.Hash.SHA256 import SHA256Hash as SHA256 +from Crypto.Hash.SHA384 import SHA384Hash as SHA384 +from Crypto.Hash.SHA512 import SHA512Hash as SHA512 + + +logger = logging.getLogger(__name__) + + +globals().update((name, getattr(cryptech.libhal, name)) + for name in dir(cryptech.libhal) + if any(name.startswith(prefix) + for prefix in ("HAL", "RPC", "SLIP"))) + + +class PKey(cryptech.libhal.Handle): + + def __init__(self, hsm, handle, uuid): + self.hsm = hsm + self.handle = handle + self.uuid = uuid + self.deleted = False + + @coroutine + def close(self): + yield self.hsm.pkey_close(self) + + @coroutine + def delete(self): + yield self.hsm.pkey_delete(self) + self.deleted = True + + @coroutine + def sign(self, data, length = 1024): + r = yield self.hsm.pkey_sign(self, data = data, length = length) + raise Return(r) + + @coroutine + def verify(self, data = "", signature = None): + yield self.hsm.pkey_verify(self, data = data, signature = signature) + + +class ContextManagedUnpacker(xdrlib.Unpacker): + def __enter__(self): + return self + def __exit__(self, exc_type, exc_val, exc_tb): + self.done() + + +class HSM(cryptech.libhal.HSM): + + def __init__(self, + sockname = os.getenv("CRYPTECH_RPC_CLIENT_SOCKET_NAME", + "/tmp/.cryptech_muxd.rpc"), + debug_io = False): + self.hsm = self + self.debug_io = debug_io + self.socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) + self.socket.connect(sockname) + self.iostream = IOStream(self.socket) + + @coroutine + def rpc(self, code, *args, **kwargs): + client = kwargs.get("client", 0) + packer = xdrlib.Packer() + packer.pack_uint(code) + packer.pack_uint(client) + self._pack_args(packer, args) + packer = cryptech.libhal.slip_encode(packer.get_buffer()) + if self.debug_io: + logger.debug("send: %s", ":".join("{:02x}".format(ord(c)) for c in packer)) + yield self.iostream.write(packer) + while True: + try: + unpacker = yield self.iostream.read_until(SLIP_END) + except StreamClosedError: + raise HAL_ERROR_RPC_TRANSPORT() + if self.debug_io: + logger.debug("recv: %s", ":".join("{:02x}".format(ord(c)) for c in unpacker)) + unpacker = cryptech.libhal.slip_decode(unpacker) + if not unpacker: + continue + unpacker = ContextManagedUnpacker("".join(unpacker)) + if unpacker.unpack_uint() == code: + break + client = unpacker.unpack_uint() + self._raise_if_error(unpacker.unpack_uint()) + raise Return(unpacker) + + @coroutine + def login(self, user, pin, client = 0): + with (yield self.rpc(RPC_FUNC_LOGIN, user, pin, client = client)): + pass + + @coroutine + def logout(self, client = 0): + with (yield self.rpc(RPC_FUNC_LOGOUT, client = client)): + pass + + @coroutine + def pkey_load(self, der, flags = 0, client = 0, session = 0): + r = yield self.rpc(RPC_FUNC_PKEY_LOAD, session, der, flags, client = client) + with r: + pkey = PKey(self, r.unpack_uint(), cryptech.libhal.UUID(bytes = r.unpack_bytes())) + logger.debug("Loaded pkey %s", pkey.uuid) + raise Return(pkey) + + @coroutine + def pkey_close(self, pkey): + try: + logger.debug("Closing pkey %s", pkey.uuid) + except AttributeError: + pass + with (yield self.rpc(RPC_FUNC_PKEY_CLOSE, pkey)): + pass + + @coroutine + def pkey_delete(self, pkey): + try: + logger.debug("Deleting pkey %s", pkey.uuid) + except AttributeError: + pass + with (yield self.rpc(RPC_FUNC_PKEY_DELETE, pkey)): + pass + + @coroutine + def pkey_sign(self, pkey, data, length = 1024): + with (yield self.rpc(RPC_FUNC_PKEY_SIGN, pkey, 0, data, length)) as r: + raise Return(r.unpack_bytes()) + + +def pkcs1_hash_and_pad(text): + return DerSequence([DerSequence([SHA256.oid, DerNull().encode()]).encode(), + DerOctetString(SHA256(text).digest()).encode()]).encode() + + +@coroutine +def worker(args, k, p, q, r, m): + while True: + n = yield q.get() + logger.debug("Signing %s", n) + try: + t0 = datetime.datetime.now() + s = yield p.sign(data = m) + t1 = datetime.datetime.now() + if args.verify: + k.verify(s) + r.add(t0, t1) + except: + logger.exception("Signature failed") + finally: + q.task_done() + +@coroutine +def main(): + parser = ArgumentParser(description = __doc__, formatter_class = ArgumentDefaultsHelpFormatter) + parser.add_argument("-i", "--iterations", default = 1000, type = int, help = "iterations") + parser.add_argument("-k", "--key", choices = tuple(key_table), + default = "rsa_2048", help = "key to test") + parser.add_argument("-p", "--pin", default = "fnord", help = "user PIN") + parser.add_argument("-q", "--quiet", action = "store_true", help = "be less chatty") + parser.add_argument("-t", "--text", default = "Hamsters'R'Us", help = "plaintext to sign") + parser.add_argument("-v", "--verify", action = "store_true", help = "verify signatures") + parser.add_argument("-w", "--workers", default = 4, type = int, help = "worker count") + args = parser.parse_args() + + k = key_table[args.key] + q = Queue() + + tbs = pkcs1_hash_and_pad(args.text) + der = k.exportKey(format = "DER", pkcs = 8) + + hsms = [HSM() for i in xrange(args.workers)] + + for hsm in hsms: + yield hsm.login(HAL_USER_NORMAL, args.pin) + + pkeys = yield [hsm.pkey_load(der, HAL_KEY_FLAG_USAGE_DIGITALSIGNATURE) for hsm in hsms] + + r = Result(args, args.key) + + for pkey in pkeys: + IOLoop.current().spawn_callback(worker, args, k, pkey, q, r, tbs) + + yield [q.put(i) for i in xrange(args.iterations)] + yield q.join() + + yield [pkey.delete() for pkey in pkeys] + + r.report() + + +class Result(object): + + def __init__(self, args, name): + self.args = args + self.name = name + self.sum = datetime.timedelta(seconds = 0) + self.t0 = None + self.t1 = None + self.n = 0 + + def add(self, t0, t1): + if self.t0 is None: + self.t0 = t0 + self.t1 = t1 + delta = t1 - t0 + self.sum += delta + self.n += 1 + if not self.args.quiet: + sys.stdout.write("\r{:4d} {}".format(self.n, delta)) + sys.stdout.flush() + + @property + def mean(self): + return self.sum / self.n + + @property + def secs_per_sig(self): + return (self.t1 - self.t0) / self.n + + @property + def sigs_per_sec(self): + return self.n / (self.t1 - self.t0).total_seconds() + + @property + def speedup(self): + return self.sum.total_seconds() / (self.t1 - self.t0).total_seconds() + + def report(self): + sys.stdout.write(("\r{0.name} " + "sigs/sec {0.sigs_per_sec} " + "secs/sig {0.secs_per_sig} " + "mean {0.mean} " + "speedup {0.speedup} " + "(n {0.n}, " + "t0 {0.t0} " + "t1 {0.t1})\n").format(self)) + sys.stdout.flush() + + +key_table = collections.OrderedDict() + +key_table.update(rsa_1024 = RSA.importKey('''\ +-----BEGIN RSA PRIVATE KEY----- +MIICXQIBAAKBgQC95QlDOvlQhdCe/a7eIoX9SGPVfXfA8/62ilnF+NcwLrhxkr2R +4EVQB65+9AbxqM8Hqol6fhZzmDs48cl2tOFGJpE8iMhiFm4i6SGl2RXYaG0xi+lJ +FrXXCLFQovIEMuukBE129wra1xIB72tYR14lu8REX+Mhpbuz44M1jlCrlQIDAQAB +AoGAeU928l8bZIiH9PnlG318kYkMVhd4SGjXQK/zl9hXSC2goNV4i1d1kCHIJMwq +H3mTALe+aeVg3GnU85Tq+g2llzogoyXl8q902KbvImrM/XSbsue9/oj0OSgw+jKB +faFzX6FxAtNV5pmU9QiwauBIl/3yPCF9ifim5zg+pWCqLaECQQD59Z/R6TrTHxp6 +w2vH4CJyP5KORcf+eMa50SAriMVBXsJzsBiLLVxKIZfWbQn9gytJqJZKmIHezZQm +dyam84fpAkEAwnvSF27RhxLXE037+t7k5MZti6BfNTeUBrwffteepL6qax9HK+h9 +IQZ1vfNIqjZm8i7kQQyy4L8tRnk8mjZmzQJBAIUwfXWTilW+yBRMFx1M7+3itAv9 +YODWqEWRCkxIN5tqi8CrP5jBleCmX8rRFTaxcxpvq42aD/GRp3SLntvs/ikCQCSg +GOKc1gyv+Z0DFK8cBtMmoz6mRwfInbHe/7dtd8zis0lVLJwSPm5Xvxi0ljyn3h9B +wW6Wq6Ezn50j+8u27wkCQQCcIFE01BDAdtFHtTJ3aaEM9IdMCYrcJ0I/Y0NTE2M6 +lsTSiPyQjc4dQQJxFduvWHLx28bx+l7FTav7FaKntCJo +-----END RSA PRIVATE KEY----- +''')) + +key_table.update(rsa_2048 = RSA.importKey('''\ +-----BEGIN R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dTbfVly1gATDcCgYEAyOaoWmFL3k7hl1SLx9eR +YVj0Q3iNk0XX5BPjTmxIQCEjYVwRHFh1d897Rhk0kja26kepmypH0UADXNaofDqa +lpE10CZhGIOz1sTr6ICBCbscrN6VpgH5GGTa5AjPVNijNBBa1/DZjOWCzIGnOKuC +kWLicE3E4gIN/exBKOQdNqkCgYEAjA5PMg38BoGexoCvad8L81b4qqUvSg0HGv91 +X1Plp3hvXRWKoFHUKWlox528UoOPz8V2ReteIZXQ1BhdSMtBKO8lPHa0CyuW/XR3 +CdCY/Jorfg7HW1WlU0fRpxHPf8xdxAxGzhK1T86kM+kWrIpqnzf62zy5TK1HUYfW +WC8DhOECgYBzU8hIA0PU7aRPUs0o9MO9XcvVPvdX6UOKdNb9CnBMudS/chKHJUYP +d0fFAiVaRX0JMQ0RSrenxCqfWVtW3T3wFYNHB/IFRIUT3I44wwXJTNOeoi3FDTMx +EQfc0UFoFHyc3mYEKR4zHheqQG5OFBN89LqG3S+O69vc1qwCvNKL+Q== +-----END RSA PRIVATE KEY----- +''')) + +key_table.update(rsa_4096 = RSA.importKey('''\ +-----BEGIN RSA PRIVATE KEY----- +MIIJKAIBAAKCAgEAzWpYSQt+DrUNI+EJT/ko92wM2POfFnmm3Kc34nmuK6sez0DJ +r9Vib9R5K46RNgqcUdAodjU6cy3/MZA53SqP7RwR/LQtWmK2a+T4iey2vQZ0iCDA +2NI4gjgmCAjZnOD/m5yUXjCig/wJ8pGXolg8oHnvdeLg1joIOSF9OudLrI6aJnDg +OfdegzmCWXmWl7TXrqHVIWZhZZF7qQZRso6ZQ1/8mjpvVD0drASBxMnIzvpe4ynr +Y2NB807X/D5bbScp292ZKTNf5unPN1SsFy5ymzfLZrfNksYef6xPXcVr6OiObi49 +De8e11aNPj6fgLzzqAu1rjjrDkgvXx5G7gPJXq1aq6uxB2cKMrRS+ivmyC8vQlzP +lQwW20oYeeOfCg7ddNAJcu3jNTuNJaZdhc9szpVhV8DXZoXe/RzUNjZH7wUque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xMzgO0xmg2J1taDwFl74zHyjeG4bz77IX6JQ8I4C9TX5+YH3lyqsiBrF6x +M6g6k9Ozh24/zhO3pPVfymmUtX/O20nLxzi5v4H9dfwULxVia33upsxvOaUYiNlX +K5J641gGbmE93UN7X4HhhhTStrHnkEpalDEASKOPKSCQ3M/U9ptYUoVURuyGDYkB +wkcOl0HLtdcBwLN59lWkr7X519fNREUCggEBAMk39k+shD2DW8ubE/LgoforwfT2 +558FPxpZ+pGwMHL3ZnLuQuiROyPyQZj/ZmmLAa2TPrwS/ssln46Y2KesejWK/0Hq +8SaFLhOjacF8u5IOOKBZvx+HOT6ctRNBVyzt9A8wu0DE6nzc5HQpm9TMXrOLuZ0L +u22yFikwoIgYpU6hBdbg1mnirZS/ZyqJV9gWB6ZYyUAUGdgBqL6euSAAqBp93qz8 +sQLesqTufT1mVZd/ndLyvjDJjNKUE0w1g/1xNtg6N5aM+7pc/DwE/s+EtCxc/858 +dQYLBHIPcw6e0FdL3nTs44BpAqcK28N5eWbe/KaZ3EA0lHRmyOQ++WgU6jo= +-----END RSA PRIVATE KEY----- +''')) + +if __name__ == "__main__": + IOLoop.current().run_sync(main) diff --git a/tests/test-aes-key-wrap.c b/tests/test-aes-key-wrap.c index 5ecd46d..aa894cc 100644 --- a/tests/test-aes-key-wrap.c +++ b/tests/test-aes-key-wrap.c @@ -163,7 +163,7 @@ static int run_test(hal_core_t *core, return ok1 && ok2; } -int main (int argc, char *argv[]) +int main(void) { int failures = 0; diff --git a/tests/test-ecdsa.c b/tests/test-ecdsa.c index da2b367..fe04a87 100644 --- a/tests/test-ecdsa.c +++ b/tests/test-ecdsa.c @@ -359,7 +359,7 @@ static void show_core(const hal_core_t *core, const char *whinge) printf("%s core not present\n", whinge); } -int main(int argc, char *argv[]) +int main(void) { const hal_core_t *sha256_core = hal_core_find(SHA256_NAME, NULL); const hal_core_t *sha512_core = hal_core_find(SHA512_NAME, NULL); diff --git a/tests/test-hash.c b/tests/test-hash.c index 4e78243..20bd446 100644 --- a/tests/test-hash.c +++ b/tests/test-hash.c @@ -652,7 +652,7 @@ static void show_core(hal_core_t *core, const char *whinge) printf("%s core not present\n", whinge); } -int main (int argc, char *argv[]) +int main(void) { hal_core_t * const sha1_core = hal_core_find(SHA1_NAME, NULL); hal_core_t * const sha256_core = hal_core_find(SHA256_NAME, NULL); diff --git a/tests/test-hashsig.h b/tests/test-hashsig.h new file mode 100644 index 0000000..4b8333f --- /dev/null +++ b/tests/test-hashsig.h @@ -0,0 +1,925 @@ +/* + * draft-mcgrew test cases + */ + +/* Test Case 1 Public Key */ + +static uint8_t tc1_key[] = { + 0x00, 0x00, 0x00, 0x02, + 0x00, 0x00, 0x00, 0x05, + 0x00, 0x00, 0x00, 0x04, + 0x61, 0xa5, 0xd5, 0x7d, 0x37, 0xf5, 0xe4, 0x6b, + 0xfb, 0x75, 0x20, 0x80, 0x6b, 0x07, 0xa1, 0xb8, + 0x50, 0x65, 0x0e, 0x3b, 0x31, 0xfe, 0x4a, 0x77, + 0x3e, 0xa2, 0x9a, 0x07, 0xf0, 0x9c, 0xf2, 0xea, + 0x30, 0xe5, 0x79, 0xf0, 0xdf, 0x58, 0xef, 0x8e, + 0x29, 0x8d, 0xa0, 0x43, 0x4c, 0xb2, 0xb8, 0x78, +}; + +/* Test Case 1 Message */ + +static uint8_t tc1_msg[] = { + 0x54, 0x68, 0x65, 0x20, 0x70, 0x6f, 0x77, 0x65, + 0x72, 0x73, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x64, + 0x65, 0x6c, 0x65, 0x67, 0x61, 0x74, 0x65, 0x64, + 0x20, 0x74, 0x6f, 0x20, 0x74, 0x68, 0x65, 0x20, + 0x55, 0x6e, 0x69, 0x74, 0x65, 0x64, 0x20, 0x53, + 0x74, 0x61, 0x74, 0x65, 0x73, 0x20, 0x62, 0x79, + 0x20, 0x74, 0x68, 0x65, 0x20, 0x43, 0x6f, 0x6e, + 0x73, 0x74, 0x69, 0x74, 0x75, 0x74, 0x69, 0x6f, + 0x6e, 0x2c, 0x20, 0x6e, 0x6f, 0x72, 0x20, 0x70, + 0x72, 0x6f, 0x68, 0x69, 0x62, 0x69, 0x74, 0x65, + 0x64, 0x20, 0x62, 0x79, 0x20, 0x69, 0x74, 0x20, + 0x74, 0x6f, 0x20, 0x74, 0x68, 0x65, 0x20, 0x53, + 0x74, 0x61, 0x74, 0x65, 0x73, 0x2c, 0x20, 0x61, + 0x72, 0x65, 0x20, 0x72, 0x65, 0x73, 0x65, 0x72, + 0x76, 0x65, 0x64, 0x20, 0x74, 0x6f, 0x20, 0x74, + 0x68, 0x65, 0x20, 0x53, 0x74, 0x61, 0x74, 0x65, + 0x73, 0x20, 0x72, 0x65, 0x73, 0x70, 0x65, 0x63, + 0x74, 0x69, 0x76, 0x65, 0x6c, 0x79, 0x2c, 0x20, + 0x6f, 0x72, 0x20, 0x74, 0x6f, 0x20, 0x74, 0x68, + 0x65, 0x20, 0x70, 0x65, 0x6f, 0x70, 0x6c, 0x65, + 0x2e, 0x0a, +}; + +/* Test Case 1 Signature */ +/* 2 levels, both h=5, w=8 */ + +static uint8_t tc1_sig[] = { + 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x05, + 0x00, 0x00, 0x00, 0x04, + 0xd3, 0x2b, 0x56, 0x67, 0x1d, 0x7e, 0xb9, 0x88, + 0x33, 0xc4, 0x9b, 0x43, 0x3c, 0x27, 0x25, 0x86, + 0xbc, 0x4a, 0x1c, 0x8a, 0x89, 0x70, 0x52, 0x8f, + 0xfa, 0x04, 0xb9, 0x66, 0xf9, 0x42, 0x6e, 0xb9, + 0x96, 0x5a, 0x25, 0xbf, 0xd3, 0x7f, 0x19, 0x6b, + 0x90, 0x73, 0xf3, 0xd4, 0xa2, 0x32, 0xfe, 0xb6, + 0x91, 0x28, 0xec, 0x45, 0x14, 0x6f, 0x86, 0x29, + 0x2f, 0x9d, 0xff, 0x96, 0x10, 0xa7, 0xbf, 0x95, + 0xa6, 0x4c, 0x7f, 0x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x62, 0x03, + 0x5a, 0xbc, 0x9a, 0x70, 0x1b, 0x47, 0x3e, 0xcb, + 0xc3, 0x94, 0x3c, 0x6b, 0x9c, 0x4f, 0x24, 0x05, + 0xa3, 0xcb, 0x8b, 0xf8, 0xa6, 0x91, 0xca, 0x51, + 0xd3, 0xf6, 0xad, 0x2f, 0x42, 0x8b, 0xab, 0x6f, + 0x3a, 0x30, 0xf5, 0x5d, 0xd9, 0x62, 0x55, 0x63, + 0xf0, 0xa7, 0x5e, 0xe3, 0x90, 0xe3, 0x85, 0xe3, + 0xae, 0x0b, 0x90, 0x69, 0x61, 0xec, 0xf4, 0x1a, + 0xe0, 0x73, 0xa0, 0x59, 0x0c, 0x2e, 0xb6, 0x20, + 0x4f, 0x44, 0x83, 0x1c, 0x26, 0xdd, 0x76, 0x8c, + 0x35, 0xb1, 0x67, 0xb2, 0x8c, 0xe8, 0xdc, 0x98, + 0x8a, 0x37, 0x48, 0x25, 0x52, 0x30, 0xce, 0xf9, + 0x9e, 0xbf, 0x14, 0xe7, 0x30, 0x63, 0x2f, 0x27, + 0x41, 0x44, 0x89, 0x80, 0x8a, 0xfa, 0xb1, 0xd1, + 0xe7, 0x83, 0xed, 0x04, 0x51, 0x6d, 0xe0, 0x12, + 0x49, 0x86, 0x82, 0x21, 0x2b, 0x07, 0x81, 0x05, + 0x79, 0xb2, 0x50, 0x36, 0x59, 0x41, 0xbc, 0xc9, + 0x81, 0x42, 0xda, 0x13, 0x60, 0x9e, 0x97, 0x68, + 0xaa, 0xf6, 0x5d, 0xe7, 0x62, 0x0d, 0xab, 0xec, + 0x29, 0xeb, 0x82, 0xa1, 0x7f, 0xde, 0x35, 0xaf, + 0x15, 0xad, 0x23, 0x8c, 0x73, 0xf8, 0x1b, 0xdb, + 0x8d, 0xec, 0x2f, 0xc0, 0xe7, 0xf9, 0x32, 0x70, + 0x10, 0x99, 0x76, 0x2b, 0x37, 0xf4, 0x3c, 0x4a, + 0x3c, 0x20, 0x01, 0x0a, 0x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0x50, 0xe3, 0xee, 0xbd, 0xfe, 0xd3, 0x9c, 0xbd, + 0xc3, 0xce, 0x97, 0x04, 0x88, 0x2a, 0x20, 0x72, + 0xc7, 0x5e, 0x13, 0x52, 0x7b, 0x7a, 0x58, 0x1a, + 0x55, 0x61, 0x68, 0x78, 0x3d, 0xc1, 0xe9, 0x75, + 0x45, 0xe3, 0x18, 0x65, 0xdd, 0xc4, 0x6b, 0x3c, + 0x95, 0x78, 0x35, 0xda, 0x25, 0x2b, 0xb7, 0x32, + 0x8d, 0x3e, 0xe2, 0x06, 0x24, 0x45, 0xdf, 0xb8, + 0x5e, 0xf8, 0xc3, 0x5f, 0x8e, 0x1f, 0x33, 0x71, + 0xaf, 0x34, 0x02, 0x3c, 0xef, 0x62, 0x6e, 0x0a, + 0xf1, 0xe0, 0xbc, 0x01, 0x73, 0x51, 0xaa, 0xe2, + 0xab, 0x8f, 0x5c, 0x61, 0x2e, 0xad, 0x0b, 0x72, + 0x9a, 0x1d, 0x05, 0x9d, 0x02, 0xbf, 0xe1, 0x8e, + 0xfa, 0x97, 0x1b, 0x73, 0x00, 0xe8, 0x82, 0x36, + 0x0a, 0x93, 0xb0, 0x25, 0xff, 0x97, 0xe9, 0xe0, + 0xee, 0xc0, 0xf3, 0xf3, 0xf1, 0x30, 0x39, 0xa1, + 0x7f, 0x88, 0xb0, 0xcf, 0x80, 0x8f, 0x48, 0x84, + 0x31, 0x60, 0x6c, 0xb1, 0x3f, 0x92, 0x41, 0xf4, + 0x0f, 0x44, 0xe5, 0x37, 0xd3, 0x02, 0xc6, 0x4a, + 0x4f, 0x1f, 0x4a, 0xb9, 0x49, 0xb9, 0xfe, 0xef, + 0xad, 0xcb, 0x71, 0xab, 0x50, 0xef, 0x27, 0xd6, + 0xd6, 0xca, 0x85, 0x10, 0xf1, 0x50, 0xc8, 0x5f, + 0xb5, 0x25, 0xbf, 0x25, 0x70, 0x3d, 0xf7, 0x20, + 0x9b, 0x60, 0x66, 0xf0, 0x9c, 0x37, 0x28, 0x0d, + 0x59, 0x12, 0x8d, 0x2f, 0x0f, 0x63, 0x7c, 0x7d, + 0x7d, 0x7f, 0xad, 0x4e, 0xd1, 0xc1, 0xea, 0x04, + 0xe6, 0x28, 0xd2, 0x21, 0xe3, 0xd8, 0xdb, 0x77, + 0xb7, 0xc8, 0x78, 0xc9, 0x41, 0x1c, 0xaf, 0xc5, + 0x07, 0x1a, 0x34, 0xa0, 0x0f, 0x4c, 0xf0, 0x77, + 0x38, 0x91, 0x27, 0x53, 0xdf, 0xce, 0x48, 0xf0, + 0x75, 0x76, 0xf0, 0xd4, 0xf9, 0x4f, 0x42, 0xc6, + 0xd7, 0x6f, 0x7c, 0xe9, 0x73, 0xe9, 0x36, 0x70, + 0x95, 0xba, 0x7e, 0x9a, 0x36, 0x49, 0xb7, 0xf4, + 0x61, 0xd9, 0xf9, 0xac, 0x13, 0x32, 0xa4, 0xd1, + 0x04, 0x4c, 0x96, 0xae, 0xfe, 0xe6, 0x76, 0x76, + 0x40, 0x1b, 0x64, 0x45, 0x7c, 0x54, 0xd6, 0x5f, + 0xef, 0x65, 0x00, 0xc5, 0x9c, 0xdf, 0xb6, 0x9a, + 0xf7, 0xb6, 0xdd, 0xdf, 0xcb, 0x0f, 0x08, 0x62, + 0x78, 0xdd, 0x8a, 0xd0, 0x68, 0x60, 0x78, 0xdf, + 0xb0, 0xf3, 0xf7, 0x9c, 0xd8, 0x93, 0xd3, 0x14, + 0x16, 0x86, 0x48, 0x49, 0x98, 0x98, 0xfb, 0xc0, + 0xce, 0xd5, 0xf9, 0x5b, 0x74, 0xe8, 0xff, 0x14, + 0xd7, 0x35, 0xcd, 0xea, 0x96, 0x8b, 0xee, 0x74, + 0x00, 0x00, 0x00, 0x05, + 0xd8, 0xb8, 0x11, 0x2f, 0x92, 0x00, 0xa5, 0xe5, + 0x0c, 0x4a, 0x26, 0x21, 0x65, 0xbd, 0x34, 0x2c, + 0xd8, 0x00, 0xb8, 0x49, 0x68, 0x10, 0xbc, 0x71, + 0x62, 0x77, 0x43, 0x5a, 0xc3, 0x76, 0x72, 0x8d, + 0x12, 0x9a, 0xc6, 0xed, 0xa8, 0x39, 0xa6, 0xf3, + 0x57, 0xb5, 0xa0, 0x43, 0x87, 0xc5, 0xce, 0x97, + 0x38, 0x2a, 0x78, 0xf2, 0xa4, 0x37, 0x29, 0x17, + 0xee, 0xfc, 0xbf, 0x93, 0xf6, 0x3b, 0xb5, 0x91, + 0x12, 0xf5, 0xdb, 0xe4, 0x00, 0xbd, 0x49, 0xe4, + 0x50, 0x1e, 0x85, 0x9f, 0x88, 0x5b, 0xf0, 0x73, + 0x6e, 0x90, 0xa5, 0x09, 0xb3, 0x0a, 0x26, 0xbf, + 0xac, 0x8c, 0x17, 0xb5, 0x99, 0x1c, 0x15, 0x7e, + 0xb5, 0x97, 0x11, 0x15, 0xaa, 0x39, 0xef, 0xd8, + 0xd5, 0x64, 0xa6, 0xb9, 0x02, 0x82, 0xc3, 0x16, + 0x8a, 0xf2, 0xd3, 0x0e, 0xf8, 0x9d, 0x51, 0xbf, + 0x14, 0x65, 0x45, 0x10, 0xa1, 0x2b, 0x8a, 0x14, + 0x4c, 0xca, 0x18, 0x48, 0xcf, 0x7d, 0xa5, 0x9c, + 0xc2, 0xb3, 0xd9, 0xd0, 0x69, 0x2d, 0xd2, 0xa2, + 0x0b, 0xa3, 0x86, 0x34, 0x80, 0xe2, 0x5b, 0x1b, + 0x85, 0xee, 0x86, 0x0c, 0x62, 0xbf, 0x51, 0x36, + 0x00, 0x00, 0x00, 0x05, + 0x00, 0x00, 0x00, 0x04, + 0xd2, 0xf1, 0x4f, 0xf6, 0x34, 0x6a, 0xf9, 0x64, + 0x56, 0x9f, 0x7d, 0x6c, 0xb8, 0x80, 0xa1, 0xb6, + 0x6c, 0x50, 0x04, 0x91, 0x7d, 0xa6, 0xea, 0xfe, + 0x4d, 0x9e, 0xf6, 0xc6, 0x40, 0x7b, 0x3d, 0xb0, + 0xe5, 0x48, 0x5b, 0x12, 0x2d, 0x9e, 0xbe, 0x15, + 0xcd, 0xa9, 0x3c, 0xfe, 0xc5, 0x82, 0xd7, 0xab, + 0x00, 0x00, 0x00, 0x0a, + 0x00, 0x00, 0x00, 0x04, + 0x07, 0x03, 0xc4, 0x91, 0xe7, 0x55, 0x8b, 0x35, + 0x01, 0x1e, 0xce, 0x35, 0x92, 0xea, 0xa5, 0xda, + 0x4d, 0x91, 0x87, 0x86, 0x77, 0x12, 0x33, 0xe8, + 0x35, 0x3b, 0xc4, 0xf6, 0x23, 0x23, 0x18, 0x5c, + 0x95, 0xca, 0xe0, 0x5b, 0x89, 0x9e, 0x35, 0xdf, + 0xfd, 0x71, 0x70, 0x54, 0x70, 0x62, 0x09, 0x98, + 0x8e, 0xbf, 0xdf, 0x6e, 0x37, 0x96, 0x0b, 0xb5, + 0xc3, 0x8d, 0x76, 0x57, 0xe8, 0xbf, 0xfe, 0xef, + 0x9b, 0xc0, 0x42, 0xda, 0x4b, 0x45, 0x25, 0x65, + 0x04, 0x85, 0xc6, 0x6d, 0x0c, 0xe1, 0x9b, 0x31, + 0x75, 0x87, 0xc6, 0xba, 0x4b, 0xff, 0xcc, 0x42, + 0x8e, 0x25, 0xd0, 0x89, 0x31, 0xe7, 0x2d, 0xfb, + 0x6a, 0x12, 0x0c, 0x56, 0x12, 0x34, 0x42, 0x58, + 0xb8, 0x5e, 0xfd, 0xb7, 0xdb, 0x1d, 0xb9, 0xe1, + 0x86, 0x5a, 0x73, 0xca, 0xf9, 0x65, 0x57, 0xeb, + 0x39, 0xed, 0x3e, 0x3f, 0x42, 0x69, 0x33, 0xac, + 0x9e, 0xed, 0xdb, 0x03, 0xa1, 0xd2, 0x37, 0x4a, + 0xf7, 0xbf, 0x77, 0x18, 0x55, 0x77, 0x45, 0x62, + 0x37, 0xf9, 0xde, 0x2d, 0x60, 0x11, 0x3c, 0x23, + 0xf8, 0x46, 0xdf, 0x26, 0xfa, 0x94, 0x20, 0x08, + 0xa6, 0x98, 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 0x4e, 0x71, 0x33, 0x9e, + 0xce, 0x78, 0x0f, 0xd0, 0x25, 0xbd, 0x41, 0xec, + 0x34, 0xeb, 0xff, 0x9d, 0x42, 0x70, 0xa3, 0x22, + 0x4e, 0x01, 0x9f, 0xcb, 0x44, 0x44, 0x74, 0xd4, + 0x82, 0xfd, 0x2d, 0xbe, 0x75, 0xef, 0xb2, 0x03, + 0x89, 0xcc, 0x10, 0xcd, 0x60, 0x0a, 0xbb, 0x54, + 0xc4, 0x7e, 0xde, 0x93, 0xe0, 0x8c, 0x11, 0x4e, + 0xdb, 0x04, 0x11, 0x7d, 0x71, 0x4d, 0xc1, 0xd5, + 0x25, 0xe1, 0x1b, 0xed, 0x87, 0x56, 0x19, 0x2f, + 0x92, 0x9d, 0x15, 0x46, 0x2b, 0x93, 0x9f, 0xf3, + 0xf5, 0x2f, 0x22, 0x52, 0xda, 0x2e, 0xd6, 0x4d, + 0x8f, 0xae, 0x88, 0x81, 0x8b, 0x1e, 0xfa, 0x2c, + 0x7b, 0x08, 0xc8, 0x79, 0x4f, 0xb1, 0xb2, 0x14, + 0xaa, 0x23, 0x3d, 0xb3, 0x16, 0x28, 0x33, 0x14, + 0x1e, 0xa4, 0x38, 0x3f, 0x1a, 0x6f, 0x12, 0x0b, + 0xe1, 0xdb, 0x82, 0xce, 0x36, 0x30, 0xb3, 0x42, + 0x91, 0x14, 0x46, 0x31, 0x57, 0xa6, 0x4e, 0x91, + 0x23, 0x4d, 0x47, 0x5e, 0x2f, 0x79, 0xcb, 0xf0, + 0x5e, 0x4d, 0xb6, 0xa9, 0x40, 0x7d, 0x72, 0xc6, + 0xbf, 0xf7, 0xd1, 0x19, 0x8b, 0x5c, 0x4d, 0x6a, + 0xad, 0x28, 0x31, 0xdb, 0x61, 0x27, 0x49, 0x93, + 0x71, 0x5a, 0x01, 0x82, 0xc7, 0xdc, 0x80, 0x89, + 0xe3, 0x2c, 0x85, 0x31, 0xde, 0xed, 0x4f, 0x74, + 0x31, 0xc0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e2, 0xf2, 0x97, + 0x77, 0x4f, 0xe6, 0x05, 0x35, 0x98, 0x45, 0x7c, + 0xc6, 0x19, 0x08, 0x31, 0x8d, 0xe4, 0xb8, 0x26, + 0xf0, 0xfc, 0x86, 0xd4, 0xbb, 0x11, 0x7d, 0x33, + 0xe8, 0x65, 0xaa, 0x80, 0x50, 0x09, 0xcc, 0x29, + 0x18, 0xd9, 0xc2, 0xf8, 0x40, 0xc4, 0xda, 0x43, + 0xa7, 0x03, 0xad, 0x9f, 0x5b, 0x58, 0x06, 0x16, + 0x3d, 0x71, 0x61, 0x69, 0x6b, 0x5a, 0x0a, 0xdc, + 0x00, 0x00, 0x00, 0x05, + 0xd5, 0xc0, 0xd1, 0xbe, 0xbb, 0x06, 0x04, 0x8e, + 0xd6, 0xfe, 0x2e, 0xf2, 0xc6, 0xce, 0xf3, 0x05, + 0xb3, 0xed, 0x63, 0x39, 0x41, 0xeb, 0xc8, 0xb3, + 0xbe, 0xc9, 0x73, 0x87, 0x54, 0xcd, 0xdd, 0x60, + 0xe1, 0x92, 0x0a, 0xda, 0x52, 0xf4, 0x3d, 0x05, + 0x5b, 0x50, 0x31, 0xce, 0xe6, 0x19, 0x25, 0x20, + 0xd6, 0xa5, 0x11, 0x55, 0x14, 0x85, 0x1c, 0xe7, + 0xfd, 0x44, 0x8d, 0x4a, 0x39, 0xfa, 0xe2, 0xab, + 0x23, 0x35, 0xb5, 0x25, 0xf4, 0x84, 0xe9, 0xb4, + 0x0d, 0x6a, 0x4a, 0x96, 0x93, 0x94, 0x84, 0x3b, + 0xdc, 0xf6, 0xd1, 0x4c, 0x48, 0xe8, 0x01, 0x5e, + 0x08, 0xab, 0x92, 0x66, 0x2c, 0x05, 0xc6, 0xe9, + 0xf9, 0x0b, 0x65, 0xa7, 0xa6, 0x20, 0x16, 0x89, + 0x99, 0x9f, 0x32, 0xbf, 0xd3, 0x68, 0xe5, 0xe3, + 0xec, 0x9c, 0xb7, 0x0a, 0xc7, 0xb8, 0x39, 0x90, + 0x03, 0xf1, 0x75, 0xc4, 0x08, 0x85, 0x08, 0x1a, + 0x09, 0xab, 0x30, 0x34, 0x91, 0x1f, 0xe1, 0x25, + 0x63, 0x10, 0x51, 0xdf, 0x04, 0x08, 0xb3, 0x94, + 0x6b, 0x0b, 0xde, 0x79, 0x09, 0x11, 0xe8, 0x97, + 0x8b, 0xa0, 0x7d, 0xd5, 0x6c, 0x73, 0xe7, 0xee, +}; + +/* Test Case 2 Public Key */ + +static uint8_t tc2_key[] = { + 0x00, 0x00, 0x00, 0x02, + 0x00, 0x00, 0x00, 0x06, + 0x00, 0x00, 0x00, 0x03, + 0xd0, 0x8f, 0xab, 0xd4, 0xa2, 0x09, 0x1f, 0xf0, + 0xa8, 0xcb, 0x4e, 0xd8, 0x34, 0xe7, 0x45, 0x34, + 0x32, 0xa5, 0x88, 0x85, 0xcd, 0x9b, 0xa0, 0x43, + 0x12, 0x35, 0x46, 0x6b, 0xff, 0x96, 0x51, 0xc6, + 0xc9, 0x21, 0x24, 0x40, 0x4d, 0x45, 0xfa, 0x53, + 0xcf, 0x16, 0x1c, 0x28, 0xf1, 0xad, 0x5a, 0x8e, +}; + +/* Test Case 2 Message */ + +static uint8_t tc2_msg[] = { + 0x54, 0x68, 0x65, 0x20, 0x65, 0x6e, 0x75, 0x6d, + 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, + 0x69, 0x6e, 0x20, 0x74, 0x68, 0x65, 0x20, 0x43, + 0x6f, 0x6e, 0x73, 0x74, 0x69, 0x74, 0x75, 0x74, + 0x69, 0x6f, 0x6e, 0x2c, 0x20, 0x6f, 0x66, 0x20, + 0x63, 0x65, 0x72, 0x74, 0x61, 0x69, 0x6e, 0x20, + 0x72, 0x69, 0x67, 0x68, 0x74, 0x73, 0x2c, 0x20, + 0x73, 0x68, 0x61, 0x6c, 0x6c, 0x20, 0x6e, 0x6f, + 0x74, 0x20, 0x62, 0x65, 0x20, 0x63, 0x6f, 0x6e, + 0x73, 0x74, 0x72, 0x75, 0x65, 0x64, 0x20, 0x74, + 0x6f, 0x20, 0x64, 0x65, 0x6e, 0x79, 0x20, 0x6f, + 0x72, 0x20, 0x64, 0x69, 0x73, 0x70, 0x61, 0x72, + 0x61, 0x67, 0x65, 0x20, 0x6f, 0x74, 0x68, 0x65, + 0x72, 0x73, 0x20, 0x72, 0x65, 0x74, 0x61, 0x69, + 0x6e, 0x65, 0x64, 0x20, 0x62, 0x79, 0x20, 0x74, + 0x68, 0x65, 0x20, 0x70, 0x65, 0x6f, 0x70, 0x6c, + 0x65, 0x2e, 0x0a, +}; + +/* Test Case 2 Signature */ +/* 2 levels: h=10, w=4; h=5, w=8 */ + +static uint8_t tc2_sig[] = { + 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x03, + 0x00, 0x00, 0x00, 0x03, + 0x3d, 0x46, 0xbe, 0xe8, 0x66, 0x0f, 0x8f, 0x21, + 0x5d, 0x3f, 0x96, 0x40, 0x8a, 0x7a, 0x64, 0xcf, + 0x1c, 0x4d, 0xa0, 0x2b, 0x63, 0xa5, 0x5f, 0x62, + 0xc6, 0x66, 0xef, 0x57, 0x07, 0xa9, 0x14, 0xce, + 0x06, 0x74, 0xe8, 0xcb, 0x7a, 0x55, 0xf0, 0xc4, + 0x8d, 0x48, 0x4f, 0x31, 0xf3, 0xaa, 0x4a, 0xf9, + 0x71, 0x9a, 0x74, 0xf2, 0x2c, 0xf8, 0x23, 0xb9, + 0x44, 0x31, 0xd0, 0x1c, 0x92, 0x6e, 0x2a, 0x76, + 0xbb, 0x71, 0x22, 0x6d, 0x27, 0x97, 0x00, 0xec, + 0x81, 0xc9, 0xe9, 0x5f, 0xb1, 0x1a, 0x0d, 0x10, + 0xd0, 0x65, 0x27, 0x9a, 0x57, 0x96, 0xe2, 0x65, + 0xae, 0x17, 0x73, 0x7c, 0x44, 0xeb, 0x8c, 0x59, + 0x45, 0x08, 0xe1, 0x26, 0xa9, 0xa7, 0x87, 0x0b, + 0xf4, 0x36, 0x08, 0x20, 0xbd, 0xeb, 0x9a, 0x01, + 0xd9, 0x69, 0x37, 0x79, 0xe4, 0x16, 0x82, 0x8e, + 0x75, 0xbd, 0xdd, 0x7d, 0x8c, 0x70, 0xd5, 0x0a, + 0x0a, 0xc8, 0xba, 0x39, 0x81, 0x09, 0x09, 0xd4, + 0x45, 0xf4, 0x4c, 0xb5, 0xbb, 0x58, 0xde, 0x73, + 0x7e, 0x60, 0xcb, 0x43, 0x45, 0x30, 0x27, 0x86, + 0xef, 0x2c, 0x6b, 0x14, 0xaf, 0x21, 0x2c, 0xa1, + 0x9e, 0xde, 0xaa, 0x3b, 0xfc, 0xfe, 0x8b, 0xaa, + 0x66, 0x21, 0xce, 0x88, 0x48, 0x0d, 0xf2, 0x37, + 0x1d, 0xd3, 0x7a, 0xdd, 0x73, 0x2c, 0x9d, 0xe4, + 0xea, 0x2c, 0xe0, 0xdf, 0xfa, 0x53, 0xc9, 0x26, + 0x49, 0xa1, 0x8d, 0x39, 0xa5, 0x07, 0x88, 0xf4, + 0x65, 0x29, 0x87, 0xf2, 0x26, 0xa1, 0xd4, 0x81, + 0x68, 0x20, 0x5d, 0xf6, 0xae, 0x7c, 0x58, 0xe0, + 0x49, 0xa2, 0x5d, 0x49, 0x07, 0xed, 0xc1, 0xaa, + 0x90, 0xda, 0x8a, 0xa5, 0xe5, 0xf7, 0x67, 0x17, + 0x73, 0xe9, 0x41, 0xd8, 0x05, 0x53, 0x60, 0x21, + 0x5c, 0x6b, 0x60, 0xdd, 0x35, 0x46, 0x3c, 0xf2, + 0x24, 0x0a, 0x9c, 0x06, 0xd6, 0x94, 0xe9, 0xcb, + 0x54, 0xe7, 0xb1, 0xe1, 0xbf, 0x49, 0x4d, 0x0d, + 0x1a, 0x28, 0xc0, 0xd3, 0x1a, 0xcc, 0x75, 0x16, + 0x1f, 0x4f, 0x48, 0x5d, 0xfd, 0x3c, 0xb9, 0x57, + 0x8e, 0x83, 0x6e, 0xc2, 0xdc, 0x72, 0x2f, 0x37, + 0xed, 0x30, 0x87, 0x2e, 0x07, 0xf2, 0xb8, 0xbd, + 0x03, 0x74, 0xeb, 0x57, 0xd2, 0x2c, 0x61, 0x4e, + 0x09, 0x15, 0x0f, 0x6c, 0x0d, 0x87, 0x74, 0xa3, + 0x9a, 0x6e, 0x16, 0x82, 0x11, 0x03, 0x5d, 0xc5, + 0x29, 0x88, 0xab, 0x46, 0xea, 0xca, 0x9e, 0xc5, + 0x97, 0xfb, 0x18, 0xb4, 0x93, 0x6e, 0x66, 0xef, + 0x2f, 0x0d, 0xf2, 0x6e, 0x8d, 0x1e, 0x34, 0xda, + 0x28, 0xcb, 0xb3, 0xaf, 0x75, 0x23, 0x13, 0x72, + 0x0c, 0x7b, 0x34, 0x54, 0x34, 0xf7, 0x2d, 0x65, + 0x31, 0x43, 0x28, 0xbb, 0xb0, 0x30, 0xd0, 0xf0, + 0xf6, 0xd5, 0xe4, 0x7b, 0x28, 0xea, 0x91, 0x00, + 0x8f, 0xb1, 0x1b, 0x05, 0x01, 0x77, 0x05, 0xa8, + 0xbe, 0x3b, 0x2a, 0xdb, 0x83, 0xc6, 0x0a, 0x54, + 0xf9, 0xd1, 0xd1, 0xb2, 0xf4, 0x76, 0xf9, 0xe3, + 0x93, 0xeb, 0x56, 0x95, 0x20, 0x3d, 0x2b, 0xa6, + 0xad, 0x81, 0x5e, 0x6a, 0x11, 0x1e, 0xa2, 0x93, + 0xdc, 0xc2, 0x10, 0x33, 0xf9, 0x45, 0x3d, 0x49, + 0xc8, 0xe5, 0xa6, 0x38, 0x7f, 0x58, 0x8b, 0x1e, + 0xa4, 0xf7, 0x06, 0x21, 0x7c, 0x15, 0x1e, 0x05, + 0xf5, 0x5a, 0x6e, 0xb7, 0x99, 0x7b, 0xe0, 0x9d, + 0x56, 0xa3, 0x26, 0xa3, 0x2f, 0x9c, 0xba, 0x1f, + 0xbe, 0x1c, 0x07, 0xbb, 0x49, 0xfa, 0x04, 0xce, + 0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d, 0x71, 0x9b, 0x16, + 0x35, 0xa7, 0xd8, 0xa1, 0x38, 0x91, 0x95, 0x79, + 0x44, 0xb1, 0xc2, 0x9b, 0xb1, 0x01, 0x91, 0x3e, + 0x16, 0x6e, 0x11, 0xbd, 0x5f, 0x34, 0x18, 0x6f, + 0xa6, 0xc0, 0xa5, 0x55, 0xc9, 0x02, 0x6b, 0x25, + 0x6a, 0x68, 0x60, 0xf4, 0x86, 0x6b, 0xd6, 0xd0, + 0xb5, 0xbf, 0x90, 0x62, 0x70, 0x86, 0xc6, 0x14, + 0x91, 0x33, 0xf8, 0x28, 0x2c, 0xe6, 0xc9, 0xb3, + 0x62, 0x24, 0x42, 0x44, 0x3d, 0x5e, 0xca, 0x95, + 0x9d, 0x6c, 0x14, 0xca, 0x83, 0x89, 0xd1, 0x2c, + 0x40, 0x68, 0xb5, 0x03, 0xe4, 0xe3, 0xc3, 0x9b, + 0x63, 0x5b, 0xea, 0x24, 0x5d, 0x9d, 0x05, 0xa2, + 0x55, 0x8f, 0x24, 0x9c, 0x96, 0x61, 0xc0, 0x42, + 0x7d, 0x2e, 0x48, 0x9c, 0xa5, 0xb5, 0xdd, 0xe2, + 0x20, 0xa9, 0x03, 0x33, 0xf4, 0x86, 0x2a, 0xec, + 0x79, 0x32, 0x23, 0xc7, 0x81, 0x99, 0x7d, 0xa9, + 0x82, 0x66, 0xc1, 0x2c, 0x50, 0xea, 0x28, 0xb2, + 0xc4, 0x38, 0xe7, 0xa3, 0x79, 0xeb, 0x10, 0x6e, + 0xca, 0x0c, 0x7f, 0xd6, 0x00, 0x6e, 0x9b, 0xf6, + 0x12, 0xf3, 0xea, 0x0a, 0x45, 0x4b, 0xa3, 0xbd, + 0xb7, 0x6e, 0x80, 0x27, 0x99, 0x2e, 0x60, 0xde, + 0x01, 0xe9, 0x09, 0x4f, 0xdd, 0xeb, 0x33, 0x49, + 0x88, 0x39, 0x14, 0xfb, 0x17, 0xa9, 0x62, 0x1a, + 0xb9, 0x29, 0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13, 0xd2, 0x8d, 0x41, 0xa5, 0xc6, 0xfe, + 0x6c, 0xf3, 0x59, 0x5d, 0xd5, 0xee, 0x63, 0xf0, + 0xa4, 0xc4, 0x06, 0x5a, 0x08, 0x35, 0x90, 0xb2, + 0x75, 0x78, 0x8b, 0xee, 0x7a, 0xd8, 0x75, 0xa7, + 0xf8, 0x8d, 0xd7, 0x37, 0x20, 0x70, 0x8c, 0x6c, + 0x6c, 0x0e, 0xcf, 0x1f, 0x43, 0xbb, 0xaa, 0xda, + 0xe6, 0xf2, 0x08, 0x55, 0x7f, 0xdc, 0x07, 0xbd, + 0x4e, 0xd9, 0x1f, 0x88, 0xce, 0x4c, 0x0d, 0xe8, + 0x42, 0x76, 0x1c, 0x70, 0xc1, 0x86, 0xbf, 0xda, + 0xfa, 0xfc, 0x44, 0x48, 0x34, 0xbd, 0x34, 0x18, + 0xbe, 0x42, 0x53, 0xa7, 0x1e, 0xaf, 0x41, 0xd7, + 0x18, 0x75, 0x3a, 0xd0, 0x77, 0x54, 0xca, 0x3e, + 0xff, 0xd5, 0x96, 0x0b, 0x03, 0x36, 0x98, 0x17, + 0x95, 0x72, 0x14, 0x26, 0x80, 0x35, 0x99, 0xed, + 0x5b, 0x2b, 0x75, 0x16, 0x92, 0x0e, 0xfc, 0xbe, + 0x32, 0xad, 0xa4, 0xbc, 0xf6, 0xc7, 0x3b, 0xd2, + 0x9e, 0x3f, 0xa1, 0x52, 0xd9, 0xad, 0xec, 0xa3, + 0x60, 0x20, 0xfd, 0xee, 0xee, 0x1b, 0x73, 0x95, + 0x21, 0xd3, 0xea, 0x8c, 0x0d, 0xa4, 0x97, 0x00, + 0x3d, 0xf1, 0x51, 0x38, 0x97, 0xb0, 0xf5, 0x47, + 0x94, 0xa8, 0x73, 0x67, 0x0b, 0x8d, 0x93, 0xbc, + 0xca, 0x2a, 0xe4, 0x7e, 0x64, 0x42, 0x4b, 0x74, + 0x23, 0xe1, 0xf0, 0x78, 0xd9, 0x55, 0x4b, 0xb5, + 0x23, 0x2c, 0xc6, 0xde, 0x8a, 0xae, 0x9b, 0x83, + 0xfa, 0x5b, 0x95, 0x10, 0xbe, 0xb3, 0x9c, 0xcf, + 0x4b, 0x4e, 0x1d, 0x9c, 0x0f, 0x19, 0xd5, 0xe1, + 0x7f, 0x58, 0xe5, 0xb8, 0x70, 0x5d, 0x9a, 0x68, + 0x37, 0xa7, 0xd9, 0xbf, 0x99, 0xcd, 0x13, 0x38, + 0x7a, 0xf2, 0x56, 0xa8, 0x49, 0x16, 0x71, 0xf1, + 0xf2, 0xf2, 0x2a, 0xf2, 0x53, 0xbc, 0xff, 0x54, + 0xb6, 0x73, 0x19, 0x9b, 0xdb, 0x7d, 0x05, 0xd8, + 0x10, 0x64, 0xef, 0x05, 0xf8, 0x0f, 0x01, 0x53, + 0xd0, 0xbe, 0x79, 0x19, 0x68, 0x4b, 0x23, 0xda, + 0x8d, 0x42, 0xff, 0x3e, 0xff, 0xdb, 0x7c, 0xa0, + 0x98, 0x50, 0x33, 0xf3, 0x89, 0x18, 0x1f, 0x47, + 0x65, 0x91, 0x38, 0x00, 0x3d, 0x71, 0x2b, 0x5e, + 0xc0, 0xa6, 0x14, 0xd3, 0x1c, 0xc7, 0x48, 0x7f, + 0x52, 0xde, 0x86, 0x64, 0x91, 0x6a, 0xf7, 0x9c, + 0x98, 0x45, 0x6b, 0x2c, 0x94, 0xa8, 0x03, 0x80, + 0x83, 0xdb, 0x55, 0x39, 0x1e, 0x34, 0x75, 0x86, + 0x22, 0x50, 0x27, 0x4a, 0x1d, 0xe2, 0x58, 0x4f, + 0xec, 0x97, 0x5f, 0xb0, 0x95, 0x36, 0x79, 0x2c, + 0xfb, 0xfc, 0xf6, 0x19, 0x28, 0x56, 0xcc, 0x76, + 0xeb, 0x5b, 0x13, 0xdc, 0x47, 0x09, 0xe2, 0xf7, + 0x30, 0x1d, 0xdf, 0xf2, 0x6e, 0xc1, 0xb2, 0x3d, + 0xe2, 0xd1, 0x88, 0xc9, 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b, + 0xda, 0x93, 0xd9, 0xf5, 0xf6, 0xfa, 0x6f, 0x6c, + 0x0f, 0x03, 0xce, 0x43, 0x36, 0x2b, 0x84, 0x14, + 0x94, 0x03, 0x55, 0xfb, 0x54, 0xd3, 0xdf, 0xdd, + 0x03, 0x63, 0x3a, 0xe1, 0x08, 0xf3, 0xde, 0x3e, + 0xbc, 0x85, 0xa3, 0xff, 0x51, 0xef, 0xee, 0xa3, + 0xbc, 0x2c, 0xf2, 0x7e, 0x16, 0x58, 0xf1, 0x78, + 0x9e, 0xe6, 0x12, 0xc8, 0x3d, 0x0f, 0x5f, 0xd5, + 0x6f, 0x7c, 0xd0, 0x71, 0x93, 0x0e, 0x29, 0x46, + 0xbe, 0xee, 0xca, 0xa0, 0x4d, 0xcc, 0xea, 0x9f, + 0x97, 0x78, 0x60, 0x01, 0x47, 0x5e, 0x02, 0x94, + 0xbc, 0x28, 0x52, 0xf6, 0x2e, 0xb5, 0xd3, 0x9b, + 0xb9, 0xfb, 0xee, 0xf7, 0x59, 0x16, 0xef, 0xe4, + 0x4a, 0x66, 0x2e, 0xca, 0xe3, 0x7e, 0xde, 0x27, + 0xe9, 0xd6, 0xea, 0xdf, 0xde, 0xb8, 0xf8, 0xb2, + 0xb2, 0xdb, 0xcc, 0xbf, 0x96, 0xfa, 0x6d, 0xba, + 0xf7, 0x32, 0x1f, 0xb0, 0xe7, 0x01, 0xf4, 0xd4, + 0x29, 0xc2, 0xf4, 0xdc, 0xd1, 0x53, 0xa2, 0x74, + 0x25, 0x74, 0x12, 0x6e, 0x5e, 0xac, 0xcc, 0x77, + 0x68, 0x6a, 0xcf, 0x6e, 0x3e, 0xe4, 0x8f, 0x42, + 0x37, 0x66, 0xe0, 0xfc, 0x46, 0x68, 0x10, 0xa9, + 0x05, 0xff, 0x54, 0x53, 0xec, 0x99, 0x89, 0x7b, + 0x56, 0xbc, 0x55, 0xdd, 0x49, 0xb9, 0x91, 0x14, + 0x2f, 0x65, 0x04, 0x3f, 0x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27, 0x9a, 0x13, 0x9b, 0xe0, 0x9f, 0xcf, 0x6e, + 0x98, 0xa4, 0x70, 0xa0, 0xbc, 0xec, 0xa1, 0x91, + 0xfc, 0xe4, 0x76, 0xf9, 0x37, 0x00, 0x21, 0xcb, + 0xc0, 0x55, 0x18, 0xa7, 0xef, 0xd3, 0x5d, 0x89, + 0xd8, 0x57, 0x7c, 0x99, 0x0a, 0x5e, 0x19, 0x96, + 0x1b, 0xa1, 0x62, 0x03, 0xc9, 0x59, 0xc9, 0x18, + 0x29, 0xba, 0x74, 0x97, 0xcf, 0xfc, 0xbb, 0x4b, + 0x29, 0x45, 0x46, 0x45, 0x4f, 0xa5, 0x38, 0x8a, + 0x23, 0xa2, 0x2e, 0x80, 0x5a, 0x5c, 0xa3, 0x5f, + 0x95, 0x65, 0x98, 0x84, 0x8b, 0xda, 0x67, 0x86, + 0x15, 0xfe, 0xc2, 0x8a, 0xfd, 0x5d, 0xa6, 0x1a, + 0x00, 0x00, 0x00, 0x06, + 0xb3, 0x26, 0x49, 0x33, 0x13, 0x05, 0x3c, 0xed, + 0x38, 0x76, 0xdb, 0x9d, 0x23, 0x71, 0x48, 0x18, + 0x1b, 0x71, 0x73, 0xbc, 0x7d, 0x04, 0x2c, 0xef, + 0xb4, 0xdb, 0xe9, 0x4d, 0x2e, 0x58, 0xcd, 0x21, + 0xa7, 0x69, 0xdb, 0x46, 0x57, 0xa1, 0x03, 0x27, + 0x9b, 0xa8, 0xef, 0x3a, 0x62, 0x9c, 0xa8, 0x4e, + 0xe8, 0x36, 0x17, 0x2a, 0x9c, 0x50, 0xe5, 0x1f, + 0x45, 0x58, 0x17, 0x41, 0xcf, 0x80, 0x83, 0x15, + 0x0b, 0x49, 0x1c, 0xb4, 0xec, 0xbb, 0xab, 0xec, + 0x12, 0x8e, 0x7c, 0x81, 0xa4, 0x6e, 0x62, 0xa6, + 0x7b, 0x57, 0x64, 0x0a, 0x0a, 0x78, 0xbe, 0x1c, + 0xbf, 0x7d, 0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 0x81, 0xc1, + 0x8c, 0x2c, 0xf4, 0xde, 0x48, 0xe9, 0xce, 0x94, + 0x9b, 0xe7, 0xc8, 0x88, 0xe9, 0xca, 0xeb, 0xe4, + 0xa4, 0x15, 0xe2, 0x91, 0xfd, 0x10, 0x7d, 0x21, + 0xdc, 0x1f, 0x08, 0x4b, 0x11, 0x58, 0x20, 0x82, + 0x49, 0xf2, 0x8f, 0x4f, 0x7c, 0x7e, 0x93, 0x1b, + 0xa7, 0xb3, 0xbd, 0x0d, 0x82, 0x4a, 0x45, 0x70, + 0x00, 0x00, 0x00, 0x05, + 0x00, 0x00, 0x00, 0x04, + 0x21, 0x5f, 0x83, 0xb7, 0xcc, 0xb9, 0xac, 0xbc, + 0xd0, 0x8d, 0xb9, 0x7b, 0x0d, 0x04, 0xdc, 0x2b, + 0xa1, 0xcd, 0x03, 0x58, 0x33, 0xe0, 0xe9, 0x00, + 0x59, 0x60, 0x3f, 0x26, 0xe0, 0x7a, 0xd2, 0xaa, + 0xd1, 0x52, 0x33, 0x8e, 0x7a, 0x5e, 0x59, 0x84, + 0xbc, 0xd5, 0xf7, 0xbb, 0x4e, 0xba, 0x40, 0xb7, + 0x00, 0x00, 0x00, 0x04, + 0x00, 0x00, 0x00, 0x04, + 0x0e, 0xb1, 0xed, 0x54, 0xa2, 0x46, 0x0d, 0x51, + 0x23, 0x88, 0xca, 0xd5, 0x33, 0x13, 0x8d, 0x24, + 0x05, 0x34, 0xe9, 0x7b, 0x1e, 0x82, 0xd3, 0x3b, + 0xd9, 0x27, 0xd2, 0x01, 0xdf, 0xc2, 0x4e, 0xbb, + 0x11, 0xb3, 0x64, 0x90, 0x23, 0x69, 0x6f, 0x85, + 0x15, 0x0b, 0x18, 0x9e, 0x50, 0xc0, 0x0e, 0x98, + 0x85, 0x0a, 0xc3, 0x43, 0xa7, 0x7b, 0x36, 0x38, + 0x31, 0x9c, 0x34, 0x7d, 0x73, 0x10, 0x26, 0x9d, + 0x3b, 0x77, 0x14, 0x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, 0x56, 0x82, 0xc0, + 0x17, 0xe2, 0x90, 0x7e, 0xab, 0x07, 0xe5, 0xbb, + 0x2f, 0x19, 0x01, 0x43, 0x47, 0x5a, 0x60, 0x43, + 0xd5, 0xe6, 0xd5, 0x26, 0x34, 0x71, 0xf4, 0xee, + 0xcf, 0x6e, 0x25, 0x75, 0xfb, 0xc6, 0xff, 0x37, + 0xed, 0xfa, 0x24, 0x9d, 0x6c, 0xda, 0x1a, 0x09, + 0xf7, 0x97, 0xfd, 0x5a, 0x3c, 0xd5, 0x3a, 0x06, + 0x67, 0x00, 0xf4, 0x58, 0x63, 0xf0, 0x4b, 0x6c, + 0x8a, 0x58, 0xcf, 0xd3, 0x41, 0x24, 0x1e, 0x00, + 0x2d, 0x0d, 0x2c, 0x02, 0x17, 0x47, 0x2b, 0xf1, + 0x8b, 0x63, 0x6a, 0xe5, 0x47, 0xc1, 0x77, 0x13, + 0x68, 0xd9, 0xf3, 0x17, 0x83, 0x5c, 0x9b, 0x0e, + 0xf4, 0x30, 0xb3, 0xdf, 0x40, 0x34, 0xf6, 0xaf, + 0x00, 0xd0, 0xda, 0x44, 0xf4, 0xaf, 0x78, 0x00, + 0xbc, 0x7a, 0x5c, 0xf8, 0xa5, 0xab, 0xdb, 0x12, + 0xdc, 0x71, 0x8b, 0x55, 0x9b, 0x74, 0xca, 0xb9, + 0x09, 0x0e, 0x33, 0xcc, 0x58, 0xa9, 0x55, 0x30, + 0x09, 0x81, 0xc4, 0x20, 0xc4, 0xda, 0x8f, 0xfd, + 0x67, 0xdf, 0x54, 0x08, 0x90, 0xa0, 0x62, 0xfe, + 0x40, 0xdb, 0xa8, 0xb2, 0xc1, 0xc5, 0x48, 0xce, + 0xd2, 0x24, 0x73, 0x21, 0x9c, 0x53, 0x49, 0x11, + 0xd4, 0x8c, 0xca, 0xab, 0xfb, 0x71, 0xbc, 0x71, + 0x86, 0x2f, 0x4a, 0x24, 0xeb, 0xd3, 0x76, 0xd2, + 0x88, 0xfd, 0x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, 0x2a, + 0x8d, 0x64, 0xc3, 0xd3, 0xd8, 0x58, 0x29, 0x68, + 0xc2, 0x83, 0x99, 0x02, 0x22, 0x9f, 0x85, 0xae, + 0xe2, 0x97, 0xe7, 0x17, 0xc0, 0x94, 0xc8, 0xdf, + 0x4a, 0x23, 0xbb, 0x5d, 0xb6, 0x58, 0xdd, 0x37, + 0x7b, 0xf0, 0xf4, 0xff, 0x3f, 0xfd, 0x8f, 0xba, + 0x5e, 0x38, 0x3a, 0x48, 0x57, 0x48, 0x02, 0xed, + 0x54, 0x5b, 0xbe, 0x7a, 0x6b, 0x47, 0x53, 0x53, + 0x33, 0x53, 0xd7, 0x37, 0x06, 0x06, 0x76, 0x40, + 0x13, 0x5a, 0x7c, 0xe5, 0x17, 0x27, 0x9c, 0xd6, + 0x83, 0x03, 0x97, 0x47, 0xd2, 0x18, 0x64, 0x7c, + 0x86, 0xe0, 0x97, 0xb0, 0xda, 0xa2, 0x87, 0x2d, + 0x54, 0xb8, 0xf3, 0xe5, 0x08, 0x59, 0x87, 0x62, + 0x95, 0x47, 0xb8, 0x30, 0xd8, 0x11, 0x81, 0x61, + 0xb6, 0x50, 0x79, 0xfe, 0x7b, 0xc5, 0x9a, 0x99, + 0xe9, 0xc3, 0xc7, 0x38, 0x0e, 0x3e, 0x70, 0xb7, + 0x13, 0x8f, 0xe5, 0xd9, 0xbe, 0x25, 0x51, 0x50, + 0x2b, 0x69, 0x8d, 0x09, 0xae, 0x19, 0x39, 0x72, + 0xf2, 0x7d, 0x40, 0xf3, 0x8d, 0xea, 0x26, 0x4a, + 0x01, 0x26, 0xe6, 0x37, 0xd7, 0x4a, 0xe4, 0xc9, + 0x2a, 0x62, 0x49, 0xfa, 0x10, 0x34, 0x36, 0xd3, + 0xeb, 0x0d, 0x40, 0x29, 0xac, 0x71, 0x2b, 0xfc, + 0x7a, 0x5e, 0xac, 0xbd, 0xd7, 0x51, 0x8d, 0x6d, + 0x4f, 0xe9, 0x03, 0xa5, 0xae, 0x65, 0x52, 0x7c, + 0xd6, 0x5b, 0xb0, 0xd4, 0xe9, 0x92, 0x5c, 0xa2, + 0x4f, 0xd7, 0x21, 0x4d, 0xc6, 0x17, 0xc1, 0x50, + 0x54, 0x4e, 0x42, 0x3f, 0x45, 0x0c, 0x99, 0xce, + 0x51, 0xac, 0x80, 0x05, 0xd3, 0x3a, 0xcd, 0x74, + 0xf1, 0xbe, 0xd3, 0xb1, 0x7b, 0x72, 0x66, 0xa4, + 0xa3, 0xbb, 0x86, 0xda, 0x7e, 0xba, 0x80, 0xb1, + 0x01, 0xe1, 0x5c, 0xb7, 0x9d, 0xe9, 0xa2, 0x07, + 0x85, 0x2c, 0xf9, 0x12, 0x49, 0xef, 0x48, 0x06, + 0x19, 0xff, 0x2a, 0xf8, 0xca, 0xbc, 0xa8, 0x31, + 0x25, 0xd1, 0xfa, 0xa9, 0x4c, 0xbb, 0x0a, 0x03, + 0xa9, 0x06, 0xf6, 0x83, 0xb3, 0xf4, 0x7a, 0x97, + 0xc8, 0x71, 0xfd, 0x51, 0x3e, 0x51, 0x0a, 0x7a, + 0x25, 0xf2, 0x83, 0xb1, 0x96, 0x07, 0x57, 0x78, + 0x49, 0x61, 0x52, 0xa9, 0x1c, 0x2b, 0xf9, 0xda, + 0x76, 0xeb, 0xe0, 0x89, 0xf4, 0x65, 0x48, 0x77, + 0xf2, 0xd5, 0x86, 0xae, 0x71, 0x49, 0xc4, 0x06, + 0xe6, 0x63, 0xea, 0xde, 0xb2, 0xb5, 0xc7, 0xe8, + 0x24, 0x29, 0xb9, 0xe8, 0xcb, 0x48, 0x34, 0xc8, + 0x34, 0x64, 0xf0, 0x79, 0x99, 0x53, 0x32, 0xe4, + 0xb3, 0xc8, 0xf5, 0xa7, 0x2b, 0xb4, 0xb8, 0xc6, + 0xf7, 0x4b, 0x0d, 0x45, 0xdc, 0x6c, 0x1f, 0x79, + 0x95, 0x2c, 0x0b, 0x74, 0x20, 0xdf, 0x52, 0x5e, + 0x37, 0xc1, 0x53, 0x77, 0xb5, 0xf0, 0x98, 0x43, + 0x19, 0xc3, 0x99, 0x39, 0x21, 0xe5, 0xcc, 0xd9, + 0x7e, 0x09, 0x75, 0x92, 0x06, 0x45, 0x30, 0xd3, + 0x3d, 0xe3, 0xaf, 0xad, 0x57, 0x33, 0xcb, 0xe7, + 0x70, 0x3c, 0x52, 0x96, 0x26, 0x3f, 0x77, 0x34, + 0x2e, 0xfb, 0xf5, 0xa0, 0x47, 0x55, 0xb0, 0xb3, + 0xc9, 0x97, 0xc4, 0x32, 0x84, 0x63, 0xe8, 0x4c, + 0xaa, 0x2d, 0xe3, 0xff, 0xdc, 0xd2, 0x97, 0xba, + 0xaa, 0xac, 0xd7, 0xae, 0x64, 0x6e, 0x44, 0xb5, + 0xc0, 0xf1, 0x60, 0x44, 0xdf, 0x38, 0xfa, 0xbd, + 0x29, 0x6a, 0x47, 0xb3, 0xa8, 0x38, 0xa9, 0x13, + 0x98, 0x2f, 0xb2, 0xe3, 0x70, 0xc0, 0x78, 0xed, + 0xb0, 0x42, 0xc8, 0x4d, 0xb3, 0x4c, 0xe3, 0x6b, + 0x46, 0xcc, 0xb7, 0x64, 0x60, 0xa6, 0x90, 0xcc, + 0x86, 0xc3, 0x02, 0x45, 0x7d, 0xd1, 0xcd, 0xe1, + 0x97, 0xec, 0x80, 0x75, 0xe8, 0x2b, 0x39, 0x3d, + 0x54, 0x20, 0x75, 0x13, 0x4e, 0x2a, 0x17, 0xee, + 0x70, 0xa5, 0xe1, 0x87, 0x07, 0x5d, 0x03, 0xae, + 0x3c, 0x85, 0x3c, 0xff, 0x60, 0x72, 0x9b, 0xa4, + 0x00, 0x00, 0x00, 0x05, + 0x4d, 0xe1, 0xf6, 0x96, 0x5b, 0xda, 0xbc, 0x67, + 0x6c, 0x5a, 0x4d, 0xc7, 0xc3, 0x5f, 0x97, 0xf8, + 0x2c, 0xb0, 0xe3, 0x1c, 0x68, 0xd0, 0x4f, 0x1d, + 0xad, 0x96, 0x31, 0x4f, 0xf0, 0x9e, 0x6b, 0x3d, + 0xe9, 0x6a, 0xee, 0xe3, 0x00, 0xd1, 0xf6, 0x8b, + 0xf1, 0xbc, 0xa9, 0xfc, 0x58, 0xe4, 0x03, 0x23, + 0x36, 0xcd, 0x81, 0x9a, 0xaf, 0x57, 0x87, 0x44, + 0xe5, 0x0d, 0x13, 0x57, 0xa0, 0xe4, 0x28, 0x67, + 0x04, 0xd3, 0x41, 0xaa, 0x0a, 0x33, 0x7b, 0x19, + 0xfe, 0x4b, 0xc4, 0x3c, 0x2e, 0x79, 0x96, 0x4d, + 0x4f, 0x35, 0x10, 0x89, 0xf2, 0xe0, 0xe4, 0x1c, + 0x7c, 0x43, 0xae, 0x0d, 0x49, 0xe7, 0xf4, 0x04, + 0xb0, 0xf7, 0x5b, 0xe8, 0x0e, 0xa3, 0xaf, 0x09, + 0x8c, 0x97, 0x52, 0x42, 0x0a, 0x8a, 0xc0, 0xea, + 0x2b, 0xbb, 0x1f, 0x4e, 0xeb, 0xa0, 0x52, 0x38, + 0xae, 0xf0, 0xd8, 0xce, 0x63, 0xf0, 0xc6, 0xe5, + 0xe4, 0x04, 0x1d, 0x95, 0x39, 0x8a, 0x6f, 0x7f, + 0x3e, 0x0e, 0xe9, 0x7c, 0xc1, 0x59, 0x18, 0x49, + 0xd4, 0xed, 0x23, 0x63, 0x38, 0xb1, 0x47, 0xab, + 0xde, 0x9f, 0x51, 0xef, 0x9f, 0xd4, 0xe1, 0xc1, +}; + +typedef struct { const uint8_t *val; size_t len; } hashsig_tc_bn_t; +typedef struct { hashsig_tc_bn_t key, msg, sig; } hashsig_tc_t; + +static const hashsig_tc_t hashsig_tc[] = { + { { tc1_key, sizeof(tc1_key) }, + { tc1_msg, sizeof(tc1_msg) }, + { tc1_sig, sizeof(tc1_sig) } }, + { { tc2_key, sizeof(tc2_key) }, + { tc2_msg, sizeof(tc2_msg) }, + { tc2_sig, sizeof(tc2_sig) } }, +}; diff --git a/tests/test-pbkdf2.c b/tests/test-pbkdf2.c index f3072a7..603a833 100644 --- a/tests/test-pbkdf2.c +++ b/tests/test-pbkdf2.c @@ -196,7 +196,7 @@ static int _test_pbkdf2(hal_core_t *core, pbkdf2_tc_##_n_##_DK, sizeof(pbkdf2_tc_##_n_##_DK), \ pbkdf2_tc_##_n_##_count, #_n_) -int main (int argc, char *argv[]) +int main(void) { hal_core_t *core = hal_core_find(SHA1_NAME, NULL); int ok = 1; diff --git a/tests/test-rpc_hashsig.c b/tests/test-rpc_hashsig.c new file mode 100644 index 0000000..00728c3 --- /dev/null +++ b/tests/test-rpc_hashsig.c @@ -0,0 +1,594 @@ +/* + * test-rpc_hashsig.c + * ------------------ + * Test code for RPC interface to Cryptech public key operations. + * + * Copyright (c) 2018, NORDUnet A/S + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of the NORDUnet nor the names of its contributors may + * be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* Parts of this may eventually get folded into test-rpc_pkey.c, + * but for now I'd rather do it stand-alone. + */ + +#include <stdio.h> +#include <stdlib.h> +#include <getopt.h> +#include <assert.h> +#include <string.h> +#include <errno.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> + +#include <hal.h> +#include <hashsig.h> +#include "test-hashsig.h" + +#include <sys/time.h> +/* not included in my glibc, sigh... */ +void timersub(struct timeval *a, struct timeval *b, struct timeval *res) +{ + res->tv_sec = a->tv_sec - b->tv_sec; + res->tv_usec = a->tv_usec - b->tv_usec; + if (res->tv_usec < 0) { + res->tv_usec += 1000000; + --res->tv_sec; + } + if (res->tv_usec > 1000000) { + res->tv_usec -= 1000000; + ++res->tv_sec; + } +} + +static int debug = 0; +static int info = 0; + +#define lose(...) do { printf(__VA_ARGS__); goto fail; } while (0) + +static int test_hashsig_testvec_local(const hashsig_tc_t * const tc, hal_key_flags_t flags) +{ + hal_error_t err; + + assert(tc != NULL); + + printf("Starting local hashsig test vector test\n"); + + uint8_t tc_keybuf[hal_hashsig_key_t_size]; + hal_hashsig_key_t *tc_key = NULL; + + if ((err = hal_hashsig_key_load_public_xdr(&tc_key, + tc_keybuf, sizeof(tc_keybuf), + tc->key.val, tc->key.len)) != HAL_OK) + lose("Could not load public key from test vector: %s\n", hal_error_string(err)); + + if ((err = hal_hashsig_verify(NULL, tc_key, tc->msg.val, tc->msg.len, tc->sig.val, tc->sig.len)) != HAL_OK) + lose("Verify failed: %s\n", hal_error_string(err)); + + printf("OK\n"); + return 1; + +fail: + return 0; +} + +static int test_hashsig_testvec_remote(const hashsig_tc_t * const tc, hal_key_flags_t flags) +{ + const hal_client_handle_t client = {HAL_HANDLE_NONE}; + const hal_session_handle_t session = {HAL_HANDLE_NONE}; + hal_pkey_handle_t public_key = {HAL_HANDLE_NONE}; + hal_error_t err; + size_t len; + + assert(tc != NULL); + + { + flags |= HAL_KEY_FLAG_USAGE_DIGITALSIGNATURE; + + printf("Starting remote hashsig test vector test, flags 0x%lx\n", (unsigned long) flags); + + uint8_t tc_keybuf[hal_hashsig_key_t_size]; + hal_hashsig_key_t *tc_key = NULL; + + if ((err = hal_hashsig_key_load_public_xdr(&tc_key, + tc_keybuf, sizeof(tc_keybuf), + tc->key.val, tc->key.len)) != HAL_OK) + lose("Could not load public key from test vector: %s\n", hal_error_string(err)); + + hal_uuid_t public_name; + + uint8_t public_der[hal_hashsig_public_key_to_der_len(tc_key)]; + + if ((err = hal_hashsig_public_key_to_der(tc_key, public_der, &len, sizeof(public_der))) != HAL_OK) + lose("Could not DER encode public key from test vector: %s\n", hal_error_string(err)); + + assert(len == sizeof(public_der)); + + if ((err = hal_rpc_pkey_load(client, session, &public_key, &public_name, + public_der, sizeof(public_der), flags)) != HAL_OK) + lose("Could not load public key into RPC: %s\n", hal_error_string(err)); + + if ((err = hal_rpc_pkey_verify(public_key, hal_hash_handle_none, + tc->msg.val, tc->msg.len, tc->sig.val, tc->sig.len)) != HAL_OK) + lose("Could not verify: %s\n", hal_error_string(err)); + + if ((err = hal_rpc_pkey_delete(public_key)) != HAL_OK) + lose("Could not delete public key: %s\n", hal_error_string(err)); + + printf("OK\n"); + return 1; + } + +fail: + if (public_key.handle != HAL_HANDLE_NONE && + (err = hal_rpc_pkey_delete(public_key)) != HAL_OK) + printf("Warning: could not delete public key: %s\n", hal_error_string(err)); + + return 0; +} + +static void hexdump(const char * const label, const uint8_t * const buf, const size_t len) +{ + printf("%-11s ", label); + + for (size_t i = 0; i < len; ++i) { + printf("%02x", buf[i]); + if ((i & 0x0f) == 0x0f) { + printf("\n"); + if (i < len - 1) + printf(" "); + } + } + if ((len & 0x0f) != 0) + printf("\n"); +} + +static inline size_t lms_type_to_h(const lms_algorithm_t lms_type) +{ + switch (lms_type) { + case lms_sha256_n32_h5: return 5; + case lms_sha256_n32_h10: return 10; + case lms_sha256_n32_h15: return 15; + case lms_sha256_n32_h20: return 20; + case lms_sha256_n32_h25: return 25; + default: return 0; + } +} + +static inline size_t lmots_type_to_w(const lmots_algorithm_t lmots_type) +{ + switch (lmots_type) { + case lmots_sha256_n32_w1: return 1; + case lmots_sha256_n32_w2: return 2; + case lmots_sha256_n32_w4: return 4; + case lmots_sha256_n32_w8: return 8; + default: return 0; + } +} + +static inline size_t lmots_type_to_p(const lmots_algorithm_t lmots_type) +{ + switch (lmots_type) { + case lmots_sha256_n32_w1: return 265; + case lmots_sha256_n32_w2: return 133; + case lmots_sha256_n32_w4: return 67; + case lmots_sha256_n32_w8: return 34; + default: return 0; + } +} + +#include <xdr_internal.h> + +static hal_error_t dump_hss_signature(const uint8_t * const sig, const size_t len) +{ + const uint8_t *sigptr = sig; + const uint8_t * const siglim = sig + len; + hal_error_t err; + + hexdump("Nspk", sigptr, 4); + uint32_t Nspk; + if ((err = hal_xdr_decode_int(&sigptr, siglim, &Nspk)) != HAL_OK) return err; + + for (size_t i = 0; i < Nspk + 1; ++i) { + printf("--------------------------------------------\nsig[%lu]\n", i); + hexdump("q", sigptr, 4); sigptr += 4; + + { + hexdump("lmots type", sigptr, 4); + uint32_t lmots_type; + if ((err = hal_xdr_decode_int(&sigptr, siglim, &lmots_type)) != HAL_OK) return err; + hexdump("C", sigptr, 32); sigptr += 32; + size_t p = lmots_type_to_p((const lmots_algorithm_t)lmots_type); + for (size_t j = 0; j < p; ++j) { + char label[16]; + sprintf(label, "y[%lu]", j); + hexdump(label, sigptr, 32); sigptr += 32; + } + } + + hexdump("lms type", sigptr, 4); + uint32_t lms_type; + if ((err = hal_xdr_decode_int(&sigptr, siglim, &lms_type)) != HAL_OK) return err; + size_t h = lms_type_to_h((const lms_algorithm_t)lms_type); + for (size_t j = 0; j < h; ++j) { + char label[16]; + sprintf(label, "path[%lu]", j); + hexdump(label, sigptr, 32); sigptr += 32; + } + + if (i == Nspk) + break; + + printf("--------------------------------------------\npubkey[%lu]\n", i + 1); + hexdump("lms type", sigptr, 4); sigptr += 4; + hexdump("lmots type", sigptr, 4); sigptr += 4; + hexdump("I", sigptr, 16); sigptr += 16; + hexdump("T[1]", sigptr, 32); sigptr += 32; + } + + if (sigptr < siglim) { + printf("--------------------------------------------\nextra\n"); + hexdump("", sigptr, siglim - sigptr); + } + + return HAL_OK; +} + +static int test_hashsig_sign(const size_t L, + const lms_algorithm_t lms_type, + const lmots_algorithm_t lmots_type, + size_t iterations, + int save, int keep) +{ + const hal_client_handle_t client = {HAL_HANDLE_NONE}; + const hal_session_handle_t session = {HAL_HANDLE_NONE}; + hal_pkey_handle_t private_key = {HAL_HANDLE_NONE}; + hal_pkey_handle_t public_key = {HAL_HANDLE_NONE}; + hal_error_t err; + size_t len; + + { + char save_name[16]; + if (save) { + sprintf(save_name, "L%d.lms%d.ots%d", (int)L, (int)lms_type, (int)lmots_type); + FILE *fp; + if ((fp = fopen(save_name, "wb")) == NULL) + lose("Error opening %s: %s\n", save_name, strerror(errno)); + size_t len1; + if ((len1 = fwrite(tc1_msg, 1, sizeof(tc1_msg), fp)) != sizeof(tc1_msg)) + lose("Wrote %lu bytes to %s, expected %lu\n", len1, save_name, sizeof(tc1_msg)); + if (fclose(fp) != 0) + lose("Error closing %s: %s\n", save_name, strerror(errno)); + } + + hal_key_flags_t flags = HAL_KEY_FLAG_USAGE_DIGITALSIGNATURE | HAL_KEY_FLAG_TOKEN; + + printf("Starting hashsig key test: L %lu, lms type %u (h=%lu), lmots type %u (w=%lu)\n", + L, lms_type, lms_type_to_h(lms_type), lmots_type, lmots_type_to_w(lmots_type)); + + if (info) + printf("Info: signature length %lu, lmots private key length %lu\n", + hal_hashsig_signature_len(L, lms_type, lmots_type), + hal_hashsig_lmots_private_key_len(lmots_type)); + + hal_uuid_t private_name, public_name; + struct timeval tv_start, tv_end, tv_diff; + + size_t h = lms_type_to_h(lms_type); + + if (info) + gettimeofday(&tv_start, NULL); + if ((err = hal_rpc_pkey_generate_hashsig(client, session, &private_key, &private_name, + L, lms_type, lmots_type, flags)) != HAL_OK) + lose("Could not generate hashsig private key: %s\n", hal_error_string(err)); + if (info) { + gettimeofday(&tv_end, NULL); + timersub(&tv_end, &tv_start, &tv_diff); + long per_key = (tv_diff.tv_sec * 1000000 + tv_diff.tv_usec) / (L * (1 << h)); + printf("Info: %ldm%ld.%03lds to generate key (%ld.%03lds per lmots key)\n", + tv_diff.tv_sec / 60, tv_diff.tv_sec % 60, tv_diff.tv_usec / 1000, + per_key / 1000000, (per_key % 1000000) / 1000); + } + + uint8_t public_der[hal_rpc_pkey_get_public_key_len(private_key)]; + + if ((err = hal_rpc_pkey_get_public_key(private_key, public_der, &len, sizeof(public_der))) != HAL_OK) + lose("Could not DER encode public key from private key: %s\n", hal_error_string(err)); + + assert(len == sizeof(public_der)); + + if ((err = hal_rpc_pkey_load(client, session, &public_key, &public_name, + public_der, sizeof(public_der), flags)) != HAL_OK) + lose("Could not load public key into RPC: %s\n", hal_error_string(err)); + + if (save) { + char fn[strlen(save_name) + 5]; + sprintf(fn, "%s.pub", save_name); + FILE *fp; + if ((fp = fopen(fn, "wb")) == NULL) + lose("Error opening %s: %s\n", fn, strerror(errno)); + uint8_t pub[60]; + if ((err = hal_hashsig_public_key_der_to_xdr(public_der, sizeof(public_der), pub, &len, sizeof(pub))) != HAL_OK) + lose("Could not XDR encode public key: %s\n", hal_error_string(err)); + size_t len1; + if ((len1 = fwrite(pub, 1, len, fp)) != len) + lose("Wrote %lu bytes to %s, expected %lu\n", len1, fn, len); + if (fclose(fp) != 0) + lose("Error closing %s: %s\n", fn, strerror(errno)); + } + + if (iterations > 0) { + uint8_t sig[hal_hashsig_signature_len(L, lms_type, lmots_type)]; + + if (info) + gettimeofday(&tv_start, NULL); + int i; + for (i = 0; i < iterations; ++i) { + if ((err = hal_rpc_pkey_sign(private_key, hal_hash_handle_none, + tc1_msg, sizeof(tc1_msg), sig, &len, sizeof(sig))) == HAL_OK) { + assert(len == sizeof(sig)); + if (debug) { + printf("Debug: received signature:\n"); + dump_hss_signature(sig, len); + } + } + else { + if (i == (1 << (L * h)) && err == HAL_ERROR_HASHSIG_KEY_EXHAUSTED) + break; + else + lose("Could not sign (%d): %s\n", i, hal_error_string(err)); + } + if (save) { + char fn[strlen(save_name) + 16]; + sprintf(fn, "%s.%d.sig", save_name, i); + FILE *fp; + if ((fp = fopen(fn, "wb")) == NULL) + lose("Error opening %s: %s\n", fn, strerror(errno)); + size_t len1; + if ((len1 = fwrite(sig, 1, len, fp)) != len) + lose("Wrote %lu bytes to %s, expected %lu\n", len1, fn, len); + if (fclose(fp) != 0) + lose("Error closing %s: %s\n", fn, strerror(errno)); + } + } + if (info) { + gettimeofday(&tv_end, NULL); + timersub(&tv_end, &tv_start, &tv_diff); + long per_sig = (tv_diff.tv_sec * 1000000 + tv_diff.tv_usec) / i; + printf("Info: %ldm%ld.%03lds to generate %d signatures (%ld.%03lds per signature)\n", + tv_diff.tv_sec / 60, tv_diff.tv_sec % 60, tv_diff.tv_usec / 1000, i, + per_sig / 1000000, (per_sig % 1000000) / 1000); + } + + if (info) + gettimeofday(&tv_start, NULL); + if ((err = hal_rpc_pkey_verify(public_key, hal_hash_handle_none, + tc1_msg, sizeof(tc1_msg), sig, len)) != HAL_OK) + lose("Could not verify: %s\n", hal_error_string(err)); + if (info) { + gettimeofday(&tv_end, NULL); + timersub(&tv_end, &tv_start, &tv_diff); + printf("Info: %ldm%ld.%03lds to verify 1 signature\n", + tv_diff.tv_sec / 60, tv_diff.tv_sec % 60, tv_diff.tv_usec / 1000); + } + } + + if (!keep) { + if ((err = hal_rpc_pkey_delete(private_key)) != HAL_OK) + lose("Could not delete private key: %s\n", hal_error_string(err)); + } + + if ((err = hal_rpc_pkey_delete(public_key)) != HAL_OK) + lose("Could not delete public key: %s\n", hal_error_string(err)); + + printf("OK\n"); + return 1; + } + +fail: + if (private_key.handle != HAL_HANDLE_NONE && + (err = hal_rpc_pkey_delete(private_key)) != HAL_OK) + printf("Warning: could not delete private key: %s\n", hal_error_string(err)); + + if (public_key.handle != HAL_HANDLE_NONE && + (err = hal_rpc_pkey_delete(public_key)) != HAL_OK) + printf("Warning: could not delete public key: %s\n", hal_error_string(err)); + + return 0; +} + +static int read_sig(char *fn) +{ + { + FILE *fp; + if ((fp = fopen(fn, "rb")) == NULL) + lose("Error opening %s: %s\n", fn, strerror(errno)); + + struct stat statbuf; + if (stat(fn, &statbuf) != 0) + lose("Error statting %s: %s\n", fn, strerror(errno)); + + uint8_t sig[statbuf.st_size]; + size_t len; + if ((len = fread(sig, 1, sizeof(sig), fp)) != sizeof(sig)) + lose("Read %lu bytes from %s, expected %lu\n", len, fn, sizeof(sig)); + + if (fclose(fp) != 0) + lose("Error closing %s: %s\n", fn, strerror(errno)); + + hal_error_t err; + if ((err = dump_hss_signature(sig, len)) != HAL_OK) + lose("Error parsing signature: %s\n", hal_error_string(err)); + } + + return 1; +fail: + return 0; +} + +int main(int argc, char *argv[]) +{ + const hal_client_handle_t client = {HAL_HANDLE_NONE}; + char *pin = "fnord"; + int do_default = 1; + int do_testvec = 0; + size_t iterations = 1; + size_t L_lo = 0, L_hi = 0; + size_t lms_lo = 5, lms_hi = 0; + size_t lmots_lo = 3, lmots_hi = 0; + int save = 0, keep = 0; + char *p; + hal_error_t err; + int ok = 1; + +char usage[] = "\ +Usage: %s [-d] [-i] [-p pin] [-t] [-L n] [-l n] [-o n] [-n n] [-s] [-r file]\n\ + -d: enable debugging - hexdump signatures\n\ + -i: enable informational messages - runtimes and signature lengths\n\ + -p: user PIN\n\ + -t: verify test vectors\n\ + -L: number of levels in the HSS scheme (1..8)\n\ + -l: LMS type (5..9)\n\ + -o: LM-OTS type (1..4)\n\ + -n: number of signatures to generate (0..'max')\n\ + -s: save generated public key and signatures\n\ + -k: keep (don't delete) the generated keys on the hsm\n\ + -r: read and pretty-print a saved signature file\n\ +Numeric arguments can be a single number or a range, e.g. '1..4'\n"; + + int opt; + while ((opt = getopt(argc, argv, "ditp:L:l:o:n:skr:h?")) != -1) { + switch (opt) { + case 'd': + debug = 1; + break; + case 'i': + info = 1; + break; + case 't': + do_testvec = 1; + do_default = 0; + break; + case 'p': + pin = optarg; + break; + case 'n': + if (strcmp(optarg, "max") == 0) + iterations = (size_t)-1; + else + iterations = (size_t)atoi(optarg); + do_default = 0; + break; + case 'L': + if ((p = strtok(optarg, ".")) != NULL) + L_lo = (size_t)atoi(p); + if ((p = strtok(NULL, ".")) != NULL) + L_hi = (size_t)atoi(p); + do_default = 0; + break; + case 'l': + if ((p = strtok(optarg, ".")) != NULL) + lms_lo = (size_t)atoi(p); + if ((p = strtok(NULL, ".")) != NULL) + lms_hi = (size_t)atoi(p); + do_default = 0; + break; + case 'o': + if ((p = strtok(optarg, ".")) != NULL) + lmots_lo = (size_t)atoi(p); + if ((p = strtok(NULL, ".")) != NULL) + lmots_hi = (size_t)atoi(p); + do_default = 0; + break; + case's': + save = 1; + break; + case 'k': + keep = 1; + break; + case 'r': + ok &= read_sig(optarg); + do_default = 0; + break; + case 'h': + case '?': + fprintf(stdout, usage, argv[0]); + exit(EXIT_SUCCESS); + default: + fprintf(stderr, usage, argv[0]); + exit(EXIT_FAILURE); + } + } + + if (do_default) { + do_testvec = 1; + L_lo = 1; + } + + if (L_hi < L_lo) L_hi = L_lo; + if (lms_hi < lms_lo) lms_hi = lms_lo; + if (lmots_hi < lmots_lo) lmots_hi = lmots_lo; + + if ((err = hal_rpc_client_init()) != HAL_OK) + printf("Warning: Trouble initializing RPC client: %s\n", hal_error_string(err)); + + if ((err = hal_rpc_login(client, HAL_USER_NORMAL, pin, strlen(pin))) != HAL_OK) + printf("Warning: Trouble logging into HSM: %s\n", hal_error_string(err)); + + if (do_testvec) { + for (int i = 0; i < (sizeof(hashsig_tc)/sizeof(*hashsig_tc)); i++) + ok &= test_hashsig_testvec_local(&hashsig_tc[i], 0); + + for (int i = 0; i < (sizeof(hashsig_tc)/sizeof(*hashsig_tc)); i++) + for (int j = 0; j < 2; j++) + ok &= test_hashsig_testvec_remote(&hashsig_tc[i], j * HAL_KEY_FLAG_TOKEN); + } + + /* signing/performance tests: run with -i */ + /* A single test would be of the form '-L 2 -l 5 -o 3 -n 1' */ + /* A range test of just keygen would be of the form '-o 1..4 -n 0' */ + /* A test to key exhaustion would be of the form '-n max' */ + if (L_lo > 0) { + for (size_t L = L_lo; L <= L_hi; ++L) { + for (lms_algorithm_t lms_type = lms_lo; lms_type <= lms_hi; ++lms_type) { + for (lmots_algorithm_t lmots_type = lmots_lo; lmots_type <= lmots_hi; ++lmots_type) { + ok &= test_hashsig_sign(L, lms_type, lmots_type, iterations, save, keep); + } + } + } + } + + if ((err = hal_rpc_logout(client)) != HAL_OK) + printf("Warning: Trouble logging out of HSM: %s\n", hal_error_string(err)); + + if ((err = hal_rpc_client_close()) != HAL_OK) + printf("Warning: Trouble shutting down RPC client: %s\n", hal_error_string(err)); + + return !ok; +} diff --git a/tests/test-rsa.c b/tests/test-rsa.c index 57037c0..176ba03 100644 --- a/tests/test-rsa.c +++ b/tests/test-rsa.c @@ -56,12 +56,21 @@ static int test_modexp(hal_core_t *core, const rsa_tc_bn_t * const exp, /* Exponent */ const rsa_tc_bn_t * const val) /* Expected result */ { - uint8_t result[tc->n.len]; + uint8_t result[tc->n.len], C[tc->n.len], F[tc->n.len]; printf("%s test for %lu-bit RSA key\n", kind, (unsigned long) tc->size); - if (hal_modexp(core, msg->val, msg->len, exp->val, exp->len, - tc->n.val, tc->n.len, result, sizeof(result)) != HAL_OK) + hal_modexp_arg_t args = { + .core = core, + .msg = msg->val, .msg_len = msg->len, + .exp = exp->val, .exp_len = exp->len, + .mod = tc->n.val, .mod_len = tc->n.len, + .result = result, .result_len = sizeof(result), + .coeff = C, .coeff_len = sizeof(C), + .mont = F, .mont_len = sizeof(F) + }; + + if (hal_modexp(1, &args) != HAL_OK) return printf("ModExp failed\n"), 0; if (memcmp(result, val->val, val->len)) @@ -98,7 +107,7 @@ static int test_decrypt(hal_core_t *core, uint8_t result[tc->n.len]; - if ((err = hal_rsa_decrypt(core, key, tc->m.val, tc->m.len, result, sizeof(result))) != HAL_OK) + if ((err = hal_rsa_decrypt(core, NULL, key, tc->m.val, tc->m.len, result, sizeof(result))) != HAL_OK) printf("RSA CRT failed: %s\n", hal_error_string(err)); const int mismatch = (err == HAL_OK && memcmp(result, tc->s.val, tc->s.len) != 0); @@ -165,7 +174,7 @@ static int test_gen(hal_core_t *core, uint8_t result[tc->n.len]; - if ((err = hal_rsa_decrypt(core, key1, tc->m.val, tc->m.len, result, sizeof(result))) != HAL_OK) + if ((err = hal_rsa_decrypt(core, NULL, key1, tc->m.val, tc->m.len, result, sizeof(result))) != HAL_OK) printf("RSA CRT failed: %s\n", hal_error_string(err)); snprintf(fn, sizeof(fn), "test-rsa-sig-%04lu.der", (unsigned long) tc->size); @@ -296,7 +305,7 @@ static int test_rsa(hal_core_t *core, const rsa_tc_t * const tc) return ok; } -int main(int argc, char *argv[]) +int main(void) { hal_core_t *core = hal_core_find(MODEXPS6_NAME, NULL); if (core == NULL) @@ -314,7 +323,7 @@ int main(int argc, char *argv[]) /* Normal test */ - for (int i = 0; i < (sizeof(rsa_tc)/sizeof(*rsa_tc)); i++) + for (size_t i = 0; i < (sizeof(rsa_tc)/sizeof(*rsa_tc)); i++) if (!test_rsa(core, &rsa_tc[i])) return 1; diff --git a/tests/test-trng.c b/tests/test-trng.c index f570752..45dec56 100644 --- a/tests/test-trng.c +++ b/tests/test-trng.c @@ -43,6 +43,7 @@ #include <sys/time.h> #include <hal.h> +#include <hal_internal.h> #include <verilog_constants.h> #ifndef WAIT_FOR_CSPRNG_VALID diff --git a/tests/test-xdr.c b/tests/test-xdr.c new file mode 100644 index 0000000..eedf48d --- /dev/null +++ b/tests/test-xdr.c @@ -0,0 +1,111 @@ +/* + * xdr.c + * ----- + * Serialization/deserialization routines, using XDR (RFC 4506) encoding. + * These functions are not part of the public libhal API. + * + * Copyright (c) 2016-2018, NORDUnet A/S All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of the NORDUnet nor the names of its contributors may + * be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <stdio.h> +#include <stdint.h> +#include <stddef.h> /* ptrdiff_t */ +#include <string.h> /* memcpy, memset */ + +#include "hal.h" +#include "hal_internal.h" /* htonl/ntohl */ +#include "xdr_internal.h" + +static void hexdump(uint8_t *buf, uint32_t len) +{ + for (uint32_t i = 0; i < len; ++i) + printf("%02x%c", buf[i], ((i & 0x07) == 0x07) ? '\n' : ' '); + if ((len & 0x07) != 0) + printf("\n"); +} + +int main(int argc, char *argv[]) +{ + uint32_t i; + uint8_t buf[256] = {0}; + uint8_t *bufptr = buf; + const uint8_t *readptr; + uint8_t *limit = buf + sizeof(buf); + hal_error_t ret; + uint8_t alphabet[] = "abcdefghijklmnopqrstuvwxyz"; + uint8_t readbuf[256] = {0}; + + printf("hal_xdr_encode_int: work to failure\n"); + for (i = 1; i < 100; ++i) { + if ((ret = hal_xdr_encode_int(&bufptr, limit, i)) != HAL_OK) { + printf("%d: %s\n", i, hal_error_string(ret)); + break; + } + } + hexdump(buf, ((uint8_t *)bufptr - buf)); + + printf("\nhal_xdr_decode_int:\n"); + readptr = buf; + while (readptr < bufptr) { + if ((ret = hal_xdr_decode_int(&readptr, limit, &i)) != HAL_OK) { + printf("%s\n", hal_error_string(ret)); + break; + } + printf("%u ", i); + } + printf("\n"); + + printf("\nhal_xdr_encode_variable_opaque: work to failure\n"); + memset(buf, 0, sizeof(buf)); + bufptr = buf; + for (i = 1; ; ++i) { + if ((ret = hal_xdr_encode_variable_opaque(&bufptr, limit, alphabet, i)) != HAL_OK) { + printf("%d: %s\n", i, hal_error_string(ret)); + break; + } + } + hexdump(buf, ((uint8_t *)bufptr - buf)); + + printf("\nhal_xdr_decode_variable_opaque:\n"); + readptr = buf; + while (readptr < bufptr) { + size_t len = bufptr - readptr; + if ((ret = hal_xdr_decode_variable_opaque(&readptr, limit, readbuf, &len)) != HAL_OK) { + printf("%s\n", hal_error_string(ret)); + break; + } + printf("%lu: ", len); + for (size_t j = 0; j < len; ++j) + putchar(readbuf[j]); + putchar('\n'); + memset(readbuf, 0, sizeof(readbuf)); + } + + return 0; +} diff --git a/tests/time-keygen.py b/tests/time-keygen.py new file mode 100755 index 0000000..b7311ba --- /dev/null +++ b/tests/time-keygen.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python + +""" +Time libhal RSA key generation +""" + +from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter +from datetime import datetime, timedelta + +from cryptech.libhal import * + +parser = ArgumentParser(description = __doc__, formatter_class = ArgumentDefaultsHelpFormatter) +parser.add_argument("-i", "--iterations", default = 100, type = int, help = "iterations") +parser.add_argument("-p", "--pin", default = "fnord", help = "user PIN") +parser.add_argument("-t", "--token", action = "store_true", help = "store key on token") +parser.add_argument("-k", "--keylen", default = 2048, type = int, help = "key length") +args = parser.parse_args() + +hsm = HSM() +hsm.login(HAL_USER_NORMAL, args.pin) + +flags = HAL_KEY_FLAG_USAGE_DIGITALSIGNATURE | (HAL_KEY_FLAG_TOKEN if args.token else 0) +sum = timedelta() + +for n in xrange(1, args.iterations + 1): + + t0 = datetime.now() + + k = hsm.pkey_generate_rsa(args.keylen, flags) + + t1 = datetime.now() + + k.delete() + + sum += t1 - t0 + + print "{:4d} this {} mean {}".format(n, t1 - t0, sum / n) |