summaryrefslogtreecommitdiff
path: root/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private
diff options
context:
space:
mode:
Diffstat (limited to 'digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private')
-rw-r--r--digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspAuthenticHandler.h75
-rw-r--r--digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspCcmHandler.h171
-rw-r--r--digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspChallengeGenHandler.h42
-rw-r--r--digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspHashHandler.h118
-rw-r--r--digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspManager.h174
-rw-r--r--digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspMem.h238
-rw-r--r--digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspSfpHandler.h134
-rw-r--r--digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspSkkeHandler.h96
8 files changed, 1048 insertions, 0 deletions
diff --git a/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspAuthenticHandler.h b/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspAuthenticHandler.h
new file mode 100644
index 00000000..37c66d44
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspAuthenticHandler.h
@@ -0,0 +1,75 @@
+/**************************************************************************//**
+ \file sspAuthenticHandler.h
+
+ \brief Mutual Symmetric-Key Entity Authentication routine handler's header file.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 17/12/07 ALuzhetsky - Created.
+******************************************************************************/
+#ifndef _SSPAUTHENTICHANDLER_H
+#define _SSPAUTHENTICHANDLER_H
+
+#ifdef _LINK_SECURITY_
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+#include <types.h>
+#include <sspManager.h>
+#include <sspHashHandler.h>
+#include <sspAesHandler.h>
+
+/******************************************************************************
+ Types section.
+******************************************************************************/
+/******************************************************************************
+ TBD
+******************************************************************************/
+typedef struct
+{
+ SspKeyedHashMacReq_t keyedHashMacParams;
+ BEGIN_PACK
+ struct PACK
+ {
+ volatile uint8_t keyExpander[SECURITY_KEY_SIZE];
+ uint8_t macData[MAX_HASH_TEXT_SIZE];
+ volatile uint8_t bitsExpander[16];
+ };
+ END_PACK
+} SspAuthenticHandlerMem_t;
+/******************************************************************************
+ Prototypes section.
+******************************************************************************/
+/*******************************************************************************
+ Calculates parameters (MacTag1) for Mutual Symmetric-Key Entity Authentication
+ procedure.
+ Parameters:
+ none.
+ Return:
+ none.
+********************************************************************************/
+void sspCalculateAuthenticMacTag1ReqHandler(void);
+
+/*******************************************************************************
+ Calculates parameters (MacTag2) for Mutual Symmetric-Key Entity Authentication
+ procedure.
+ Parameters:
+ none.
+ Return:
+ none.
+********************************************************************************/
+void sspCalculateAuthenticMacTag2ReqHandler(void);
+
+#endif // _LINK_SECURITY_
+
+#endif //_SSPAUTHENTICHANDLER_H
+
+// eof sspAuthenticHandler.h
+
diff --git a/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspCcmHandler.h b/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspCcmHandler.h
new file mode 100644
index 00000000..1e924c49
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspCcmHandler.h
@@ -0,0 +1,171 @@
+/**************************************************************************//**
+ \file sspCcmHandler.h
+
+ \brief CCM routine header file.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 2006 - VGribanovsky created.
+ 29/11/2007 - ALuzhetsky API corrected.
+******************************************************************************/
+#ifndef _SSPCCMHANDLER_H
+#define _SSPCCMHANDLER_H
+
+
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+#include <types.h>
+
+
+/******************************************************************************
+ Definitions section.
+******************************************************************************/
+#define CCM_MIC_MAX_SIZE 16
+#define CCM_NONCE_SIZE 13
+
+/******************************************************************************
+ Types' definitions section.
+******************************************************************************/
+/**************************************************************************//**
+ TBD
+******************************************************************************/
+typedef enum
+{
+ CCM_REQ_TYPE_CRYPT,
+ CCM_REQ_TYPE_AUTH,
+ CCM_REQ_TYPE_CHECK_MIC
+} CcmReqType_t;
+
+/**************************************************************************//**
+ TBD
+******************************************************************************/
+typedef enum
+{
+ CCM_STATE_IDLE,
+ CCM_STATE_SET_KEY_WHILE_AUTH_OR_MIC_CHECK,
+ CCM_STATE_SET_KEY_WHILE_CRYPT,
+ CCM_STATE_CALC_X1_FOR_HDR_WHILE_AUTH_OR_MIC_CHECK,
+ CCM_STATE_CALC_XN_FOR_HDR_WHILE_AUTH_OR_MIC_CHECK,
+ CCM_STATE_CALC_XN_FOR_PLD_WHILE_CRYPT_OR_MIC_CHECK,
+ CCM_STATE_CALC_LAST_X_FOR_HDR_WHILE_MIC_CHECK,
+ CCM_STATE_CALC_LAST_X_FOR_HDR_WHILE_AUTH,
+ CCM_STATE_CALC_LAST_X_FOR_PLD_WHILE_CRYPT_OR_MIC_CHECK,
+ CCM_STATE_CRYPT_NEXT_PLD_BLOCK_WHILE_CRYPT_OR_MIC_CHECK,
+ CCM_STATE_CALC_XN_FOR_PLD_WHILE_AUTH,
+ CCM_STATE_CALC_LAST_X_FOR_PLD_WHILE_AUTH,
+ CCM_STATE_CRYPT_MIC,
+} SspCcmState_t;
+
+/**************************************************************************//**
+ \brief Input param structure for CCM authentification & encrypt
+ OR decode & authentification operations.
+******************************************************************************/
+typedef struct
+{
+ //!< key
+ uint8_t *key/*[SECURITY_KEY_SIZE]*/;
+ //!< nonce
+ uint8_t *nonce/*[CCM_NONCE_SIZE]*/;
+ //!< header
+ uint8_t *a/*[len_a]*/;
+ //!< pdu
+ uint8_t *m/*[len_m]*/;
+ //!< MIC length (or MAC - message authentication code).
+ //!< Limitations: does not work correctly if MIC length >= 0xfeff.
+ uint8_t M;
+ //!< header length
+ uint8_t len_a;
+ //!< pdu length
+ uint8_t len_m;
+ //!< Pointer to MIC memory - real MIC value will be XORed to this memory.
+ //!< Set to zero MIC byte values if you want the new MIC to be generated.
+ //!< To verify MIC check that it's value is all zeroes after authentication.
+ uint8_t *mic/*[M]*/;
+ //!< Confirm callback function
+ void (*ccmConfirm)(void);
+} CcmReq_t;
+
+/******************************************************************************
+ \brief Cryptographic context. Used for only for MIC generation and checking.
+******************************************************************************/
+typedef struct
+{
+ uint8_t textSize;
+ uint8_t *text/*[textSize]*/;
+ uint8_t x_i[SECURITY_BLOCK_SIZE];
+} CcmAuthCtx_t;
+
+/**************************************************************************//**
+ \brief CCM handler module static memory structure.
+******************************************************************************/
+typedef struct
+{
+ //!< Current CCM request pointer
+ CcmReq_t *ccmReq;
+ //!< Current CCM request type
+ CcmReqType_t reqType;
+ //!< Current CCM module state
+ SspCcmState_t ccmState;
+ //!< Buffer is used to save intermidiate decryption results while MIC
+ //!< calculating procedure and to form B1 while authentication.
+ uint8_t tmpCcmBuf[SECURITY_BLOCK_SIZE];
+ //!< Payload block counter
+ uint8_t pldBlockCounter;
+ CcmAuthCtx_t ccmAuthCtx;
+} SspCcmHandlerMem_t;
+
+
+/******************************************************************************
+ Prototypes section.
+******************************************************************************/
+/******************************************************************************
+ Calculate the CCM* authentication tag (CBC-MAC in RFC 3610 terms).
+ Arguments:
+ key - AES-128 key;
+ nonce_block - 16-byte block containing nonce in bytes 1..13
+ (bytes 0,14,15 are arbitrary);
+ frame - ptr to data to be protected by the authentication tag;
+ len_auth - data that have to be authentified only;
+ len_crypt - data that have to be authentified and encrypted;
+ auth - buffer to place the authentication tag;
+ M - MIC length,
+ temp - 176-byte array used by AES encryption algorithm.
+ If M=0 (which is permitted by ZigBee Standard but not by RFC 3610)
+ the function returns immediately.
+ Limitations: does not work correctly if len_auth >= 0xfeff.
+******************************************************************************/
+void ccmAuthReq(CcmReq_t *ccmParam);
+
+
+/******************************************************************************
+ Encrypt the buffer in place by the CCM*. Arguments:
+ key - AES-128 key;
+ nonce_block - 16-byte block containing nonce in bytes 1..13
+ (bytes 0,14,15 are arbitrary);
+ payload - buffer to be encrypted;
+ len_payload - length of this buffer;
+ auth - MIC which have to be encrypted additionally (also in place);
+ M - its length;
+ temp - 176-byte array used by AES encryption algorithm.
+******************************************************************************/
+void ccmCryptReq(CcmReq_t *);
+
+/**************************************************************************//**
+ \brief Performs encrypted frame MIC check procedure.
+
+ \param checMecReq - request parametrs structure pointer. Take a look at the
+ CcmReq_t type declaration for the detailes.
+******************************************************************************/
+void ccmCheckMicReq(CcmReq_t *checkMicReq);
+
+#endif //_SSPCCMHANDLER_H
+
+//eof sspCcmHandler.h
diff --git a/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspChallengeGenHandler.h b/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspChallengeGenHandler.h
new file mode 100644
index 00000000..a245e581
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspChallengeGenHandler.h
@@ -0,0 +1,42 @@
+/**************************************************************************//**
+ \file sspChallengeGenHandler.h
+
+ \brief Challenge generator handler header file.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 17/12/07 ALuzhetsky - Created.
+******************************************************************************/
+#ifndef _SSPCHALLENGEGENHANDLER_H
+#define _SSPCHALLENGEGENHANDLER_H
+
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+
+/******************************************************************************
+ Definition section.
+******************************************************************************/
+
+/******************************************************************************
+ Prototypes section.
+******************************************************************************/
+/*******************************************************************************
+ Resets Security Service Provider entity.
+ Parameters:
+ challenge - pointer to the memory for saving generated challenge.
+ Return:
+ none.
+********************************************************************************/
+void sspGenerateChallengeHandler(uint8_t challenge[/*CHALLENGE_SEQUENCE_SIZE*/]);
+#endif //_SSPCHALLENGEGENHANDLER_H
+
+// eof sspChallengeGenHandler.h
+
diff --git a/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspHashHandler.h b/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspHashHandler.h
new file mode 100644
index 00000000..c89a1193
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspHashHandler.h
@@ -0,0 +1,118 @@
+/**************************************************************************//**
+ \file sspHashHandler.h
+
+ \brief Hash routine header file.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 29/11/07 ALuzhetsky - Created.
+******************************************************************************/
+
+#ifndef _SSPHASHHANDLER_H
+#define _SSPHASHHANDLER_H
+
+#ifdef _LINK_SECURITY_
+
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+#include <types.h>
+#include <sspCommon.h>
+
+/******************************************************************************
+ Definitions section.
+******************************************************************************/
+#define MAX_HASH_TEXT_SIZE 53 // 1 + 2*sizeof(uint64_t) + 2*CHALLENGE_SIZE + sizeof(uint32_t)
+#define IPAD 0x36
+#define OPAD 0x5C
+
+/******************************************************************************
+ Types' definitions section.
+******************************************************************************/
+/******************************************************************************
+ TBD
+******************************************************************************/
+typedef struct
+{
+ // Service field - for internal needs.
+ SSP_Service_t service;
+ // There is should be an additional memory before and after text (16 bytes in both cases).
+ uint8_t *text/*[SECURITY_KEY_SIZE + textSize + 16]*/;
+ // Pointer to key fir Keyed Hash Function.
+ const uint8_t *key/*[SECURITY_KEY_SIZE]*/;
+ // Size of the text.
+ uint8_t textSize;
+ // Buffer for generated hash. Shoul be initialized by the user.
+ uint8_t *hash_i/*[SECURITY_KEY_SIZE]*/;
+ void (*sspKeyedHashMacConfirm)(void);
+} SspKeyedHashMacReq_t;
+
+/******************************************************************************
+ TBD
+******************************************************************************/
+typedef enum
+{
+ HASH_STATE_IDLE,
+ HASH_STATE_CREATE_HASH1,
+ HASH_STATE_CREATE_HASH2,
+} SspHashHandlerState_t;
+
+/******************************************************************************
+ TBD
+******************************************************************************/
+typedef struct
+{
+ uint8_t *M/*[textSize + 16]*/;
+ uint8_t *hash_i/*[SECURITY_KEY_SIZE]*/;
+ uint8_t textSize;
+ void (*bcbHashConf)(void);
+} SspBcbHashReq_t;
+
+/******************************************************************************
+ TBD
+******************************************************************************/
+typedef struct
+{
+ SspBcbHashReq_t *currentBcbHashReq;
+ SspKeyedHashMacReq_t *keyedHashMacReq;
+ SspBcbHashReq_t bcbHashReq;
+ uint8_t bcbBlockCounter;
+ SspHashHandlerState_t hashHandlerState;
+} SspHashHandlerMem_t;
+
+
+/******************************************************************************
+ Prototypes section.
+******************************************************************************/
+/*******************************************************************************
+ Keyed hash function implementation.
+ Parameters:
+ param - parameters of the primitive (for detailed description look at
+ SspKeyedHashMacReq_t declaration).
+ Return:
+ none.
+********************************************************************************/
+void sspKeyedHashMacReq(SspKeyedHashMacReq_t *param);
+
+/*******************************************************************************
+ Block Cipher Based hash function implementation.
+ Parameters:
+ param - parameters of the primitive (for detailed description look at
+ SspBcbHashReq_t declaration).
+ Return:
+ none.
+********************************************************************************/
+void sspBcbHashReq(SspBcbHashReq_t *param);
+
+#endif // _LINK_SECURITY_
+
+#endif //_SSPHASHHANDLER_H
+
+//eof sspHashHandler.h
diff --git a/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspManager.h b/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspManager.h
new file mode 100644
index 00000000..034ebf89
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspManager.h
@@ -0,0 +1,174 @@
+/**************************************************************************//**
+ \file sspManager.h
+
+ \brief Security Service Provider header file.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 06/12/2007 - ALuzhetsky API corrected.
+******************************************************************************/
+#ifndef _SSPMANAGER_H
+#define _SSPMANAGER_H
+
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+#include <queue.h>
+
+/******************************************************************************
+ Definition section.
+******************************************************************************/
+#ifdef _SSP_USE_FLASH_FOR_CONST_DATA
+ #include <types.h>
+ #define HANDLERS_MEM FLASH_VAR
+ #define HANDLERS_GET(A, I) memcpy_P(A, &sspHandlers[I], sizeof(SspTask_t))
+#else // _SSP_USE_FLASH_FOR_CONST_DATA
+ #define HANDLERS_MEM
+ #define HANDLERS_GET(A, I) (((A)->task) = sspHandlers[I].task)
+#endif // _SSP_USE_FLASH_FOR_CONST_DATA
+
+#if defined(_MAC_HW_AES_) || defined(_HAL_HW_AES_)
+ #ifdef _LINK_SECURITY_
+ #define SSP_TASKS_LIST \
+ {sspCalculateAuthenticMacTag1ReqHandler}, \
+ {sspCalculateAuthenticMacTag2ReqHandler}, \
+ {sspCalculateSkkeParamsReqHandler}, \
+ {sspKeyedHashReqHandler}, \
+ {sspEncryptFrameReqHandler}, \
+ {sspDecryptFrameReqHandler}
+ #else // _LINK_SECURITY_
+ #define SSP_TASKS_LIST \
+ {sspEncryptFrameReqHandler}, \
+ {sspDecryptFrameReqHandler}
+ #endif // _LINK_SECURITY_
+
+#elif defined(_SSP_SW_AES_)
+ #ifdef _LINK_SECURITY_
+ #define SSP_TASKS_LIST \
+ {sspCalculateAuthenticMacTag1ReqHandler}, \
+ {sspCalculateAuthenticMacTag2ReqHandler}, \
+ {sspCalculateSkkeParamsReqHandler}, \
+ {sspKeyedHashReqHandler}, \
+ {sspEncryptFrameReqHandler}, \
+ {sspDecryptFrameReqHandler}, \
+ {sspAesReqHandler},
+ #else // _LINK_SECURITY_
+ #define SSP_TASKS_LIST \
+ {sspEncryptFrameReqHandler}, \
+ {sspDecryptFrameReqHandler}, \
+ {sspAesReqHandler}
+ #endif // _LINK_SECURITY_
+
+#else
+ #error Unknown AES routine provider
+#endif
+
+/******************************************************************************
+ Types section.
+******************************************************************************/
+/**************************************************************************//**
+ \brief TBD.
+
+ TBD
+******************************************************************************/
+typedef struct
+{
+ void (*task)(void);
+} SspTask_t;
+
+/**************************************************************************//**
+ \brief TBD.
+
+ TBD
+******************************************************************************/
+typedef enum
+{
+#ifdef _LINK_SECURITY_
+ SSP_TASK_AUTHENTIC_MAC_TAG1,
+ SSP_TASK_AUTHENTIC_MAC_TAG2,
+ SSP_TASK_SKKE,
+ SSP_TASK_KEYED_HASH,
+#endif // _LINK_SECURITY_
+ SSP_TASK_ENCRYPT_FRAME,
+ SSP_TASK_DECRYPT_FRAME,
+#ifdef _SSP_SW_AES_
+ SSP_TASK_AES,
+#endif // _SSP_SW_AES_
+
+ SSP_TASKS_SIZE,
+} SspTaskId_t;
+
+/**************************************************************************//**
+ \brief TBD.
+
+ TBD
+******************************************************************************/
+typedef enum // ssp possible requests' types.
+{
+#ifdef _LINK_SECURITY_
+ SSP_REQ_ID_AUTHENTIC_MAC_TAG1 = SSP_TASK_AUTHENTIC_MAC_TAG1,
+ SSP_REQ_ID_AUTHENTIC_MAC_TAG2 = SSP_TASK_AUTHENTIC_MAC_TAG2,
+ SSP_REQ_ID_SKKE = SSP_TASK_SKKE,
+ SSP_REQ_ID_KEYED_HASH = SSP_TASK_KEYED_HASH,
+#endif // _LINK_SECURITY_
+ SSP_REQ_ID_SFP_ENCRYPT_FRAME = SSP_TASK_ENCRYPT_FRAME,
+ SSP_REQ_ID_SFP_DECRYPT_FRAME = SSP_TASK_DECRYPT_FRAME,
+
+} SspRequestId_t;
+
+/**************************************************************************//**
+ \brief TBD.
+
+ TBD
+******************************************************************************/
+typedef uint8_t SspTaskBitMask_t;
+
+/**************************************************************************//**
+ \brief TBD.
+
+ TBD
+******************************************************************************/
+typedef struct
+{
+ SspTaskBitMask_t taskBitMask;
+ QueueDescriptor_t reqQueueDescr;
+} SspManagerMem_t;
+
+/******************************************************************************
+ Functions prototypes section.
+******************************************************************************/
+/**************************************************************************//**
+ \brief TBD.
+
+ \param TBD.
+ \return TBD.
+******************************************************************************/
+void sspPostTask(SspTaskId_t taskID);
+
+/**************************************************************************//**
+ \brief TBD.
+
+ \param TBD.
+ \return TBD.
+******************************************************************************/
+void sspResetTaskManager(void);
+
+/******************************************************************************
+ Sends confirmation to the SSP user.
+ Parameters:
+ request - parameters of the request to be confirmed.
+ Returns:
+ none.
+******************************************************************************/
+void sspSendConfToUpperLayer(void *request);
+
+#endif // _SSPMANAGER_H
+
+// eof sspManager.h
diff --git a/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspMem.h b/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspMem.h
new file mode 100644
index 00000000..1512a170
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspMem.h
@@ -0,0 +1,238 @@
+/**************************************************************************//**
+ \file sspMem.h
+
+ \brief Security Service Provider memory manager header file.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 06/12/2007 - ALuzhetsky created.
+******************************************************************************/
+#ifndef _SSPMEM_H
+#define _SSPMEM_H
+
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+#include <queue.h>
+#include <sspManager.h>
+#include <sspAuthenticHandler.h>
+#include <sspSkkeHandler.h>
+#include <sspSfpHandler.h>
+#include <sspCcmHandler.h>
+
+/******************************************************************************
+ Types section.
+******************************************************************************/
+typedef struct
+{
+ void *sspReq; // Used by all modules which need to save requests' parameters.
+ // For Manager needs.
+ SspManagerMem_t managerMem;
+ SspAesMem_t aes;
+ union
+ {
+#ifdef _LINK_SECURITY_
+ SspAuthenticHandlerMem_t authenticHandlerMem;
+ SspSkkeHandlerMem_t skkeHandlerMem;
+#endif // _LINK_SECURITY_
+ SspSfpHandlerMem_t sfpHandlerMem;
+ };
+ union
+ {
+#ifdef _LINK_SECURITY_
+ SspHashHandlerMem_t hashHandlerMem;
+#endif // _LINK_SECURITY_
+ SspCcmHandlerMem_t ccmHandlerMem;
+ };
+} SspMem_t;
+
+/******************************************************************************
+ External variables.
+******************************************************************************/
+extern SspMem_t sspMem;
+
+/******************************************************************************
+ Inline static functions prototypes section.
+******************************************************************************/
+/******************************************************************************
+ Stores the pointer to the current request.
+ Parameters:
+ req - pointer to the current request.
+ returns:
+ none.
+******************************************************************************/
+INLINE void sspStoreReqParams(void *req)
+{
+ sspMem.sspReq = req;
+}
+
+/******************************************************************************
+ Gets the pointer to the current request.
+ Parameters:
+ none.
+ returns:
+ Pointer to the current request.
+******************************************************************************/
+INLINE void* sspGetReqParams(void)
+{
+ return sspMem.sspReq;
+}
+
+/******************************************************************************
+ Gets the current manager state.
+ Parameters:
+ none.
+ returns:
+ current manager state.
+******************************************************************************/
+/*INLINE SspState_t sspGetManagerState(void)
+{
+ return sspMem.managerMem.managerState;
+}*/
+
+/******************************************************************************
+ Sets the current manager state.
+ Parameters:
+ new state.
+ returns:
+ none.
+******************************************************************************/
+/*INLINE void sspSetManagerState(SspState_t newState)
+{
+ sspMem.managerMem.managerState = newState;
+}*/
+
+/******************************************************************************
+ Gets pointer to the queue descriptor.
+ Parameters:
+ none.
+ returns:
+ pointer to the queue descriptor.
+******************************************************************************/
+INLINE QueueDescriptor_t* sspGetQueueDescr(void)
+{
+ return &sspMem.managerMem.reqQueueDescr;
+}
+
+/******************************************************************************
+ Gets pointer to the queue descriptor.
+ Parameters:
+ none.
+ returns:
+ pointer to the queue descriptor.
+******************************************************************************/
+INLINE SspTaskBitMask_t* sspGetTaskBitMask(void)
+{
+ return &sspMem.managerMem.taskBitMask;
+}
+
+/******************************************************************************
+ Gets pointer to the current request.
+ Parameters:
+ none.
+ returns:
+ pointer to the current request.
+******************************************************************************/
+INLINE void* sspGetCurrentReq(void)
+{
+ return sspMem.sspReq;
+}
+
+/******************************************************************************
+ Stores pointer to the current request.
+ Parameters:
+ pointer to the current request.
+ returns:
+ none.
+******************************************************************************/
+INLINE void sspSetCurrentReq(void* param)
+{
+ sspMem.sspReq = param;
+}
+
+#ifdef _LINK_SECURITY_
+/******************************************************************************
+ Gets pointer to the authentic handler memory.
+ Parameters:
+ none.
+ returns:
+ pointer to the authentic handler memory.
+******************************************************************************/
+INLINE SspAuthenticHandlerMem_t* sspGetAuthenticHandlerMem(void)
+{
+ return &sspMem.authenticHandlerMem;
+}
+
+/******************************************************************************
+ Gets pointer to the skke handler memory.
+ Parameters:
+ none.
+ returns:
+ pointer to the skke handler memory.
+******************************************************************************/
+INLINE SspSkkeHandlerMem_t* sspGetSkkeHandlerMem(void)
+{
+ return &sspMem.skkeHandlerMem;
+}
+
+/******************************************************************************
+ Gets pointer to the hash handler memory.
+ Parameters:
+ none.
+ returns:
+ pointer to the hash handler memory.
+******************************************************************************/
+INLINE SspHashHandlerMem_t* sspGetHashHandlerMem(void)
+{
+ return &sspMem.hashHandlerMem;
+}
+#endif // _LINK_SECURITY_
+
+/******************************************************************************
+ Gets pointer to the sfp handler memory.
+ Parameters:
+ none.
+ returns:
+ pointer to the sfp handler memory.
+******************************************************************************/
+INLINE SspSfpHandlerMem_t* sspGetSfpHandlerMem(void)
+{
+ return &sspMem.sfpHandlerMem;
+}
+
+/******************************************************************************
+ Gets pointer to the memory for aes encryption procedure.
+ Parameters:
+ none.
+ returns:
+ pointer to the memory for aes encryption procedure.
+******************************************************************************/
+INLINE SspAesMem_t* sspGetAesMem(void)
+{
+ return &sspMem.aes;
+}
+
+/******************************************************************************
+ Gets pointer to the ccm handler memory.
+ Parameters:
+ none.
+ returns:
+ pointer to the ccm handler memory.
+******************************************************************************/
+INLINE SspCcmHandlerMem_t* sspGetCcmHandlerMem(void)
+{
+ return &sspMem.ccmHandlerMem;
+}
+
+
+//#endif // _SSP_USE_STATIC_MEM_
+
+#endif //_SSPMEM_H
+// eof sspMem.h
diff --git a/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspSfpHandler.h b/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspSfpHandler.h
new file mode 100644
index 00000000..3cc50904
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspSfpHandler.h
@@ -0,0 +1,134 @@
+/**************************************************************************//**
+ \file sspSfpHandler.h
+
+ \brief SFP routine header file.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 2006 - VGribanovsky created.
+ 29/11/2007 - ALuzhetsky API corrected.
+******************************************************************************/
+
+#ifndef _SSPSFPHANDLER_H
+#define _SSPSFPHANDLER_H
+
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+#include <bcEndian.h>
+#include <sspManager.h>
+#include <sspSfp.h>
+#include <sspAesHandler.h>
+#include <sspCcmHandler.h>
+
+/******************************************************************************
+ Types definition section.
+******************************************************************************/
+/**************************************************************************//**
+ \brief TBD
+******************************************************************************/
+typedef enum
+{
+ SFP_STATE_IDLE,
+ SFP_STATE_ENCRYPTION_KEY_TRANSFORMING,
+ SFP_STATE_ENCRYPTION_AUTHENTIC,
+ SFP_STATE_ENCRYPTION_ENCRYPT,
+ SFP_STATE_DECRYPTION_KEY_TRANSFORMING,
+ SFP_STATE_DECRYPTION_AUTHENTIC,
+ SFP_STATE_DECRYPTION_ENCRYPT,
+ SFP_STATE_DECRYPTION_MIC_CHECK
+} SspSfpHandlerState_t;
+
+/**************************************************************************//**
+ \brief TBD
+******************************************************************************/
+typedef struct
+{
+ SspSfpHandlerState_t sfpState;
+ uint8_t nonce[CCM_NONCE_SIZE];
+ uint8_t transformedKey[SECURITY_KEY_SIZE];
+ uint8_t mic[CCM_MIC_MAX_SIZE];
+ uint8_t auxiliaryHeaderLength;
+ union
+ {
+ CcmReq_t ccmReq;
+#ifdef _LINK_SECURITY_
+ SspKeyedHashMacReq_t hashMacReq;
+#endif // _LINK_SECURITY_
+ };
+ BEGIN_PACK
+ struct PACK
+ {
+ volatile uint8_t keyExpander[16];
+ uint8_t text;
+ volatile uint8_t bitsExpander[16];
+ }; // For hash function
+ END_PACK
+} SspSfpHandlerMem_t;
+
+/**************************************************************************//**
+ \brief Security Control field format.
+******************************************************************************/
+BEGIN_PACK
+typedef struct PACK
+{
+ LITTLE_ENDIAN_OCTET(4,(
+ uint8_t securityLevel : 3,
+ uint8_t keyIdentifier : 2,
+ uint8_t extendedNonce : 1,
+ uint8_t reserved : 2
+ ))
+} SecurityCtrlField_t;
+END_PACK
+
+/******************************************************************************
+ Prototypes section.
+******************************************************************************/
+/******************************************************************************
+ Encrypts frame. Encoding is based on incoming param which are extracted from
+ SSP_EncryptFrameReq param.
+ Parameters:
+ none.
+ Return:
+ none.
+******************************************************************************/
+void sspEncryptFrameReqHandler(void);
+
+/******************************************************************************
+ Decrypts frame. Decrypting is based on incoming param which are extracted from
+ SSP_DecryptFrameReq param.
+ Parameters:
+ none.
+ Return:
+ none.
+******************************************************************************/
+void sspDecryptFrameReqHandler(void);
+
+/******************************************************************************
+ Parses auxiliary frame header.
+ Parameters:
+ param - contains pointer to the frame and parameters to be initialized.
+ Return:
+ Auxiliary header length.
+******************************************************************************/
+uint8_t sspParseAuxiliaryHeaderHandler(SSP_ParseAuxiliaryHeader_t *param);
+
+/******************************************************************************
+ Security Frame Processor Handler's task.
+ Parameters:
+ none
+ Return:
+ none.
+******************************************************************************/
+void sspSfpTaskHandler(void);
+
+#endif //_SSPSFPHANDLER_H
+
+// eof sspSfpHandler.h
diff --git a/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspSkkeHandler.h b/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspSkkeHandler.h
new file mode 100644
index 00000000..c9d881e0
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspSkkeHandler.h
@@ -0,0 +1,96 @@
+/**************************************************************************//**
+ \file sspSkkeHandler.h
+
+ \brief SKKE routine handler header file.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 29/11/07 ALuzhetsky - Created.
+******************************************************************************/
+#ifndef _SSPSKKEHANDLER_H
+#define _SSPSKKEHANDLER_H
+
+#ifdef _LINK_SECURITY_
+
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+#include <types.h>
+#include <sspManager.h>
+#include <sspAesHandler.h>
+
+/******************************************************************************
+ Types section.
+******************************************************************************/
+typedef enum
+{
+ SKKE_STATE_IDLE,
+ SKKE_STATE_CALCULATE_MACTAG1,
+ SKKE_STATE_CALCULATE_MACTAG2,
+ SKKE_STATE_CALCULATE_FINAL_MACTAG1,
+ SKKE_STATE_CALCULATE_HASH1,
+ SKKE_STATE_CALCULATE_HASH2,
+} SspSkkeState_t;
+/******************************************************************************
+ TBD
+******************************************************************************/
+typedef struct
+{
+ SspSkkeState_t skkeState;
+ uint8_t macKey[SECURITY_KEY_SIZE];
+ BEGIN_PACK
+ struct PACK
+ {
+ volatile uint8_t keyExpander[SECURITY_KEY_SIZE];
+ uint8_t macData[MAX_HASH_TEXT_SIZE];
+ volatile uint8_t bitsExpander[16];
+ };
+ END_PACK
+ union
+ {
+ SspKeyedHashMacReq_t keyedHashMacParam;
+ SspBcbHashReq_t bcbHashReqParam;
+ };
+} SspSkkeHandlerMem_t;
+
+/******************************************************************************
+ Prototypes section.
+******************************************************************************/
+/*******************************************************************************
+ Calculates parameters of Security-Key Key Esteblishment procedure.
+ Parameters:
+ none.
+ Return:
+ none.
+********************************************************************************/
+void sspCalculateSkkeParamsReqHandler(void);
+
+/***************************************************************************\\**
+ \brief Copies with mirroring "length" bytes from "src" to "dst".
+
+ \param
+ dst - destination memory.
+ src - source memory.
+ length - number of bytes to copy.
+ \return
+ none.
+********************************************************************************/
+INLINE void mirrorMemcpy(uint8_t *dst, uint8_t *src, uint8_t length)
+{
+ while(length)
+ *(dst++) = *(src + --length);
+}
+
+#endif // _LINK_SECURITY_
+
+#endif //_SSPSKKEHANDLER_H
+
+// eof sspSkkeHandler.h
+