wolfcaam_sha.h
1 /* wolfcaam_sha.h
2  *
3  * Copyright (C) 2006-2020 wolfSSL Inc.
4  *
5  * This file is part of wolfSSL.
6  *
7  * wolfSSL is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * wolfSSL is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20  */
21 
22 #ifndef WOLF_CRYPT_CAAM_SHA_H
23 #define WOLF_CRYPT_CAAM_SHA_H
24 
25 #include <wolfssl/wolfcrypt/settings.h>
26 
27 #ifdef WOLFSSL_IMX6_CAAM
28 
30 
31 #define WOLFSSL_NO_HASH_RAW
32 
33 #ifndef WC_CAAM_CTXLEN
34 /* last 8 bytes of context is for length */
35 #define WC_CAAM_CTXLEN 8
36 #endif
37 
38 #ifndef WC_CAAM_HASH_BLOCK
39 /* define sha structures and also get the max possible digest. Start with SHA
40  digest size */
41 #define WC_CAAM_HASH_BLOCK 64
42 #endif
43 
44 #ifndef WC_CAAM_MAX_DIGEST
45 #define WC_CAAM_MAX_DIGEST 20
46 #ifdef WOLFSSL_SHA224
47  #undef WC_CAAM_MAX_DIGEST
48  #define WC_CAAM_MAX_DIGEST 32
49 #endif
50 
51 #ifndef NO_SHA256
52  #undef WC_CAAM_MAX_DIGEST
53  #define WC_CAAM_MAX_DIGEST 32
54 #endif
55 
56 #ifdef WOLFSSL_SHA384
57  #undef WC_CAAM_MAX_DIGEST
58  #define WC_CAAM_MAX_DIGEST 64
59 #endif
60 
61 #ifdef WOLFSSL_SHA512
62  #undef WC_CAAM_MAX_DIGEST
63  #define WC_CAAM_MAX_DIGEST 64
64 #endif
65 #endif /* WC_CAAM_MAX_DIGEST */
66 
67 
68 typedef struct wc_Sha {
69  word32 ctx[(WC_CAAM_MAX_DIGEST + WC_CAAM_CTXLEN) / sizeof(word32)];
70  word32 buffLen; /* in bytes */
71  word32 buffer[WC_CAAM_HASH_BLOCK / sizeof(word32)];
72 } wc_Sha;
73 
74 #ifndef NO_MD5
75  typedef struct wc_Sha wc_Md5;
76 #endif
77 
78 #ifndef NO_SHA256
79  typedef struct wc_Sha wc_Sha256;
80 #endif
81 
82 #ifdef WOLFSSL_SHA512
83  typedef struct wc_Sha wc_Sha512;
84 #endif
85 
86 #endif /* WOLFSSL_IMX6_CAAM */
87 
88 #endif /* WOLF_CRYPT_CAAM_SHA_H */
Definition: sha256.h:132
Definition: md5.h:79
Definition: sha512.h:116
Definition: wolfcaam_sha.h:68