t_dst.c revision 19ce0d25d31e716a737674c4e04a88c33b222fe4
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington/*
499b34cea04a46823d003d4c0520c8b03e8513cbBrian Wellington * Copyright (C) 1999, 2000 Internet Software Consortium.
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence *
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington * Permission to use, copy, modify, and distribute this software for any
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington * purpose with or without fee is hereby granted, provided that the above
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington * copyright notice and this permission notice appear in all copies.
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence *
15a44745412679c30a6d022733925af70a38b715David Lawrence * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
15a44745412679c30a6d022733925af70a38b715David Lawrence * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
15a44745412679c30a6d022733925af70a38b715David Lawrence * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
15a44745412679c30a6d022733925af70a38b715David Lawrence * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
15a44745412679c30a6d022733925af70a38b715David Lawrence * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
15a44745412679c30a6d022733925af70a38b715David Lawrence * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
15a44745412679c30a6d022733925af70a38b715David Lawrence * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
15a44745412679c30a6d022733925af70a38b715David Lawrence * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington */
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington/* $Id: t_dst.c,v 1.42 2000/11/15 00:20:34 tale Exp $ */
4b171ebd702d72200a4d7609f11c5f79d6b6f964Brian Wellington
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington#include <config.h>
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington#include <sys/types.h> /* Required for dirent.h */
564c1b8f42d33a66c0f5c67d66bf0cd063c8b047Brian Wellington#include <sys/stat.h>
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington
0f80bfec687db08a6e6ce945ef1d818da06c7ca9Brian Wellington#include <dirent.h> /* XXX */
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence#include <errno.h>
6734ac097f78601a8194b06360e62e043dcffdb8Brian Wellington#include <fcntl.h>
100d0d2ec64ab1a85f8c0d2da9b47ae411a10b21Brian Wellington#include <limits.h>
6028d1ce0380d0ba7f6c6ecd1ad20b31ddd1becbDavid Lawrence#include <stdlib.h>
364a82f7c25b62967678027043425201a5e5171aBob Halley
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington#include <unistd.h> /* XXX */
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington
a5e73f3e9d909e86baca18713c5697f52aca87caBrian Wellington#include <isc/buffer.h>
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington#include <isc/dir.h>
a49acbf201a411a47e18d136b38bbea8cf283adaBrian Wellington#include <isc/entropy.h>
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington#include <isc/file.h>
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington#include <isc/mem.h>
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington#include <isc/region.h>
0f80bfec687db08a6e6ce945ef1d818da06c7ca9Brian Wellington#include <isc/string.h>
09f22ac5b09e70bc526015f37168ba33e21ea91fDavid Lawrence#include <isc/util.h>
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington#include <dns/fixedname.h>
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington#include <dns/name.h>
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington
92ef1a9b9dbd48ecb507b42ac62c15afefdaf838David Lawrence#include <dst/dst.h>
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence#include <dst/result.h>
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington
b984520acca2532d048eae929dc0682dd334c7a3Brian Wellington#include <tests/t_api.h>
a00c5e2151cc03c06bae5cdd3b40a5de05664059Brian Wellington
a00c5e2151cc03c06bae5cdd3b40a5de05664059Brian Wellington/*
0e5d6900bdfcbeef8919e6fb453ca6c44f62ccd8Brian Wellington * Adapted from the original dst_test.c program.
0e5d6900bdfcbeef8919e6fb453ca6c44f62ccd8Brian Wellington * XXXDCL should use isc_dir_*.
f2338a0d6aa0327372eb20ab5dc29502bc8c71efBrian Wellington */
1e2749dba8aae3233b8962f1efe15385e92a77d9Brian Wellington
1e2749dba8aae3233b8962f1efe15385e92a77d9Brian Wellingtonstatic void
4755b174df8221dff7e872f21d42b3572a74bf2fAndreas Gustafssoncleandir(char *path) {
4755b174df8221dff7e872f21d42b3572a74bf2fAndreas Gustafsson DIR *dirp;
1e2749dba8aae3233b8962f1efe15385e92a77d9Brian Wellington struct dirent *pe;
4755b174df8221dff7e872f21d42b3572a74bf2fAndreas Gustafsson char fullname[PATH_MAX + 1];
4755b174df8221dff7e872f21d42b3572a74bf2fAndreas Gustafsson
4755b174df8221dff7e872f21d42b3572a74bf2fAndreas Gustafsson dirp = opendir(path);
4755b174df8221dff7e872f21d42b3572a74bf2fAndreas Gustafsson if (dirp == NULL) {
4755b174df8221dff7e872f21d42b3572a74bf2fAndreas Gustafsson t_info("opendir(%s) failed %d\n", path, opendir);
4755b174df8221dff7e872f21d42b3572a74bf2fAndreas Gustafsson return;
4755b174df8221dff7e872f21d42b3572a74bf2fAndreas Gustafsson }
1e2749dba8aae3233b8962f1efe15385e92a77d9Brian Wellington
1e2749dba8aae3233b8962f1efe15385e92a77d9Brian Wellington while ((pe = readdir(dirp)) != NULL) {
4755b174df8221dff7e872f21d42b3572a74bf2fAndreas Gustafsson if (! strcmp(pe->d_name, "."))
4755b174df8221dff7e872f21d42b3572a74bf2fAndreas Gustafsson continue;
4755b174df8221dff7e872f21d42b3572a74bf2fAndreas Gustafsson if (! strcmp(pe->d_name, ".."))
4755b174df8221dff7e872f21d42b3572a74bf2fAndreas Gustafsson continue;
4755b174df8221dff7e872f21d42b3572a74bf2fAndreas Gustafsson strcpy(fullname, path);
4755b174df8221dff7e872f21d42b3572a74bf2fAndreas Gustafsson strcat(fullname, "/");
4755b174df8221dff7e872f21d42b3572a74bf2fAndreas Gustafsson strcat(fullname, pe->d_name);
4755b174df8221dff7e872f21d42b3572a74bf2fAndreas Gustafsson if (remove(fullname))
4755b174df8221dff7e872f21d42b3572a74bf2fAndreas Gustafsson t_info("remove(%s) failed %d\n", fullname, errno);
4755b174df8221dff7e872f21d42b3572a74bf2fAndreas Gustafsson
4755b174df8221dff7e872f21d42b3572a74bf2fAndreas Gustafsson }
4755b174df8221dff7e872f21d42b3572a74bf2fAndreas Gustafsson (void)closedir(dirp);
a00c5e2151cc03c06bae5cdd3b40a5de05664059Brian Wellington if (rmdir(path))
a00c5e2151cc03c06bae5cdd3b40a5de05664059Brian Wellington t_info("rmdir(%s) failed %d\n", path, errno);
e61793f0865117ad87a19d6e245bea8f3b712d1bDanny Mayer
a00c5e2151cc03c06bae5cdd3b40a5de05664059Brian Wellington return;
0e5d6900bdfcbeef8919e6fb453ca6c44f62ccd8Brian Wellington}
4755b174df8221dff7e872f21d42b3572a74bf2fAndreas Gustafsson
4755b174df8221dff7e872f21d42b3572a74bf2fAndreas Gustafssonstatic void
4755b174df8221dff7e872f21d42b3572a74bf2fAndreas Gustafssonuse(dst_key_t *key, isc_mem_t *mctx, isc_result_t exp_result, int *nfails) {
4755b174df8221dff7e872f21d42b3572a74bf2fAndreas Gustafsson
4755b174df8221dff7e872f21d42b3572a74bf2fAndreas Gustafsson isc_result_t ret;
4755b174df8221dff7e872f21d42b3572a74bf2fAndreas Gustafsson const char *data = "This is some data";
4755b174df8221dff7e872f21d42b3572a74bf2fAndreas Gustafsson unsigned char sig[512];
4755b174df8221dff7e872f21d42b3572a74bf2fAndreas Gustafsson isc_buffer_t databuf, sigbuf;
4755b174df8221dff7e872f21d42b3572a74bf2fAndreas Gustafsson isc_region_t datareg, sigreg;
4755b174df8221dff7e872f21d42b3572a74bf2fAndreas Gustafsson dst_context_t *ctx = NULL;
0e5d6900bdfcbeef8919e6fb453ca6c44f62ccd8Brian Wellington
0e5d6900bdfcbeef8919e6fb453ca6c44f62ccd8Brian Wellington isc_buffer_init(&sigbuf, sig, sizeof(sig));
e61793f0865117ad87a19d6e245bea8f3b712d1bDanny Mayer isc_buffer_init(&databuf, data, strlen(data));
0e5d6900bdfcbeef8919e6fb453ca6c44f62ccd8Brian Wellington isc_buffer_add(&databuf, strlen(data));
b984520acca2532d048eae929dc0682dd334c7a3Brian Wellington isc_buffer_usedregion(&databuf, &datareg);
809fdfba224a83fcc5a8ae4394cf2a477d13dc91Brian Wellington
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington ret = dst_context_create(key, mctx, &ctx);
76c8294c81fb48b1da6e1fc5b83322a4cedb8e58Andreas Gustafsson if (ret != exp_result) {
76c8294c81fb48b1da6e1fc5b83322a4cedb8e58Andreas Gustafsson t_info("dst_context_create(%d) returned (%s) expected (%s)\n",
76c8294c81fb48b1da6e1fc5b83322a4cedb8e58Andreas Gustafsson dst_key_alg(key), dst_result_totext(ret),
76c8294c81fb48b1da6e1fc5b83322a4cedb8e58Andreas Gustafsson dst_result_totext(exp_result));
020ebf119089ef68070d6a0df2def3142f1eeff4Brian Wellington ++*nfails;
020ebf119089ef68070d6a0df2def3142f1eeff4Brian Wellington return;
020ebf119089ef68070d6a0df2def3142f1eeff4Brian Wellington }
020ebf119089ef68070d6a0df2def3142f1eeff4Brian Wellington if (exp_result != ISC_R_SUCCESS)
020ebf119089ef68070d6a0df2def3142f1eeff4Brian Wellington return;
020ebf119089ef68070d6a0df2def3142f1eeff4Brian Wellington ret = dst_context_adddata(ctx, &datareg);
020ebf119089ef68070d6a0df2def3142f1eeff4Brian Wellington if (ret != ISC_R_SUCCESS) {
020ebf119089ef68070d6a0df2def3142f1eeff4Brian Wellington t_info("dst_context_adddata(%d) returned (%s)\n",
020ebf119089ef68070d6a0df2def3142f1eeff4Brian Wellington dst_key_alg(key), dst_result_totext(ret));
020ebf119089ef68070d6a0df2def3142f1eeff4Brian Wellington ++*nfails;
020ebf119089ef68070d6a0df2def3142f1eeff4Brian Wellington dst_context_destroy(&ctx);
020ebf119089ef68070d6a0df2def3142f1eeff4Brian Wellington return;
020ebf119089ef68070d6a0df2def3142f1eeff4Brian Wellington }
020ebf119089ef68070d6a0df2def3142f1eeff4Brian Wellington ret = dst_context_sign(ctx, &sigbuf);
020ebf119089ef68070d6a0df2def3142f1eeff4Brian Wellington if (ret != ISC_R_SUCCESS) {
020ebf119089ef68070d6a0df2def3142f1eeff4Brian Wellington t_info("dst_context_sign(%d) returned (%s)\n",
020ebf119089ef68070d6a0df2def3142f1eeff4Brian Wellington dst_key_alg(key), dst_result_totext(ret));
020ebf119089ef68070d6a0df2def3142f1eeff4Brian Wellington ++*nfails;
020ebf119089ef68070d6a0df2def3142f1eeff4Brian Wellington dst_context_destroy(&ctx);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington return;
a00c5e2151cc03c06bae5cdd3b40a5de05664059Brian Wellington }
a00c5e2151cc03c06bae5cdd3b40a5de05664059Brian Wellington dst_context_destroy(&ctx);
a00c5e2151cc03c06bae5cdd3b40a5de05664059Brian Wellington
a00c5e2151cc03c06bae5cdd3b40a5de05664059Brian Wellington isc_buffer_remainingregion(&sigbuf, &sigreg);
a00c5e2151cc03c06bae5cdd3b40a5de05664059Brian Wellington ret = dst_context_create(key, mctx, &ctx);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington if (ret != ISC_R_SUCCESS) {
3f6dc1703f76a24b34ed3bc839447291c33ca837Brian Wellington t_info("dst_context_create(%d) returned (%s)\n",
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington dst_key_alg(key), dst_result_totext(ret));
100d0d2ec64ab1a85f8c0d2da9b47ae411a10b21Brian Wellington ++*nfails;
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington return;
e552b980379e3a7ffce1411a939c62e27f953133Brian Wellington }
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington ret = dst_context_adddata(ctx, &datareg);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington if (ret != ISC_R_SUCCESS) {
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington t_info("dst_context_adddata(%d) returned (%s)\n",
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington dst_key_alg(key), dst_result_totext(ret));
e552b980379e3a7ffce1411a939c62e27f953133Brian Wellington ++*nfails;
e552b980379e3a7ffce1411a939c62e27f953133Brian Wellington dst_context_destroy(&ctx);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington return;
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington }
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington ret = dst_context_verify(ctx, &sigreg);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington if (ret != exp_result) {
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington t_info("dst_context_verify(%d) returned (%s) expected (%s)\n",
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington dst_key_alg(key), dst_result_totext(ret),
1f1d36a87b65186d9f89aac7f456ab1fd2a39ef6Andreas Gustafsson dst_result_totext(exp_result));
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington ++*nfails;
ff7b9eede951083d1f8a1ad919611659c3e20b34Brian Wellington dst_context_destroy(&ctx);
f2338a0d6aa0327372eb20ab5dc29502bc8c71efBrian Wellington return;
ff7b9eede951083d1f8a1ad919611659c3e20b34Brian Wellington }
ff7b9eede951083d1f8a1ad919611659c3e20b34Brian Wellington dst_context_destroy(&ctx);
ff7b9eede951083d1f8a1ad919611659c3e20b34Brian Wellington}
ff7b9eede951083d1f8a1ad919611659c3e20b34Brian Wellington
ff7b9eede951083d1f8a1ad919611659c3e20b34Brian Wellingtonstatic void
a00c5e2151cc03c06bae5cdd3b40a5de05664059Brian Wellingtondh(dns_name_t *name1, int id1, dns_name_t *name2, int id2, isc_mem_t *mctx,
ff7b9eede951083d1f8a1ad919611659c3e20b34Brian Wellington isc_result_t exp_result, int *nfails, int *nprobs)
ff7b9eede951083d1f8a1ad919611659c3e20b34Brian Wellington{
ff7b9eede951083d1f8a1ad919611659c3e20b34Brian Wellington dst_key_t *key1 = NULL, *key2 = NULL;
ff7b9eede951083d1f8a1ad919611659c3e20b34Brian Wellington isc_result_t ret;
ff7b9eede951083d1f8a1ad919611659c3e20b34Brian Wellington char current[PATH_MAX + 1];
0e5d6900bdfcbeef8919e6fb453ca6c44f62ccd8Brian Wellington char tmp[PATH_MAX + 1];
ff7b9eede951083d1f8a1ad919611659c3e20b34Brian Wellington char *p;
ff7b9eede951083d1f8a1ad919611659c3e20b34Brian Wellington int alg = DST_ALG_DH;
ff7b9eede951083d1f8a1ad919611659c3e20b34Brian Wellington int type = DST_TYPE_PUBLIC|DST_TYPE_PRIVATE;
ff7b9eede951083d1f8a1ad919611659c3e20b34Brian Wellington unsigned char array1[1024], array2[1024];
ff7b9eede951083d1f8a1ad919611659c3e20b34Brian Wellington isc_buffer_t b1, b2;
a00c5e2151cc03c06bae5cdd3b40a5de05664059Brian Wellington isc_region_t r1, r2;
7863e6bd4396e99a82805feccb59275530670829Andreas Gustafsson
f2338a0d6aa0327372eb20ab5dc29502bc8c71efBrian Wellington UNUSED(exp_result);
f2338a0d6aa0327372eb20ab5dc29502bc8c71efBrian Wellington
f2338a0d6aa0327372eb20ab5dc29502bc8c71efBrian Wellington p = getcwd(current, PATH_MAX);;
f2338a0d6aa0327372eb20ab5dc29502bc8c71efBrian Wellington if (p == NULL) {
f2338a0d6aa0327372eb20ab5dc29502bc8c71efBrian Wellington t_info("getcwd failed %d\n", errno);
f2338a0d6aa0327372eb20ab5dc29502bc8c71efBrian Wellington ++*nprobs;
f2338a0d6aa0327372eb20ab5dc29502bc8c71efBrian Wellington return;
f2338a0d6aa0327372eb20ab5dc29502bc8c71efBrian Wellington }
f2338a0d6aa0327372eb20ab5dc29502bc8c71efBrian Wellington
f2338a0d6aa0327372eb20ab5dc29502bc8c71efBrian Wellington ret = dst_key_fromfile(name1, id1, alg, type, current, mctx, &key1);
f2338a0d6aa0327372eb20ab5dc29502bc8c71efBrian Wellington if (ret != ISC_R_SUCCESS) {
1f1d36a87b65186d9f89aac7f456ab1fd2a39ef6Andreas Gustafsson t_info("dst_key_fromfile(%d) returned: %s\n",
1f1d36a87b65186d9f89aac7f456ab1fd2a39ef6Andreas Gustafsson alg, dst_result_totext(ret));
f2338a0d6aa0327372eb20ab5dc29502bc8c71efBrian Wellington ++*nfails;
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington return;
d598338952797df77417e69fcb8782b73651f9a9Brian Wellington }
d598338952797df77417e69fcb8782b73651f9a9Brian Wellington
d598338952797df77417e69fcb8782b73651f9a9Brian Wellington ret = dst_key_fromfile(name2, id2, alg, type, current, mctx, &key2);
d598338952797df77417e69fcb8782b73651f9a9Brian Wellington if (ret != ISC_R_SUCCESS) {
d598338952797df77417e69fcb8782b73651f9a9Brian Wellington t_info("dst_key_fromfile(%d) returned: %s\n",
d598338952797df77417e69fcb8782b73651f9a9Brian Wellington alg, dst_result_totext(ret));
d598338952797df77417e69fcb8782b73651f9a9Brian Wellington ++*nfails;
4be64854b4a3da0465bf962caa8488699e0e0681Brian Wellington return;
d598338952797df77417e69fcb8782b73651f9a9Brian Wellington }
d598338952797df77417e69fcb8782b73651f9a9Brian Wellington
d598338952797df77417e69fcb8782b73651f9a9Brian Wellington ret = isc_file_mktemplate("/tmp/", tmp, sizeof(tmp));
d598338952797df77417e69fcb8782b73651f9a9Brian Wellington if (ret != ISC_R_SUCCESS) {
1e2749dba8aae3233b8962f1efe15385e92a77d9Brian Wellington t_info("isc_file_mktemplate failed %s\n",
4a2f65ad8a26261e758d9682d88eb29395422fb9Brian Wellington isc_result_totext(ret));
d598338952797df77417e69fcb8782b73651f9a9Brian Wellington ++*nprobs;
a00c5e2151cc03c06bae5cdd3b40a5de05664059Brian Wellington return;
49c8a96fba8d85810d470fdc7dd3388f0c767c9eBrian Wellington }
49c8a96fba8d85810d470fdc7dd3388f0c767c9eBrian Wellington
a00c5e2151cc03c06bae5cdd3b40a5de05664059Brian Wellington ret = isc_dir_createunique(tmp);
a00c5e2151cc03c06bae5cdd3b40a5de05664059Brian Wellington if (ret != ISC_R_SUCCESS) {
a00c5e2151cc03c06bae5cdd3b40a5de05664059Brian Wellington t_info("isc_dir_createunique failed %s\n",
a00c5e2151cc03c06bae5cdd3b40a5de05664059Brian Wellington isc_result_totext(ret));
49c8a96fba8d85810d470fdc7dd3388f0c767c9eBrian Wellington ++*nprobs;
a00c5e2151cc03c06bae5cdd3b40a5de05664059Brian Wellington return;
1a2c699f0eb89fbd776a2dfabb6e197fe36a8c20Brian Wellington }
100d0d2ec64ab1a85f8c0d2da9b47ae411a10b21Brian Wellington
a00c5e2151cc03c06bae5cdd3b40a5de05664059Brian Wellington ret = dst_key_tofile(key1, type, tmp);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington if (ret != 0) {
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington t_info("dst_key_tofile(%d) returned: %s\n",
e552b980379e3a7ffce1411a939c62e27f953133Brian Wellington alg, dst_result_totext(ret));
100d0d2ec64ab1a85f8c0d2da9b47ae411a10b21Brian Wellington ++*nfails;
100d0d2ec64ab1a85f8c0d2da9b47ae411a10b21Brian Wellington return;
ac335315cddc0a42b9235001197dcf719ae737b6Brian Wellington }
fb01226bcd598c36b5edc566489c890c39f03ed3Brian Wellington
fb01226bcd598c36b5edc566489c890c39f03ed3Brian Wellington ret = dst_key_tofile(key2, type, tmp);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington if (ret != 0) {
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence t_info("dst_key_tofile(%d) returned: %s\n",
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington alg, dst_result_totext(ret));
b6666e61dc9b91f4ac6af3aa1172bfd8a5f2d6ffBrian Wellington ++*nfails;
8447ecf6fd002e264c4746a10193916aa64dd8c7Brian Wellington return;
70d950d16e9623fec1bc89b158047de507071ce3Brian Wellington }
70d950d16e9623fec1bc89b158047de507071ce3Brian Wellington
70d950d16e9623fec1bc89b158047de507071ce3Brian Wellington cleandir(tmp);
70d950d16e9623fec1bc89b158047de507071ce3Brian Wellington
26a5f97dd8770ced729025488091b77d8beb0ab6Brian Wellington isc_buffer_init(&b1, array1, sizeof(array1));
26a5f97dd8770ced729025488091b77d8beb0ab6Brian Wellington ret = dst_key_computesecret(key1, key2, &b1);
70d950d16e9623fec1bc89b158047de507071ce3Brian Wellington if (ret != 0) {
b6666e61dc9b91f4ac6af3aa1172bfd8a5f2d6ffBrian Wellington t_info("dst_computesecret() returned: %s\n",
b6666e61dc9b91f4ac6af3aa1172bfd8a5f2d6ffBrian Wellington dst_result_totext(ret));
b6666e61dc9b91f4ac6af3aa1172bfd8a5f2d6ffBrian Wellington ++*nfails;
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington return;
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington }
f2338a0d6aa0327372eb20ab5dc29502bc8c71efBrian Wellington
f2338a0d6aa0327372eb20ab5dc29502bc8c71efBrian Wellington isc_buffer_init(&b2, array2, sizeof(array2));
f2338a0d6aa0327372eb20ab5dc29502bc8c71efBrian Wellington ret = dst_key_computesecret(key2, key1, &b2);
f2338a0d6aa0327372eb20ab5dc29502bc8c71efBrian Wellington if (ret != 0) {
f2338a0d6aa0327372eb20ab5dc29502bc8c71efBrian Wellington t_info("dst_computesecret() returned: %s\n",
f2338a0d6aa0327372eb20ab5dc29502bc8c71efBrian Wellington dst_result_totext(ret));
f2338a0d6aa0327372eb20ab5dc29502bc8c71efBrian Wellington ++*nfails;
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington return;
f2338a0d6aa0327372eb20ab5dc29502bc8c71efBrian Wellington }
ddbc279e7b6a2d6ba682e60ca12956406030054bBrian Wellington
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington isc_buffer_usedregion(&b1, &r1);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington isc_buffer_usedregion(&b2, &r2);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington if (r1.length != r2.length || memcmp(r1.base, r2.base, r1.length) != 0)
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington {
a00c5e2151cc03c06bae5cdd3b40a5de05664059Brian Wellington t_info("computed secrets don't match\n");
a00c5e2151cc03c06bae5cdd3b40a5de05664059Brian Wellington ++*nfails;
a00c5e2151cc03c06bae5cdd3b40a5de05664059Brian Wellington return;
a00c5e2151cc03c06bae5cdd3b40a5de05664059Brian Wellington }
a00c5e2151cc03c06bae5cdd3b40a5de05664059Brian Wellington
a00c5e2151cc03c06bae5cdd3b40a5de05664059Brian Wellington dst_key_free(&key1);
a00c5e2151cc03c06bae5cdd3b40a5de05664059Brian Wellington dst_key_free(&key2);
a00c5e2151cc03c06bae5cdd3b40a5de05664059Brian Wellington}
a00c5e2151cc03c06bae5cdd3b40a5de05664059Brian Wellington
a00c5e2151cc03c06bae5cdd3b40a5de05664059Brian Wellingtonstatic void
a00c5e2151cc03c06bae5cdd3b40a5de05664059Brian Wellingtonio(dns_name_t *name, int id, int alg, int type, isc_mem_t *mctx,
a00c5e2151cc03c06bae5cdd3b40a5de05664059Brian Wellington isc_result_t exp_result, int *nfails, int *nprobs)
a00c5e2151cc03c06bae5cdd3b40a5de05664059Brian Wellington{
a00c5e2151cc03c06bae5cdd3b40a5de05664059Brian Wellington dst_key_t *key = NULL;
a00c5e2151cc03c06bae5cdd3b40a5de05664059Brian Wellington isc_result_t ret;
7863e6bd4396e99a82805feccb59275530670829Andreas Gustafsson char current[PATH_MAX + 1];
a00c5e2151cc03c06bae5cdd3b40a5de05664059Brian Wellington char tmp[PATH_MAX + 1];
9d967288c374ad4988334cd575ba1cca2b69f70eBrian Wellington char *p;
a00c5e2151cc03c06bae5cdd3b40a5de05664059Brian Wellington
a00c5e2151cc03c06bae5cdd3b40a5de05664059Brian Wellington p = getcwd(current, PATH_MAX);;
a00c5e2151cc03c06bae5cdd3b40a5de05664059Brian Wellington if (p == NULL) {
a00c5e2151cc03c06bae5cdd3b40a5de05664059Brian Wellington t_info("getcwd failed %d\n", errno);
a00c5e2151cc03c06bae5cdd3b40a5de05664059Brian Wellington ++*nprobs;
a00c5e2151cc03c06bae5cdd3b40a5de05664059Brian Wellington return;
a00c5e2151cc03c06bae5cdd3b40a5de05664059Brian Wellington }
5c29047792191d6141f69b2684314d0b762fedebBrian Wellington
a00c5e2151cc03c06bae5cdd3b40a5de05664059Brian Wellington ret = dst_key_fromfile(name, id, alg, type, current, mctx, &key);
a00c5e2151cc03c06bae5cdd3b40a5de05664059Brian Wellington if (ret != ISC_R_SUCCESS) {
a00c5e2151cc03c06bae5cdd3b40a5de05664059Brian Wellington t_info("dst_key_fromfile(%d) returned: %s\n",
a00c5e2151cc03c06bae5cdd3b40a5de05664059Brian Wellington alg, dst_result_totext(ret));
a00c5e2151cc03c06bae5cdd3b40a5de05664059Brian Wellington ++*nfails;
a00c5e2151cc03c06bae5cdd3b40a5de05664059Brian Wellington return;
a00c5e2151cc03c06bae5cdd3b40a5de05664059Brian Wellington }
a00c5e2151cc03c06bae5cdd3b40a5de05664059Brian Wellington
a00c5e2151cc03c06bae5cdd3b40a5de05664059Brian Wellington ret = isc_file_mktemplate("/tmp/", tmp, sizeof(tmp));
a00c5e2151cc03c06bae5cdd3b40a5de05664059Brian Wellington if (ret != ISC_R_SUCCESS) {
a00c5e2151cc03c06bae5cdd3b40a5de05664059Brian Wellington t_info("isc_file_mktemplate failed %s\n",
a00c5e2151cc03c06bae5cdd3b40a5de05664059Brian Wellington isc_result_totext(ret));
af602636644fdfaabc331bd926b0aabb9432e152Brian Wellington ++*nprobs;
af602636644fdfaabc331bd926b0aabb9432e152Brian Wellington return;
af602636644fdfaabc331bd926b0aabb9432e152Brian Wellington }
af602636644fdfaabc331bd926b0aabb9432e152Brian Wellington
af602636644fdfaabc331bd926b0aabb9432e152Brian Wellington ret = isc_dir_createunique(tmp);
100d0d2ec64ab1a85f8c0d2da9b47ae411a10b21Brian Wellington if (ret != ISC_R_SUCCESS) {
af602636644fdfaabc331bd926b0aabb9432e152Brian Wellington t_info("mkdir failed %d\n", errno);
af602636644fdfaabc331bd926b0aabb9432e152Brian Wellington ++*nprobs;
af602636644fdfaabc331bd926b0aabb9432e152Brian Wellington return;
d0345e08f26267c1d11e02af57a6555868068415Brian Wellington }
af602636644fdfaabc331bd926b0aabb9432e152Brian Wellington
af602636644fdfaabc331bd926b0aabb9432e152Brian Wellington ret = dst_key_tofile(key, type, tmp);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington if (ret != 0) {
af602636644fdfaabc331bd926b0aabb9432e152Brian Wellington t_info("dst_key_tofile(%d) returned: %s\n",
af602636644fdfaabc331bd926b0aabb9432e152Brian Wellington alg, dst_result_totext(ret));
f2338a0d6aa0327372eb20ab5dc29502bc8c71efBrian Wellington ++*nfails;
f2338a0d6aa0327372eb20ab5dc29502bc8c71efBrian Wellington return;
f2338a0d6aa0327372eb20ab5dc29502bc8c71efBrian Wellington }
f2338a0d6aa0327372eb20ab5dc29502bc8c71efBrian Wellington
af602636644fdfaabc331bd926b0aabb9432e152Brian Wellington if (dst_key_alg(key) != DST_ALG_DH)
af602636644fdfaabc331bd926b0aabb9432e152Brian Wellington use(key, mctx, exp_result, nfails);
af602636644fdfaabc331bd926b0aabb9432e152Brian Wellington
af602636644fdfaabc331bd926b0aabb9432e152Brian Wellington cleandir(tmp);
af602636644fdfaabc331bd926b0aabb9432e152Brian Wellington
d598338952797df77417e69fcb8782b73651f9a9Brian Wellington dst_key_free(&key);
100d0d2ec64ab1a85f8c0d2da9b47ae411a10b21Brian Wellington}
af602636644fdfaabc331bd926b0aabb9432e152Brian Wellington
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellingtonstatic void
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellingtongenerate(int alg, isc_mem_t *mctx, int size, int *nfails) {
d0345e08f26267c1d11e02af57a6555868068415Brian Wellington isc_result_t ret;
a49acbf201a411a47e18d136b38bbea8cf283adaBrian Wellington dst_key_t *key = NULL;
a49acbf201a411a47e18d136b38bbea8cf283adaBrian Wellington
100d0d2ec64ab1a85f8c0d2da9b47ae411a10b21Brian Wellington ret = dst_key_generate(dns_rootname, alg, size, 0, 0, 0,
d0345e08f26267c1d11e02af57a6555868068415Brian Wellington dns_rdataclass_in, mctx, &key);
a49acbf201a411a47e18d136b38bbea8cf283adaBrian Wellington if (ret != ISC_R_SUCCESS) {
a49acbf201a411a47e18d136b38bbea8cf283adaBrian Wellington t_info("dst_key_generate(%d) returned: %s\n", alg,
100d0d2ec64ab1a85f8c0d2da9b47ae411a10b21Brian Wellington dst_result_totext(ret));
a49acbf201a411a47e18d136b38bbea8cf283adaBrian Wellington ++*nfails;
100d0d2ec64ab1a85f8c0d2da9b47ae411a10b21Brian Wellington return;
d0345e08f26267c1d11e02af57a6555868068415Brian Wellington }
100d0d2ec64ab1a85f8c0d2da9b47ae411a10b21Brian Wellington
a49acbf201a411a47e18d136b38bbea8cf283adaBrian Wellington if (alg != DST_ALG_DH)
100d0d2ec64ab1a85f8c0d2da9b47ae411a10b21Brian Wellington use(key, mctx, ISC_R_SUCCESS, nfails);
100d0d2ec64ab1a85f8c0d2da9b47ae411a10b21Brian Wellington dst_key_free(&key);
d0345e08f26267c1d11e02af57a6555868068415Brian Wellington}
d0345e08f26267c1d11e02af57a6555868068415Brian Wellington
949d406b57fe80fabc6a60d36a0dcee927c780b3Brian Wellington#define DBUFSIZ 25
949d406b57fe80fabc6a60d36a0dcee927c780b3Brian Wellington
a49acbf201a411a47e18d136b38bbea8cf283adaBrian Wellingtonstatic const char *a1 =
a49acbf201a411a47e18d136b38bbea8cf283adaBrian Wellington "the dst module provides the capability to "
a49acbf201a411a47e18d136b38bbea8cf283adaBrian Wellington "generate, store and retrieve public and private keys, "
a49acbf201a411a47e18d136b38bbea8cf283adaBrian Wellington "sign and verify data using the RSA, DSA and MD5 algorithms, "
a49acbf201a411a47e18d136b38bbea8cf283adaBrian Wellington "and compute Diffie-Hellman shared secrets.";
a49acbf201a411a47e18d136b38bbea8cf283adaBrian Wellingtonstatic void
949d406b57fe80fabc6a60d36a0dcee927c780b3Brian Wellingtont1(void) {
949d406b57fe80fabc6a60d36a0dcee927c780b3Brian Wellington isc_mem_t *mctx;
1e2749dba8aae3233b8962f1efe15385e92a77d9Brian Wellington isc_entropy_t *ectx;
1e2749dba8aae3233b8962f1efe15385e92a77d9Brian Wellington int nfails;
1e2749dba8aae3233b8962f1efe15385e92a77d9Brian Wellington int nprobs;
1e2749dba8aae3233b8962f1efe15385e92a77d9Brian Wellington int result;
1e2749dba8aae3233b8962f1efe15385e92a77d9Brian Wellington isc_result_t isc_result;
1e2749dba8aae3233b8962f1efe15385e92a77d9Brian Wellington dns_fixedname_t fname;
1e2749dba8aae3233b8962f1efe15385e92a77d9Brian Wellington dns_name_t *name;
1e2749dba8aae3233b8962f1efe15385e92a77d9Brian Wellington isc_buffer_t b;
1e2749dba8aae3233b8962f1efe15385e92a77d9Brian Wellington
1e2749dba8aae3233b8962f1efe15385e92a77d9Brian Wellington t_assert("dst", 1, T_REQUIRED, a1);
1e2749dba8aae3233b8962f1efe15385e92a77d9Brian Wellington
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington nfails = 0;
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington nprobs = 0;
3f6dc1703f76a24b34ed3bc839447291c33ca837Brian Wellington mctx = NULL;
0f80bfec687db08a6e6ce945ef1d818da06c7ca9Brian Wellington isc_result = isc_mem_create(0, 0, &mctx);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington if (isc_result != ISC_R_SUCCESS) {
3b2b306f47867d0037fb851623fb5a5736d64348Michael Graff t_info("isc_mem_create failed %d\n",
4556681e191b7c1654639895ce719d98f2822ee2Michael Graff isc_result_totext(isc_result));
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington t_result(T_UNRESOLVED);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington return;
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington }
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington ectx = NULL;
d1cbf714097e900ed1703529584d3e1a50e8a4a8Brian Wellington isc_result = isc_entropy_create(mctx, &ectx);
d692d9991a731d60b63e6389da1ebf2b2839cfabBrian Wellington if (isc_result != ISC_R_SUCCESS) {
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington t_info("isc_entropy_create failed %d\n",
4fe8755480c108a1232b7189fd5434ab35a6b623Brian Wellington isc_result_totext(isc_result));
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington t_result(T_UNRESOLVED);
1e2749dba8aae3233b8962f1efe15385e92a77d9Brian Wellington return;
a00c5e2151cc03c06bae5cdd3b40a5de05664059Brian Wellington }
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington result = isc_entropy_createfilesource(ectx, "randomfile");
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington if (isc_result != ISC_R_SUCCESS) {
af602636644fdfaabc331bd926b0aabb9432e152Brian Wellington t_info("isc_entropy_create failed %d\n",
05b6b2e6802d503a9e131415b4720f35ab9f08d1Brian Wellington isc_result_totext(isc_result));
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence t_result(T_UNRESOLVED);
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence return;
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence }
fe0e3c7707580da885bb6819e4f307986eb60cd0Brian Wellington isc_result = dst_lib_init(mctx, ectx, ISC_ENTROPY_BLOCKING);
05b6b2e6802d503a9e131415b4720f35ab9f08d1Brian Wellington if (isc_result != ISC_R_SUCCESS) {
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington t_info("dst_lib_init failed %d\n",
c3a4d8072ccd3b33aa3fc84cdeadd1a6fac87e08Michael Graff isc_result_totext(isc_result));
c3a4d8072ccd3b33aa3fc84cdeadd1a6fac87e08Michael Graff t_result(T_UNRESOLVED);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington return;
af602636644fdfaabc331bd926b0aabb9432e152Brian Wellington }
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington
7e8dd00fce7057d1da8158b65395a09ced43a892Brian Wellington t_info("testing use of stored keys [1]\n");
7e8dd00fce7057d1da8158b65395a09ced43a892Brian Wellington
7e8dd00fce7057d1da8158b65395a09ced43a892Brian Wellington dns_fixedname_init(&fname);
7e8dd00fce7057d1da8158b65395a09ced43a892Brian Wellington name = dns_fixedname_name(&fname);
7e8dd00fce7057d1da8158b65395a09ced43a892Brian Wellington isc_buffer_init(&b, "test.", 5);
f2338a0d6aa0327372eb20ab5dc29502bc8c71efBrian Wellington isc_buffer_add(&b, 5);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington dns_name_fromtext(name, &b, NULL, ISC_FALSE, NULL);
58aaab3687aac838542ee4ef65a9c094a5d34ab0Michael Graff io(name, 6204, DST_ALG_DSA, DST_TYPE_PRIVATE|DST_TYPE_PUBLIC,
19c7cce8555ccc0c95455a0c35dedd017d420d05Mark Andrews mctx, ISC_R_SUCCESS, &nfails, &nprobs);
7e8dd00fce7057d1da8158b65395a09ced43a892Brian Wellington t_info("testing use of stored keys [2]\n");
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington io(name, 54622, DST_ALG_RSAMD5, DST_TYPE_PRIVATE|DST_TYPE_PUBLIC,
7e8dd00fce7057d1da8158b65395a09ced43a892Brian Wellington mctx, ISC_R_SUCCESS, &nfails, &nprobs);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington
6e49e91bd08778d7eae45a2229dcf41ed97cc636David Lawrence t_info("testing use of stored keys [3]\n");
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington io(name, 0, DST_ALG_DSA, DST_TYPE_PRIVATE|DST_TYPE_PUBLIC,
d84ce5d5c69a7e144fb90fd4b3c349e88e4dcdddBrian Wellington mctx, DST_R_NULLKEY, &nfails, &nprobs);
7e8dd00fce7057d1da8158b65395a09ced43a892Brian Wellington t_info("testing use of stored keys [4]\n");
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington io(name, 0, DST_ALG_RSAMD5, DST_TYPE_PRIVATE|DST_TYPE_PUBLIC,
7e8dd00fce7057d1da8158b65395a09ced43a892Brian Wellington mctx, DST_R_NULLKEY, &nfails, &nprobs);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington
7e8dd00fce7057d1da8158b65395a09ced43a892Brian Wellington isc_buffer_init(&b, "dh.", 3);
7e8dd00fce7057d1da8158b65395a09ced43a892Brian Wellington isc_buffer_add(&b, 3);
7e8dd00fce7057d1da8158b65395a09ced43a892Brian Wellington dns_name_fromtext(name, &b, NULL, ISC_FALSE, NULL);
1e2749dba8aae3233b8962f1efe15385e92a77d9Brian Wellington
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington dh(name, 18088, name, 48443, mctx, ISC_R_SUCCESS, &nfails, &nprobs);
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence
1e2749dba8aae3233b8962f1efe15385e92a77d9Brian Wellington t_info("testing use of generated keys\n");
1e2749dba8aae3233b8962f1efe15385e92a77d9Brian Wellington generate(DST_ALG_RSAMD5, mctx, 512, &nfails);
1e2749dba8aae3233b8962f1efe15385e92a77d9Brian Wellington generate(DST_ALG_DSA, mctx, 512, &nfails);
1e2749dba8aae3233b8962f1efe15385e92a77d9Brian Wellington generate(DST_ALG_DH, mctx, 512, &nfails);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington /*
1e2749dba8aae3233b8962f1efe15385e92a77d9Brian Wellington * This one uses a constant.
1e2749dba8aae3233b8962f1efe15385e92a77d9Brian Wellington */
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington generate(DST_ALG_DH, mctx, 768, &nfails);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington generate(DST_ALG_HMACMD5, mctx, 512, &nfails);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington
4fe8755480c108a1232b7189fd5434ab35a6b623Brian Wellington dst_lib_destroy();
d84ce5d5c69a7e144fb90fd4b3c349e88e4dcdddBrian Wellington
1e2749dba8aae3233b8962f1efe15385e92a77d9Brian Wellington isc_entropy_detach(&ectx);
d84ce5d5c69a7e144fb90fd4b3c349e88e4dcdddBrian Wellington
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence isc_mem_destroy(&mctx);
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence result = T_UNRESOLVED;
d84ce5d5c69a7e144fb90fd4b3c349e88e4dcdddBrian Wellington if ((nfails == 0) && (nprobs == 0))
c03bb27f0675a6e60ceea66b451548e8481bc05cMark Andrews result = T_PASS;
0f80bfec687db08a6e6ce945ef1d818da06c7ca9Brian Wellington else if (nfails)
fe0e3c7707580da885bb6819e4f307986eb60cd0Brian Wellington result = T_FAIL;
0f80bfec687db08a6e6ce945ef1d818da06c7ca9Brian Wellington t_result(result);
4fe8755480c108a1232b7189fd5434ab35a6b623Brian Wellington
fe0e3c7707580da885bb6819e4f307986eb60cd0Brian Wellington}
0f80bfec687db08a6e6ce945ef1d818da06c7ca9Brian Wellington
0f80bfec687db08a6e6ce945ef1d818da06c7ca9Brian Wellington#define T_SIGMAX 512
0f80bfec687db08a6e6ce945ef1d818da06c7ca9Brian Wellington
4fe8755480c108a1232b7189fd5434ab35a6b623Brian Wellington#undef NEWSIG /* Define NEWSIG to generate the original signature file. */
0f80bfec687db08a6e6ce945ef1d818da06c7ca9Brian Wellington
0f80bfec687db08a6e6ce945ef1d818da06c7ca9Brian Wellington#ifdef NEWSIG
0f80bfec687db08a6e6ce945ef1d818da06c7ca9Brian Wellington
0f80bfec687db08a6e6ce945ef1d818da06c7ca9Brian Wellington/*
0f80bfec687db08a6e6ce945ef1d818da06c7ca9Brian Wellington * Write a sig in buf to file at path.
4fe8755480c108a1232b7189fd5434ab35a6b623Brian Wellington */
0f80bfec687db08a6e6ce945ef1d818da06c7ca9Brian Wellingtonstatic int
0f80bfec687db08a6e6ce945ef1d818da06c7ca9Brian Wellingtonsig_tofile(char *path, isc_buffer_t *buf) {
0f80bfec687db08a6e6ce945ef1d818da06c7ca9Brian Wellington int rval;
6e49e91bd08778d7eae45a2229dcf41ed97cc636David Lawrence int fd;
4fe8755480c108a1232b7189fd5434ab35a6b623Brian Wellington int len;
d84ce5d5c69a7e144fb90fd4b3c349e88e4dcdddBrian Wellington int nprobs;
4fe8755480c108a1232b7189fd5434ab35a6b623Brian Wellington int cnt;
d84ce5d5c69a7e144fb90fd4b3c349e88e4dcdddBrian Wellington unsigned char c;
d84ce5d5c69a7e144fb90fd4b3c349e88e4dcdddBrian Wellington unsigned char val;
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence cnt = 0;
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence nprobs = 0;
6e49e91bd08778d7eae45a2229dcf41ed97cc636David Lawrence len = buf->used - buf->current;
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington
6e49e91bd08778d7eae45a2229dcf41ed97cc636David Lawrence t_info("buf: current %d used %d len %d\n",
4fe8755480c108a1232b7189fd5434ab35a6b623Brian Wellington buf->current, buf->used, len);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington
4fe8755480c108a1232b7189fd5434ab35a6b623Brian Wellington fd = open(path, O_CREAT|O_TRUNC|O_WRONLY, S_IRWXU|S_IRWXO|S_IRWXG);
c7f13217d11f26739a79f0dab391ec372b49b96bBrian Wellington if (fd < 0) {
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence t_info("open %s failed %d\n", path, errno);
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence return(1);
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence }
6e49e91bd08778d7eae45a2229dcf41ed97cc636David Lawrence
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington while (len) {
4fe8755480c108a1232b7189fd5434ab35a6b623Brian Wellington c = (unsigned char) isc_buffer_getuint8(buf);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington val = ((c >> 4 ) & 0x0f);
4fe8755480c108a1232b7189fd5434ab35a6b623Brian Wellington if ((0 <= val) && (val <= 9))
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington val = '0' + val;
c7f13217d11f26739a79f0dab391ec372b49b96bBrian Wellington else
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence val = 'A' + val - 10;
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence rval = write(fd, &val, 1);
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence if (rval != 1) {
c7f13217d11f26739a79f0dab391ec372b49b96bBrian Wellington ++nprobs;
4fe8755480c108a1232b7189fd5434ab35a6b623Brian Wellington t_info("write failed %d %d\n", rval, errno);
c7f13217d11f26739a79f0dab391ec372b49b96bBrian Wellington break;
4fe8755480c108a1232b7189fd5434ab35a6b623Brian Wellington }
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington val = (c & 0x0f);
c7f13217d11f26739a79f0dab391ec372b49b96bBrian Wellington if ((0 <= val) && (val <= 9))
c7f13217d11f26739a79f0dab391ec372b49b96bBrian Wellington val = '0' + val;
c7f13217d11f26739a79f0dab391ec372b49b96bBrian Wellington else
6e49e91bd08778d7eae45a2229dcf41ed97cc636David Lawrence val = 'A' + val - 10;
4fe8755480c108a1232b7189fd5434ab35a6b623Brian Wellington rval = write(fd, &val, 1);
c7f13217d11f26739a79f0dab391ec372b49b96bBrian Wellington if (rval != 1) {
4fe8755480c108a1232b7189fd5434ab35a6b623Brian Wellington ++nprobs;
c7f13217d11f26739a79f0dab391ec372b49b96bBrian Wellington t_info("write failed %d %d\n", rval, errno);
7e8dd00fce7057d1da8158b65395a09ced43a892Brian Wellington break;
4fe8755480c108a1232b7189fd5434ab35a6b623Brian Wellington }
c7f13217d11f26739a79f0dab391ec372b49b96bBrian Wellington --len;
4fe8755480c108a1232b7189fd5434ab35a6b623Brian Wellington ++cnt;
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington if ((cnt % 16) == 0) {
c7f13217d11f26739a79f0dab391ec372b49b96bBrian Wellington val = '\n';
c7f13217d11f26739a79f0dab391ec372b49b96bBrian Wellington rval = write(fd, &val, 1);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington if (rval != 1) {
0c70ab306505d89983186e9f8bb8647de55b5d04Mark Andrews ++nprobs;
0c70ab306505d89983186e9f8bb8647de55b5d04Mark Andrews t_info("write failed %d %d\n", rval, errno);
0c70ab306505d89983186e9f8bb8647de55b5d04Mark Andrews break;
7e8dd00fce7057d1da8158b65395a09ced43a892Brian Wellington }
6e49e91bd08778d7eae45a2229dcf41ed97cc636David Lawrence }
4fe8755480c108a1232b7189fd5434ab35a6b623Brian Wellington }
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington val = '\n';
4fe8755480c108a1232b7189fd5434ab35a6b623Brian Wellington rval = write(fd, &val, 1);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington if (rval != 1) {
c7f13217d11f26739a79f0dab391ec372b49b96bBrian Wellington ++nprobs;
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence t_info("write failed %d %d\n", rval, errno);
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence }
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence (void) close(fd);
c7f13217d11f26739a79f0dab391ec372b49b96bBrian Wellington return(nprobs);
7e8dd00fce7057d1da8158b65395a09ced43a892Brian Wellington}
7e8dd00fce7057d1da8158b65395a09ced43a892Brian Wellington
c7f13217d11f26739a79f0dab391ec372b49b96bBrian Wellington#endif /* NEWSIG */
6e49e91bd08778d7eae45a2229dcf41ed97cc636David Lawrence
4fe8755480c108a1232b7189fd5434ab35a6b623Brian Wellington/*
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington * Read sig in file at path to buf.
4fe8755480c108a1232b7189fd5434ab35a6b623Brian Wellington */
c7f13217d11f26739a79f0dab391ec372b49b96bBrian Wellingtonstatic int
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrencesig_fromfile(char *path, isc_buffer_t *iscbuf) {
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence int rval;
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence int len;
7e8dd00fce7057d1da8158b65395a09ced43a892Brian Wellington int fd;
7e8dd00fce7057d1da8158b65395a09ced43a892Brian Wellington unsigned char val;
7e8dd00fce7057d1da8158b65395a09ced43a892Brian Wellington struct stat sb;
4fe8755480c108a1232b7189fd5434ab35a6b623Brian Wellington char *p;
c7f13217d11f26739a79f0dab391ec372b49b96bBrian Wellington char *buf;
4fe8755480c108a1232b7189fd5434ab35a6b623Brian Wellington
c7f13217d11f26739a79f0dab391ec372b49b96bBrian Wellington rval = stat(path, &sb);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington if (rval != 0) {
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington t_info("stat %s failed, errno == %d\n", path, errno);
81ab85fd39c3f6c781ecac725d830364a311479dBrian Wellington return(1);
d5334bc18380d25e8a7ee804f68f22dc746b9c20Brian Wellington }
4fe8755480c108a1232b7189fd5434ab35a6b623Brian Wellington
a00c5e2151cc03c06bae5cdd3b40a5de05664059Brian Wellington buf = (char *) malloc((sb.st_size + 1) * sizeof(unsigned char));
7e8dd00fce7057d1da8158b65395a09ced43a892Brian Wellington if (buf == NULL) {
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington t_info("malloc failed, errno == %d\n", errno);
4fe8755480c108a1232b7189fd5434ab35a6b623Brian Wellington return(1);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington }
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington
a00c5e2151cc03c06bae5cdd3b40a5de05664059Brian Wellington fd = open(path, O_RDONLY);
4fe8755480c108a1232b7189fd5434ab35a6b623Brian Wellington if (fd < 0) {
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington t_info("open failed, errno == %d\n", errno);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington (void) free(buf);
4fe8755480c108a1232b7189fd5434ab35a6b623Brian Wellington return(1);
a00c5e2151cc03c06bae5cdd3b40a5de05664059Brian Wellington }
1e2749dba8aae3233b8962f1efe15385e92a77d9Brian Wellington
7e8dd00fce7057d1da8158b65395a09ced43a892Brian Wellington len = sb.st_size;
7e8dd00fce7057d1da8158b65395a09ced43a892Brian Wellington p = buf;
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington while (len) {
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington rval = read(fd, p, len);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington if (rval > 0) {
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington len -= rval;
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington p += rval;
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington }
6e49e91bd08778d7eae45a2229dcf41ed97cc636David Lawrence else {
0dc4e6a6aef01175b8cdd71cb757f09ba1e69c49Brian Wellington t_info("read failed %d, errno == %d\n", rval, errno);
2c12fc4d63f1d5f9d55fc0ecb198d582da6fd7d3Brian Wellington (void) free(buf);
c3a4d8072ccd3b33aa3fc84cdeadd1a6fac87e08Michael Graff (void) close(fd);
7e8dd00fce7057d1da8158b65395a09ced43a892Brian Wellington return(1);
0dc4e6a6aef01175b8cdd71cb757f09ba1e69c49Brian Wellington }
2c12fc4d63f1d5f9d55fc0ecb198d582da6fd7d3Brian Wellington }
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington close(fd);
0f80bfec687db08a6e6ce945ef1d818da06c7ca9Brian Wellington
0f80bfec687db08a6e6ce945ef1d818da06c7ca9Brian Wellington p = buf;
7e8dd00fce7057d1da8158b65395a09ced43a892Brian Wellington len = sb.st_size;
a00c5e2151cc03c06bae5cdd3b40a5de05664059Brian Wellington while(len) {
7e8dd00fce7057d1da8158b65395a09ced43a892Brian Wellington if (*p == '\n') {
7e8dd00fce7057d1da8158b65395a09ced43a892Brian Wellington ++p;
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington --len;
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington continue;
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington }
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington if (('0' <= *p) && (*p <= '9'))
0f80bfec687db08a6e6ce945ef1d818da06c7ca9Brian Wellington val = *p - '0';
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington else
d1cbf714097e900ed1703529584d3e1a50e8a4a8Brian Wellington val = *p - 'A' + 10;
d1cbf714097e900ed1703529584d3e1a50e8a4a8Brian Wellington ++p;
d1cbf714097e900ed1703529584d3e1a50e8a4a8Brian Wellington val <<= 4;
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington --len;
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington if (('0' <= *p) && (*p <= '9'))
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington val |= (*p - '0');
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington else
8c56932f9a3dc252ab13a529a75f75966468a7c1Andreas Gustafsson val |= (*p - 'A' + 10);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington ++p;
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington --len;
0dc4e6a6aef01175b8cdd71cb757f09ba1e69c49Brian Wellington isc_buffer_putuint8(iscbuf, val);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington }
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington (void) free(buf);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington return(0);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington}
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellingtonstatic void
d1cbf714097e900ed1703529584d3e1a50e8a4a8Brian Wellingtont2_sigchk(char *datapath, char *sigpath, char *keyname,
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington int id, int alg, int type,
1f1d36a87b65186d9f89aac7f456ab1fd2a39ef6Andreas Gustafsson isc_mem_t *mctx, char *expected_result,
1f1d36a87b65186d9f89aac7f456ab1fd2a39ef6Andreas Gustafsson int *nfails, int *nprobs)
fe0e3c7707580da885bb6819e4f307986eb60cd0Brian Wellington{
5caab9f99d19ab9ebb0a0ba64c09c8de80e89e29Brian Wellington int rval;
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington int len;
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington int fd;
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington int exp_res;
d1cbf714097e900ed1703529584d3e1a50e8a4a8Brian Wellington dst_key_t *key = NULL;
d1cbf714097e900ed1703529584d3e1a50e8a4a8Brian Wellington unsigned char sig[T_SIGMAX];
d1cbf714097e900ed1703529584d3e1a50e8a4a8Brian Wellington unsigned char *p;
2c12fc4d63f1d5f9d55fc0ecb198d582da6fd7d3Brian Wellington unsigned char *data;
2c12fc4d63f1d5f9d55fc0ecb198d582da6fd7d3Brian Wellington struct stat sb;
2c12fc4d63f1d5f9d55fc0ecb198d582da6fd7d3Brian Wellington isc_result_t isc_result;
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington isc_buffer_t databuf;
7e8dd00fce7057d1da8158b65395a09ced43a892Brian Wellington isc_buffer_t sigbuf;
6e5fa98df021f2b1eeb0ca6193b2f9f36e82ff36Brian Wellington isc_region_t datareg;
4fe8755480c108a1232b7189fd5434ab35a6b623Brian Wellington isc_region_t sigreg;
4fe8755480c108a1232b7189fd5434ab35a6b623Brian Wellington dns_fixedname_t fname;
4fe8755480c108a1232b7189fd5434ab35a6b623Brian Wellington dns_name_t *name;
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington isc_buffer_t b;
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington dst_context_t *ctx = NULL;
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington /*
b984520acca2532d048eae929dc0682dd334c7a3Brian Wellington * Read data from file in a form usable by dst_verify.
3b2efab212088496d5588ca5ed2d802c72d21a08Brian Wellington */
b984520acca2532d048eae929dc0682dd334c7a3Brian Wellington rval = stat(datapath, &sb);
0f80bfec687db08a6e6ce945ef1d818da06c7ca9Brian Wellington if (rval != 0) {
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington t_info("t2_sigchk: stat (%s) failed %d\n", datapath, errno);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington ++*nprobs;
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington return;
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington }
c03bb27f0675a6e60ceea66b451548e8481bc05cMark Andrews
d692d9991a731d60b63e6389da1ebf2b2839cfabBrian Wellington data = (unsigned char *) malloc(sb.st_size * sizeof(char));
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington if (data == NULL) {
af602636644fdfaabc331bd926b0aabb9432e152Brian Wellington t_info("t2_sigchk: malloc failed %d\n", errno);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington ++*nprobs;
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington return;
4fe8755480c108a1232b7189fd5434ab35a6b623Brian Wellington }
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington fd = open(datapath, O_RDONLY);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington if (fd < 0) {
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington t_info("t2_sigchk: open failed %d\n", errno);
a523752c602dc6bdb69a8d9c6267a1e4188a9782Andreas Gustafsson (void) free(data);
af602636644fdfaabc331bd926b0aabb9432e152Brian Wellington ++*nprobs;
af602636644fdfaabc331bd926b0aabb9432e152Brian Wellington return;
05b6b2e6802d503a9e131415b4720f35ab9f08d1Brian Wellington }
f7fbd68b1cd96c733140fce938a61faf8b459b6fBrian Wellington
f7fbd68b1cd96c733140fce938a61faf8b459b6fBrian Wellington p = data;
b984520acca2532d048eae929dc0682dd334c7a3Brian Wellington len = sb.st_size;
809fdfba224a83fcc5a8ae4394cf2a477d13dc91Brian Wellington do {
b984520acca2532d048eae929dc0682dd334c7a3Brian Wellington rval = read(fd, p, len);
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence if (rval > 0) {
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence len -= rval;
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence p += rval;
fe0e3c7707580da885bb6819e4f307986eb60cd0Brian Wellington }
05b6b2e6802d503a9e131415b4720f35ab9f08d1Brian Wellington } while (len);
05b6b2e6802d503a9e131415b4720f35ab9f08d1Brian Wellington (void) close(fd);
05b6b2e6802d503a9e131415b4720f35ab9f08d1Brian Wellington
05b6b2e6802d503a9e131415b4720f35ab9f08d1Brian Wellington /*
05b6b2e6802d503a9e131415b4720f35ab9f08d1Brian Wellington * Read key from file in a form usable by dst_verify.
05b6b2e6802d503a9e131415b4720f35ab9f08d1Brian Wellington */
05b6b2e6802d503a9e131415b4720f35ab9f08d1Brian Wellington dns_fixedname_init(&fname);
fe0e3c7707580da885bb6819e4f307986eb60cd0Brian Wellington name = dns_fixedname_name(&fname);
05b6b2e6802d503a9e131415b4720f35ab9f08d1Brian Wellington isc_buffer_init(&b, keyname, strlen(keyname));
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington isc_buffer_add(&b, strlen(keyname));
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington dns_name_fromtext(name, &b, dns_rootname, ISC_FALSE, NULL);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington isc_result = dst_key_fromfile(name, id, alg, type, NULL, mctx, &key);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington if (isc_result != ISC_R_SUCCESS) {
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington t_info("dst_key_fromfile failed %s\n",
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington isc_result_totext(isc_result));
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington (void) free(data);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington ++*nprobs;
5caab9f99d19ab9ebb0a0ba64c09c8de80e89e29Brian Wellington return;
fe0e3c7707580da885bb6819e4f307986eb60cd0Brian Wellington }
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington isc_buffer_init(&databuf, data, sb.st_size);
fe0e3c7707580da885bb6819e4f307986eb60cd0Brian Wellington isc_buffer_add(&databuf, sb.st_size);
0f80bfec687db08a6e6ce945ef1d818da06c7ca9Brian Wellington isc_buffer_usedregion(&databuf, &datareg);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington
0f80bfec687db08a6e6ce945ef1d818da06c7ca9Brian Wellington#ifdef NEWSIG
368b37b616234fce3d23099eb180f1dd38e1fb62Mark Andrews
0f80bfec687db08a6e6ce945ef1d818da06c7ca9Brian Wellington /*
fe0e3c7707580da885bb6819e4f307986eb60cd0Brian Wellington * If we're generating a signature for the first time,
0f80bfec687db08a6e6ce945ef1d818da06c7ca9Brian Wellington * sign the data and save the signature to a file
0f80bfec687db08a6e6ce945ef1d818da06c7ca9Brian Wellington */
fe0e3c7707580da885bb6819e4f307986eb60cd0Brian Wellington
0f80bfec687db08a6e6ce945ef1d818da06c7ca9Brian Wellington memset(sig, 0, sizeof(sig));
0f80bfec687db08a6e6ce945ef1d818da06c7ca9Brian Wellington isc_buffer_init(&sigbuf, sig, sizeof(sig));
0f80bfec687db08a6e6ce945ef1d818da06c7ca9Brian Wellington
0f80bfec687db08a6e6ce945ef1d818da06c7ca9Brian Wellington isc_result = dst_context_create(key, mctx, &ctx);
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence if (isc_result != ISC_R_SUCCESS) {
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence t_info("dst_context_create(%d) failed %s\n",
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence dst_result_totext(isc_result));
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence (void) free(data);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington dst_key_free(&key);
af602636644fdfaabc331bd926b0aabb9432e152Brian Wellington ++*nprobs;
0f80bfec687db08a6e6ce945ef1d818da06c7ca9Brian Wellington return;
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington }
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington isc_result = dst_context_adddata(ctx, &datareg);
020ebf119089ef68070d6a0df2def3142f1eeff4Brian Wellington if (isc_result != ISC_R_SUCCESS) {
020ebf119089ef68070d6a0df2def3142f1eeff4Brian Wellington t_info("dst_context_adddata(%d) failed %s\n",
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington dst_result_totext(isc_result));
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington (void) free(data);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington dst_key_free(&key);
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence dst_context_destroy(&ctx);
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence ++*nprobs;
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence return;
fb01226bcd598c36b5edc566489c890c39f03ed3Brian Wellington }
fb01226bcd598c36b5edc566489c890c39f03ed3Brian Wellington isc_result = dst_context_sign(ctx, &sigbuf);
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence if (isc_result != ISC_R_SUCCESS) {
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence t_info("dst_sign(%d) failed %s\n",
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence dst_result_totext(isc_result));
af602636644fdfaabc331bd926b0aabb9432e152Brian Wellington (void) free(data);
b984520acca2532d048eae929dc0682dd334c7a3Brian Wellington dst_key_free(&key);
3b2efab212088496d5588ca5ed2d802c72d21a08Brian Wellington dst_context_destroy(&ctx);
b984520acca2532d048eae929dc0682dd334c7a3Brian Wellington ++*nprobs;
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence return;
3b2efab212088496d5588ca5ed2d802c72d21a08Brian Wellington }
b984520acca2532d048eae929dc0682dd334c7a3Brian Wellington dst_context_destroy(&ctx);
3b2efab212088496d5588ca5ed2d802c72d21a08Brian Wellington
0f0162e6297ddf5e4abe848d27f3bcdb373189daBrian Wellington rval = sig_tofile(sigpath, &sigbuf);
0f0162e6297ddf5e4abe848d27f3bcdb373189daBrian Wellington if (rval != 0) {
0f80bfec687db08a6e6ce945ef1d818da06c7ca9Brian Wellington t_info("sig_tofile failed\n");
0f0162e6297ddf5e4abe848d27f3bcdb373189daBrian Wellington ++*nprobs;
fb01226bcd598c36b5edc566489c890c39f03ed3Brian Wellington (void) free(data);
49c8a96fba8d85810d470fdc7dd3388f0c767c9eBrian Wellington dst_key_free(&key);
0f0162e6297ddf5e4abe848d27f3bcdb373189daBrian Wellington return;
0f80bfec687db08a6e6ce945ef1d818da06c7ca9Brian Wellington }
020ebf119089ef68070d6a0df2def3142f1eeff4Brian Wellington
0f0162e6297ddf5e4abe848d27f3bcdb373189daBrian Wellington#endif /* NEWSIG */
0f0162e6297ddf5e4abe848d27f3bcdb373189daBrian Wellington
7077846f3bf941f626a8623bd29a56a5ce7a1e11Brian Wellington memset(sig, 0, sizeof(sig));
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington isc_buffer_init(&sigbuf, sig, sizeof(sig));
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington /*
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington * Read precomputed signature from file in a form usable by dst_verify.
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence */
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence rval = sig_fromfile(sigpath, &sigbuf);
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence if (rval != 0) {
564c1b8f42d33a66c0f5c67d66bf0cd063c8b047Brian Wellington t_info("sig_fromfile failed\n");
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington (void) free(data);
564c1b8f42d33a66c0f5c67d66bf0cd063c8b047Brian Wellington dst_key_free(&key);
5ea0d11ca45bfd1ea9db8db07f18fbb02f500661Brian Wellington ++*nprobs;
564c1b8f42d33a66c0f5c67d66bf0cd063c8b047Brian Wellington return;
564c1b8f42d33a66c0f5c67d66bf0cd063c8b047Brian Wellington }
564c1b8f42d33a66c0f5c67d66bf0cd063c8b047Brian Wellington
5ea0d11ca45bfd1ea9db8db07f18fbb02f500661Brian Wellington /*
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington * Verify that the key signed the data.
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington */
0f80bfec687db08a6e6ce945ef1d818da06c7ca9Brian Wellington isc_buffer_remainingregion(&sigbuf, &sigreg);
0f80bfec687db08a6e6ce945ef1d818da06c7ca9Brian Wellington
0f80bfec687db08a6e6ce945ef1d818da06c7ca9Brian Wellington exp_res = 0;
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington if (strstr(expected_result, "!"))
4fe8755480c108a1232b7189fd5434ab35a6b623Brian Wellington exp_res = 1;
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington
1e2749dba8aae3233b8962f1efe15385e92a77d9Brian Wellington isc_result = dst_context_create(key, mctx, &ctx);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington if (isc_result != ISC_R_SUCCESS) {
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington t_info("dst_context_create returned %s\n",
6e49e91bd08778d7eae45a2229dcf41ed97cc636David Lawrence isc_result_totext(isc_result));
0f80bfec687db08a6e6ce945ef1d818da06c7ca9Brian Wellington ++*nfails;
6e49e91bd08778d7eae45a2229dcf41ed97cc636David Lawrence }
4fe8755480c108a1232b7189fd5434ab35a6b623Brian Wellington isc_result = dst_context_adddata(ctx, &datareg);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington if (isc_result != ISC_R_SUCCESS) {
4fe8755480c108a1232b7189fd5434ab35a6b623Brian Wellington t_info("dst_context_adddata returned %s\n",
0f80bfec687db08a6e6ce945ef1d818da06c7ca9Brian Wellington isc_result_totext(isc_result));
0f80bfec687db08a6e6ce945ef1d818da06c7ca9Brian Wellington dst_context_destroy(&ctx);
0f80bfec687db08a6e6ce945ef1d818da06c7ca9Brian Wellington ++*nfails;
4fe8755480c108a1232b7189fd5434ab35a6b623Brian Wellington }
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington isc_result = dst_context_verify(ctx, &sigreg);
4fe8755480c108a1232b7189fd5434ab35a6b623Brian Wellington if ( ((exp_res == 0) && (isc_result != ISC_R_SUCCESS)) ||
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington ((exp_res != 0) && (isc_result == ISC_R_SUCCESS))) {
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington t_info("dst_context_verify returned %s, expected %s\n",
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence isc_result_totext(isc_result),
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence expected_result);
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence dst_context_destroy(&ctx);
6e49e91bd08778d7eae45a2229dcf41ed97cc636David Lawrence ++*nfails;
c7f13217d11f26739a79f0dab391ec372b49b96bBrian Wellington }
c7f13217d11f26739a79f0dab391ec372b49b96bBrian Wellington
c7f13217d11f26739a79f0dab391ec372b49b96bBrian Wellington (void) free(data);
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence dst_context_destroy(&ctx);
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence dst_key_free(&key);
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence return;
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington}
db1bfc315197de36919f211bb6e4e98c5ce197caDanny Mayer
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington/*
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington * The astute observer will note that t1() signs then verifies data
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence * during the test but that t2() verifies data that has been
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence * signed at some earlier time, possibly with an entire different
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence * version or implementation of the DSA and RSA algorithms
0f80bfec687db08a6e6ce945ef1d818da06c7ca9Brian Wellington */
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellingtonstatic const char *a2 =
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington "the dst module provides the capability to "
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence "verify data signed with the RSA and DSA algorithms";
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence/*
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington * av == datafile, sigpath, keyname, keyid, alg, exp_result.
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington */
4fe8755480c108a1232b7189fd5434ab35a6b623Brian Wellingtonstatic int
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellingtont2_vfy(char **av) {
4fe8755480c108a1232b7189fd5434ab35a6b623Brian Wellington char *datapath;
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington char *sigpath;
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence char *keyname;
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence char *key;
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence int keyid;
6e49e91bd08778d7eae45a2229dcf41ed97cc636David Lawrence char *alg;
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington int algid;
d598338952797df77417e69fcb8782b73651f9a9Brian Wellington char *exp_result;
4fe8755480c108a1232b7189fd5434ab35a6b623Brian Wellington int nfails;
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington int nprobs;
4fe8755480c108a1232b7189fd5434ab35a6b623Brian Wellington isc_mem_t *mctx;
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington isc_entropy_t *ectx;
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence isc_result_t isc_result;
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence int result;
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington datapath = *av++;
4fe8755480c108a1232b7189fd5434ab35a6b623Brian Wellington sigpath = *av++;
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington keyname = *av++;
4fe8755480c108a1232b7189fd5434ab35a6b623Brian Wellington key = *av++;
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington keyid = atoi(key);
6e49e91bd08778d7eae45a2229dcf41ed97cc636David Lawrence alg = *av++;
0f80bfec687db08a6e6ce945ef1d818da06c7ca9Brian Wellington exp_result = *av++;
fe0e3c7707580da885bb6819e4f307986eb60cd0Brian Wellington nfails = 0;
6e49e91bd08778d7eae45a2229dcf41ed97cc636David Lawrence nprobs = 0;
4fe8755480c108a1232b7189fd5434ab35a6b623Brian Wellington
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington if (! strcasecmp(alg, "DST_ALG_DSA"))
4fe8755480c108a1232b7189fd5434ab35a6b623Brian Wellington algid = DST_ALG_DSA;
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington else if (! strcasecmp(alg, "DST_ALG_RSAMD5"))
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence algid = DST_ALG_RSAMD5;
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence else {
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence t_info("Unknown algorithm %s\n", alg);
f2338a0d6aa0327372eb20ab5dc29502bc8c71efBrian Wellington return(T_UNRESOLVED);
4fe8755480c108a1232b7189fd5434ab35a6b623Brian Wellington }
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington
4fe8755480c108a1232b7189fd5434ab35a6b623Brian Wellington mctx = NULL;
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington isc_result = isc_mem_create(0, 0, &mctx);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington if (isc_result != ISC_R_SUCCESS) {
1e2749dba8aae3233b8962f1efe15385e92a77d9Brian Wellington t_info("isc_mem_create failed %d\n",
0f80bfec687db08a6e6ce945ef1d818da06c7ca9Brian Wellington isc_result_totext(isc_result));
0f80bfec687db08a6e6ce945ef1d818da06c7ca9Brian Wellington return(T_UNRESOLVED);
0f80bfec687db08a6e6ce945ef1d818da06c7ca9Brian Wellington }
6e49e91bd08778d7eae45a2229dcf41ed97cc636David Lawrence ectx = NULL;
4fe8755480c108a1232b7189fd5434ab35a6b623Brian Wellington isc_result = isc_entropy_create(mctx, &ectx);
4fe8755480c108a1232b7189fd5434ab35a6b623Brian Wellington if (isc_result != ISC_R_SUCCESS) {
4fe8755480c108a1232b7189fd5434ab35a6b623Brian Wellington t_info("isc_entropy_create failed %d\n",
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington isc_result_totext(isc_result));
0f80bfec687db08a6e6ce945ef1d818da06c7ca9Brian Wellington return(T_UNRESOLVED);
0f80bfec687db08a6e6ce945ef1d818da06c7ca9Brian Wellington }
0f80bfec687db08a6e6ce945ef1d818da06c7ca9Brian Wellington result = isc_entropy_createfilesource(ectx, "randomfile");
4fe8755480c108a1232b7189fd5434ab35a6b623Brian Wellington if (isc_result != ISC_R_SUCCESS) {
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington t_info("isc_entropy_create failed %d\n",
4fe8755480c108a1232b7189fd5434ab35a6b623Brian Wellington isc_result_totext(isc_result));
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington return(T_UNRESOLVED);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington }
4fe8755480c108a1232b7189fd5434ab35a6b623Brian Wellington isc_result = dst_lib_init(mctx, ectx, ISC_ENTROPY_BLOCKING);
4fe8755480c108a1232b7189fd5434ab35a6b623Brian Wellington if (isc_result != ISC_R_SUCCESS) {
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington t_info("dst_lib_init failed %d\n",
3aec811249fc1bde4476ced9432d3ebea0ad4dc4Brian Wellington isc_result_totext(isc_result));
020ebf119089ef68070d6a0df2def3142f1eeff4Brian Wellington return(T_UNRESOLVED);
020ebf119089ef68070d6a0df2def3142f1eeff4Brian Wellington }
3aec811249fc1bde4476ced9432d3ebea0ad4dc4Brian Wellington
1e2749dba8aae3233b8962f1efe15385e92a77d9Brian Wellington t_info("testing %s, %s, %s, %s, %s, %s\n",
4fe8755480c108a1232b7189fd5434ab35a6b623Brian Wellington datapath, sigpath, keyname, key, alg, exp_result);
b70f6ae9d0be6bcf11bddc42f5e066ab6ac16517Brian Wellington t2_sigchk(datapath, sigpath, keyname, keyid,
b70f6ae9d0be6bcf11bddc42f5e066ab6ac16517Brian Wellington algid, DST_TYPE_PRIVATE|DST_TYPE_PUBLIC,
1e2749dba8aae3233b8962f1efe15385e92a77d9Brian Wellington mctx, exp_result,
1e2749dba8aae3233b8962f1efe15385e92a77d9Brian Wellington &nfails, &nprobs);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington dst_lib_destroy();
020ebf119089ef68070d6a0df2def3142f1eeff4Brian Wellington
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington isc_entropy_detach(&ectx);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington isc_mem_destroy(&mctx);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington result = T_UNRESOLVED;
5ea0d11ca45bfd1ea9db8db07f18fbb02f500661Brian Wellington if (nfails)
5ea0d11ca45bfd1ea9db8db07f18fbb02f500661Brian Wellington result = T_FAIL;
5ea0d11ca45bfd1ea9db8db07f18fbb02f500661Brian Wellington else if ((nfails == 0) && (nprobs == 0))
5ea0d11ca45bfd1ea9db8db07f18fbb02f500661Brian Wellington result = T_PASS;
5ea0d11ca45bfd1ea9db8db07f18fbb02f500661Brian Wellington
5ea0d11ca45bfd1ea9db8db07f18fbb02f500661Brian Wellington return(result);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington}
f7fbd68b1cd96c733140fce938a61faf8b459b6fBrian Wellington
f7fbd68b1cd96c733140fce938a61faf8b459b6fBrian Wellingtonstatic void
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellingtont2(void) {
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington int result;
4fe8755480c108a1232b7189fd5434ab35a6b623Brian Wellington t_assert("dst", 2, T_REQUIRED, a2);
4fe8755480c108a1232b7189fd5434ab35a6b623Brian Wellington result = t_eval("dst_2_data", t2_vfy, 6);
4fe8755480c108a1232b7189fd5434ab35a6b623Brian Wellington t_result(result);
0f80bfec687db08a6e6ce945ef1d818da06c7ca9Brian Wellington}
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellingtontestspec_t T_testlist[] = {
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington { t1, "basic dst module verification" },
b984520acca2532d048eae929dc0682dd334c7a3Brian Wellington { t2, "signature ineffability" },
809fdfba224a83fcc5a8ae4394cf2a477d13dc91Brian Wellington { NULL, NULL }
0f80bfec687db08a6e6ce945ef1d818da06c7ca9Brian Wellington};
c7f13217d11f26739a79f0dab391ec372b49b96bBrian Wellington
c7f13217d11f26739a79f0dab391ec372b49b96bBrian Wellington