TrustCore SDK NanoTAP API reference  version 3.0
mocana.h File Reference

Digicert SoT Platform initialization header file. More...

Go to the source code of this file.

Macros

#define MOC_DP_MAPPING_RELEASE   TRUE
 
#define MOC_EXTERN_MOCANA_H   extern
 
#define MOC_EXTERN_P   MOC_EXTERN_MOCANA_H
 

Typedefs

typedef void(* logFn) (sbyte4 module, sbyte4 severity, sbyte *msg)
 Callback for logging function. More...
 
typedef sbyte4(* ShutdownHandler) (void)
 

Functions

MOC_EXTERN sbyte4 MOCANA_addEntropy32Bits (ubyte4 entropyBits)
 Add 32 random bits to application's random number generator. More...
 
MOC_EXTERN sbyte4 MOCANA_addEntropyBit (ubyte entropyBit)
 Add a random bit to application's random number generator. More...
 
MOC_EXTERN sbyte4 MOCANA_appendFile (const char *pFilename, const ubyte *pBuffer, ubyte4 bufLength)
 Appends a buffer's contents to a file, file is created if it does not exist. More...
 
MOC_EXTERN sbyte4 MOCANA_checkFile (const char *pFilename, const char *pExt, intBoolean *pFileExist)
 Check if a file exists on the filesystem. More...
 
MOC_EXTERN sbyte4 MOCANA_copyFile (const char *pSrcFilename, const char *pDestFilename)
 Copy a file. More...
 
MOC_EXTERN sbyte4 MOCANA_deleteFile (const char *pFilename)
 Delete a file from the filesystem. More...
 
MOC_EXTERN sbyte4 MOCANA_freeMocana (void)
 Release memory allocated by MOCANA_initMocana. More...
 
MOC_EXTERN sbyte4 MOCANA_freeReadFile (ubyte **ppRetBuffer)
 Release memory allocated by MOCANA_readFile(). More...
 
MOC_EXTERN sbyte4 MOCANA_initLog (logFn lFn)
 Register a callback function for the Digicert logging system. More...
 
MOC_EXTERN sbyte4 MOCANA_initMocana (void)
 Initialize Digicert common code base. More...
 
MOC_EXTERN sbyte4 MOCANA_initMocanaStaticMemory (ubyte *pStaticMem, ubyte4 staticMemSize)
 This is the same as initMocana, except it will set up static memory. More...
 
MOC_EXTERN sbyte4 MOCANA_readFile (const char *pFilename, ubyte **ppRetBuffer, ubyte4 *pRetBufLength)
 Allocate a buffer and fill with data read from a file. More...
 
MOC_EXTERN sbyte4 MOCANA_writeFile (const char *pFilename, const ubyte *pBuffer, ubyte4 bufLength)
 Write a buffer's contents to a file. More...
 

Variables

MOC_EXTERN_MOCANA_H ShutdownHandler g_sslShutdownHandler
 

Detailed Description

This header file contains enumerations and initialization function declarations used by all Digicert SoT Platform components.

Whether the following flags are defined determines which additional header files are included:

  • __ENABLE_MOCANA_IKE_SERVER__
  • __ENABLE_MOCANA_MEM_PART__
  • __ENABLE_MOCANA_PEM_CONVERSION__
  • __ENABLE_MOCANA_PKCS10__
  • __ENABLE_MOCANA_RADIUS_CLIENT__
  • __ENABLE_MOCANA_SSH_SERVER__
  • __DISABLE_MOCANA_INIT__
  • __DISABLE_MOCANA_TCP_INTERFACE__
  • IPCOM_KERNEL

Whether the following flags are defined determines which function declarations are enabled:

  • __DISABLE_MOCANA_ADD_ENTROPY__
  • __DISABLE_MOCANA_FILE_SYSTEM_HELPER__
  • __DISABLE_MOCANA_INIT__

Copyright 2019-2024 DigiCert, Inc. All Rights Reserved. Proprietary and Confidential Material.

Typedef Documentation

◆ logFn

typedef void(* logFn) (sbyte4 module, sbyte4 severity, sbyte *msg)

Users can create custom logging functions and register them via MOCANA_initLog(), provided the custom functions have this signature.

For example, you can define a custom logging function as follows:

void MY_logFn(sbyte4 module, sbyte4 severity, sbyte *msg)
{
<custom logging code>
}

You would then register the custom logging function as follows:

status = MOCANA_initLog(MY_logFn);
if (OK != status)
{
<error handling code>
}

Function Documentation

◆ MOCANA_addEntropyBit()

MOC_EXTERN sbyte4 MOCANA_addEntropyBit ( ubyte  entropyBit)

This function adds a random bit to your application's random number generator. Before calling this function, your application should have already initialized the Digicert common code base by calling MOCANA_initMocana().

To enable this function, the following flag must not be defined:

  • __DISABLE_MOCANA_ADD_ENTROPY__
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h. To retrieve a string containing an English text error identifier corresponding to the function's returned error status, use the DISPLAY_ERROR macro.
Parameters
[in]entropyBit1-bit char used to add randomness to your application's cryptography.
sbyte4 status = 0;
ubyte ebit;
status = MOCANA_addEntropyBit(ebit);

◆ MOCANA_checkFile()

MOC_EXTERN sbyte4 MOCANA_checkFile ( const char *  pFilename,
const char *  pExt,
intBoolean pFileExist 
)

To enable this function, the following flag must not be defined:

  • __DISABLE_MOCANA_FILE_SYSTEM_HELPER__
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h. To retrieve a string containing an English text error identifier corresponding to the function's returned error status, use the DISPLAY_ERROR macro.
Parameters
[in]pFilenamePointer to name of the file to delete.
[in]pExtOptional extension that will be appended onto the filename if provided.
[out]pFileExistReference to a pointer that will be set to TRUE if the file exists, otherwise it will be FALSE.

◆ MOCANA_copyFile()

MOC_EXTERN sbyte4 MOCANA_copyFile ( const char *  pSrcFilename,
const char *  pDestFilename 
)

To enable this function, the following flag must not be defined:

  • __DISABLE_MOCANA_FILE_SYSTEM_HELPER__
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h. To retrieve a string containing an English text error identifier corresponding to the function's returned error status, use the DISPLAY_ERROR macro.
Parameters
[in]pSrcFilenamePointer to name of the source file to copy.
[in]pDestFilenamePointer to name of the destination file.
Remarks
This is a convenience function provided for your application's use; it is not used by Digicert SoT Platform code.

◆ MOCANA_deleteFile()

MOC_EXTERN sbyte4 MOCANA_deleteFile ( const char *  pFilename)

To enable this function, the following flag must not be defined:

  • __DISABLE_MOCANA_FILE_SYSTEM_HELPER__
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h. To retrieve a string containing an English text error identifier corresponding to the function's returned error status, use the DISPLAY_ERROR macro.
Parameters
[in]pFilenamePointer to name of the file to delete.
Remarks
This is a convenience function provided for your application's use; it is not used by Digicert SoT Platform code.

◆ MOCANA_initMocanaStaticMemory()

MOC_EXTERN sbyte4 MOCANA_initMocanaStaticMemory ( ubyte pStaticMem,
ubyte4  staticMemSize 
)

This is an older function, you should use MOCANA_initialize instead (see initmocana.h).

The caller passes in a buffer which will be all the memory the Mocana functions will use. That is, the Digicert functions will not use "malloc" or "GlobalAlloc" or any other system memory allocator. All Digicert memory allocations will simply grab some of the area inside the buffer provided by the caller.

Whether you call MOCANA_initMocana or MOCANA_initMocanaStaticMem, you must call MOCANA_freeMocana when you are done.

See the documentation for MOCANA_initMocana for more information.

Parameters
pStaticMemThe buffer that will be used as the source of memory.
staticMemSizeThe size, in bytes, of the staticMem buffer. mocana.h
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h. To retrieve a string containing an English text error identifier corresponding to the function's returned error status, use the DISPLAY_ERROR macro.