summaryrefslogtreecommitdiff
path: root/bsp/airm2m/air32f103/libraries/AIR32F10xLib/lib/cryptlib/air_sha.h
blob: 18c411863e185e060a4b2e679a0d4841c7fd9d04 (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

#ifndef __AIR_SHA_H
#define __AIR_SHA_H

#ifdef __cplusplus
extern "C" {
#endif

#include <stdint.h>
#include "air_crypt.h"


#define AIR_RET_SHA_INIT                         (0x576C39AA)
#define AIR_RET_SHA_PARAM_ERR                    ((AIR_RET_SHA_INIT + 0x01))
#define AIR_RET_SHA_BUSY                         ((AIR_RET_SHA_INIT + 0x02))
#define AIR_RET_SHA_MODE_ERR                     ((AIR_RET_SHA_INIT + 0x03))
#define AIR_RET_SHA_SUCCESS                      ((AIR_RET_SHA_INIT + 0x0100))


typedef struct
{
    uint32_t au32Total[2];
    uint8_t au8Buffer[64];
    uint32_t au32State[5];
}AIRSHA1_Context;

typedef struct
{
    uint32_t au32Total[2];
    uint8_t  au8Buffer[64];
    uint32_t au32State[8];
}AIRSHA2_Context;

typedef enum
{
    AIRSHA1 = 0,
    AIRSHA224 = 1,
    AIRSHA256 = 2,
//    AIRSHA384 = 3,
//    AIRSHA512 = 4
}AIRSHA_MOD_TYPE;

uint32_t AIRSHA1_Starts(AIRSHA1_Context *pCtx);
uint32_t AIRSHA1_Update(AIRSHA1_Context *pCtx, const uint8_t *pu8Input, uint32_t u32InputLen);
uint32_t AIRSHA1_Finish(AIRSHA1_Context *pCtx, uint8_t au8Digest[20]);

uint32_t AIRSHA256_Starts(AIRSHA2_Context *pCtx);
uint32_t AIRSHA256_Update(AIRSHA2_Context *pCtx, const uint8_t *pu8Input, uint32_t u32InputLen);
uint32_t AIRSHA256_Finish(AIRSHA2_Context *pCtx, uint8_t au8Digest[32]);

uint32_t AIRSHA_Sha(AIRSHA_MOD_TYPE ShaType, const uint8_t *pu8Input, uint32_t u32Ibytes, uint8_t *pu8Output, uint32_t u32Outlen);

#ifdef __cplusplus
}
#endif

#endif