pkcs11-keygen.c revision 78608b0a454246d0e1e0169f1d671b8427e48199
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews * Copyright (C) 2009, 2012, 2015 Internet Systems Consortium, Inc. ("ISC")
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * Permission to use, copy, modify, and/or distribute this software for any
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * purpose with or without fee is hereby granted, provided that the above
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * copyright notice and this permission notice appear in all copies.
9c3531d72aeaad6c5f01efe6a1c82023e1379e4dDavid Lawrence * THE SOFTWARE IS PROVIDED "AS IS" AND ISC AND NETWORK ASSOCIATES DISCLAIMS
9b2267b5ba9d0640512a41e139a4a36caa43730dBob Halley * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
9b2267b5ba9d0640512a41e139a4a36caa43730dBob Halley * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE
9b2267b5ba9d0640512a41e139a4a36caa43730dBob Halley * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
9b2267b5ba9d0640512a41e139a4a36caa43730dBob Halley * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
c2bc56dc65b4b103a5600565680eb5f33fa4c90bMark Andrews * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
9b2267b5ba9d0640512a41e139a4a36caa43730dBob Halley * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
9b2267b5ba9d0640512a41e139a4a36caa43730dBob Halley * Portions copyright (c) 2008 Nominet UK. All rights reserved.
9b2267b5ba9d0640512a41e139a4a36caa43730dBob Halley * Redistribution and use in source and binary forms, with or without
9b2267b5ba9d0640512a41e139a4a36caa43730dBob Halley * modification, are permitted provided that the following conditions
9b2267b5ba9d0640512a41e139a4a36caa43730dBob Halley * 1. Redistributions of source code must retain the above copyright
422009fe5b15e31e7f5d09212bd1480121a1464eEvan Hunt * notice, this list of conditions and the following disclaimer.
9b2267b5ba9d0640512a41e139a4a36caa43730dBob Halley * 2. Redistributions in binary form must reproduce the above copyright
9b2267b5ba9d0640512a41e139a4a36caa43730dBob Halley * notice, this list of conditions and the following disclaimer in the
9b2267b5ba9d0640512a41e139a4a36caa43730dBob Halley * documentation and/or other materials provided with the distribution.
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#define WANT_DH_PRIMES
#define WANT_ECC_CURVES
} key_class_t;
#define PRIVATE_LABEL 0
#define RSA_LABEL 0
#define ECC_LABEL 0
#define DSA_LABEL 0
#define DSA_PARAM_PRIME 0
#define DSA_DOMAIN_PRIMEBITS 0
#define DH_LABEL 0
#define DH_PARAM_PRIME 0
#define DH_DOMAIN_PRIMEBITS 0
static key_class_t
return (key_unknown);
return (key_rsa);
return (key_dsa);
return (key_dh);
return (key_ecc);
return (key_ecx);
return (key_unknown);
usage(void) {
int error = 0;
int c, errflg = 0;
unsigned long id = 0;
hide = 0;
errflg++;
errflg++;
usage();
switch (keyclass) {
case key_rsa:
if (expsize == 0)
if (bits == 0)
usage();
case key_ecc:
if (bits == 0)
sizeof(pk11_ecc_prime256v1);
sizeof(pk11_ecc_secp384r1);
case key_ecx:
#ifndef CKM_EDDSA_KEY_PAIR_GEN
usage();
if (bits == 0)
sizeof(pk11_ecc_ed25519);
sizeof(pk11_ecc_ed448);
case key_dsa:
if (bits == 0)
usage();
case key_dh:
else if (special &&
} else if (bits == 0)
usage();
case key_unknown:
usage();
if (idlen == 0) {
goto exit_session;
goto exit_search;
if (ulObjectCount != 0) {
goto exit_search;
if (!hide) {
goto generate_keys;
if (special != 0) {
sizeof(pk11_dh_bn768);
sizeof(pk11_dh_bn1024);
sizeof(pk11_dh_bn1536);
param_attrcnt = 0;
goto generate_keys;
goto exit_search;
goto exit_domain;
for (i = 0; i < param_attrcnt; i++)
goto exit_params;
switch (keyclass) {
case key_dsa:
case key_dh:
} else if (!quiet)
for (i = 0; i < param_attrcnt; i++)
(void) pk11_finalize();