8 #ifndef _INTAPI_DEFINED
10 #define _INTAPI_DEFINED
33 #define isBadPassword( password ) \
34 ( !isReadPtrConst( password, sizeof( wchar_t ) ) || \
35 ( wcslen( password ) < 1 ) )
37 #define isBadPassword( password ) \
38 ( !isReadPtrConst( password, 1 ) || \
39 ( strlen( password ) < 1 ) )
68 int getRandomInteger(
void );
100 int readTextLine( READCHARFUNCTION readCharFunction,
110 #if defined( __WIN32__ ) || defined( __WINCE__ )
120 #elif defined( __UNIX__ )
142 #define HWCAP_FLAG_NONE 0x00
143 #define HWCAP_FLAG_RDTSC 0x01
144 #define HWCAP_FLAG_XSTORE 0x02
145 #define HWCAP_FLAG_XCRYPT 0x04
146 #define HWCAP_FLAG_XSHA 0x08
147 #define HWCAP_FLAG_MONTMUL 0x10
148 #define HWCAP_FLAG_TRNG 0x20
149 #define HWCAP_FLAG_AES 0x40
150 #define HWCAP_FLAG_RDRAND 0x80
160 void *initACLInfo(
const int access );
162 void *getACLInfo(
void *securityInfoPtr );
164 void freeACLInfo(
void *securityInfoPtr );
166 #define initACLInfo( x ) NULL
167 #define getACLInfo( x ) NULL
168 #define freeACLInfo( x )
181 #if defined( __UNIX__ ) && !( defined( __CYGWIN__ ) )
182 #if defined( __TANDEM_NSK__ ) || defined( __TANDEM_OSS__ )
185 #define strnicmp strncasecmp
186 #define stricmp strcasecmp
187 #elif defined( __WINCE__ )
188 #define strnicmp _strnicmp
189 #define stricmp _stricmp
190 #elif defined( _MSC_VER ) && ( _MSC_VER >= 1300 )
193 #define strnicmp _strnicmp
194 #define stricmp _stricmp
195 #elif defined( __ECOS__ )
196 #define strnicmp strncasecmp
197 #define stricmp strcasecmp
198 #elif defined __PALMOS__
201 #include <StringMgr.h>
203 #define strnicmp StrNCaselessCompare
204 #define stricmp StrCaselessCompare
205 #elif defined( __xxxOS___ )
206 int strnicmp(
const char *src,
const char *dest,
const int length );
207 int stricmp(
const char *src,
const char *dest );
269 #define INTERNAL_ERROR 0
270 #define retIntError() \
272 assert( INTERNAL_ERROR ); \
273 return( CRYPT_ERROR_INTERNAL ); \
275 #define retIntError_Null() \
277 assert( INTERNAL_ERROR ); \
280 #define retIntError_Boolean() \
282 assert( INTERNAL_ERROR ); \
285 #define retIntError_Void() \
287 assert( INTERNAL_ERROR ); \
290 #define retIntError_Ext( value ) \
292 assert( INTERNAL_ERROR ); \
295 #define retIntError_Stream( stream ) \
297 assert( INTERNAL_ERROR ); \
298 return( sSetError( stream, CRYPT_ERROR_INTERNAL ) ); \
303 #define REQUIRES( x ) if( !( x ) ) retIntError()
304 #define REQUIRES_N( x ) if( !( x ) ) retIntError_Null()
305 #define REQUIRES_B( x ) if( !( x ) ) retIntError_Boolean()
306 #define REQUIRES_V( x ) if( !( x ) ) retIntError_Void()
307 #define REQUIRES_EXT( x, y ) if( !( x ) ) retIntError_Ext( y )
308 #define REQUIRES_S( x ) if( !( x ) ) retIntError_Stream( stream )
310 #define ENSURES( x ) if( !( x ) ) retIntError()
311 #define ENSURES_N( x ) if( !( x ) ) retIntError_Null()
312 #define ENSURES_B( x ) if( !( x ) ) retIntError_Boolean()
313 #define ENSURES_V( x ) if( !( x ) ) retIntError_Void()
314 #define ENSURES_EXT( x, y ) if( !( x ) ) retIntError_Ext( y )
315 #define ENSURES_S( x ) if( !( x ) ) retIntError_Stream( stream )
328 int errorStringLength;
375 #define clearErrorString( errorInfoPtr )
376 #define setErrorString( errorInfoPtr, string, stringLength );
389 CHECK_RETVAL STDC_NONNULL_ARG( ( 2, 4 ) ) STDC_PRINTF_FN( 4, 5 ) \
394 CHECK_RETVAL STDC_NONNULL_ARG( ( 2, 3, 5 ) ) STDC_PRINTF_FN( 5, 6 ) \
400 CHECK_RETVAL STDC_NONNULL_ARG( ( 2, 3, 4 ) ) STDC_PRINTF_FN( 4, 5 ) \
405 CHECK_RETVAL STDC_NONNULL_ARG( ( 2, 3 ) ) STDC_PRINTF_FN( 3, 4 ) \
411 #define retExt( status, extStatus ) return retExtFn extStatus
412 #define retExtArg( status, extStatus ) return retExtArgFn extStatus
413 #define retExtObj( status, extStatus ) return retExtObjFn extStatus
414 #define retExtStr( status, extStatus ) return retExtStrFn extStatus
415 #define retExtErr( status, extStatus ) return retExtErrFn extStatus
416 #define retExtErrAlt( status, extStatus ) return retExtErrAltFn extStatus
417 #define retExt_IntError( status, extStatus ) \
419 assert( INTERNAL_ERROR ); \
420 return retExtFn extStatus; \
425 #define retExt( status, extStatus ) return status
426 #define retExtArg( status, extStatus ) return status
427 #define retExtObj( status, extStatus ) return status
428 #define retExtStr( status, extStatus ) return status
429 #define retExtErr( status, extStatus ) return status
430 #define retExtErrAlt( status, extStatus ) return status
431 #define retExt_IntError( status, extStatus ) \
433 assert( INTERNAL_ERROR ); \
442 #define ENVELOPE_ERRINFO &envelopeInfoPtr->errorInfo
443 #define KEYSET_ERRINFO &keysetInfoPtr->errorInfo
444 #define SESSION_ERRINFO &sessionInfoPtr->errorInfo
445 #define STREAM_ERRINFO stream->errorInfo
446 #define NETSTREAM_ERRINFO &netStream->errorInfo
497 int exportAttributeToStream(
INOUT void *streamPtr,
502 int exportVarsizeAttributeToStream(
INOUT void *streamPtr,
507 const int attributeDataLength );
509 int exportCertToStream(
INOUT void *streamPtr,
514 int importCertFromStream(
INOUT void *streamPtr,
531 int base64encodeLen(
IN_LENGTH_MIN( 10 )
const int dataLength,
544 int base64decodeLen(
IN_BUFFER( dataLength )
const char *data,
548 int base64decode(
OUT_BUFFER( destMaxLen, *destLen )
void *dest,
567 IN_RANGE( 3, 4 )
const int noCodeGroups );
585 #define insertSingleListElement( listHead, insertPoint, newElement ) \
587 if( *( listHead ) == NULL ) \
590 *( listHead ) = ( newElement ); \
594 if( ( insertPoint ) == NULL ) \
598 ( newElement )->next = *( listHead ); \
599 *( listHead ) = ( newElement ); \
604 ( newElement )->next = ( insertPoint )->next; \
605 ( insertPoint )->next = ( newElement ); \
610 #define insertDoubleListElements( listHead, insertPoint, newStartElement, newEndElement ) \
612 if( *( listHead ) == NULL ) \
615 *( listHead ) = ( newStartElement ); \
619 if( ( insertPoint ) == NULL ) \
623 ( newEndElement )->next = *( listHead ); \
624 ( *( listHead ) )->prev = ( newEndElement ); \
625 *( listHead ) = ( newStartElement ); \
630 ENSURES( ( insertPoint )->next == NULL || \
631 ( insertPoint )->next->prev == ( insertPoint ) ); \
634 ( newEndElement )->next = ( insertPoint )->next; \
637 if( ( insertPoint )->next != NULL ) \
638 ( insertPoint )->next->prev = ( newEndElement ); \
639 ( insertPoint )->next = ( newStartElement ); \
640 ( newStartElement )->prev = ( insertPoint ); \
645 #define insertDoubleListElement( listHead, insertPoint, newElement ) \
646 insertDoubleListElements( listHead, insertPoint, newElement, newElement )
648 #define deleteSingleListElement( listHead, listPrev, element ) \
651 REQUIRES( listHead != NULL && element != NULL ); \
652 REQUIRES( element == *( listHead ) || listPrev != NULL ); \
654 if( element == *( listHead ) ) \
657 *( listHead ) = element->next; \
661 ANALYSER_HINT( listPrev != NULL ); \
664 listPrev->next = element->next; \
668 #define deleteDoubleListElement( listHead, element ) \
671 REQUIRES( listHead != NULL && element != NULL ); \
674 REQUIRES( ( element )->next == NULL || \
675 ( element )->next->prev == ( element ) ); \
676 REQUIRES( ( element )->prev == NULL || \
677 ( element )->prev->next == ( element ) ); \
680 if( element == *( listHead ) ) \
683 *( listHead ) = ( element )->next; \
688 REQUIRES( ( element )->prev != NULL ); \
691 ( element )->prev->next = ( element )->next; \
693 if( ( element )->next != NULL ) \
694 ( element )->next->prev = ( element )->prev; \
717 typedef CHECK_RETVAL_PTR_FNPTR \
719 OUT_OPT_ATTRIBUTE_Z \
720 CRYPT_ATTRIBUTE_TYPE *groupID,
721 OUT_OPT_ATTRIBUTE_Z \
723 OUT_OPT_ATTRIBUTE_Z \
724 CRYPT_ATTRIBUTE_TYPE *instanceID,
729 void *attributeFindStart(
IN_OPT const void *attributePtr,
732 void *attributeFindEnd(
IN_OPT const void *attributePtr,
735 void *attributeFind(
IN_OPT const void *attributePtr,
739 void *attributeFindEx(
IN_OPT const void *attributePtr,
748 void *attributeFindNextInstance(
IN_OPT const void *attributePtr,
751 const
void *attributeMoveCursor(
IN_OPT const void *currentCursor,
757 const int cursorMoveType );
795 time_t endTime, origTimeout, timeRemaining;
827 #define DYNBUF_SIZE 1024
849 #define dynLength( dynBuf ) ( dynBuf ).length
850 #define dynData( dynBuf ) ( dynBuf ).data
865 int initMemPool(
OUT void *statePtr,
899 #define DECLARE_VARSTRUCT_VARS \
901 void *_align_value; \
902 BUFFER_FIXED( storageSize ) \
905 #define initVarStruct( structure, structureType, size ) \
906 memset( structure, 0, sizeof( structureType ) ); \
907 structure->value = structure->storage; \
908 structure->storageSize = size
910 #define copyVarStruct( destStructure, srcStructure, structureType ) \
911 memcpy( destStructure, srcStructure, \
912 sizeof( structureType ) + srcStructure->storageSize ); \
913 destStructure->value = destStructure->storage;
915 #define endVarStruct( structure, structureType ) \
916 zeroise( structure, sizeof( structureType ) + structure->storageSize )
918 #define sizeofVarStruct( structure, structureType ) \
919 ( sizeof( structureType ) + structure->storageSize )
946 #if defined( USE_SHA2_EXT )
949 #elif defined( SYSTEM_64BIT )
965 typedef STDC_NONNULL_ARG( ( 1, 3 ) ) \
972 STDC_NONNULL_ARG( ( 3 ) ) \
977 STDC_NONNULL_ARG( ( 3 ) ) \
988 #define HASH_DATA_SIZE 16
993 STDC_NONNULL_ARG( ( 1, 3 ) ) \
1041 #define initSigParams( sigParams ) \
1043 memset( ( sigParams ), 0, sizeof( SIGPARAMS ) ); \
1044 ( sigParams )->iAuthAttr = ( sigParams )->iTspSession = \
1045 ( sigParams )->iSecondHash = CRYPT_ERROR; \
1065 int iCryptCheckSignature(
IN_BUFFER( signatureLength )
const void *signature,
1097 #ifdef USE_ENVELOPES
1103 int envelopeWrap(
IN_BUFFER( inDataLength )
const void *inData,
1105 OUT_BUFFER( outDataMaxLength, *outDataLength )
void *outData,
1112 int envelopeUnwrap(
IN_BUFFER( inDataLength )
const void *inData,
1114 OUT_BUFFER( outDataMaxLength, *outDataLength )
void *outData,
1119 int envelopeSign(
IN_BUFFER( inDataLength )
const void *inData,
1121 OUT_BUFFER( outDataMaxLength, *outDataLength )
void *outData,
1128 int envelopeSigCheck(
IN_BUFFER( inDataLength )
const void *inData,
1130 OUT_BUFFER( outDataMaxLength, *outDataLength )
void *outData,
1168 #define setX509FormatInfo( formatInfo, formatTag, formatIsExplicit ) \
1169 memset( formatInfo, 0, sizeof( X509SIG_FORMATINFO ) ); \
1170 ( formatInfo )->tag = ( formatTag ); \
1171 ( formatInfo )->isExplicit = ( formatIsExplicit )
1185 int checkX509signature(
IN_BUFFER( signedObjectLength )
const void *signedObject,
1198 int checkRawSignature(
IN_BUFFER( signatureLength )
const void *signature,
1221 #ifdef USE_CERTIFICATES
1228 #define createCertificateIndirect( createInfo, auxDataPtr, auxValue ) \
1229 CRYPT_ERROR_NOTAVAIL
1259 #if defined( USE_ECDH ) || defined( USE_ECDSA )
1261 int importECCPoint(
INOUT void *bignumPtr1,
1262 INOUT void *bignumPtr2,
1268 IN_OPT const void *maxRangePtr,
1272 int exportECCPoint(
OUT_BUFFER_OPT( dataMaxLength, *dataLength )
void *data,
1275 const void *bignumPtr1,
const void *bignumPtr2,