Struct:ttEspAlgorithm
typedef struct tsEspAlgorithm { int ealgName; ttUser8Bit ealgBlockSize; /* block size, in bytes */ ttUser8Bit ealgPaddingFlag; ttUser16Bit ealgKeyMin; /* in bits */ ttUser16Bit ealgKeyMax; /* in bits */ ttUser16Bit ealgKeyDefault; /* use for IKE */ int (TM_CODE_FAR *ealgScheduleLenFuncPtr) (void); int (TM_CODE_FAR *ealgScheduleFuncPtr) ( struct tsEspAlgorithm TM_FAR * algPtr, ttGenericKeyPtr keyPtr); int (TM_CODE_FAR *ealgBlockDecryptFuncPtr) ( struct tsEspAlgorithm TM_FAR * algPtr, ttGenericKeyPtr keyPtr, ttUser8BitPtr srcPtr, ttUser8BitPtr dstPtr); int (TM_CODE_FAR *ealgBlockEncryptFuncPtr) ( struct tsEspAlgorithm TM_FAR * algPtr, ttGenericKeyPtr keyPtr, ttUser8BitPtr srcPtr, ttUser8BitPtr dstPtr); } ttEspAlgorithm; typedef ttEspAlgorithm TM_FAR * ttEspAlgorithmPtr;
Contents
Structure Description
Any encryption algorithm must follow the format of ttEspAlgorithm. The user may use this format to add more encryption algorithms. See the examples of adding a ttAhAlgorithm. For encryption algorithms, the user needs to modify espAlgorithms in the file <trespcor.c>.
Members
- ealgName
- Algorithm name (i.e. SADB_EALG_DESCBC).
- ealgBlockSize
- Block size (in bytes) of this algorithm, generally, it is either 8 or 16 bytes.
- ealgPaddingFlag
- Indicates how to pad the ESP: either use the minimum length or a random length. Currently, set this flag to one. We do not support random size padding at this time.
- ealgKeyMin
- The minimum key size (in bits).
- ealgKeyMax
- The maximum key size (in bits).
- ealgKeyDefault
- The default key size (in bits).
- ealgScheduleLenFuncPtr
- A pointer to the function which computes the schedule length of this algorithm.
- ealgScheduleFuncPtr
- A pointer to the function which computes the schedule. This function will allocate memory for the schedule using the size computed from ealgScheduleLenFuncPtr, calculate the schedule, and save it into the generic key. The function prototype for the ealgScheduleFuncPtr is below.
- ealgBlockDecryptFuncPtr
- A pointer to the function which decrypts a single block of data using the key located in keyPtr.The function prototype for the ealgBlockDecryptFuncPtr is below.
- ealgBlockEncryptFuncPtr
- A pointer to the function which encrypts a single block of data using the key located in keyPtr.The function prototype for the ealgBlockEncryptFuncPtr is below.
Function Prototypes
ealgScheduleFuncPtr
int TM_CODE_FAR * ealgScheduleFuncPtr(struct tsEspAlgorithm TM_FAR * algPtr, ttGenericKeyPtr keyPtr);
ealgBlockDecryptFuncPtr
int TM_CODE_FAR * ealgBlockDecryptFuncPtr(struct tsEspAlgorithm TM_FAR * algPtr, ttGenericKeyPtr keyPtr, ttUser8BitPtr srcPtr, ttUser8BitPtr dstPtr);
ealgBlockEncryptFuncPtr
int TM_CODE_FAR * ealgBlockEncryptFuncPtr(struct tsEspAlgorithm TM_FAR * algPtr, ttGenericKeyPtr keyPtr, ttUser8BitPtr srcPtr, ttUser8BitPtr dstPtr);
Encryption Algorithm Key Length Table
| Keylength (in bits) | Min | Max | Default |
| DES: | 64 | 64 | 64 |
| 3DES: | 192 | 192 | 192 |
| Blowfish: | 40 | 448 | 128 |
| Cast128: | 40 | 128 | 128 |
| AES: | 128 | 256 | 128 |
| TWOFISH: | 128 | 256 | 128 |
| AES and Twofish keylength can be 128, 192 or 256 only. |