ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzajc_5.4.0.1/rzajcloadfcvc.htm

208 lines
9.7 KiB
HTML

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-us" xml:lang="en-us">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="security" content="public" />
<meta name="Robots" content="index,follow" />
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
<meta name="DC.Type" content="reference" />
<meta name="DC.Title" content="Example: ILE C program for loading a function control vector for your Cryptographic Coprocessor" />
<meta name="abstract" content="Change this program example to suit your needs for loading a function control vector for your Cryptographic Coprocessor." />
<meta name="description" content="Change this program example to suit your needs for loading a function control vector for your Cryptographic Coprocessor." />
<meta name="DC.Relation" scheme="URI" content="rzajccontrolvector.htm" />
<meta name="copyright" content="(C) Copyright IBM Corporation 2006" />
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 2006" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="loadfcvc" />
<meta name="DC.Language" content="en-us" />
<!-- All rights reserved. Licensed Materials Property of IBM -->
<!-- US Government Users Restricted Rights -->
<!-- Use, duplication or disclosure restricted by -->
<!-- GSA ADP Schedule Contract with IBM Corp. -->
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
<link rel="stylesheet" type="text/css" href="./ic.css" />
<title>Example: ILE C program for loading a function control vector for your
Cryptographic Coprocessor</title>
</head>
<body id="loadfcvc"><a name="loadfcvc"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Example: ILE C program for loading a function control vector for your
Cryptographic Coprocessor</h1>
<div><p>Change this program example to suit your needs for loading a function
control vector for your Cryptographic Coprocessor.</p>
<div class="section"> <div class="note"><span class="notetitle">Note:</span> Read the <a href="codedisclaimer.htm#codedisclaimer">Code license and disclaimer information</a> for
important legal information.</div>
</div>
<div class="example"> <pre>/*------------------------------------------------------------*/
/* Load the Function Control Vector into the card. */
/* The Function Control Vector enables the cryptographic */
/* functions of the card and is shipped with the */
/* Cryptographic Access Provider products. */
/* */
/* COPYRIGHT 5769-SS1 (c) IBM Corp 1999 */
/* */
/* 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. */
/* */
/* Note: The Function Control Vector is stored in an IFS */
/* file owned by the system. The format of this */
/* vector is described in an appendix of the */
/* IBM CCA Basic Services Reference and Guide */
/* (SC31-8609) publication. */
/* */
/* Parameters: */
/* none. */
/* */
/* Example: */
/* CALL PGM(LOAD_FCV) */
/* */
/* Note: This program assumes the device you want to load is */
/* already identified either by defaulting to the CRP01 */
/* device or has been explicitly named using the */
/* Cryptographic_Resource_Allocate verb. Also this */
/* device must be varied on and you must be authorized */
/* to use this device description. */
/* */
/* Use the following commands to compile this program: */
/* ADDLIBLE LIB(QCCA) */
/* CRTCMOD MODULE(LOAD_FCV) SRCFILE(SAMPLE) SYSIFCOPT(*IFSIO) */
/* CRTPGM PGM(LOAD_FCV) MODULE(LOAD_FCV) + */
/* BNDSRVPGM(QCCA/CSUACFC) */
/* */
/* Note: Authority to the CSUACFC service program in the */
/* QCCA library is assumed. */
/* */
/* Common Cryptographic Architecture (CCA) verbs used: */
/* Cryptographic_Facility_Control (CSUACFC) */
/* */
/*------------------------------------------------------------*/
#include &lt;stdlib.h&gt;
#include &lt;stdio.h&gt;
#include &lt;string.h&gt;
#include &lt;decimal.h&gt;
#include "csucincl.h" /* header file for CCA Cryptographic
Service Provider */
/*-------------------------------------------------------------------*/
/* function to translate ASCII to EBCDIC and/or EBCDIC to ASCII */
/*-------------------------------------------------------------------*/
#pragma linkage(QDCXLATE, OS, nowiden)
void QDCXLATE(decimal(5,0)*,
char *,
char *,
char *);
int main(void)
{
/*-------------------------------------------------------------------*/
/* 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 verb_data_length;
char *verb_data;
char buffer[1000];
char description[81];
decimal(5,0) descr_length = 80;
int num_bytes;
FILE *fcv;
/*-------------------------------------------------------------------*/
/* retrieve FCV from IBM supplied file */
/*-------------------------------------------------------------------*/
fcv = fopen("/QIBM/ProdData/CAP/FCV.CRT", "rb");
if (fcv==NULL)
{
printf("Function Control Vector file not available\n\n");
return ERROR; /* File not found or not authorized */
}
num_bytes = fread(buffer,1,1000,fcv);
fclose(fcv);
if (num_bytes != 802)
{
printf("Function Control Vector file has wrong size\n\n");
return ERROR; /* Incorrect number of bytes read */
}
/*-------------------------------------------------------------------*/
/* extract fields in FCV needed by card */
/* Note: use offsets and lengths from CCA publication listed earlier */
/*-------------------------------------------------------------------*/
memcpy(description, &amp;buffer[390],80);
description[80] = 0;
QDCXLATE(&amp;descr_length, description, "QEBCDIC ", "QSYS ");
printf("Loading Function Control Vector: %s\n",description);
verb_data_length = 204;
verb_data = &amp;buffer[470];
rule_array_count = 2;
memcpy((char*)rule_array,"ADAPTER1LOAD-FCV",16);
/*-------------------------------------------------------------------*/
/* Load the card with the FCV just retrieved */
/*-------------------------------------------------------------------*/
CSUACFC(&amp;return_code,
&amp;reason_code,
&amp;exit_data_length,
exit_data,
&amp;rule_array_count,
(char*)rule_array,
&amp;verb_data_length,
verb_data);
if (return_code != 0)
{
printf("Function Control Vector rejected for reason %d/%d\n\n",
return_code, reason_code);
return ERROR; /* Operation failed. */
}
else
{
printf("Loading Function Control Vector succeeded\n\n");
printf("SAPI returned %ld/%ld\n\n", return_code, reason_code);
return OK;
}
}</pre>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="rzajccontrolvector.htm" title="The function control vector tells the Cryptographic Coprocessor what key length to use to create keys. You cannot perform any cryptographic functions without loading a function control vector.">Load a function control vector</a></div>
</div>
</div>
</body>
</html>