/* genkey - pkcs11 rsa key generator
*
* create RSASHA1 key in the keystore of an SCA6000
* The calculation of key tag is left to the script
* that converts the key into a DNSKEY RR and inserts
* it into a zone file.
*
* usage:
* genkey [-P] [-s slot] -b keysize -l label [-p pin]
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#ifndef OPENCRYPTOKI
#include <security/cryptoki.h>
#else
#include <opencryptoki/pkcs11.h>
#endif
/* Define static key template values */
int
{
int error = 0;
int i = 0;
int c, errflg = 0;
/* Set search template */
};
};
};
extern char *optarg;
extern int optopt;
switch (c) {
case 'P':
hide = 0;
break;
case 's':
break;
case 'b':
break;
case 'l':
break;
case 'p':
break;
case ':':
errflg++;
break;
case '?':
default:
errflg++;
}
}
"usage: genkey [-P] [-s slot] -b keysize -l label [-p pin]\n");
exit(2);
}
/* Set public exponent to 65537 */
public_exponent[0] = 0x01;
/* Set up mechanism for generating key pair */
genmech.ulParameterLen = 0;
/* Initialize the CRYPTOKI library */
exit(1);
}
/* Open a session on the slot found */
error = 1;
goto exit_program;
}
/* Login to the Token (Keystore) */
if (!pin)
#ifndef OPENCRYPTOKI
#else
#endif
error = 1;
goto exit_session;
}
/* check if a key with the same id already exists */
error = 1;
goto exit_session;
}
error = 1;
goto exit_search;
}
if (ulObjectCount != 0) {
error = 1;
goto exit_search;
}
/* Set attributes if the key is not to be hidden */
if (!hide) {
}
(sizeof (publickey_template) /
sizeof (CK_ATTRIBUTE)),
(sizeof (privatekey_template) /
sizeof (CK_ATTRIBUTE)),
&publickey, &privatekey);
error = 1;
}
error = 1;
}
(void) C_CloseSession(hSession);
(void) C_Finalize(NULL_PTR);
}