211 lines
9.6 KiB
HTML
211 lines
9.6 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: Requesting information from your Cryptographic Coprocessor" />
|
|
<meta name="abstract" content="Change this program example to suit your needs for requesting information from your Cryptographic Coprocessor. This program prompts the user for the second required keyword." />
|
|
<meta name="description" content="Change this program example to suit your needs for requesting information from your Cryptographic Coprocessor. This program prompts the user for the second required keyword." />
|
|
<meta name="DC.Relation" scheme="URI" content="rzajcquerying.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="cfgtxt" />
|
|
<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: Requesting information from your Cryptographic Coprocessor</title>
|
|
</head>
|
|
<body id="cfgtxt"><a name="cfgtxt"><!-- --></a>
|
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
|
<h1 class="topictitle1">Example: Requesting information from your Cryptographic Coprocessor</h1>
|
|
<div><p>Change this program example to suit your needs for requesting information
|
|
from your Cryptographic Coprocessor. This program prompts the user for the
|
|
second required keyword.</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.<p>If you choose to use this program example,
|
|
change it to suit your specific needs. For security reasons, IBM<sup>®</sup> recommends
|
|
that you individualize these program examples rather than using the default
|
|
values provided.</p>
|
|
</div>
|
|
</div>
|
|
<div class="example"> <pre>/*-------------------------------------------------------------------*/
|
|
/* Query the card for status or other information. */
|
|
/* This sample program prompts the user for the second required */
|
|
/* keyword. (ADAPTER1 keyword is assumed.) */
|
|
/* */
|
|
/* */
|
|
/* 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 program. All programs contained herein are */
|
|
/* provided to you "AS IS". THE IMPLIED WARRANTIES OF */
|
|
/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
|
|
/* ARE EXPRESSLY DISCLAIMED. IBM provides no program services for */
|
|
/* these programs and files. */
|
|
/* */
|
|
/* */
|
|
/* Note: This verb is more fully described in Chapter 2 of */
|
|
/* IBM CCA Basic Services Reference and Guide */
|
|
/* (SC31-8609) publication. */
|
|
/* */
|
|
/* Parameters: */
|
|
/* char * keyword2 upto 8 bytes */
|
|
/* */
|
|
/* Example: */
|
|
/* CALL PGM(CFQ) TIMEDATE */
|
|
/* */
|
|
/* */
|
|
/* Note: This program assumes the device to use is */
|
|
/* already identified either by defaulting to the CRP01 */
|
|
/* device or by being 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 these commands to compile this program on the system: */
|
|
/* ADDLIBLE LIB(QCCA) */
|
|
/* CRTCMOD MODULE(CFQ) SRCFILE(SAMPLE) */
|
|
/* CRTPGM PGM(CFQ) MODULE(CFQ) BNDSRVPGM(QCCA/CSUACFQ) */
|
|
/* */
|
|
/* Note: Authority to the CSUACFQ service program in the */
|
|
/* QCCA library is assumed. */
|
|
/* */
|
|
/* The Common Cryptographic Architecture (CCA) verb used is */
|
|
/* Cryptographic_Facility_Query (CSUACFQ). */
|
|
/* */
|
|
/*-------------------------------------------------------------------*/
|
|
|
|
|
|
#include "csucincl.h" /* header file for CCA Cryptographic */
|
|
/* Service Provider */
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <stdlib.h>
|
|
|
|
/*-------------------------------------------------------------------*/
|
|
/* standard return codes */
|
|
/*-------------------------------------------------------------------*/
|
|
|
|
#define ERROR -1
|
|
#define OK 0
|
|
#define WARNING 4
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
/*-------------------------------------------------------------------*/
|
|
/* standard CCA parameters */
|
|
/*-------------------------------------------------------------------*/
|
|
|
|
long return_code = 0;
|
|
long reason_code = 0;
|
|
long exit_data_length = 2;
|
|
char exit_data[4];
|
|
char rule_array[18][8];
|
|
long rule_array_count = 2;
|
|
|
|
/*-------------------------------------------------------------------*/
|
|
/* fields unique to this sample program */
|
|
/*-------------------------------------------------------------------*/
|
|
|
|
long verb_data_length = 0; /* currently not used by this verb */
|
|
char * verb_data = " ";
|
|
|
|
int i;
|
|
|
|
/* check the keyboard input */
|
|
|
|
if (argc != 2)
|
|
{
|
|
printf("You did not enter the keyword parameter.\n");
|
|
|
|
printf("Enter one of the following: STATCCA, STATCARD, ");
|
|
|
|
printf("STATDIAG, STATEXPT, STATMOFN, STATEID, TIMEDATE\n");
|
|
|
|
return(ERROR);
|
|
}
|
|
|
|
if ( (strlen(argv[1]) > 8) | (strlen(argv[1]) < 7) )
|
|
{
|
|
printf("Your input string is not the right length.\n");
|
|
|
|
printf("Input keyword must be 7 or 8 characters.\n");
|
|
|
|
printf("Enter one of the following: STATCCA, STATCARD, ");
|
|
|
|
printf("STATDIAG, STATEXPT, STATMOFN, STATEID, TIMEDATE\n");
|
|
|
|
return(ERROR);
|
|
}
|
|
|
|
/* set keywords in the rule array */
|
|
|
|
memcpy(rule_array,"ADAPTER1 ",16);
|
|
|
|
memcpy(&rule_array[1], argv[1], strlen(argv[1]));
|
|
|
|
/* get the requested data from the card */
|
|
|
|
CSUACFQ( &return_code,
|
|
&reason_code,
|
|
&exit_data_length,
|
|
exit_data,
|
|
&rule_array_count,
|
|
(char *)rule_array,
|
|
&verb_data_length,
|
|
verb_data);
|
|
|
|
if ( (return_code == OK) | (return_code == WARNING) )
|
|
{
|
|
|
|
printf("Requested data was successfully returned.\n");
|
|
|
|
printf("Return/reason codes ");
|
|
|
|
printf("%ld/%ld\n\n", return_code, reason_code);
|
|
|
|
printf("%s data = ", argv[1]);
|
|
|
|
for (i = 0; i < 8 * rule_array_count; i++)
|
|
printf("%c", rule_array[i / 8][i % 8]);
|
|
printf("\n");
|
|
}
|
|
|
|
else
|
|
{
|
|
printf("An error occurred while getting the requested data.\n");
|
|
|
|
printf("You requested %s\n", argv[1]);
|
|
|
|
printf("Return/reason codes ");
|
|
|
|
printf("%ld/%ld\n\n", return_code, reason_code);
|
|
|
|
return(ERROR);
|
|
}
|
|
|
|
}</pre>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="rzajcquerying.htm" title="You can query your Cryptographic Coprocessor to determine characteristics such as which algorithms are enabled, the key lengths it supports, the status of the master key, the status of cloning, and the clock setting.">Query status or request information</a></div>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html> |