summaryrefslogtreecommitdiff
path: root/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspManager.h
blob: 034ebf89a92980a85e685f2ae229ee565fb556e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
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