summaryrefslogtreecommitdiff
path: root/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspHashHandler.h
blob: c89a11931f02fff78f3ab94d1eac9d7f4e75bd05 (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
/**************************************************************************//**
  \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