test/crypto.c

Tue, 12 Dec 2017 23:58:54 +0100

author
Mike Becker <universe@uap-core.de>
date
Tue, 12 Dec 2017 23:58:54 +0100
branch
v1.1
changeset 343
b9c6e0be5774
parent 308
82275f589d8d
child 470
6bf798ad3aec
child 481
ff477f1f7765
permissions
-rw-r--r--

fixes infinite loop when trying to overwrite a collection with a regular file

305
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1 /*
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
3 *
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
4 * Copyright 2017 Olaf Wintermann. All rights reserved.
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
5 *
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
7 * modification, are permitted provided that the following conditions are met:
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
8 *
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
11 *
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
15 *
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
27 */
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
28
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
29 #include <stdio.h>
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
30 #include <stdlib.h>
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
31 #include <string.h>
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
32 #include <inttypes.h>
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
33
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
34 #include "crypto.h"
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
35
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
36 #include <ucx/string.h>
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
37 #include <ucx/utils.h>
308
82275f589d8d adds test for crypto streams
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 305
diff changeset
38 #include <ucx/buffer.h>
305
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
39 #include <libidav/utils.h>
308
82275f589d8d adds test for crypto streams
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 305
diff changeset
40 #include <libidav/crypto.h>
305
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
41
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
42 static DavKey keys256[16];
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
43 static DavKey keys128[16];
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
44
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
45 static char *strings[] = {
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
46 "a",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
47 "ab",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
48 "abc",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
49 "abcd",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
50 "a string",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
51 "hello world",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
52 "0 1",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
53 "0123 abcd XXXX <>",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
54 "libidav+dav+dav-sync",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
55 "R2xd1dI9o0HHd3aDuQrvuPyB",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
56 "7XxUqWvOvQOFo0SlKyEWzerR",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
57 "Ert2g8bjjyKpAebBNxdaJ5o7",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
58 "C0jReDRLHxF6MW1stR00OFiF",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
59 "eRD76vIQIUNRRFrnUrGtTI13",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
60 "VmfdNDkSzLKiEgCkWQ4Es4XaiY7TlW3LCm1gt3r66uJ0TeQm",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
61 "AdeoBAIo8Q54yO1Pwe1WH3rgDe4m5ZBUSgNUlrNqGjtN4UNN",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
62 "Ajkt3kmdG9uPRi41Q5299yuW9DJNKc0yGlF08K6PfodpYyOxzOiL7TbeDML0RbJAOaL2fpCC",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
63 "mmGmeUTxxAEyhx1Qw9CAodQ550rQpQhSR4ZuC4im9SDSl5ykGJOEJrdrTPciaIdyY9M6WSmg",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
64 "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
65 "--aabb2234000000001ffffffffffffffffas"
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
66 "very long string ..............................................."
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
67 "----------------------------------------------------------------"
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
68 "0000000000000000000000000000000000000000000000000000000000000000"
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
69 ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
70 };
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
71
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
72 static char *cryptkey0aes256strings[] = {
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
73 "UtIyzMm3e39YFEccglOxyJ4WPlqA01tohXCJSeaVKIA=",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
74 "rfHc8KMEp9HoGAHz08gyne+YH053EIoiheacHe0yiOY=",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
75 "C6oaFjGiPe0aN3SAC146ptKyyGbWO1X2hHDOHtV5PBU=",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
76 "y+bwmzxtjepi1Gpm1dwI7qJywu32hErGLCxFv4K5Zz4=",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
77 "I1uRSZ/fOvJ4Ng2VhBYMGAhfejhdJdu5Sjc67qdyHIY=",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
78 "J0s/JwsBebiBEhUJUjm9aliuX6NsMxfkHyD8t1yZqeA=",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
79 "riCsL+VoMX9Np+zHJ6sBf7YJxNPtubGWvpIf2vQ3Cfj46bJ+OtbQWjEr4qEreYSi",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
80 "2RtZKgawmf2ZhSE4a58WW2Vqq1She3+IK2PkthWsH9CsDUBTGjcLtng2Csj6IVsQ",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
81 "G+iHYAcw26KdN4P/ZtJmUsPq/NrVkTyT0S8bAKtJe8b4/ZrD3lFVoujVFebxvAsW",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
82 "sEqfG73duZVlWpgMs4PrgMmw2gaFc3n5SyxLTL3km50Uhc/SfmSbNa8x3J1CdrYH",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
83 "TvdiTxgZ3ojjhLDfD5EHDGi98PXFmwXDCkzBYojYchyEplAfSYBALgYwQpw03/EE",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
84 "rQdJ83pmLinsaViwJN2X6cC/WNvuJF5SpKdvx7Isc8nJAHZxPqZMwGdGutGsCcZp",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
85 "CKnjU5Bw1xUrhCqR9i1PHQr7W8N/D0gx6lbj8+f40fNPoJSHxPl53fpxjXUj0a+f",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
86 "iM4cKOKnFh2mNqqETilnyCSE2VuLxoMac1q40wcHtGLdwHEXRjx/GLouhA+sksyZ",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
87 "iEQt7tHNNs+C4fM1ioPLRtdxBB0prCYX6147r7DOgaJO3I3nLKRjdVhxCMTu6vtEbQEdldtPOAai1AQvGUIHCR0vysUEpuaHW1jL/nbdos4=",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
88 "N7l3vRd0PNGdj5qwNGpxpGy4TvTd59jPSqMsfkMSP44Qb/UwmJF+WwN6OMSuy8OAkSz8oXPNnozYv1neE40IbT+eNEtX2+VNLLcoyRvLIko=",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
89 "THUKZwEFfYdhkObEaagcR1fLLxusTP0kFYdovNWl/XdBTTiKIrG+RMIod5VrFUe0bx3yZDZJtuAn1J/E+5F8/CXQ5WoxQM66B8BzXVC/EaSJlFJcG9MNstx4HXQPiBq3",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
90 "YMk6nlKxsLqXwXwFiIXJNZR/m5Gqd6h2R5ddN0UEjDBNkCWBnrnMyE22rrcz6oogVZCh1mWYYO0WiqhG3qqWSzJcb7lGrbdFl4rfD+ogQPkM3c0jgEnV2/rLHyu3x57l",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
91 "tkaz9523cM6fYJDW4E/Q99cxy1ZpRO3hoFtV2iCQ/zWqvhfL96GjbV2yiqMY2iX2bJ+4iXKerrQMmxDUAYJYzQ==",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
92 "GrRF4S9W75f6Y82Bw1PS3ZfMs0sSY8yc5F7zwJ6YtAUCWvCpgLJ2fd1UGAdYrMoB9f8R2gXXM4ROGD1N/tWo5vDgQDFrzSttN6J+4n9yg18JuQ5Kna2P9sEOkPTSgZDmB9wjOAQ5U4LlmHI35ykcc0LjFkwy9qxXw1GbsATeD4WY+wq800ru6E158a9Fb6teRQUteNZCtgwTqPSr2sYJIQAaJO4Yv0vNp/7BgxI9CZM/Hvr+05GVVRA9YE3qwed3Hk1RMd15cfBo/+bsttTDg1sKtviPHtkBV88codPfoWYZjd8UPYE+q9P0zOM/wRvb5b2sUccRKbmRNmM+OKQySyG/lyCb+HedxjPQ+24i8NLjku3GWJG3egDnRQHY/nb1TBmOFjpNtARq4QhLf0HwDaGcZwchhGn0xpggcrqTuv4="
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
93 };
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
94
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
95 static char *cryptkey1aes256strings[] = {
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
96 "zAkuGJUT4tkdbYg/oxLROlzHNWQPojgyFSGhEw3FpNE=",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
97 "RiDdDBabx2dxPWH/Hu+FRHN9e8dnoaX2sjNae81VoTU=",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
98 "ocdZlAi8uGD7JvmVNGA94BhZ7RoJrYWgjwENZ7+CmVQ=",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
99 "HMtoE2bd6VdJGtcRICoCI1o51jeoWoJyGVPhLLNzFc0=",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
100 "/lTX94wq8KMKK6IAO+/TxZbE9hCIXd+aribRzIzEcSs=",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
101 "GKZjuYqJXFyNd26SHrd+kgeHTq7SlDB11igXyyulJ9c=",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
102 "0il4W1FjrMzDeyaBkswYG+UYgKUBGAhNivzDAPngH3ENN8pSr8cE2m9Q1AKIyKcQ",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
103 "Can1I90vUnRynV74Y10EFEX7TGtaYKeUgkSLLG2UBOX1gspDeDK5Mea3ajPYT8GU",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
104 "6/jEE+HPx5CIr/NqK8mZ9jLeOJXqol6F8Dwzg+uGsDChoXwVwcuKdWBpCHwPDSpE",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
105 "BE8YyUqrqKnjIYP3NYvyPToaSj5Sy8OW3DAFdrPpbCKG1wmyYo7E6pSO9/7DPrQ6",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
106 "pKMowelyCqYG9hC1xVYwSNMcz4BxU+wSJCWeuqNf2gfin7O2GbzRGN4ZOQjHT/5z",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
107 "DHgqVkKZ1vRkM4wqmAy89vZySNDi4HUAf0lzhE/6szzsP1H6vEFCetsTcEcx2umH",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
108 "wmv89rc6xO6b2PrOYtVBurnJvbWRElqpeV2bV3+gTOMnaq7M7kdwty0zT2S9aCAq",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
109 "BTJqEnCTkmX9e7bXxGHsRMsHPincVlFnrL1r513BSnX4e+T4N4vwua1VCiVhLbCX",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
110 "lNH6ysiyVl7ulQIkeWwfF4KDmOgOFSuYqsexMCichTPfoPW66UM5OIN5z2GKJVQbJ8QIgIVHJ2z8b7/xpx1FEyEwHhhasjmnlgTJzbFtR/Y=",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
111 "mByn4m8cJzGAJTJcq7WoBWjmUpcyET9WcZopRJYKzzg6WMdpqb0Hd6KWxnojRY15zGsDlftTCSUVCMvN978fuve2tUcH0vDrwA3VW7cplag=",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
112 "Qm1cteXs4h2veYPmq6+go+zIp3spUwhbO4/FTIKIx3FG/iloAeyNCHvE75uwQ35qUvsDKNfaLme/HNoLPIy1Ss2z3HezdmbMK5bL5GYfOFqUwk4UN2LNosidWyHhREqR",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
113 "3+0fmdc8ifQ9ETG+1rc7OYeyMZzYIcl9o1qqZ/DSzZGwrSZJoLaBobwLvkHPOY5UFC3k8YHXGZZfd3OvhCth9fEA7xEkxH070VXczZu+k5iDNFlwps9SSIIlsR5WAMBr",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
114 "w+8brnAHAorhX9iX/YeYNxJHGRCiyAp8iWshWlw+QU2n+IqNBkINYRj389A+HPcEus7kqqQuITRoCicaykYoGA==",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
115 "2yVLOZEMpy2kXSqtmgGJ10FwIVs1I8sPkDuSQmSb3nwBw5NA96A7ul9N9Z8Qxr7oxiYi+1ZADEdKRUOlIbntSHel6zW8XJAdnP8fqfV/HFv6DdwNbdc9Ofm3PkfkKcudkLhofGr8Tma5kIyESGmA7jLUrLLPtXvM4jneCZoUh/DpWwTcfgeaAuujNO/FPSJsheEZu4ck2wv5qvlYaQx716xkTsXugnpecOSOq5uQkqmSGI0O+aVJ8sgel/JsiGEJew3JDh+jnuK/lKHnsKxhHcX/ZX+OluGK0KbCHYM5RWl5Fb2zJA1SDaDneFqgOqLdSryBOKJeLoNdiFsL7LQY+RK/ElUZn07QoQDLk+xJwFMbF/KTH9KjWA3vEVdh9C0Wc02Jf3AwpaRmrq9/q62dhm+bc+I4NRH1BmROll8PS5Y="
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
116 };
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
117
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
118 static char *cryptkey0aes128strings[] = {
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
119 "yWwheGMLOFi7bUia+105EHpuS2Tv4shfRZh3T0CaXts=",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
120 "wdpntIG/wpTGUOzgt7Pi6GSnc8dVOtvHbjyF6h1p1LY=",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
121 "IJnMdm2WinhlDsQItx/DSW3CFygtEtxAw7cEacoP9j8=",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
122 "vd3IRIru28Xb35+3jKA7PfftbBMvF2z/Cb4e7/2e1vE=",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
123 "ub3TJHUtIsc2Sb1ZeNDfcDYEq9qDcAb6j+qm7Xyg1VA=",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
124 "tXgBCUyxvh7AXiw5ysbMM75v36aeoDniDLUjH723xsA=",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
125 "8g/Vj58LmuGz64biZiA+Oz8nG/e7s0EyF3kcWd5Lmgy86K+AG8c4FlQiAHk7Bscb",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
126 "BuEFNArQgT2uSrK6IsXeFiGlSz9Y3Sh1O7Xgqy6TzGt3XKx6Ixubv7sU8Xo0nKDz",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
127 "jjr0Qliga7PjqJ4rdTqCbd6p3jt3tIQ0xCftctoxaPFZQuiumWT47CxV+alclgV9",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
128 "G0rsiGmM4HZlpnkrPdjEI2+K1d/unmn2QAkl8I68j2+rswPY9VY1zPsRV3x0SfVZ",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
129 "WaoJI8oySoB3sgBSzdflISJRBz0zHarnkrV9wIn0wbKIeN2xxlzxQmUp/RtNnQZq",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
130 "YQNtCIRW0oeTbHPBRMCnfHlm6Xr8uvRgODhv3aVm5OPLmxtlEYAFPja1XvJEcsD6",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
131 "pAdDt3gDc+IsFkzya1cBEV+hi0kYGGDn8HYAq6gs8/sL1i6BjLX8EV1y0oxMIhZk",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
132 "RpOaTK9gAoboRy0oc2y/EY0ZinuG2Cnntc0KvWe7p7QpHqFdOgvhPy5PxF/OImIb",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
133 "bK71oogoMekXTWBycpiBZQ9tz13LDKePfYmsMTZWr1g4Z/9/baSBVHzJvZ2td253310QNVN7elQh5YBLauEaf6nqnRCfhFJjCbAaTMLNN8w=",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
134 "MyypcyOCy39DQJbUsy0fggduPkJVslSRizUqXQZUpuMQf6bDICuXjNBARV6HTBUqhWqatC+35wDBL771udPDPacy3UutZ/nJWQh1nEX0ffE=",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
135 "ps6CbvSuEhuQdzQCr77rgfpHKjWlyDLTPSlDN1ziLlfK4NOgzLRbhQNNfLzoSkGj4eMTqPDoOzeKrbpbpbisxdjUeylPYznuLcFyBVyZn9CRuOOJdkwkkhnooWDpMzSE",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
136 "oQ+IOj9HRGhv0FSpqsVfsHU50TYncFELLRFILA/JQUP9esKYNVjJG1c6uUaRtwCU9dtenBkKP/e/zh+3RSKY26GO/vxG3RWDnYUD1HvJDSR+W7xNUaakFMpGRPCBv6cK",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
137 "aiL1TCWid4j6F/UIPrpz4cq54SHfcp7KLTSaDrcGNIXnLHctbWU1aWHdBjmyZyACIAmQ5l8ul5KafKqaFqPbsw==",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
138 "cOLQc1zi9/l/02FVMBp9D98jnZhwrLLs/1Hn+XT1XxWO2lD56dYiGjMMwjJ0zuHvOGA4wmUwyL0z8kKK3XGhfQqu046i1GXCK/qdHB2b1hnBEEyv0PmKTr28RINP0xckxMk45SYq+HSfeiAyqdupiIHu3Wzx5aBbOjPd9aoGEx7mXRywgzJ56h6jwcNGv7UP3tKaTjkuUDvwhB2Lo875nd9cytC5kj4HLeSXBhtUcxaMxDEWTFK67pqMT6q51t2BV83eAp/BXkis8wpamhYqdv0yiSt4yamLm8IecGfPsHgfCcrnTtK220xbVBRvHMEbP3gui1nApB2vQiweE6Gk5IXIgwN+P/YrihjUzKtJgqCoQ0FigNTQemUGkNalg9+LxiXSg4AFundZQMaRNMNJA/MRKKvHcCps6POwENtYfBY="
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
139 };
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
140
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
141 static char *cryptkey1aes128strings[] = {
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
142 "jJyZsBeggvHnPFCt4ABzJPPI88RHWXLREw760Pwh5VU=",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
143 "R+NDojkR6jmLQBKNk0lu11Ks5OpcOhhnNEh1st5bUB8=",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
144 "ZPjJ09PT65Nb/avJZ/rKiKdTQh2EqFj8C4SCggP8Tdo=",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
145 "Wq4poohvLvgTH07olEbU+1DJ+X5R+rxpeWwHJjeD6/w=",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
146 "mJy65R4TKUIaavlMi06zNxEWHFe+emV9y/EpqGfiR4c=",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
147 "X9ukqaTv+yl8P0xq3+lsSnq0Kq2Vra9QStpT7NWrSUo=",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
148 "2wZ4OBX6UlQ8BKdqVgM4zxfdHhh/GPdWqob0/ryBz9mp4w15omTd1Yy8+1xZ/saz",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
149 "5TV7mnMX48QTjJ3mvn1QQnQCj8OfMbx4mRy1r+OJS/p5lPB3kzGaikaxhtVPuOIU",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
150 "wm5Wx9IhOwteBXjoO4UI79gxBd8LHYfp98akutwmOqYLSz2mJ1ZJPjhlu+fB84Jc",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
151 "3m+JFgTgi0djCnU/hcsFFh4AefpkJ5S1ucX1EDhukm0Dbmxtlw8SWO6sIyA8UsUp",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
152 "G96QAM7L9XHn7/z50CAPadqDEyxHQvJJvvHkiL9VZ7LA2WYfm6/gmJIOPgMZfSxT",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
153 "ZxnZLW2M2P1pYIS6JcTwG3qIA5NlcFsLZvQWpiDTwSGZWcOq5mv+fo6i+sDFu3Gl",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
154 "jXgcKe5k6+B7Jgv5erI571JoR39QlaCtv7IJbYb3Y8C1jTq1DLLgYM7mvBiOaCDT",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
155 "rUWtaNg3xqeRqKl/F6Pjg0C6+uPLOX1DXVwwql6Izer89E1vQTGGpjvN5O0UmWNb",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
156 "LRS2XeeIGPzuMFn3ClMS6HRqnfKqmNQcJx41jkL0JitnufZtnyQYojp4LRf331Z0uE3ZCxwCMxJ+GqX8CLpbR6KVWEdhBmnOXjWFY1nZsiw=",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
157 "jg4aA6BJ7RVy4l9sLz/WPGZfSfUxnFbmfGErnMy6LWJGIQzPvISHkLY6pSH3FSMZMUtnLLDW8KVIGstt5lo8AcflSryGrOwvzm+88HUO5Z8=",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
158 "hkS1WQs4SvLTzr95MaIzV56inCkHMWAt1prL6mzv9UadUYEkpPQK/w3Sq9N/3oeNCb21TqF1I9tAbWJOhRqTj098EnmnmJVI6p2mfRESEBEJULBYKsdQPE85CdL2b0Sh",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
159 "wscy5Q5mi1l8tdA/8v6MrdFQY1PuS10uQNFe/FXnnJS/MRcbcA/R9wlLuWiMt7cUg9Zs74lXc8w7tKkOrSX6zMOHu3hpDjCJA+ZE9gkbP70KIGRnddW5aFhXNy/Sz808",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
160 "92S3C7m5lQnj5Gpjz9zbPyYdPO5j03b/AZ5sSPHbuM/HIlIfcj289sNnFz08MLgDSxLqZsJnlVjLLahWWo1KSA==",
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
161 "0WQozX4DdbVUATNnxn8kzkG30QGLB0kCUMmm1wdbPCqCWzOqo/id98xh++8PHfD/gmOHwIeZgcW6PTsIT7KI17LRq+ryHI8xdRYMW/oPzXQcaKCis0MbBYpaS9OZp6Wbrkbk9NUShqV340DdydBCtl3RXGhEJLyLWqF2XTyuXNL4srNPFP934rHLSSkU7eUD7FzNiE7mTgQ73E5o/h8porPRtNRnbH1hT5SZK71qC8pRlJjMSVBdMgNHfOJDvjFd0Xv+QwDqm3QqcrpirYhkP5M1ofiwBsuFNra1bnojMPiyXgduhUpxsJ0StvBlzEixrtA2NsxfEgDtrJik8ScOQ7GkB8alHPn3jEFa8KsucyQwxuoJ7W1pIzBYKQqZ3QU3I75aSZ5mAM8PxVVxLdC75iZuBe1PvUNle/bljmKJ3QA="
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
162 };
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
163
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
164 static char *d0 = "01234567890123456789012345678901";
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
165 static char *d1 = "gfXa3IJa;.d-afHS1237.:_A12=$%&%!";
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
166 static char *d2 = "%$dhXfdhgf(z@pWqoiv)Zal=di}weQ<c";
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
167 static char *d3 = "%$dhXfdhgf(z@pWqoiv)Zal=di}weQ<c";
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
168 static char *d4 = "<>/(!'§)._,;*++-<Qq@,.=)($%§1aX:";
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
169 static char *d5 = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
170 static char *d6 = ".-.-.-.-.-.-.-.-.-$$$$$$$$$$$$$$";
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
171 static char *d7 = "uAh281._;(12<?2@@$2..;---assf34v";
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
172 static uint32_t d8[] = {17635, 0, 4274927276, 76546, 6098723, 516, 4193367221, 1224964255};
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
173 static uint32_t d9[] = {2234966275, 643123, 427492276, 3334964712, 1337123, 722464014, 4193367111, 3234966518};
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
174 static uint32_t d10[] = {3231664275, 1578414324, 427496129, 4034960712, 93371873, 1722499994, 4193300111, 8765678};
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
175 static uint32_t d11[] = {764564, 12348792, 999432723, 128943278, 664512343, 84327634, 709712334};
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
176 static uint8_t d12[] = {14, 94, 240, 253, 14, 0, 123, 94, 72, 197, 71, 56, 64, 156, 204, 231, 17, 18, 101, 24, 200, 15, 208, 150, 1, 85, 171, 18, 205, 30, 231, 7};
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
177 static uint8_t d13[] = {25, 43, 219, 253, 14, 0, 223, 94, 87, 127, 171, 56, 34, 26, 204, 31, 64, 18, 151, 124, 233, 12, 118, 154, 1, 185, 11, 18, 25, 30, 231, 207};
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
178 static uint8_t d14[] = {15, 0, 220, 253, 14, 5, 223, 234, 157, 157, 121, 56, 71, 216, 254, 31, 61, 192, 151, 255, 0, 12, 118, 14, 5, 185, 124, 18, 25, 54, 131, 227};
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
179 static uint8_t d15[] = {0, 43, 210, 25, 14, 0, 243, 94, 87, 0, 1, 156, 234, 6, 214, 31, 64, 18, 151, 124, 3, 12, 118, 154, 1, 18, 111, 18, 225, 31, 251, 207};
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
180
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
181 static void create_keys() {
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
182 void *data[16] = {d0, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11, d12, d13, d14, d15};
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
183
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
184 for(int i=0;i<16;i++) {
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
185 keys256[i].length = 32;
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
186 keys256[i].type = DAV_KEY_AES256;
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
187 keys256[i].data = data[i];
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
188
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
189 keys128[i].length = 16;
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
190 keys128[i].type = DAV_KEY_AES128;
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
191 keys128[i].data = data[i];
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
192 }
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
193 }
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
194
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
195 UCX_TEST(test_util_decrypt_str_k) {
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
196 create_keys();
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
197
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
198 DavContext *ctx = dav_context_new();
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
199 DavSession *sn = dav_session_new(ctx, "http://localhost/");
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
200
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
201 UCX_TEST_BEGIN;
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
202
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
203 for(int k=0;k<2;k++) {
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
204 for(int i=0;i<20;i++) {
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
205 char *c1;
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
206 char *c2;
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
207 if(k == 0) {
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
208 c1 = cryptkey0aes128strings[i];
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
209 c2 = cryptkey0aes256strings[i];
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
210 } else {
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
211 c1 = cryptkey1aes128strings[i];
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
212 c2 = cryptkey1aes256strings[i];
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
213 }
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
214
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
215 char *s128 = util_decrypt_str_k(sn, c1, &keys128[k]);
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
216 char *s256 = util_decrypt_str_k(sn, c2, &keys256[k]);
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
217
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
218 UCX_TEST_ASSERT(!strcmp(s128, strings[i]), "s128 wrong");
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
219 UCX_TEST_ASSERT(!strcmp(s256, strings[i]), "s256 wrong");
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
220 }
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
221 }
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
222
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
223 UCX_TEST_END;
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
224
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
225 dav_context_destroy(ctx);
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
226 }
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
227
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
228 UCX_TEST(test_util_encrypt_str_k) {
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
229 DavContext *ctx = dav_context_new();
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
230 DavSession *sn = dav_session_new(ctx, "http://localhost/");
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
231
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
232 UCX_TEST_BEGIN;
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
233
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
234 for(int k=0;k<16;k++) {
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
235 for(int i=0;i<20;i++) {
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
236 char *aes128 = util_encrypt_str_k(sn, strings[i], &keys128[k]);
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
237 char *aes256 = util_encrypt_str_k(sn, strings[i], &keys256[k]);
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
238
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
239 char *d1 = util_decrypt_str_k(sn, aes128, &keys128[k]);
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
240 char *d2 = util_decrypt_str_k(sn, aes256, &keys256[k]);
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
241
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
242 UCX_TEST_ASSERT(!strcmp(d1, strings[i]), "aes128 encrypt failed");
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
243 UCX_TEST_ASSERT(!strcmp(d2, strings[i]), "aes256 encrypt failed");
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
244 }
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
245 }
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
246
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
247 UCX_TEST_END;
c3d98b2cccf3 adds tests for crypto util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
248 }
308
82275f589d8d adds test for crypto streams
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 305
diff changeset
249
82275f589d8d adds test for crypto streams
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 305
diff changeset
250 UCX_TEST(test_crypto_stream) {
82275f589d8d adds test for crypto streams
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 305
diff changeset
251 UcxBuffer *data = ucx_buffer_new(NULL, 1024, UCX_BUFFER_AUTOEXTEND);
82275f589d8d adds test for crypto streams
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 305
diff changeset
252 UcxBuffer *cbuf = ucx_buffer_new(NULL, 1024, UCX_BUFFER_AUTOEXTEND);
82275f589d8d adds test for crypto streams
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 305
diff changeset
253 UcxBuffer *pbuf = ucx_buffer_new(NULL, 1024, UCX_BUFFER_AUTOEXTEND);
82275f589d8d adds test for crypto streams
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 305
diff changeset
254
82275f589d8d adds test for crypto streams
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 305
diff changeset
255 UCX_TEST_BEGIN;
82275f589d8d adds test for crypto streams
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 305
diff changeset
256
82275f589d8d adds test for crypto streams
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 305
diff changeset
257 for(int i=0;i<32;i++) {
82275f589d8d adds test for crypto streams
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 305
diff changeset
258 DavKey *key = i < 16 ? &keys256[i] : &keys128[i%16];
82275f589d8d adds test for crypto streams
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 305
diff changeset
259 for(int j=0;j<20;j++) {
82275f589d8d adds test for crypto streams
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 305
diff changeset
260 data->pos = 0;
82275f589d8d adds test for crypto streams
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 305
diff changeset
261 data->size = 0;
82275f589d8d adds test for crypto streams
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 305
diff changeset
262 size_t slen = strlen(strings[j]);
82275f589d8d adds test for crypto streams
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 305
diff changeset
263 ucx_buffer_write(strings[j], 1, slen, data);
82275f589d8d adds test for crypto streams
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 305
diff changeset
264 ucx_buffer_seek(data, 0, SEEK_SET);
82275f589d8d adds test for crypto streams
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 305
diff changeset
265
82275f589d8d adds test for crypto streams
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 305
diff changeset
266 cbuf->pos = 0;
82275f589d8d adds test for crypto streams
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 305
diff changeset
267 cbuf->size = 0;
82275f589d8d adds test for crypto streams
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 305
diff changeset
268 pbuf->pos = 0;
82275f589d8d adds test for crypto streams
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 305
diff changeset
269 pbuf->size = 0;
82275f589d8d adds test for crypto streams
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 305
diff changeset
270
82275f589d8d adds test for crypto streams
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 305
diff changeset
271 AESEncrypter *enc = aes_encrypter_new(key, data, (dav_read_func)ucx_buffer_read);
82275f589d8d adds test for crypto streams
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 305
diff changeset
272 char buf[1024];
82275f589d8d adds test for crypto streams
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 305
diff changeset
273 size_t r = 0;
82275f589d8d adds test for crypto streams
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 305
diff changeset
274 while((r = aes_read(buf, 1, 1024, enc)) != 0) {
82275f589d8d adds test for crypto streams
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 305
diff changeset
275 ucx_buffer_write(buf, 1, r, cbuf);
82275f589d8d adds test for crypto streams
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 305
diff changeset
276 }
82275f589d8d adds test for crypto streams
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 305
diff changeset
277 aes_encrypter_close(enc);
82275f589d8d adds test for crypto streams
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 305
diff changeset
278
82275f589d8d adds test for crypto streams
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 305
diff changeset
279 AESDecrypter *dec = aes_decrypter_new(key, pbuf, (dav_write_func)ucx_buffer_write);
82275f589d8d adds test for crypto streams
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 305
diff changeset
280 aes_write(cbuf->space, 1, cbuf->pos, dec);
82275f589d8d adds test for crypto streams
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 305
diff changeset
281 aes_decrypter_shutdown(dec);
82275f589d8d adds test for crypto streams
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 305
diff changeset
282 aes_decrypter_close(dec);
82275f589d8d adds test for crypto streams
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 305
diff changeset
283
82275f589d8d adds test for crypto streams
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 305
diff changeset
284 UCX_TEST_ASSERT(slen == pbuf->pos, "wrong length after enc-dec");
82275f589d8d adds test for crypto streams
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 305
diff changeset
285 UCX_TEST_ASSERT(!memcmp(strings[j], pbuf->space, slen), "wrong content after enc-dec");
82275f589d8d adds test for crypto streams
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 305
diff changeset
286 }
82275f589d8d adds test for crypto streams
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 305
diff changeset
287 }
82275f589d8d adds test for crypto streams
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 305
diff changeset
288
82275f589d8d adds test for crypto streams
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 305
diff changeset
289 UCX_TEST_END;
82275f589d8d adds test for crypto streams
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 305
diff changeset
290 }

mercurial