original files of m241
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
#ifndef MK1MF_BUILD
|
||||
/* created by Interpeak for crypto/cversion.c */
|
||||
#define CFLAGS "cflags"
|
||||
#define PLATFORM "ipcom"
|
||||
#define DATE "Thu Apr 19 15:18:31 CEST 2007"
|
||||
#endif
|
||||
@@ -0,0 +1,437 @@
|
||||
/* ipcrypto.h - public API of Wind River Crypto */
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK API HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcrypto.h,v $ $Revision: 1.12.16.1 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcrypto/include/ipcrypto.h,v $
|
||||
* $Author: svc-cmnet $ $Date: 2013-03-13 07:45:19 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Roger Boden <roger@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPCRYPTO_H
|
||||
#define IPCRYPTO_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
DESCRIPTION
|
||||
This library contains the API for Wind River Crypto
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcrypto_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include <ipcom_type.h>
|
||||
#include <ipcom_cstyle.h>
|
||||
|
||||
#include <openssl/aes.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/* IPCRYPTO release XYyZz,
|
||||
* X = major version
|
||||
* Yy = minor version (two different versions might be incompatible)
|
||||
* Zz = patch version (two different versions are always compatible)
|
||||
*/
|
||||
#define IPCRYPTO_RELEASE 60900
|
||||
|
||||
#ifndef AES_BLOCKSIZE
|
||||
#define AES_BLOCKSIZE 16
|
||||
#endif
|
||||
|
||||
#define AES_KEY_128_BYTES 16
|
||||
#define AES_KEY_192_BYTES 24
|
||||
#define AES_KEY_256_BYTES 32
|
||||
#define AESKW_BLOCKSIZE 8
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
typedef struct _AES_CMAC_CONTEXT
|
||||
{
|
||||
Ip_u8 IV[AES_BLOCKSIZE]; /* IV initialization vector */
|
||||
Ip_u32 ivLength; /* IV length */
|
||||
Ip_u8 k1[AES_BLOCKSIZE]; /* k1 subkey */
|
||||
Ip_u8 k2[AES_BLOCKSIZE]; /* k2 subkey */
|
||||
AES_KEY aesKey; /* AES_KEY used for cipher */
|
||||
} AES_CMAC_CTX;
|
||||
|
||||
/* Forward declaration */
|
||||
struct env_md_st;
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipcrypto_crc32 -
|
||||
*
|
||||
* \NOMANUAL:
|
||||
*
|
||||
*/
|
||||
IP_EXTERN Ip_u32 ipcrypto_crc32(
|
||||
const Ip_u8 *,
|
||||
Ip_u32
|
||||
);
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipcrypto_key_fingerprint_bubblebabble -
|
||||
*
|
||||
* \NOMANUAL:
|
||||
*
|
||||
*/
|
||||
IP_EXTERN char * ipcrypto_key_fingerprint_bubblebabble(
|
||||
Ip_u8* dgst_raw,
|
||||
unsigned int dgst_raw_len
|
||||
);
|
||||
/*******************************************************************************
|
||||
*
|
||||
* aesCmacInit - initialize a new AES CMAC context
|
||||
*
|
||||
* This routine is used to initialize an AES_CMAC_CTX object for a new CMAC
|
||||
* calculation. It calculates the CMAC subkeys and stores them
|
||||
* in the AES CMAC context.
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i <cmacCtx>
|
||||
* Pointer to the AES_CMAC_CTX structure to be initialized.
|
||||
*
|
||||
* \i <key>
|
||||
* Pointer to the key buffer. If 'key==NULL' then the subkeys stored in 'cmacCtx' are
|
||||
* used. In this way the context can be reused even after calling aesCmacFinal() if the
|
||||
* key is the same.
|
||||
*
|
||||
* \i <keyLength>
|
||||
* Length of the key in bytes.
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: 1 on success, -1 on error
|
||||
*
|
||||
*/
|
||||
IP_EXTERN int aesCmacInit(
|
||||
AES_CMAC_CTX *cmacCtx,
|
||||
Ip_u8 *key,
|
||||
int keyLength
|
||||
);
|
||||
/*******************************************************************************
|
||||
*
|
||||
* aesCmacUpdate - update the AES CMAC context with data
|
||||
*
|
||||
* This routine is used to add data to the AES CMAC context without finalizing the
|
||||
* calculation. It may be called multiple times to add to the message
|
||||
* to be authenticated.
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i <cmacCtx>
|
||||
* Pointer to the AES_CMAC_CTX structure to be used.
|
||||
*
|
||||
* \i <input>
|
||||
* Pointer to the input message.
|
||||
*
|
||||
* \i <inputLength>
|
||||
* Length of the input buffer. Must be a multiple of AES_BLOCKSIZE.
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: 1 on success, -1 on error
|
||||
*
|
||||
*/
|
||||
IP_EXTERN int aesCmacUpdate(
|
||||
AES_CMAC_CTX *cmacCtx,
|
||||
Ip_u8 *input,
|
||||
Ip_u8 inputLength
|
||||
);
|
||||
/*******************************************************************************
|
||||
*
|
||||
* aesCmacFinal - update the AES CMAC context with data and finalize the CMAC calculation.
|
||||
*
|
||||
* This routine is used to add data to the AES CMAC context and generate the CMAC for
|
||||
* data that has been added to the context.
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i <cmacCtx>
|
||||
* Pointer to the AES_CMAC_CTX structure to be used.
|
||||
*
|
||||
* \i <input>
|
||||
* Pointer to the input message.
|
||||
*
|
||||
* \i <inputLength>
|
||||
* Length of the input buffer. Must be a multiple of AES_BLOCKSIZE.
|
||||
*
|
||||
* \i <outputMac>
|
||||
* Pointer to the buffer where the output CMAC is copied.
|
||||
*
|
||||
* \i <outputMacLength>
|
||||
* Pointer to a variable containing the length of the outputMac buffer. On input, '*outputMacLength'
|
||||
* must be set to the size of the 'outputMac' buffer. On output, '*outputMacLength' is updated to the length
|
||||
* of data copied into the 'outputMac' buffer.
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: 1 on success, -1 on error
|
||||
*
|
||||
*/
|
||||
|
||||
IP_EXTERN int aesCmacFinal(
|
||||
AES_CMAC_CTX *cmacCtx,
|
||||
Ip_u8 *input,
|
||||
int inputLength,
|
||||
Ip_u8 *outputMac,
|
||||
int *outputMacLength
|
||||
);
|
||||
/*******************************************************************************
|
||||
*
|
||||
* aesCmacBlock - calculate the CMAC of a complete input message
|
||||
*
|
||||
* This routine is used to calculate the CMAC of the input message in one operation.
|
||||
* If the same key is going to be used for multiple CMAC calculations, the AES_CMAC_CTX can
|
||||
* be used to store the subkeys between calls.
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i <cmacCtx>
|
||||
* Pointer to the AES_CMAC_CTX structure to be used. If 'cmacCtx==NULL' no subkeys are returned.
|
||||
* If 'cmacCtx!=NULL' and 'key!=NULL', then the subkeys are calculated and returned in 'cmacCtx'.
|
||||
* If 'cmacCtx!=NULL' and 'key==NULL', then the subkeys stored in 'cmacCtx' from a previous calculation are
|
||||
* used, saving a recalculation.
|
||||
*
|
||||
* \i <key>
|
||||
* Pointer to the variable length key
|
||||
*
|
||||
* \i <keyLength>
|
||||
* Length in bytes of the key.
|
||||
*
|
||||
* \i <input>
|
||||
* Pointer to the input message.
|
||||
*
|
||||
* \i <inputLength>
|
||||
* Length of the input buffer. Must be a multiple of AES_BLOCKSIZE.
|
||||
*
|
||||
* \i <outputMac>
|
||||
* Pointer to the buffer where the output CMAC is copied.
|
||||
*
|
||||
* \i <outputMacLength>
|
||||
* Pointer to a variable containing the length of the outputMac buffer. On input, '*outputMacLength'
|
||||
* must be set to the size of the 'outputMac' buffer. On output, '*outputMacLength' is updated to the length
|
||||
* of data copied into the 'outputMac' buffer.
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: 1 on success, -1 on error
|
||||
*
|
||||
*/
|
||||
IP_EXTERN int aesCmacBlock(
|
||||
AES_CMAC_CTX *cmacCtx,
|
||||
Ip_u8 *key,
|
||||
int keyLength,
|
||||
Ip_u8 *input,
|
||||
int inputLength,
|
||||
Ip_u8 *outputMac,
|
||||
int *outputMacLength
|
||||
);
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* aesCmacPrf128 - AES CMAC pseudo random function
|
||||
*
|
||||
* This routine is used to calculate the AES CMAC PRF128 (RFC 4615) used in IKEv2.
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i <key>
|
||||
* Pointer to the variable length key.
|
||||
*
|
||||
* \i <keyLength>
|
||||
* Length in bytes of the key.
|
||||
*
|
||||
* \i <input>
|
||||
* Pointer to the input message.
|
||||
*
|
||||
* \i <inputLength>
|
||||
* Length of the input buffer. Must be a multiple of AES_BLOCKSIZE.
|
||||
*
|
||||
* \i <output>
|
||||
* Pointer to the buffer where the output is copied.
|
||||
*
|
||||
* \i <outputLength>
|
||||
* Pointer to a variable containing the length of the output buffer. On input, '*outputMacLength'
|
||||
* must be set to the size of the 'outputMac' buffer, and must be at least AES_BLOCKSIZE. On output, '*outputMacLength' is updated to the length
|
||||
* of data copied into the 'outputMac' buffer.
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: 1 on success, -1 on error
|
||||
*
|
||||
*/
|
||||
|
||||
IP_EXTERN int aesCmacPrf128(
|
||||
Ip_u8 *key,
|
||||
int keyLength,
|
||||
Ip_u8 *input,
|
||||
int inputLength,
|
||||
Ip_u8 *output,
|
||||
int *outputMacLength
|
||||
);
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* aeskw_wrap - encrypt a key using AES Keywrap
|
||||
*
|
||||
* This routine encrypts a key using AES Keywrap.
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i <key>
|
||||
* Pointer to key encryption key buffer.
|
||||
*
|
||||
* \i <keyLength>
|
||||
* Length of key in key buffer in bytes. Must be 16, 24 or 32 bytes.
|
||||
*
|
||||
* \i <iv>
|
||||
* Pointer to initialization vector buffer.
|
||||
*
|
||||
* \i <ivLength>
|
||||
* Length of IV in bytes. Must be AESKW_BLOCKSIZE.
|
||||
*
|
||||
* \i <plainText>
|
||||
* Pointer to buffer to encrypt.
|
||||
*
|
||||
* \i <plainTextLength>
|
||||
* Length of plainText buffer. Must be a multiple of AESKW_BLOCKSIZE.
|
||||
*
|
||||
* \i <cipherText>
|
||||
* Pointer to output buffer.
|
||||
*
|
||||
* \i <cipherTextLength>
|
||||
* Pointer to a variable containing the length of the output buffer. On input, '*cipherTextLength'
|
||||
* must be set to the size of the 'cipherText' buffer. On output, '*cipherTextLength' is updated to the length
|
||||
* of data copied into the 'cipherText' buffer.
|
||||
*
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: 1 on success, -1 on error
|
||||
*
|
||||
*/
|
||||
IP_EXTERN int aeskw_wrap(
|
||||
Ip_u8 *key,
|
||||
int keyLength,
|
||||
Ip_u8 *iv,
|
||||
int ivLength,
|
||||
Ip_u8 *plainText,
|
||||
int plainTextLength,
|
||||
Ip_u8 *cipherText,
|
||||
int *cipherTextLength
|
||||
);
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* aeskw_unwrap - decrypt a key using AES Keywrap
|
||||
*
|
||||
* This routine decrypts a key using AES Keywrap.
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i <key>
|
||||
* Pointer to key encryption key buffer.
|
||||
*
|
||||
* \i <keyLength>
|
||||
* Length of key in key buffer in bytes. Must be 16, 24 or 32 bytes.
|
||||
*
|
||||
* \i <iv>
|
||||
* Pointer to initialization vector buffer.
|
||||
*
|
||||
* \i <ivLength>
|
||||
* Length of IV in bytes. Must be AESKW_BLOCKSIZE.
|
||||
*
|
||||
* \i <cipherText>
|
||||
* Pointer to buffer to decrypt.
|
||||
*
|
||||
* \i <cipherTextLength>
|
||||
* Length of cipherText buffer. Must be a multiple of AESKW_BLOCKSIZE.
|
||||
*
|
||||
* \i <plainText>
|
||||
* Pointer to output buffer.
|
||||
*
|
||||
* \i <plainTextLength>
|
||||
* Pointer to a variable containing the length of the output buffer. On input, '*plainTextLength'
|
||||
* must be set to the size of the 'plainText' buffer. On output, '*plainTextLength' is updated to the length
|
||||
* of data copied into the 'plainText' buffer.
|
||||
*
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: 1 on success, -1 on error
|
||||
*
|
||||
*/
|
||||
|
||||
IP_EXTERN int aeskw_unwrap(
|
||||
Ip_u8 *key,
|
||||
int keyLength,
|
||||
Ip_u8 *iv,
|
||||
int ivLength,
|
||||
Ip_u8 *cipherText,
|
||||
int cipherTextLength,
|
||||
Ip_u8 *plainText,
|
||||
int *plainTextLength
|
||||
);
|
||||
|
||||
|
||||
IP_GLOBAL void ipcrypto_rsa_oaep_encode(const struct env_md_st* hash,
|
||||
unsigned char *in,
|
||||
int inlen,
|
||||
unsigned char *out,
|
||||
int outlen);
|
||||
|
||||
IP_GLOBAL Ip_err ipcrypto_rsa_oaep_decode(const struct env_md_st* hash,
|
||||
unsigned char *in,
|
||||
int in_len,
|
||||
unsigned char *out,
|
||||
int* out_len);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK API HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcrypto_iptype_map.h,v $ $Revision: 1.1.52.1 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcrypto/include/ipcrypto_iptype_map.h,v $
|
||||
* $Author: jli7 $ $Date: 2017-08-23 07:57:53 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Roger Boden <roger@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPCRYPTO_IPTYPE_MAP_H
|
||||
#define IPCRYPTO_IPTYPE_MAP_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef IPCRYPTO_USE_TYPE_MAPPING
|
||||
#include <ipcom_type.h>
|
||||
#define size_t Ip_size_t
|
||||
#define time_t Ip_time_t
|
||||
#define FILE IP_FILE
|
||||
#define NULL IP_NULL
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
Reference in New Issue
Block a user