verify.c revision ba751492fcc4f161a18b983d4f018a1a52938cb9
/*
* Copyright (C) 2012 Internet Systems Consortium, Inc. ("ISC")
*
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC AND NETWORK ASSOCIATES DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE
* FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
* IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/*
* Portions copyright (c) 2008 Nominet UK. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/* $Id$ */
/* verify [-m module] [-s $slot] [-p pin] [-t] [-n count] */
/*! \file */
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <isc/commandline.h>
#define getpassphrase(x) getpass(x)
#endif
#ifndef HAVE_CLOCK_GETTIME
#ifndef CLOCK_REALTIME
#define CLOCK_REALTIME 0
#endif
int
{
int result;
if (result)
return (result);
return (result);
}
#endif
0x00, 0xb7, 0x9c, 0x1f, 0x05, 0xa3, 0xc2, 0x99,
0x44, 0x82, 0x20, 0x78, 0x43, 0x7f, 0x5f, 0x3b,
0x10, 0xd7, 0x9e, 0x61, 0x42, 0xd2, 0x7a, 0x90,
0x50, 0x8a, 0x99, 0x33, 0xe7, 0xca, 0xc8, 0x5f,
0x16, 0x1c, 0x56, 0xf8, 0xc1, 0x06, 0x2f, 0x96,
0xe7, 0x54, 0xf2, 0x85, 0x89, 0x41, 0x36, 0xf5,
0x4c, 0xa4, 0x0d, 0x62, 0xd3, 0x42, 0x51, 0x6b,
0x9f, 0xdc, 0x36, 0xcb, 0xad, 0x56, 0xf4, 0xbd,
0x2a, 0x60, 0x33, 0xb1, 0x7a, 0x99, 0xad, 0x08,
0x9f, 0x95, 0xe8, 0xe5, 0x14, 0xd9, 0x68, 0x79,
0xca, 0x4e, 0x72, 0xeb, 0xfb, 0x2c, 0xf1, 0x45,
0xd3, 0x33, 0x65, 0xe7, 0xc5, 0x11, 0xdd, 0xe7,
0x09, 0x83, 0x13, 0xd5, 0x17, 0x1b, 0xf4, 0xbd,
0x49, 0xdd, 0x8a, 0x3c, 0x3c, 0xf7, 0xa1, 0x5d,
0x7b, 0xb4, 0xd3, 0x80, 0x25, 0xf4, 0x05, 0x8f,
0xbc, 0x2c, 0x2a, 0x47, 0xff, 0xd1, 0xc8, 0x34,
0xbf
};
int
CK_SLOT_ID slot = 0;
{
};
int error = 0;
int c, errflg = 0;
int ontoken = 0;
unsigned int count = 1000;
unsigned int i;
switch (c) {
case 'm':
break;
case 's':
break;
case 'p':
break;
case 't':
ontoken = 1;
break;
case 'n':
break;
case ':':
"Option -%c requires an operand\n",
errflg++;
break;
case '?':
default:
errflg++;
}
}
if (errflg) {
"\tverify [-m module] [-s slot] [-p pin] "
"[-t] [-n count]\n");
exit(1);
}
/* Initialize the CRYPTOKI library */
if (result != ISC_R_SUCCESS) {
exit(1);
}
/* Create the private RSA key */
if (ontoken)
error = 1;
goto exit_key;
}
/* Randomize the buffer */
goto exit_key;
}
perror("clock_gettime(start)");
goto exit_key;
}
for (i = 0; i < count; i++) {
/* Initialize Verify */
"C_VerifyInit[%u]: Error = 0x%.8lX\n",
i, rv);
error = 1;
break;
}
/* Perform Verify */
"C_Verify[%u]: Error = 0x%.8lX\n",
i, rv);
error = 1;
break;
}
}
perror("clock_gettime(end)");
goto exit_key;
}
}
printf("%u RSA verify in %ld.%09lds\n", i,
if (i > 0)
printf("%g RSA verify/s\n",
if (hKey != CK_INVALID_HANDLE) {
"C_DestroyObject: Error = 0x%.8lX\n",
rv);
errflg = 1;
}
}
}