This example demonstrates a request message that contains two Create operations, one Query, and one Discover Version KMIP operations. This is the same example as presented in JNI KMIP Example 1.
#include <stdio.h>
#include <stdlib.h>
#include <memory>
#include "cconsolestream.h"
using namespace P6R;
namespace {
0x42, 0x00, 0x78, 0x01, 0x00, 0x00, 0x03, 0x98, 0x42, 0x00, 0x77, 0x01, 0x00, 0x00, 0x00, 0x88, 0x42, 0x00, 0x69, 0x01, 0x00, 0x00, 0x00, 0x20, 0x42, 0x00, 0x6a, 0x02, 0x00, 0x00, 0x00, 0x04,
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x6b, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x50, 0x02, 0x00, 0x00, 0x00, 0x04,
0x00, 0x00, 0x01, 0xf4, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x07, 0x06, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x42, 0x00, 0x0e, 0x05, 0x00, 0x00, 0x00, 0x04,
0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x10, 0x06, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x42, 0x00, 0x92, 0x09, 0x00, 0x00, 0x00, 0x08,
0x00, 0x00, 0x00, 0x00, 0x59, 0xdc, 0x27, 0x66, 0x42, 0x00, 0x0d, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x0f, 0x01, 0x00, 0x00, 0x00, 0xe8,
0x42, 0x00, 0x5c, 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x93, 0x08, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x42, 0x00, 0x79, 0x01, 0x00, 0x00, 0x00, 0xc0, 0x42, 0x00, 0x57, 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x91, 0x01, 0x00, 0x00, 0x00, 0xa8,
0x42, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x30, 0x42, 0x00, 0x0a, 0x07, 0x00, 0x00, 0x00, 0x17, 0x43, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x67, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x20, 0x41, 0x6c,
0x67, 0x6f, 0x72, 0x69, 0x74, 0x68, 0x6d, 0x00, 0x42, 0x00, 0x0b, 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x30,
0x42, 0x00, 0x0a, 0x07, 0x00, 0x00, 0x00, 0x14, 0x43, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x67, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x20, 0x4c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x00, 0x00, 0x00, 0x00,
0x42, 0x00, 0x0b, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x30, 0x42, 0x00, 0x0a, 0x07, 0x00, 0x00, 0x00, 0x18,
0x43, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x67, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x20, 0x55, 0x73, 0x61, 0x67, 0x65, 0x20, 0x4d, 0x61, 0x73, 0x6b, 0x42, 0x00, 0x0b, 0x02, 0x00, 0x00, 0x00, 0x04,
0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x0f, 0x01, 0x00, 0x00, 0x01, 0x20, 0x42, 0x00, 0x5c, 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
0x42, 0x00, 0x93, 0x08, 0x00, 0x00, 0x00, 0x01, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x79, 0x01, 0x00, 0x00, 0x00, 0xf8, 0x42, 0x00, 0x57, 0x05, 0x00, 0x00, 0x00, 0x04,
0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x91, 0x01, 0x00, 0x00, 0x00, 0xe0, 0x42, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x30, 0x42, 0x00, 0x0a, 0x07, 0x00, 0x00, 0x00, 0x17,
0x43, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x67, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x20, 0x41, 0x6c, 0x67, 0x6f, 0x72, 0x69, 0x74, 0x68, 0x6d, 0x00, 0x42, 0x00, 0x0b, 0x05, 0x00, 0x00, 0x00, 0x04,
0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x30, 0x42, 0x00, 0x0a, 0x07, 0x00, 0x00, 0x00, 0x14, 0x43, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x67, 0x72,
0x61, 0x70, 0x68, 0x69, 0x63, 0x20, 0x4c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x0b, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
0x42, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x30, 0x42, 0x00, 0x0a, 0x07, 0x00, 0x00, 0x00, 0x18, 0x43, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x67, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x20, 0x55, 0x73,
0x61, 0x67, 0x65, 0x20, 0x4d, 0x61, 0x73, 0x6b, 0x42, 0x00, 0x0b, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x30,
0x42, 0x00, 0x0a, 0x07, 0x00, 0x00, 0x00, 0x0b, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x0b, 0x07, 0x00, 0x00, 0x00, 0x0b,
0x31, 0x20, 0x32, 0x20, 0x33, 0x20, 0x34, 0x20, 0x35, 0x20, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x0f, 0x01, 0x00, 0x00, 0x00, 0xb8, 0x42, 0x00, 0x5c, 0x05, 0x00, 0x00, 0x00, 0x04,
0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x93, 0x08, 0x00, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x79, 0x01, 0x00, 0x00, 0x00, 0x90,
0x42, 0x00, 0x74, 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x74, 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
0x42, 0x00, 0x74, 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x74, 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00,
0x42, 0x00, 0x74, 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x74, 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00,
0x42, 0x00, 0x74, 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x74, 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00,
0x42, 0x00, 0x74, 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x0f, 0x01, 0x00, 0x00, 0x00, 0x28, 0x42, 0x00, 0x5c, 0x05, 0x00, 0x00, 0x00, 0x04,
0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x93, 0x08, 0x00, 0x00, 0x00, 0x01, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x79, 0x01, 0x00, 0x00, 0x00, 0x00 };
class CKmipExample1
{
public:
CKmipExample1() : m_pPool( NULL ), m_pParser( NULL )
{ }
~CKmipExample1()
{
if (NULL != m_pPool ) m_pPool->release();
if (NULL != m_pParser) m_pParser->release();
}
protected:
};
{
{
if (
P6SUCCEEDED( err = cpSource->initialize( P6ENTROPY_HIGH )))
{
{
if (
P6SUCCEEDED( err = cpInit->initialize( P6RAND_NOFLAGS, cpSource ))) {
}
}
}
}
return err;
}
{
if (
P6FAILED( err = getRNG( m_cpRandom.addressof())))
return err;
if (
P6FAILED( err = m_pPool->initialize(
P6CTEXT(
"p6KMIPserverlib"), maxBufferSize, initialNumberOfBuffers, growBuffersBy, P6IOBF_NOFLAGS )))
return err;
if (
P6FAILED( err = m_pParser->initialize( P6KMIPFLG_TRACE_VERBOSE, 0, m_cpRandom )))
return err;
return err;
}
{
if (NULL == pEnum) return err;
err = pEnum->
next( &buffer );
{
if (NULL == (pBin =
new(std::nothrow)
P6UCHAR[buffer.
length]))
return eNoMemory;
pBin[0] = 0;
}
else err = eEndOfRecord;
return err;
}
{
{
{
switch( attribType ) {
default: err = eOk; break;
}
}
}
printf( "KSL create operation crypto algorithm: %d\n", cryptoAlg );
printf( "KSL create operation crypto length: %d\n", cryptoLength );
printf( "KSL create operation crypto maks: %d\n", cryptoMask );
printf( "KSL create operation sensitive: %d\n", sensitive );
printf( "KSL create operation extractable: %d\n", extractable );
return eOk;
}
{
{
switch ( enumValue ) {
case KMIP_QUERY_OPERATIIONS: printf( "KSL example1, query operations supported\n" ); break;
case KMIP_QUERY_OBJECTS: printf( "KSL example1, query objects supported\n" ); break;
case KMIP_QUERY_ATTENSTATIONTYPES: printf( "KSL example1, query attestation types supported\n" ); break;
case KMIP_QUERY_VALIDATIONS: printf( "KSL example1, query validationss supported\n" ); break;
case KMIP_QUERY_PROFILES: printf( "KSL example1, query profiles supported\n" ); break;
case KMIP_QUERY_SERVERINFORMATION: printf( "KSL example1, query server info supported\n" ); break;
case KMIP_QUERY_CAPABILITIES: printf( "KSL example1, query capabilities supported\n" ); break;
case KMIP_QUERY_REGMETHODS: printf( "KSL example1, query client registration methods supported\n" ); break;
case KMIP_QUERY_EXTENSIONLIST: printf( "KSL example1, query extension list supported\n" ); break;
case KMIP_QUERY_EXTENSIONMAP: printf( "KSL example1, query extension definitions supported\n" ); break;
case KMIP_QUERY_APPNAMESPACES: printf( "KSL example1, query application name spaces supported\n" ); break;
case KMIP_QUERY_RNGS: printf( "KSL example1, query random number generator algorithms supported\n" ); break;
default:
break;
}
}
return eOk;
}
{
{
{
printf(
"KSL example1, client supports protocol versions: %d.%d\n", clientSupported.
versionMajor, clientSupported.
versionMinor );
}
}
return eOk;
}
{
if (
P6FAILED( err = m_pPool->alloc( &pInBuffer )))
return err;
return err;
}
return err;
}
if (
P6FAILED( err = m_pParser->setMessageBuffer( messageFormat, pInBuffer, pStreamDebug )))
return err;
if (
P6FAILED( err = m_pParser->parseRequest( &reqHeader, &pBatchItems )))
return err;
printf(
"KSL msg header, protocol version: [ %d ]\n", reqHeader.
protocolVersion );
printf(
"KSL msg header, barch error option: [ %d ]\n", reqHeader.
batchErrorOption );
printf(
"KSL msg header, credentials object present : [ %s ]\n", (NULL != reqHeader.
pCredentials ?
"true" :
"false" ));
for( ; batchIndex < reqHeader.
batchCount &&
P6SUCCEEDED(err = pBatchItems->
at(&batchItem, batchIndex)); batchIndex++ )
{
}
switch ( batchItem.
type ) {
case KMIP_OP_CREATE:
err = createOperation( &batchItem, batchIndex );
break;
case KMIP_OP_QUERY:
err = queryOperation( &batchItem, batchIndex );
break;
case KMIP_OP_DISCOVERVERSIONS:
break;
case KMIP_OP_ACTIVATE:
case KMIP_OP_REVOKE:
case KMIP_OP_DESTROY:
case KMIP_OP_ADDATTRIBUTE:
case KMIP_OP_MODIFYATTRIBUTE:
case KMIP_OP_DELETEATTRIBUTE:
case KMIP_OP_GETATTRIBUTES:
case KMIP_OP_GETATTRIBUTELIST:
case KMIP_OP_LOCATE:
case KMIP_OP_CREATEKEYPAIR:
case KMIP_OP_GET:
case KMIP_OP_ENCRYPT:
case KMIP_OP_DECRYPT:
case KMIP_OP_GETUSAGEALLOC:
case KMIP_OP_RNGRETRIEVE:
case KMIP_OP_RNGSEED:
case KMIP_OP_OBTAINLEASE:
case KMIP_OP_REGISTER:
case KMIP_OP_CREATESPLITKEY:
case KMIP_OP_JOINSPLITKEY:
case KMIP_OP_REKEY:
case KMIP_OP_REKEYKEYPAIR:
case KMIP_OP_CERTIFY:
case KMIP_OP_RECERTIFY:
case KMIP_OP_CHECK:
case KMIP_OP_DERIVEKEY:
case KMIP_OP_SIGN:
case KMIP_OP_SIGNATUREVERIFY:
case KMIP_OP_MAC:
case KMIP_OP_MACVERIFY:
case KMIP_OP_HASH:
case KMIP_OP_LOG:
case KMIP_OP_ARCHIVE:
case KMIP_OP_RECOVER:
case KMIP_OP_IMPORT:
case KMIP_OP_EXPORT:
case KMIP_OP_CANCEL:
case KMIP_OP_POLL:
case KMIP_OP_VALIDATE:
default:
break;
}
}
}
return err;
}
{
CKmipExample1 example;
err = example.run( pDataStream, testMessage, sizeof(testMessage), KMIP_CMP_TTLV );
}
}
}
int main(int argc,char *argv[])
{
{
{
KMIP_BasicParserTest( cpDataStream );
}
else printf("ERROR: Failed to initialize the loader [ %x ]\n", err );
}
else printf( "ERROR: Failed to create CConsoleStream [ %x ]\n", err );
return err;
}
This example demonstrates how to generate a KMIP response message to a multi-batch request in TTLV, XML, and JSON. This is a similar example as presented in JNI KMIP Example 7.
#include <stdio.h>
#include <stdlib.h>
#include <memory>
#include "cconsolestream.h"
#include "p6kmipbatchresponse.h"
using namespace P6R;
namespace {
class CKmipExample2
{
public:
CKmipExample2() : m_pPool( NULL ), m_pAltPool( NULL ), m_pResponse( NULL )
{ }
~CKmipExample2()
{
if (NULL != m_pPool ) m_pPool->release();
if (NULL != m_pAltPool ) m_pAltPool->release();
if (NULL != m_pResponse) m_pResponse->release();
}
protected:
P6CLASSMETHOD freeResponseInfo( P6KMIP_OUTGOING_RESPONSE* pForClient );
};
{
P6UINT32 altBufferSize = maxBufferSize*2;
if (
P6FAILED( err = m_pPool->initialize(
P6CTEXT(
"p6KMIPserverlib-resp"), maxBufferSize, initialNumberOfBuffers, growBuffersBy, P6IOBF_NOFLAGS )))
return err;
if (
P6FAILED( err = m_pAltPool->initialize(
P6CTEXT(
"p6KMIPserverlib-altresp"), altBufferSize, initialNumberOfBuffers, growBuffersBy, P6IOBF_NOFLAGS )))
return err;
if (
P6FAILED( err = m_pResponse->initialize( P6KMIPRESP_NOFLAGS, 2, KMIP_CMP_TTLV, (
P6WCHAR*)
P6TEXT(
"ksl_error_stream"), m_pPool, m_pAltPool )))
return err;
return err;
}
{
if (NULL == (pForClient = new (std::nothrow) P6KMIP_OUTGOING_RESPONSE())) return eNoMemory;
m_cpStr->setMem( pForClient, 0, sizeof( P6KMIP_OUTGOING_RESPONSE ));
pForClient->batchCount = batchCount;
if (NULL == (pForClient->pItems = new (std::nothrow) P6KMIP_BATCHRESP[ batchCount ])) {
delete pForClient;
pForClient = NULL;
return eNoMemory;
}
err = m_cpStr->setMem( &(pForClient->pItems[i]), 0, sizeof( P6KMIP_BATCHRESP ));
}
return err;
}
{
pAttributeList = NULL;
delete pAttributes;
pAttributes = NULL;
return eNoMemory;
}
pAttributeList[0].
type = KMIP_ATTRIB_CRYPTOLENGTH;
pAttributeList[0].
index = 0;
pAttributeList[1].
type = KMIP_ATTRIB_CRYPTOUSAGEMASK;
pAttributeList[1].
index = 0;
pAttributeList[2].
type = KMIP_ATTRIB_CRYPTOALGORITHM;
pAttributeList[2].
index = 0;
return err;
}
P6CLASSMETHODIMPL CKmipExample2::freeResponseInfo( P6KMIP_OUTGOING_RESPONSE* pForClient )
{
p6IKMIPBatchResponseInit* pInst = NULL;
p6IKMIPBatchResponse* pResponse = NULL;
if (NULL == pForClient) return err;
{
if (
P6SUCCEEDED( err = pInst->initialize( pForClient ))) {
err = pInst->queryInterface(
VALIDATEIF( p6IKMIPBatchResponse, &pResponse ));
}
pInst->release();
}
if ( NULL != pResponse ) {
err = pResponse->release();
}
return err;
}
{
P6KMIP_OUTGOING_RESPONSE* pForClient = NULL;
P6UCHAR* pBID1 = NULL;
P6UCHAR* pBID2 = NULL;
P6UCHAR* pBID3 = NULL;
err = m_pResponse->setMsgFormat( messageFormat );
err = m_pResponse->setProtocolVersion( protocolVersion );
if (
P6FAILED( err = allocateResponseBatchItems( 3, pForClient )))
return err;
if (NULL == (pBID1 = new (std::nothrow) P6UCHAR[ 1 ])) return eNoMemory;
pBID1[0] = 0x01;
if (NULL == (pUID1 =
new (std::nothrow)
P6CHAR[ 37 ]))
return eNoMemory;
pUID1[0] = 0;
m_cpStr->strlcat( pUID1, 37, "A36E641F-A590-4153-9CAB-129B0AD4A04F", &copied );
err = returnAttributes( pAttributes );
pForClient->pItems[ 0 ].uniqueBatchId.pString = pBID1;
pForClient->pItems[ 0 ].uniqueBatchId.length = 1;
pForClient->pItems[ 0 ].status = KMIP_RESULT_SUCCESS;
pForClient->pItems[ 0 ].pError = NULL;
pForClient->pItems[ 0 ].type = KMIP_OP_CREATE;
pForClient->pItems[ 0 ].value.create.objectType = KMIP_OBJECT_SYMMETRICKEY;
pForClient->pItems[ 0 ].value.create.pAttributes = pAttributes;
pForClient->pItems[ 0 ].value.create.uniqueId.pString = pUID1;
pForClient->pItems[ 0 ].value.create.uniqueId.length = 36;
if (NULL == (pBID2 = new (std::nothrow) P6UCHAR[ 1 ])) return eNoMemory;
pBID2[0] = 0x02;
if (NULL == (pUID2 = new (std::nothrow) P6CHAR[ 37 ])) return eNoMemory;
pUID2[0] = 0;
m_cpStr->strlcat( pUID2, 37, "EFD6A04B-C8F5-4F03-95BE-03D43AA03106", &copied );
pForClient->pItems[ 1 ].uniqueBatchId.pString = pBID2;
pForClient->pItems[ 1 ].uniqueBatchId.length = 1;
pForClient->pItems[ 1 ].status = KMIP_RESULT_SUCCESS;
pForClient->pItems[ 1 ].pError = NULL;
pForClient->pItems[ 1 ].type = KMIP_OP_CREATE;
pForClient->pItems[ 1 ].value.create.objectType = KMIP_OBJECT_SECRETDATA;
pForClient->pItems[ 1 ].value.create.pAttributes = NULL;
pForClient->pItems[ 1 ].value.create.uniqueId.pString = pUID2;
pForClient->pItems[ 1 ].value.create.uniqueId.length = 36;
if (NULL == (pBID3 = new (std::nothrow) P6UCHAR[ 1 ])) return eNoMemory;
pBID3[0] = 0x03;
if (NULL == (pVersionList =
new (std::nothrow)
P6KMIP_VERSION[ 5 ]))
return eNoMemory;
pForClient->pItems[ 2 ].uniqueBatchId.pString = pBID3;
pForClient->pItems[ 2 ].uniqueBatchId.length = 1;
pForClient->pItems[ 2 ].status = KMIP_RESULT_SUCCESS;
pForClient->pItems[ 2 ].pError = NULL;
pForClient->pItems[ 2 ].type = KMIP_OP_DISCOVERVERSIONS;
pForClient->pItems[ 2 ].value.discoverVersions.verCount = 5;
pForClient->pItems[ 2 ].value.discoverVersions.pVersions = pVersionList;
if (
P6SUCCEEDED( err = m_pResponse->generateBatchResponse( pForClient, &pResponse )))
{
{
if ( NULL != ((*pBytes) = new (std::nothrow) P6UCHAR[msgSize+1]))
{
err = m_cpStr->moveMem((*pBytes), msgSize, pRawBuffer, msgSize );
(*pBytesLength) = msgSize;
}
else err = eNoMemory;
}
}
freeResponseInfo( pForClient );
return err;
}
{
CKmipExample2 example;
P6UCHAR* pBytes = NULL;
P6CHAR szTmp[32];
{
if (
P6SUCCEEDED( err1 = example.run( pDataStream, 4, KMIP_CMP_TTLV, &pBytes, &bytesLength )))
{
printf("\n");
for(
P6UINT32 i=0; i < bytesLength; i++ ) printf(
"%x", pBytes[i] );
printf("\n\n");
if (NULL != pBytes) {
delete [] pBytes;
pBytes = NULL;
bytesLength = 0;
}
}
if (
P6SUCCEEDED( err2 = example.run( pDataStream, 4, KMIP_CMP_MSGXML, &pBytes, &bytesLength )))
{
printf( "KSL result XML msg: %s\n", pBytes );
if (NULL != pBytes) {
delete [] pBytes;
pBytes = NULL;
bytesLength = 0;
}
}
if (
P6SUCCEEDED( err3 = example.run( pDataStream, 4, KMIP_CMP_MSGJSON, &pBytes, &bytesLength )))
{
printf( "\n\nKSL result JSON msg: %s\n", pBytes );
if (NULL != pBytes) {
delete [] pBytes;
pBytes = NULL;
bytesLength = 0;
}
}
}
}
}
int main(int argc,char *argv[])
{
{
{
KMIP_BasicResponseTest( cpDataStream );
}
else printf("ERROR: Failed to initialize the loader [ %x ]\n", err );
}
else printf( "ERROR: Failed to create CConsoleStream [ %x ]\n", err );
return err;
}