Change this program example to suit your needs for initializing a key store for your Cryptographic Coprocessor.
If you choose to use this program example, change it to suit your specific needs. For security reasons, IBM® recommends that you individualize these program examples rather than using the default values provided.
/*---------------------------------------------------------------*/ /* Create key store files for PKA keys. */ /* */ /* COPYRIGHT 5769-SS1 (c) IBM Corp 1999, 2000 */ /* */ /* This material contains programming source code for your */ /* consideration. These examples have not been thoroughly */ /* tested under all conditions. IBM, therefore, cannot */ /* guarantee or imply reliability, serviceability, or function */ /* of these programs. All programs contained herein are */ /* provided to you "AS IS". THE IMPLIED WARRANTIES OF */ /* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */ /* EXPRESSLY DISCLAIMED. IBM provides no program services for */ /* these programs and files. */ /* */ /* Parameters: */ /* Qualified File Name */ /* */ /* Examples: */ /* CALL PGM(INZPKEYST) PARM('QGPL/PKAFILE') */ /* */ /* */ /* Use the following commands to compile this program: */ /* ADDLIBLE LIB(QCCA) */ /* CRTCMOD MODULE(INZPKEYST) SRCFILE(SAMPLE) */ /* CRTPGM PGM(INZPKEYST) MODULE(INZPKEYST) + */ /* BNDSRVPGM(QCCA/CSNBKSI) */ /* */ /* Note: authority to the CSNBKSI service program in the */ /* QCCA library is assumed. */ /* */ /* Common Cryptographic Architecture (CCA) verbs used: */ /* Keystore_Initialize (CSNBKSI) */ /* */ /*---------------------------------------------------------------*/ #include <stdlib.h> #include <stdio.h> #include <string.h> #include "csucincl.h" /* header file for CCA Cryptographic Service Provider */ int main(int argc, char *argv[]) { /*-------------------------------------------------------------------*/ /* standard return codes */ /*-------------------------------------------------------------------*/ #define ERROR -1 #define OK 0 /*-------------------------------------------------------------------*/ /* standard CCA parameters */ /*-------------------------------------------------------------------*/ long return_code; long reason_code; long exit_data_length; char exit_data[2]; char rule_array[4][8]; long rule_array_count; /*-------------------------------------------------------------------*/ /* fields unique to this sample program */ /*-------------------------------------------------------------------*/ long file_name_length; unsigned char description[4]; long description_length = 0; unsigned char masterkey[8]; /*-------------------------------------------------------------------*/ /* Check if file name was passed */ /*-------------------------------------------------------------------*/ if(argc < 2) { printf("File name was not specified.\n"); return ERROR; } /*-------------------------------------------------------------------*/ /* fill in parameters for Keystore_Initialize */ /*-------------------------------------------------------------------*/ rule_array_count = 2; memcpy((char*)rule_array,"CURRENT PKA ",16); file_name_length = strlen(argv[1]); /*-------------------------------------------------------------------*/ /* Create key store file */ /*-------------------------------------------------------------------*/ CSNBKSI(&return_code, &reason_code, &exit_data_length, exit_data, &rule_array_count, (char*)rule_array, &file_name_length, argv[1], &description_length, description, masterkey); /*-------------------------------------------------------------------*/ /* Check the return code and display the result */ /*-------------------------------------------------------------------*/ if (return_code != 0) { printf("Request failed with return/reason codes: %d/%d\n", return_code, reason_code); return ERROR; } else { printf("Key store file created\n"); return OK; } }