CPM Library Provider Structures and Types
CPM Library Provider Function Argument Structures
CPM Library Provider Constants
Application-Defined Functions
The header file CPMLibProvider.h declares the API that this chapter describes.
CPM Library Provider Structures and Types
CPMCallerInfoType Struct
Purpose
This structure is passed to the provider's dispatcher. It contains all the information necessary for the provider to call back into the CPM framework and use the CPM's resources.
Declared In
CPMLibProvider.h Prototype
typedef struct _CPMCallerInfoType { void *appContext; CPMDebugOutProcPtr debugout; CPMDispatcherProcPtr dispatcher; CPMGenerateRandomBytesProcPtr generateRandom; CPMAddRandomSeedProcPtr addSeed;} CPMCallerInfoType
typedef CPMCallerInfoType *CPMCallerInfoPtr;
Fields
-
appContext - Pointer to a structure containing the provider-specific application context to be used in future CPM calls. This structure is normally created and initialized when the library is opened.
-
debugout - Pointer to a function that outputs a debug message to the debug device. See
CPMDebugOutProcPtr() -
dispatcher - Pointer to the CPM function dispatcher. See
CPMDispatcherProcPtr(). -
generateRandom - Pointer to a function that can return a requested number of random bytes. See
CPMGenerateRandomBytesProcPtr(). -
addSeed - Pointer to a function that puts a number of seed bytes into the pseudo-random number generator maintained by the CPM. See
CPMAddRandomSeedProcPtr()
CPM Library Provider Function Argument Structures
APCmdPBType Struct
Purpose
Declares the algorithm provider interface command parameter blocks.
Declared In
CPMLibProvider.h Prototype
typedef union APCmdPBType { ... } APCmdPBType, *APCmdPBPtr
Fields
Various structures. Each structure is documented separately within this section.
APDecrypt Struct
Purpose
The command paramater block for the Decrypt call.
Declared In
CPMLibProvider.h Prototype
struct { APKeyInfoType *keyInfoP; APCipherInfoType *cipherInfoP; uint8_t *bufIn; uint32_t bufInLen; uint8_t *bufOut; uint32_t *bufOutLenP; } APDecrypt;
Fields
-
keyInfoP - The key to be used for the operation.
-
cipherInfoP - Avalid context for this operation initialized by the initialization operation.
-
bufIn - The data to add to the operation.
-
bufInLen - The length of the data to add to this operation.
-
bufOut - The buffer where the results of the operation are to be placed.
-
bufOutLenP - The size of the buffer specified by
bufOut. Also returns the actual number of bytes placed inbufOuton return.
Comments
The cipherInfoP field specifies an initialized context which was created in the initialization of this class of functions.
bufInLen may not be zero and bufIn must be valid.
The provider performs a complete decryption operation using the data in bufIn of length bufInLen and puts the results in bufOut. The actual number of bytes placed in bufOut is placed in bufOutLenP.
APDecryptFinal Struct
Purpose
The command paramater block for the DecryptFinal call.
Declared In
CPMLibProvider.h Prototype
struct { APKeyInfoType *keyInfoP; APCipherInfoType *cipherInfoP; uint8_t *bufIn; uint32_t bufInLen; uint8_t *bufOut; uint32_t *bufOutLenP; } APDecryptFinal;
Fields
-
keyInfoP - The key to be used for the operation.
-
cipherInfoP - Avalid context for this operation initialized by the initialization operation.
-
bufIn - The data to add to the operation.
-
bufInLen - The length of the data to add to this operation.
-
bufOut - The buffer where the results of the operation are to be placed.
-
bufOutLenP - The size of the buffer specified by
bufOut. Also returns the actual number of bytes placed inbufOuton return.
Comments
The cipherInfoP field specifies an initialized context which was created in the initialization of this class of functions.
bufInLen may not be zero and bufIn must be valid.
The provider performs a complete decryption operation using the data in bufIn of length bufInLen and puts the results in bufOut. The actual number of bytes placed in bufOut is placed in bufOutLenP.
APDecryptInit Struct
Purpose
The command paramater block for the DecryptInit call.
Declared In
CPMLibProvider.h Prototype
struct { APKeyInfoType *keyInfoP; APCipherInfoType *cipherInfoP; } APDecryptInit;
Fields
-
keyInfoP - The key to be used for the operation.
-
cipherInfoP - A handle to a context to pass to the other members of the Decrypt functions.
Comments
The provider is responsible for initializing a context of the appropriate type with the specified keyInfoP for the operation and saving it in cipherInfoP. This Init operation must be concluded with a single finalization operation with zero or more update operations in between.
APDecryptUpdate Struct
Purpose
The command paramater block for the DecryptUpdate call.
Declared In
CPMLibProvider.h Prototype
struct { APKeyInfoType *keyInfoP; APCipherInfoType *cipherInfoP; uint8_t *bufIn; uint32_t bufInLen; uint8_t *bufOut; uint32_t *bufOutLenP; } APDecryptUpdate;
Fields
-
keyInfoP - The key to be used for the operation.
-
cipherInfoP - Avalid context for this operation initialized by the initialization operation.
-
bufIn - The data to add to the operation.
-
bufInLen - The length of the data to add to this operation.
-
bufOut - The buffer where the results of the operation are to be placed.
-
bufOutLenP - The size of the buffer specified by
bufOut. Also returns the actual number of bytes placed inbufOuton return.
Comments
The cipherInfoP field specifies an initialized context which was created in the initialization of this class of functions.
If bufInLen is non-zero, the provider uses cipherInfoP to update the operation with the data in bufIn of length bufInLen.
The provider finalizes the operation which was initialized by the Init operation and places the results of the operation in bufOut. The provider updates bufOutLenP with the actual number of bytes placed in bufOut. The provider is responsible for cleaning up the cipherInfoP parameter.
APDeriveKeyData Struct
Purpose
The command paramater block for the DeriveKeyData call.
Declared In
CPMLibProvider.h Prototype
struct { APKeyDerivationEnum kdType; APKeyDerivationUsageEnum kdUsage; uint8_t *saltP; uint32_t saltLen; uint32_t iterationCount; void *kdInfo; uint8_t *keyDataP; uint32_t *keyDataLenP; } APDeriveKeyData;
Fields
-
kdType - The type of key derivation to be performed. One of the values specified by
APKeyDerivationEnum. -
kdUsage - The allowed usage of the subsequently derived key. One of the values specified by
APKeyDerivationUsageEnum. -
saltP - Cryptographic salt to be used for the derivation function.
-
saltLen - The length, in bytes, of the salt.
-
iterationCount - The number of iterations for this particular derivation operation.
-
kdInfo - Other derivation-function-specific parameters as defined by both the provider handling the derivation and the derivation function itself.
-
keyDataP - Pointer to a buffer into which the derived key data is written. Pass
NULLto determine how large this buffer should be. -
keyDataLenP - When calling
DeriveKeyData, set the variable to which this parameter points to the size of thekeyDataPbuffer. Upon return, the variable will be set to the number of bytes written tokeyDataP. If you setkeyDataPtoNULL, set this variable to 0.
APEncrypt Struct
Purpose
The command paramater block for the Encrypt call.
Declared In
CPMLibProvider.h Prototype
struct { APKeyInfoType *keyInfoP; APCipherInfoType *cipherInfoP; uint8_t *bufIn; uint32_t bufInLen; uint8_t *bufOut; uint32_t *bufOutLenP; } APEncrypt;
Fields
-
keyInfoP - The key to be used for the operation.
-
cipherInfoP - A valid context for this operation initialized by the initialization operation.
-
bufIn - The data to add to the operation.
-
bufInLen - The length of the data to add to this operation.
-
bufOut - The buffer where the results of the operation are to be placed.
-
bufOutLenP - The size of the buffer specified by the
bufOutparameter. Also returns the actual number of bytes placed inbufOuton return.
Comments
The cipherInfoP parameter specifies an initialized context which was created during the initialization of this class of functions.
The parameter bufInLen may not be zero and bufIn must be valid.
The provider performs a complete encryption operation using the data in bufIn of length bufInLen and puts the results in bufOut. The actual number of bytes placed in bufOut is placed in bufOutLenP.
APEncryptFinal Struct
Purpose
The command paramater block for the EncryptFinal call.
Declared In
CPMLibProvider.h Prototype
struct { APKeyInfoType *keyInfoP; APCipherInfoType *cipherInfoP; uint8_t *bufIn; uint32_t bufInLen; uint8_t *bufOut; uint32_t *bufOutLenP; } APEncryptFinal;
Fields
-
keyInfoP - The key to be used for the operation.
-
cipherInfoP - A valid context for this operation initialized by the initialization operation.
-
bufIn - The data to add to the operation.
-
bufInLen - The length of the data to add to this operation.
-
bufOut - The buffer where the results of the operation are to be placed.
-
bufOutLenP - The size of the buffer specified by the
bufOutparameter. Also returns the actual number of bytes placed inbufOuton return
Comments
The cipherInfoP parameter specifies an initialized context which was created in the Init of this class of functions.
If the bufInLen is non-zero, the provider uses the cipherInfoP to update the operation with the data in bufIn of length bufInLen.
The provider finalizes the operation which was initialized by the Init operation and places the results of the operation in bufOut. The provider updates bufOutLenP with the actual number of bytes placed in bufOut. The provider is responsible for cleaning up the cipherInfoP parameter.
APEncryptInit Struct
Purpose
The command paramater block for the EncryptInit call.
Declared In
CPMLibProvider.h Prototype
struct { APKeyInfoType *keyInfoP; APCipherInfoType *cipherInfoP; } APEncryptInit;
Fields
-
keyInfoP - The key to be used for the operation.
-
cipherInfoP - A handle to a context to pass to the other members of the Encrypt functions.
Comments
The provider is responsible for initializing a context of the appropriate type with the specified keyInfoP for the operation and saving it in cipherInfoP. This initialization operation must be concluded with a single finalization operation with zero or more update operations in between.
APEncryptUpdate Struct
Purpose
The command paramater block for the EncryptUpdate call.
Declared In
CPMLibProvider.h Prototype
struct { APKeyInfoType *keyInfoP; APCipherInfoType *cipherInfoP; uint8_t *bufIn; uint32_t bufInLen; uint8_t *bufOut; uint32_t *bufOutLenP; } APEncryptUpdate;
Fields
-
keyInfoP - The key to be used for the operation.
-
cipherInfoP - A valid context for this operation initialized by the initialization operation.
-
bufIn - The data to add to the operation.
-
bufInLen - The length of the data to add to this operation.
-
bufOut - The buffer where the results of the operation are to be placed.
-
bufOutLenP - The size of the buffer specified by the
bufOutparameter. Also returns the actual number of bytes placed inbufOuton return
Comments
The cipherInfoP parameter specifies an initialized context which was created by the initialization of this class of functions. The provider uses cipherInfoP to update the operation with the data in bufIn of length bufInLen. The provider also updates cipherInfoP to reflect the update. Any number of update operations (including zero) may occur between an initialization and a finalization operation. The parameters bufIn and bufInLen must be valid for the operation or an error is returned.
APExportCipherInfo Struct
Purpose
The command paramater block for the ExportCipherInfo call.
Declared In
CPMLibProvider.h Prototype
struct { uint8_t encoding; uint8_t *exportDataP; uint32_t *dataLenP; APCipherInfoType *cipherInfoP; } APExportCipherInfo;
Fields
-
encoding - The encoding of the data being exported.
-
exportDataP - The data for the export operation.
-
dataLenP - Length of the exported data.
-
cipherInfoP - A valid context for this operation initialized by the initialization operation.
APExportHashInfo Struct
Purpose
The command paramater block for the ExportHashInfo call.
Declared In
CPMLibProvider.h Prototype
struct { uint8_t encoding; uint8_t *exportDataP; uint32_t *dataLenP; APHashInfoType *hashInfoP; } APExportHashInfo;
Fields
-
encoding - The encoding of the data being exported.
-
exportDataP - The data for the export operation.
-
dataLenP - Length of the exported data.
-
hashInfoP - An
APHashInfoTypestructure, allocated by the application, that holds information about the hashing operation.
APExportKeyInfo Struct
Purpose
The command paramater block for the ExportKey call.
Declared In
CPMLibProvider.h Prototype
struct { uint8_t encoding; APKeyInfoType *keyInfoP; uint8_t *exportDataP; uint32_t *dataLenP; } APExportKeyInfo;
Fields
-
encoding - The encoding desired for the export data.
-
keyInfoP - Pointer to the key being exported.
-
exportDataP - The data for the export operation.
-
dataLenP - Length of the exported data.
APExportKeyPairInfo Struct
Purpose
The command paramater block for the ExportKeyPair call.
Declared In
CPMLibProvider.h Prototype
struct { uint8_t encoding; uint8_t *exportDataP; uint32_t *dataLenP; APKeyInfoType *privateKeyInfoP; APKeyInfoType *publicKeyInfoP; } APExportKeyPairInfo;
Fields
-
encoding - The encoding of the data being exported.
-
exportDataP - The data for the export operation.
-
dataLenP - Length of the exported data.
-
privateKeyInfoP - Pointer to the
APKeyInfoTypestructure for the private key. -
publicKeyInfoP - Pointer to the
APKeyInfoTypestructure for the public key.
APExportMacInfo Struct
Purpose
The command paramater block for the ExportMAC call.
Declared In
CPMLibProvider.h Prototype
struct { uint8_t encoding; uint8_t *exportDataP; uint32_t *dataLenP; APMACInfoType *macInfoP; } APExportMACInfo;
Fields
-
encoding - The encoding of the data being exported.
-
exportDataP - The data for the export operation.
-
dataLenP - Length of the exported data.
-
macInfoP - Pointer to an
APMACInfoTypestructure.
APExportSignInfo Struct
Purpose
The command paramater block for the ExportSignInfo call.
Declared In
CPMLibProvider.h Prototype
struct { uint8_t encoding; uint8_t *exportDataP; uint32_t *dataLenP; APSignInfoType *signInfoP; } APExportSignInfo;
Fields
-
encoding - The encoding of the data being exported.
-
exportDataP - The data for the export operation.
-
dataLenP - Length of the exported data.
-
signInfoP - A valid context for this operation initialized by the initialization operation.
APExportVerifyInfo Struct
Purpose
The command paramater block for the ExportVerifyInfo call.
Declared In
CPMLibProvider.h Prototype
struct { uint8_t encoding; uint8_t *exportDataP; uint32_t *dataLenP; APVerifyInfoType *verifyInfoP; } APExportVerifyInfo;
Fields
-
encoding - The encoding of the data being exported.
-
exportDataP - The data for the export operation.
-
dataLenP - Length of the exported data.
-
verifyInfoP - A valid context for this operation initialized by the initialization operation.
APGenerateKey Struct
Purpose
The command paramater block for the GenerateKey call.
Declared In
CPMLibProvider.h Prototype
struct { uint8_t *keyDataP; uint32_t dataLen; APKeyInfoType *keyInfoP; } APGenerateKey;
Fields
-
keyDataP - Pointer to a buffer of seed bytes to be used by the pseudo-random number generator, or
NULLto have the pseudo-random number generator use the seed data it already has. -
dataLen - Length of the
keyDataPdata. -
keyInfoP - An opaque handle to the key generated by the provider.
Comments
If the newly-generated key is utilized for any cryptographic operations, it must be exported and saved in order to be used again. It is statistically improbably that a generated key could be regenerated.
The provider generates a key of the specified type and returns an opaque handle the key in keyInfoP.
APGenerateKeyPair Struct
Purpose
The command paramater block for the GenerateKeyPair call.
Declared In
CPMLibProvider.h Prototype
struct { uint8_t *keyDataP; uint32_t dataLen; APKeyInfoType *privateKeyInfoP; APKeyInfoType *publicKeyInfoP; } APGenerateKeyPair;
Fields
-
keyDataP - Pointer to a buffer of seed bytes to be used by the pseudo-random number generator, or
NULLto have the pseudo-random number generator use the seed data it already has. -
dataLen - Length of the
keyDataPdata. -
privateKeyInfoP - Pointer to the
APKeyInfoTypestructure for the private key. -
publicKeyInfoP - Pointer to the
APKeyInfoTypestructure for the public key.
Comments
If the newly-generated key pair is utilized for any cryptographic operations, the pair must be exported and saved in order to be used again. It is statistically improbably that a generated key pair could be regenerated.
APGetProviderInfo Struct
Purpose
The command paramater block for the GetProviderInfo call. The info field is filled in with appropriate information. The provider is responsible for filling the correct information.
Declared In
CPMLibProvider.h Prototype
struct { APProviderInfoType *infoP; } APGetProviderInfo;
Fields
APHash Struct
Purpose
The command paramater block for the Hash call.
Declared In
CPMLibProvider.h Prototype
struct { APHashEnum type; APHashInfoType *hashInfoP; uint8_t *bufIn; uint32_t bufInLen; uint8_t *bufOut; uint32_t *bufOutLenP; } APHash;
Fields
-
type - The type of hash requested for this operation.
-
hashInfoP - The hash context information for this operation.
-
bufIn - The data to add to the operation.
-
bufInLen - The length of the data to add to this operation.
-
bufOut - The buffer into which the results of the operation are to be placed.
-
bufOutLenP - The size of the buffer specified by the
bufOutparameter. Returns the actual number of bytes placed inbufOut.
Comments
The hashInfoP parameter specifies an initialized context which was created in the initialization of this class of functions.
The parameter bufInLen may not be zero and bufIn must be valid.
The provider performs a complete operation of type using the data in bufIn of length bufInLen and puts the results in bufOut. The actual number of bytes placed in bufOut is placed in bufOutLenP.
APHashFinal Struct
Purpose
The command paramater block for the HashFinal call.
Declared In
CPMLibProvider.h Prototype
struct { APHashInfoType *hashInfoP; uint8_t *bufIn; uint32_t bufInLen; uint8_t *bufOut; uint32_t *bufOutLenP; } APHashFinal;
Fields
-
hashInfoP - A valid context for this operation initialized by the HashInit operation.
-
bufIn - The data to add to the operation.
-
bufInLen - The length of the data to add to this operation.
-
bufOut - The buffer where the results of the operation are placed.
-
bufOutLenP - The size of the buffer specified by the
bufOutparameter. Returns the actual number of bytes placed inbufOut.
Comments
The hashInfoP parameter specifies an initialized context which was created in the Init of this class of functions.
If the bufInLen is non-zero, the provider uses the hashInfoP to update the operation with the data in bufIn of length bufInLen.
The provider finalizes the operation which was initialized by the Init operation and places the results of the operation in bufOut. The provider updates bufOutLenP with the actual number of bytes placed in bufOut. The provider is responsible for cleaning up the hashInfoP parameter.
APHashInit Struct
Purpose
The command paramater block for the HashInit call.
Declared In
CPMLibProvider.h Prototype
struct { APHashInfoType *hashInfoP; } APHashInit;
Fields
Comments
The provider is responsible for initializing a context of the appropriate for the operation and saving it in *hashInfoP. This initialization operation must be concluded with a single HashFinal operation with zero or more HashUpdate operations in between.
APHashUpdate Struct
Purpose
The command paramater block for the HashUpdate call.
Declared In
CPMLibProvider.h Prototype
struct { APHashInfoType *hashInfoP; uint8_t *bufIn; uint32_t bufInLen; } APHashUpdate;
Fields
-
hashInfoP - A valid context for this operation initialized by the HashInit operation.
-
bufIn - The data to add to the operation.
-
bufInLen - The length of the data to add to this operation.
Comments
The hashInfoP parameter specifies an initialized context which was created during the initialization of this class of functions. The provider uses the hashInfoP to update the operation with the data in bufIn of length bufInLen. The provider also updates the hashInfoP to reflect the update. Any number of update operations (including zero) may occur between an intialization and a finalization operation. The parameters bufIn and bufInLen must be valid for the operation or an error is returned.
APImportCipherInfo Struct
Purpose
The command paramater block for the ImportCipherInfo call.
Declared In
CPMLibProvider.h Prototype
struct { uint8_t encoding; uint8_t *importDataP; uint32_t dataLen; APCipherInfoType *cipherInfoP; } APImportCipherInfo;
Fields
-
encoding - The encoding of the data being imported.
-
importDataP - The data for the import operation.
-
dataLen - Length of the
importDataPblock. -
cipherInfoP - A valid context for this operation initialized by the initialization operation.
APImportHashInfo Struct
Purpose
The command paramater block for the ImportHashInfo call.
Declared In
CPMLibProvider.h Prototype
struct { uint8_t encoding; uint8_t *importDataP; uint32_t dataLen; APHashInfoType *hashInfoP; } APImportHashInfo;
Fields
-
encoding - The encoding of the data being imported.
-
importDataP - The data for the import operation.
-
dataLen - Length of the
importDataPblock. -
hashInfoP - Pointer to an
APHashInfoTypestructure that holds information about the hashing operation.
APImportKeyInfo Struct
Purpose
The command paramater block for the ImportKey call.
Declared In
CPMLibProvider.h Prototype
struct { uint8_t encoding; uint8_t *importDataP; uint32_t dataLen; APKeyInfoType *keyInfoP;
} APImportKeyInfo;
Fields
-
encoding - The encoding of the data being imported.
-
importDataP - The data for the import operation.
-
dataLen - Length of the
importDataPblock. -
keyInfoP - An opaque handle to the key generated by the provider.
Comments
The provider imports a key as specified by the data in importDataP and returns an opaque handle the key in keyInfoP.
APImportKeyPairInfo Struct
Purpose
The command paramater block for the ImportKeyPair call.
Declared In
CPMLibProvider.h Prototype
struct { uint8_t encoding; uint8_t *importDataP; uint32_t dataLen; APKeyInfoType *privateKeyInfoP; APKeyInfoType *publicKeyInfoP; } APImportKeyPairInfo;
Parameters
-
encoding - The encoding of the data being imported.
-
importDataP - The data for the import operation.
-
dataLen - Length of the import data.
-
privateKeyInfoP - Pointer to the
APKeyInfoTypestructure for the private key. -
publicKeyInfoP - Pointer to the
APKeyInfoTypestructure for the public key.
APImportMacInfo Struct
Purpose
The command paramater block for the ImportMAC call.
Declared In
CPMLibProvider.h Prototype
struct { uint8_t encoding; uint8_t *importDataP; uint32_t dataLen; APMACInfoType *macInfoP; } APImportMACInfo;
Fields
-
encoding - The encoding of the data being imported.
-
importDataP - The data for the import operation.
-
dataLen - Length of the
importDataPblock. -
macInfoP - Pointer to an
APMACInfoTypestructure.
APImportSignInfo Struct
Purpose
The command paramater block for the ImportSignInfo call.
Declared In
CPMLibProvider.h Prototype
struct { uint8_t encoding; uint8_t *importDataP; uint32_t dataLen; APSignInfoType *signInfoP; } APImportSignInfo;
Fields
-
encoding - The encoding of the data being imported.
-
importDataP - The data for the import operation.
-
dataLen - Length of the
importDataPblock. -
signInfoP - A valid context for this operation initialized by the initialization operation.
APImportVerifyInfo Struct
Purpose
The command paramater block for the ImportVerifyInfo call.
Declared In
CPMLibProvider.h Prototype
struct { uint8_t encoding; uint8_t *importDataP; uint32_t dataLen; APVerifyInfoType *verifyInfoP; } APImportVerifyInfo;
Fields
-
encoding - The encoding of the data being imported.
-
importDataP - The data for the import operation.
-
dataLen - Length of the
importDataPblock. -
verifyInfoP - A valid context for this operation initialized by the initialization operation.
APMac Struct
Purpose
The command paramater block for the Mac call.
Declared In
CPMLibProvider.h Prototype
struct { APKeyInfoType *keyInfoP; APHashInfoType *hashInfoP; APMACEnum type; APMACInfoType *macInfoP; uint8_t *bufIn; uint32_t bufInLen; uint8_t *bufOut; uint32_t *bufOutLenP; } APMac;
Fields
-
keyInfoP - Pointer to an
APKeyInfoTypestructure, allocated by the application, containing the key to be used for the operation. -
hashInfoP - Pointer to an
APHashInfoTypestructure, allocated by the application, that holds information about the hashing operation to be used for the operation. -
type - One of the values declared by the
APMACEnumenum. -
macInfoP - Pointer to an
APMACInfoTypestructure, allocated by the application, to be used in subsequent calls to the same class of operations. -
bufIn - Pointer to a buffer containing the data for the operation. This parameter must not be
NULL. -
bufInLen - The size, in bytes, of the buffer specified by
bufIn. This value must be greater than zero. -
bufOut - Pointer to a buffer, allocated by the application, to receive the output of the operation.
-
bufOutLenP - The size, in bytes, of the buffer specified by the
bufOutparameter.
APMacFinal Struct
Purpose
The command paramater block for the MacFinal call.
Declared In
CPMLibProvider.h Prototype
struct { APMACInfoType *macInfoP; uint8_t *bufIn; uint32_t bufInLen; uint8_t *bufOut; uint32_t *bufOutLenP; } APMacFinal;
Fields
-
macInfoP - Pointer to the
APMACInfoTypestructure that was initialized during the call toCPMLibMACInit(). -
bufIn - Pointer to a buffer containing the data for the operation, or
NULLif there is no additional data. -
bufInLen - The size, in bytes, of the buffer specified by
bufIn. -
bufOut - Pointer to a buffer, allocated by the application, to receive the output of the operation.
-
bufOutLenP - The size, in bytes, of the buffer specified by the
bufOutparameter.
APMacInit Struct
Purpose
The command paramater block for the MacInit call.
Declared In
CPMLibProvider.h Prototype
struct { APKeyInfoType keyInfoP; APHashInfoType hashInfoP; APMACInfoType *macInfoP; } APMacInit;
Parameters
-
keyInfoP - Pointer to an
APKeyInfoTypestructure, allocated by the application, containing the key to be used in the subsequent calls toCPMLibMACUpdate()andCPMLibMACFinal(). -
hashInfoP - Pointer to an
APHashInfoTypestructure, allocated by the application, that holds information about the hashing operation for use in the subsequent calls toCPMLibMACUpdate()andCPMLibMACFinal(). -
macInfoP - Pointer to an
APMACInfoTypestructure, allocated by the application, to be used in subsequent calls to the same class of operations.
APMacUpdate Struct
Purpose
The command paramater block for the MacUpdate call.
Declared In
CPMLibProvider.h Prototype
struct { APMACInfoType *macInfoP; uint8_t *bufIn; uint32_t bufInLen; uint8_t *bufOut; uint32_t *bufOutLenP; } APMacUpdate;
Fields
-
macInfoP - Pointer to the
APMACInfoTypestructure that was initialized during the call toCPMLibMACInit(). -
bufIn - Pointer to a buffer containing the data for the operation. This parameter must not be
NULL. -
bufInLen - The size, in bytes, of the buffer specified by
bufIn. This value must be greater than zero. -
bufOut - Pointer to a buffer, allocated by the application, to receive the output of the operation.
-
bufOutLenP - The size, in bytes, of the buffer specified by the
bufOutparameter.
APReleaseCipherInfo Struct
Purpose
The command paramater block for the ReleaseCipherInfo call.
Declared In
CPMLibProvider.h Prototype
struct { APCipherInfoType *cipherInfoP; } APReleaseCipherInfo;
Parameters
APReleaseHashInfo Struct
Purpose
The command paramater block for the ReleaseHashInfo call.
Declared In
CPMLibProvider.h Prototype
struct { APHashInfoType *hashInfoP; } APReleaseHashInfo;
Fields
-
hashInfoP - Pointer to the
APHashInfoTypestructure.
APReleaseKeyInfo Struct
Purpose
The command paramater block for the ReleaseKey call.
Declared In
CPMLibProvider.h Prototype
struct { APKeyInfoType *keyInfoP; } APReleaseKeyInfo;
Fields
Comments
The provider releases the key specified by keyInfoP. After this call, keyInfoP is no longer valid for any operations.
APReleaseMACInfo Struct
Purpose
The command paramater block for the ReleaseMACInfo call.
Declared In
CPMLibProvider.h Prototype
struct { APMACInfoType *macInfoP; } APReleaseMACInfo;
Fields
-
macInfoP - Pointer to an
APMACInfoTypestructure.
APReleaseSignInfo Struct
Purpose
The command paramater block for the ReleaseSignInfo call.
Declared In
CPMLibProvider.h Prototype
struct { APSignInfoType *signInfoP; } APReleaseSignInfo;
Fields
APReleaseVerifyInfo Struct
Purpose
The command paramater block for the ReleaseVerifyInfo call.
Declared In
CPMLibProvider.h Prototype
struct { APVerifyInfoType *verifyInfoP; } APReleaseVerifyInfo;
Fields
APSign Struct
Purpose
The command paramater block for the Sign call.
Declared In
CPMLibProvider.h Prototype
struct { APKeyInfoType *keyInfoP; APSignInfoType *signInfoP; uint8_t *bufIn; uint32_t bufInLen; uint8_t *bufOut; uint32_t *bufOutLenP; uint8_t *signature; uint32_t *signatureLenP; } APSign;
Fields
-
keyInfoP - The key to be used for the operation.
-
signInfoP - A valid context for this operation initialized by the initialization operation.
-
bufIn - The data to add to the operation.
-
bufInLen - The length of the data to add to this operation.
-
bufOut - The buffer where the results of the operation are to be placed.
-
bufOutLenP - The size of the buffer specified by the
bufOutparameter. Also returns the actual number of bytes placed inbufOuton return. -
signature - Pointer to a buffer, allocated by the application, to receive the calculated signature.
-
signatureLenP - The size, in bytes, of the buffer specified by the
signatureparameter.
Comments
The signInfoP parameter specifies an initialized context which was created in the Init of this class of functions.
The parameter bufInLen may not be zero and bufIn must be valid.
The provider performs a complete operation using the data in bufIn of length bufInLen and puts the results in bufOut. The actual number of bytes placed in bufOut is placed in bufOutLenP.
APSignFinal Struct
Purpose
The command paramater block for the SignFinal call.
Declared In
CPMLibProvider.h Prototype
struct { APKeyInfoType *keyInfoP; APSignInfoType *signInfoP; uint8_t *bufIn; uint32_t bufInLen; uint8_t *bufOut; uint32_t *bufOutLenP; uint8_t *signature; uint32_t *signatureLenP; } APSignFinal;
Fields
-
keyInfoP - The key to be used for the operation.
-
signInfoP - A valid context for this operation initialized by the initialization operation.
-
bufIn - The data to add to the operation.
-
bufInLen - The length of the data to add to this operation.
-
bufOut - The buffer where the results of the operation are to be placed.
-
bufOutLenP - The size of the buffer specified by the
bufOutparameter. Also returns the actual number of bytes placed inbufOuton return. -
signature - Pointer to a buffer, allocated by the application, to receive the calculated signature.
-
signatureLenP - The size, in bytes, of the buffer specified by the
signatureparameter.
APSignInit Struct
Purpose
The command paramater block for the SignInit call.
Declared In
CPMLibProvider.h Prototype
struct { APKeyInfoType *keyInfoP; APSignInfoType *signInfoP; } APSignInit;
Fields
-
keyInfoP - The key to be used for the operation.
-
signInfoP - A handle to a context to pass to the other members of the Sign functions.
Comments
The provider is responsible for initializing a context with the specified keyInfoP for the operation and saving it in signInfoP. This initialization operation must be concluded with a single finalization operation with zero or more update operations in between.
APSignUpdate Struct
Purpose
The command paramater block for the SignUpdate call.
Declared In
CPMLibProvider.h Prototype
struct { APKeyInfoType *keyInfoP; APSignInfoType *signInfoP; uint8_t *bufIn; uint32_t bufInLen; } APSignUpdate;
Fields
-
keyInfoP - The key to be used for the operation.
-
signInfoP - A valid context for this operation initialized by the initialization operation.
-
bufIn - The data to add to the operation.
-
bufInLen - The length of the data to add to this operation.
Comments
The signInfoP parameter specifies an initialized context which was during in the initialization of this class of functions. The provider uses signInfoP to update the operation with the data in bufIn of length bufInLen. The provider also updates the signInfoP to reflect the update. Any number of update operations (including zero) may occur between an initialization and a finalization operation. The parameters bufIn and bufInLen must be valid for the operation or an error is returned.
APVerify Struct
Purpose
The command paramater block for the Verify call.
Declared In
CPMLibProvider.h Prototype
struct { APKeyInfoType *keyInfoP; APVerifyInfoType *verifyInfoP; uint8_t *bufIn; uint32_t bufInLen; uint8_t *bufOut; uint32_t *bufOutLenP; uint8_t *signature; uint32_t signatureLen; VerifyResultType *verifyResultP; } APVerify;
Fields
-
keyInfoP - The key to be used for the operation.
-
verifyInfoP - A valid context for this operation initialized by the intialization operation
-
bufIn - The data to add to the operation.
-
bufInLen - The length of the data to add to this operation.
-
bufOut - The buffer where the results of the operation are to be placed.
-
bufOutLenP - The size of the buffer specified by the
bufOutparameter. Also returns the actual number of bytes placed inbufOuton return. -
signature - Pointer to a buffer containing the previously calculated signature that is being verified.
-
signatureLen - The length, in bytes, of the buffer specified by
signature. -
verifyResultP - Value that should be set by the provider to zero if the signature verifies or 1 if the signature did not verify.
Comments
The verifyInfoP parameter specifies an initialized context which was created during the initialization of this class of functions.
The parameter bufInLen may not be zero and bufIn must be valid.
The provider performs a complete verification operation using the data in bufIn of length bufInLen and puts the results in bufOut. The actual number of bytes placed in bufOut is placed in bufOutLenP.
APVerifyFinal Struct
Purpose
The command paramater block for the VerifyFinal call.
Declared In
CPMLibProvider.h Prototype
struct { APKeyInfoType *keyInfoP; APVerifyInfoType *verifyInfoP; uint8_t *bufIn; uint32_t bufInLen; uint8_t *bufOut; uint32_t *bufOutLenP; uint8_t *signature; uint32_t signatureLen; VerifyResultType *verifyResultP; } APVerifyFinal;
Fields
-
keyInfoP - The key to be used for the operation.
-
verifyInfoP - A valid context for this operation initialized by the intialization operation
-
bufIn - The data to add to the operation.
-
bufInLen - The length of the data to add to this operation.
-
bufOut - The buffer where the results of the operation are to be placed.
-
bufOutLenP - The size of the buffer specified by the
bufOutparameter. Also returns the actual number of bytes placed inbufOuton return. -
signature - Pointer to a buffer containing the previously calculated signature that is being verified.
-
signatureLen - The length, in bytes, of the buffer specified by
signature. -
verifyResultP - Value that should be set by the provider to zero if the signature verifies or 1 if the signature did not verify.
Comments
The verifyInfoP parameter specifies an initialized context which was created during the initialization of this class of functions.
If bufInLen is non-zero, the provider uses verifyInfoP to update the operation with the data in bufIn of length bufInLen.
The provider finalizes the operation which was initialized by the initialize operation and places the results of the operation in bufOut. The provider updates bufOutLenP with the actual number of bytes placed in bufOut. The provider is responsible for cleaning up the verifyInfoP parameter.
APVerifyInit Struct
Purpose
The command paramater block for the VerifyInit call.
Declared In
CPMLibProvider.h Prototype
struct { APKeyInfoType *keyInfoP; APVerifyInfoType *verifyInfoP; } APVerifyInit;
Fields
-
keyInfoP - The key to be used for the operation.
-
verifyInfoP - A handle to a context to pass to the other members of the Verify functions.
Comments
The provider is responsible for initializing a context with the specified keyInfoP for the operation and saving it in verifyInfoP. This initialization operation must be concluded with a single finalize operation with zero or more update operations in between.
APVerifyUpdate Struct
Purpose
The command paramater block for the VerifyUpdate call.
Declared In
CPMLibProvider.h Prototype
struct { APKeyInfoType *keyInfoP; APVerifyInfoType *verifyInfoP; uint8_t *bufIn; uint32_t bufInLen; } APVerifyUpdate;
Fields
-
keyInfoP - The key to be used for the operation.
-
verifyInfoP - A valid context for this operation initialized by the intialization operation
-
bufIn - The data to add to the operation.
-
bufInLen - The length of the data to add to this operation.
Comments
The verifyInfoP parameter specifies an initialized context which was created during the initialization of this class of functions. The provider uses the verifyInfoP to update the operation with the data in bufIn of length bufInLen. The provider also updates the verifyInfoP to reflect the update. Any number of update operations (including zero) may occur between an initialization and a finalization operation. The parameters bufIn and bufInLen must be valid for the operation or an error is returned.
CPM Library Provider Constants
APCmdType Enum
Purpose
Algorithm provider command selectors.
Declared In
CPMLibProvider.h Constants
-
apClose - Handles the closing of the library.
-
apDecrypt - Performs a decryption operation in one pass. Parameters are passed to this function using an
APDecryptstructure. -
apDecryptFinal - Finalizes a multi-part decryption operation. Parameters are passed to this function using an
APDecryptFinalstructure. -
apDecryptInit - Begins a multi-part decryption operation with the specified key and returns the context of the decrypt operation. Parameters are passed to this function using an
APDecryptInitstructure. -
apDecryptUpdate - Updates a multi-part decryption operation with more data. Parameters are passed to this function using an
APDecryptUpdatestructure. -
apDeriveKeyData - Derives a key from the supplied input data. Parameters are passed to this function using an
APDeriveKeyDatastructure. -
apEncrypt - Performs an encryption operation in one pass. Parameters are passed to this function using an
APEncryptstructure. -
apEncryptFinal - Finalizes a multi-part encryption operation. Parameters are passed to this function using an
APEncryptFinalstructure. -
apEncryptInit - Begins a multi-part encryption operation with the specified key and returns the context of the encrypt operation. Parameters are passed to this function using an
APEncryptInitstructure. -
apEncryptUpdate - Updates a multi-part encryption operation with more data. Parameters are passed to this function using an
APEncryptUpdatestructure. -
apExportCipherInfo - Creates a storable instance of an
APCipherInfoTypestructure. Parameters are passed to this function using anAPExportCipherInfostructure. -
apExportHashInfo - Creates a storable instance of an
APHashInfoTypestructure. Parameters are passed to this function using anAPExportHashInfostructure. -
apExportKeyInfo - Creates a storable instance of a key that is already familiar to the CPM framework. Parameters are passed to this function using an
APExportKeyInfostructure. -
apExportKeyPairInfo - Creates a storable instance of a set of
APKeyInfoTypestructures representing a private key and a public key. Parameters are passed to this function using anAPExportKeyPairInfostructure. -
apExportMACInfo - Creates a storable instance of an
APMACInfoTypestructure. Parameters are passed to this function using anAPExportMacInfostructure. -
apExportSignInfo - Creates a storable instance of an
APSignInfoTypestructure. Parameters are passed to this function using anAPExportSignInfostructure. -
apExportVerifyInfo - Creates a storable instance of an
APVerifyInfoTypestructure. Parameters are passed to this function using anAPExportVerifyInfostructure. -
apGenerateKey - Generates a new key. Parameters are passed to this function using an
APGenerateKeystructure. -
apGenerateKeyPair - Generates a new public/private key pair. Parameters are passed to this function using an
APGenerateKeyPairstructure. -
apGetInfo - Not used.
-
apGetProviderInfo - Gets information about the requested provider. Information returned includes the name of the provider, some additional text about the provider, the "algorithms" supported, and so on. Parameters are passed to this function using an
APGetProviderInfostructure. -
apHash - Performs the hashing operation in one pass. Parameters are passed to this function using an
APHashstructure. -
apHashFinal - Finalizes a multi-part hash operation. Parameters are passed to this function using an
APHashFinalstructure. -
apHashInit - Begins a multi-part hash operation of a specified type and returns the context of the hash operation. Parameters are passed to this function using an
APHashInitstructure. -
apHashUpdate - Updates a multi-part hash operation with more data. Parameters are passed to this function using an
APHashUpdatestructure. -
apImportCipherInfo - Initialize the contents of an
APCipherInfoTypestructure based upon a storable instance of that structure. Parameters are passed to this function using anAPImportCipherInfostructure. -
apImportHashInfo - Initialize the contents of an
APHashInfoTypestructure based upon a storable instance of that structure. Parameters are passed to this function using anAPImportHashInfostructure. -
apImportKeyInfo - Introduces an existing key to the CPM framework. Parameters are passed to this function using an
APImportKeyInfostructure. -
apImportKeyPairInfo - Introduces an existing public/private key pair to the CPM framework. Parameters are passed to this function using an
APImportKeyPairInfostructure. -
apImportMACInfo - Initialize the contents of an
APMACInfoTypestructure based upon a storable instance of that structure. Parameters are passed to this function using anAPImportMacInfostructure. -
apImportSignInfo - Initialize the contents of an
APSignInfoTypestructure based upon a storable instance of that structure. Parameters are passed to this function using anAPImportSignInfostructure. -
apImportVerifyInfo - Initialize the contents of an
APVerifyInfoTypestructure based upon a storable instance of that structure. Parameters are passed to this function using anAPImportVerifyInfostructure. -
apMAC - Performs the message authentication operation in one pass. Parameters are passed to this function using an
APMacstructure. -
apMACFinal - Finalizes a multi-part message authentication operation. Parameters are passed to this function using an
APMacFinalstructure. -
apMACInit - Begins a multi-part message authentication operation with the specified key and hash info and returns the context of the operation. Parameters are passed to this function using an
APMacInitstructure. -
apMACUpdate - Updates a multi-part message authentication operation with more data. Parameters are passed to this function using an
APMacUpdatestructure. -
apOpen - Handles the opening of the library.
-
apReleaseCipherInfo - Allows the CPM and the provider(s) to clean up before the application frees the
APICipherInfoTypestructure. Parameters are passed to this function using anAPReleaseCipherInfostructure. -
apReleaseHashInfo - Allows the CPM and the provider(s) to clean up before the application frees the
APIHashInfoTypestructure. Parameters are passed to this function using anAPReleaseHashInfostructure. -
apReleaseKeyInfo - Allows the CPM and the provider(s) to clean up before the application frees the
APKeyInfoTypestructure. Parameters are passed to this function using anAPReleaseKeyInfostructure. -
apReleaseMACInfo - Allows the CPM and the provider(s) to clean up before the application frees the
APMACInfoTypestructure. Parameters are passed to this function using anAPReleaseMACInfostructure. -
apReleaseSignInfo - Allows the CPM and the provider(s) to clean up before the application frees the
APSignInfoTypestructure. Parameters are passed to this function using anAPReleaseSignInfostructure. -
apReleaseVerifyInfo - Allows the CPM and the provider(s) to clean up before the application frees the
APVerifyInfoTypestructure. Parameters are passed to this function using anAPReleaseVerifyInfostructure. -
apSign - Performs the signing operation in one pass. Parameters are passed to this function using an
APSignstructure. -
apSignFinal - Finalizes a multi-part signing operation. Parameters are passed to this function using an
APSignFinalstructure. -
apSignInit - Begins a multi-part signing operation with the specified key and returns the context of the signing operation. Parameters are passed to this function using an
APSignInitstructure. -
apSignUpdate - Updates a multi-part signing operation with more data. Parameters are passed to this function using an
APSignUpdatestructure. -
apStatus -
apVerify - Performs the verify operation in one pass. Parameters are passed to this function using an
APVerifystructure. -
apVerifyFinal - Finalizes a multi-part verification operation. Parameters are passed to this function using an
APVerifyFinalstructure. -
apVerifyInit - Begins a multi-part verification operation with the specified key and returns the context of the verification operation. Parameters are passed to this function using an
APVerifyInitstructure. -
apVerifyUpdate - Updates a multi-part verification operation with more data. Parameters are passed to this function using an
APVerifyUpdatestructure. -
apLast - Not a value that represents an actual function, this is one greater than the final function selector value.
-
apZero
Miscellaneous CPM Library Provider Constants
Purpose
The CPMLibProvider.h file also declares the following constants.
Declared In
CPMLibProvider.h Constants
-
#define cpmProviderResourceID 0 - Defines the resource ID of the code resource.
-
#define cpmProviderResourceType 'cpmp' - Defines the type (creator/type) of the provider.
Application-Defined Functions
APDispatchProcPtr Function
Purpose
Pointer to the provider's command dispatch function. Each provider must export a function matching this signature as a dispatcher for the commands and command parameter blocks that will be sent to the provider by the CPM.
Declared In
CPMLibProvider.h Prototype
status_t ( *APDispatchProcPtr ) ( CPMCallerInfoPtrinfo, APCmdTypecmd, APCmdPBPtrpbP)
Parameters
-
→ info - Pointer to a
CPMCallerInfoTypestructure that contains all the information necessary for the provider to call back into the CPM's framework and use the CPM's resources. -
→ cmd - One of the values listed under "CPM Library Provider Constants."
-
↔ pbP - Pointer to the appropriate parameter block structure for the command. The documentation for each command identifies the parameter block structure to use with that command.
Returns
errNone if the operation completed successfully, or an appropriate error code (usually, one of the codes listed under "CPM Library Error Codes").
See Also
CPMAddRandomSeedProcPtr Function
Purpose
Pointer to a function that puts a number of seed bytes into the pseudo-random number generator maintained by the CPM.
Declared In
CPMLibProvider.h Prototype
status_t ( *CPMAddRandomSeedProcPtr ) ( void *appContext, uint8_t *buffer, uint32_tbuflen)
Parameters
-
→ appContext - Pointer to a structure containing the provider-specific application context to be used in future CPM calls. This structure is normally created and initialized when the library is opened.
-
→ buffer - Pointer to a buffer of seed bytes.
-
→ buflen - The number of bytes in
buffer.
Returns
errNone if the operation completed successfully, or one of the error codes listed under "CPM Library Error Codes" otherwise.
See Also
CPMDebugOutProcPtr Function
Purpose
Pointer to a function that sends a null-terminated string to the current debug device, if the level set using CPMLibSetDebugLevel() is less than or equal to the message's debug output level.
Declared In
CPMLibProvider.h Prototype
status_t ( *CPMDebugOutProcPtr ) ( void *appContext, uint8_tlevel, char *fmtstring, ... )
Parameters
-
→ appContext - Pointer to a structure containing the provider-specific application context to be used in future CPM calls. This structure is normally created and initialized when the library is opened.
-
→ level - The debug output level of the message. One of the values listed under "Debug Output Levels."
-
→ fmtstring - A printf-style format string for the debug message being sent.
-
→ ... - Zero or more arguments to be substituted as appropriate in the format string.
Returns
See Also
CPMDispatcherProcPtr Function
Purpose
Pointer to the Cryptographic Provider Manager's function dispatcher. This function attempts to locate a provider that implements the supplied command. If it is successful, it directs the command and parameter block to that provider.
Declared In
CPMLibProvider.h Prototype
status_t ( *CPMDispatcherProcPtr ) ( void *appContext, APCmdTypecmd, APCmdPBType *cmdPB, uint32_t *id)
Parameters
-
→ appContext - Pointer to a structure containing the provider-specific application context to be used. This structure is normally created and initialized when the library is opened.
-
→ cmd - One of the values listed under "CPM Library Provider Constants."
-
→ cmdPB - Pointer to the appropriate parameter block structure for the command. The documentation for each command identifies the parameter block structure to use with that command.
-
→ id - Pointer to a
uint32_tcontaining the ID of a specific provider to which the command is to be directed. If*idis 0, the CPM directs the command to the first provider that implements the requested functionality.
Returns
The return value passed back from the provider (which may be cpmErrUnimplemented if the provider recognizes but does not implement the supplied command), or one of the following if the command couldn't be directed to a provider:
-
cpmErrProviderNotFound - A provider ID was supplied, but the CPM couldn't find a provider with the supplied ID.
-
cpmErrNoProviders - Given the supplied application context, the CPM is unaware of any providers.
-
cpmErrNoAppContext - The
appContextparameter isNULL. -
cpmErrParamErr - The supplied command isn't a valid command.
-
cpmErrUnsupported - The supplied command isn't supported.
Comments
If *id is 0, the CPM's function dispatcher attempts to locate a provider that implements cmd. If it finds one, that provider's dispatch function (an APDispatchProcPtr) is called with the specified command and command parameters.
See Also
CPMGenerateRandomBytesProcPtr Function
Purpose
Pointer to a function that returns a requested number of random bytes.
Declared In
CPMLibProvider.h Prototype
status_t ( *CPMGenerateRandomBytesProcPtr ) ( void *appContext, uint8_t *buffer, uint32_t *buflenP)
Parameters
-
→ appContext - Pointer to a structure containing the provider-specific application context to be used in future CPM calls. This structure is normally created and initialized when the library is opened.
-
← buffer - Pointer to a buffer, allocated by the application, into which the random bytes are written.
-
↔ buflenP - When this function is called, the variable pointed to by this parameter is set to the size of
buffer. Upon return, the variable contains the number of random bytes written tobuffer.
errNone if the operation completed successfully, or one of the error codes listed under "CPM Library Error Codes" otherwise.
Comments
If there are not bufLenP random bytes available, this function returns the available random bytes and returns the number of available bytes in bufLenP.
