1 /**************************************************************************** 2 * * 3 * cryptlib Session Scoreboard Header File * 4 * Copyright Peter Gutmann 1998-2004 * 5 * * 6 ****************************************************************************/ 7 8 #ifndef _SCOREBRD_DEFINED 9 10 #define _SCOREBRD_DEFINED 11 12 /**************************************************************************** 13 * * 14 * Scoreboard Types and Structures * 15 * * 16 ****************************************************************************/ 17 18 /* The search key to use for a scoreboard lookup. We distinguish between 19 client and server sessionIDs in order to provide a logically distinct 20 namespace for client and server sessions */ 21 22 typedef enum { 23 SCOREBOARD_KEY_NONE, 24 SCOREBOARD_KEY_SESSIONID_CLI, /* Lookup by client session ID */ 25 SCOREBOARD_KEY_SESSIONID_SVR, /* Lookup by server session ID */ 26 SCOREBOARD_KEY_FQDN, /* Lookup by server FQDN */ 27 SCOREBOARD_KEY_LAST 28 } SCOREBOARD_KEY_TYPE; 29 30 /* Information for an entry in the scoreboard */ 31 32 typedef struct { 33 /* Scoreboard search key information */ 34 BUFFER_OPT_FIXED( keySize ) \ 35 const void *key; 36 int keySize; 37 38 /* The data stored with the scoreboard entry */ 39 BUFFER_OPT_FIXED( dataSize ) \ 40 const void *data; 41 int dataSize; 42 int metaData; 43 } SCOREBOARD_INFO; 44 45 /* Storage for the scoreboard state. When passed to scoreboard functions 46 it's declared as a void * because to the caller it's an opaque memory 47 block while to the scoreboard routines it's structured storage */ 48 49 typedef BYTE SCOREBOARD_STATE[ 64 ]; 50 51 /**************************************************************************** 52 * * 53 * Scoreboard Functions * 54 * * 55 ****************************************************************************/ 56 57 /* Session scoreboard management functions */ 58 59 CHECK_RETVAL_RANGE( 0, MAX_INTLENGTH ) STDC_NONNULL_ARG( ( 1, 3, 5 ) ) \ 60 int lookupScoreboardEntry( INOUT void *scoreboardIndexInfoPtr, 61 IN_ENUM( SCOREBOARD_KEY ) \ 62 const SCOREBOARD_KEY_TYPE keyType, 63 IN_BUFFER( keyLength ) const void *key, 64 IN_LENGTH_SHORT_MIN( 2 ) const int keyLength, 65 OUT SCOREBOARD_INFO *scoreboardInfo ); 66 CHECK_RETVAL_RANGE( 0, MAX_INTLENGTH ) STDC_NONNULL_ARG( ( 1, 2, 4 ) ) \ 67 int addScoreboardEntry( INOUT void *scoreboardIndexInfoPtr, 68 IN_BUFFER( keyLength ) const void *key, 69 IN_LENGTH_SHORT_MIN( 8 ) const int keyLength, 70 const SCOREBOARD_INFO *scoreboardInfo ); 71 CHECK_RETVAL_RANGE( 0, MAX_INTLENGTH ) STDC_NONNULL_ARG( ( 1, 2, 4, 6 ) ) \ 72 int addScoreboardEntryEx( INOUT void *scoreboardIndexInfoPtr, 73 IN_BUFFER( keyLength ) const void *key, 74 IN_LENGTH_SHORT_MIN( 8 ) const int keyLength, 75 IN_BUFFER( keyLength ) const void *altKey, 76 IN_LENGTH_SHORT_MIN( 2 ) const int altKeyLength, 77 const SCOREBOARD_INFO *scoreboardInfo ); 78 STDC_NONNULL_ARG( ( 1 ) ) \ 79 void deleteScoreboardEntry( INOUT void *scoreboardIndexInfoPtr, 80 IN_INT_Z const int uniqueID ); 81 82 #ifdef USE_SSL 83 CHECK_RETVAL STDC_NONNULL_ARG( ( 1 ) ) \ 84 int initScoreboard( INOUT void *scoreboardIndexInfoPtr, 85 IN_LENGTH_SHORT_MIN( 8 ) const int scoreboardEntries ); 86 STDC_NONNULL_ARG( ( 1 ) ) \ 87 void endScoreboard( INOUT void *scoreboardIndexInfoPtr ); 88 #else 89 #define initScoreboard( scoreboardInfo, scoreboardSize ) CRYPT_OK 90 #define endScoreboard( scoreboardInfo ) 91 #endif /* USE_SSL */ 92 #endif /* _SCOREBRD_DEFINED */ 93