99bbb58ce7c172798fecb21d2d12756c159cff14Tinderbox User * Copyright (C) 2014-2016 Internet Systems Consortium, Inc. ("ISC")
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * This Source Code Form is subject to the terms of the Mozilla Public
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * License, v. 2.0. If a copy of the MPL was not distributed with this
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * file, You can obtain one at http://mozilla.org/MPL/2.0/.
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt * Portions copyright (c) 2008 Nominet UK. All rights reserved.
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt * Redistribution and use in source and binary forms, with or without
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt * modification, are permitted provided that the following conditions
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt * 1. Redistributions of source code must retain the above copyright
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt * notice, this list of conditions and the following disclaimer.
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt * 2. Redistributions in binary form must reproduce the above copyright
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt * notice, this list of conditions and the following disclaimer in the
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt * documentation and/or other materials provided with the distribution.
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt/* random [-m module] [-s $slot] [-n count] */
699f790c49d03a9ef3c3234a72d272bb469203e8Evan Huntstatic int clock_gettime(int32_t id, struct timespec *tp);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt unsigned int i;
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt while ((c = isc_commandline_parse(argc, argv, ":m:s:n:")) != -1) {
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt switch (c) {
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt "Option -%c requires an operand\n",
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt "\trandom [-m module] [-s slot] [-n count]\n");
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt /* Initialize the CRYPTOKI library */
acbb301e648b82fcc38b876a44403cf0fe539cc9Evan Hunt result = pk11_get_session(&pctx, op_type, ISC_FALSE, ISC_FALSE,
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt fprintf(stderr, "Error initializing PKCS#11: %s\n",
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt if (clock_gettime(CLOCK_REALTIME, &starttime) < 0) {
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt for (i = 0; i < count; i++) {
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt /* Get random bytes */
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt "C_GenerateRandom[%u]: Error = 0x%.8lX\n",