SharkSSL™ Embedded SSL/TLS Stack
SharkSslCrypto.h
1 /*
2  * ____ _________ __ _
3  * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____
4  * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/
5  * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__
6  * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/
7  * /____/
8  *
9  * SharkSSL Embedded SSL/TLS Stack
10  ****************************************************************************
11  * PROGRAM MODULE
12  *
13  * $Id: SharkSslCrypto.h 4650 2020-11-17 23:54:13Z wini $
14  *
15  * COPYRIGHT: Real Time Logic LLC, 2010 - 2019
16  *
17  * This software is copyrighted by and is the sole property of Real
18  * Time Logic LLC. All rights, title, ownership, or other interests in
19  * the software remain the property of Real Time Logic LLC. This
20  * software may only be used in accordance with the terms and
21  * conditions stipulated in the corresponding license agreement under
22  * which the software has been supplied. Any unauthorized use,
23  * duplication, transmission, distribution, or disclosure of this
24  * software is expressly forbidden.
25  *
26  * This Copyright notice may not be removed or modified without prior
27  * written consent of Real Time Logic LLC.
28  *
29  * Real Time Logic LLC. reserves the right to modify this software
30  * without notice.
31  *
32  * http://www.realtimelogic.com
33  * http://www.sharkssl.com
34  ****************************************************************************
35  *
36  */
37 #ifndef _SharkSslCrypto_h
38 #define _SharkSslCrypto_h
39 
40 #define SHARKSSL_LIB 1
41 #include "SharkSSL.h"
42 
43 
44 #define SHARKSSL_MD5_HASH_LEN 16
45 #define SHARKSSL_SHA1_HASH_LEN 20
46 #define SHARKSSL_SHA256_HASH_LEN 32
47 #define SHARKSSL_SHA384_HASH_LEN 48
48 #define SHARKSSL_SHA512_HASH_LEN 64
49 #define SHARKSSL_POLY1305_HASH_LEN 16
50 
51 #define SHARKSSL_MD5_BLOCK_LEN 64
52 #define SHARKSSL_SHA1_BLOCK_LEN 64
53 #define SHARKSSL_SHA256_BLOCK_LEN 64
54 #define SHARKSSL_SHA384_BLOCK_LEN 128
55 #define SHARKSSL_SHA512_BLOCK_LEN 128
56 
59 #define SHARKSSL_HASHID_MD5 0x01
60 #define SHARKSSL_HASHID_SHA1 0x02
61 #define SHARKSSL_HASHID_SHA256 0x04
62 #define SHARKSSL_HASHID_SHA384 0x05
63 #define SHARKSSL_HASHID_SHA512 0x06
64 
65 
66 #if SHARKSSL_USE_MD5
67 
70 typedef struct SharkSslMd5Ctx
71 {
72  U32 total[2];
73  U32 state[4];
74  U8 buffer[64];
76 #endif
77 
78 
79 #if SHARKSSL_USE_SHA1
80 
83 typedef struct SharkSslSha1Ctx
84 {
85  U32 total[2];
86  U32 state[5];
87  U8 buffer[64];
89 #endif
90 
91 
92 #if SHARKSSL_USE_SHA_256
93 
96 typedef struct SharkSslSha256Ctx
97 {
98  U32 total[2];
99  U32 state[8];
100  U8 buffer[64];
102 #endif
103 
104 
105 #if (SHARKSSL_USE_SHA_384 || SHARKSSL_USE_SHA_512)
106 
109 typedef struct SharkSslSha384Ctx
110 {
111  U32 total[4];
112  U64 state[8];
113  U8 buffer[128];
115 #endif
116 
117 
118 #if SHARKSSL_USE_SHA_512
119 
122 typedef struct SharkSslSha384Ctx SharkSslSha512Ctx;
123 #endif
124 
125 
126 #if SHARKSSL_HMAC_API && (SHARKSSL_USE_SHA_512 || SHARKSSL_USE_SHA_384 || SHARKSSL_USE_SHA_256 || SHARKSSL_USE_SHA1 || SHARKSSL_USE_MD5)
127 
130 typedef struct SharkSslHMACCtx
131 {
132  union
133  {
134  #if SHARKSSL_USE_MD5
135  SharkSslMd5Ctx md5Ctx;
136  #endif
137  #if SHARKSSL_USE_SHA1
138  SharkSslSha1Ctx sha1Ctx;
139  #endif
140  #if SHARKSSL_USE_SHA_256
141  SharkSslSha256Ctx sha256Ctx;
142  #endif
143  #if SHARKSSL_USE_SHA_384
144  SharkSslSha384Ctx sha384Ctx;
145  #endif
146  #if SHARKSSL_USE_SHA_512
147  SharkSslSha512Ctx sha512Ctx;
148  #endif
149  } hashCtx;
150 
151  /* descending block length */
152  #if SHARKSSL_USE_SHA_512
153  U8 key[SHARKSSL_SHA512_BLOCK_LEN];
154  #elif SHARKSSL_USE_SHA_384
155  U8 key[SHARKSSL_SHA384_BLOCK_LEN];
156  #elif SHARKSSL_USE_SHA_256
157  U8 key[SHARKSSL_SHA256_BLOCK_LEN];
158  #elif SHARKSSL_USE_SHA1
159  U8 key[SHARKSSL_SHA1_BLOCK_LEN];
160  #elif SHARKSSL_USE_MD5
161  U8 key[SHARKSSL_MD5_BLOCK_LEN];
162  #endif
163 
164  U8 hashID;
166 #endif
167 
168 
169 #if SHARKSSL_USE_POLY1305
170 
173 typedef struct SharkSslPoly1305Ctx
174 {
175  U32 r[5];
176  U32 key[4];
177  U32 nonce[4];
178  U8 buffer[16];
179  U8 flag, blen;
181 #endif
182 
183 
184 #if SHARKSSL_USE_CHACHA20
185 
188 typedef struct
189 {
190  U32 state[16];
192 #endif
193 
194 
195 #if SHARKSSL_USE_ARC4
196 
199 typedef struct SharkSslArc4Ctx
200 {
201  U8 x;
202  U8 y;
203  U8 b[256];
204 } SharkSslArc4Ctx;
205 #endif
206 
207 
208 #if (SHARKSSL_USE_DES || SHARKSSL_USE_3DES)
209 
212 typedef struct SharkSslDesCtx
213 {
214  #if SHARKSSL_NOPACK
215  U32 key[96]; /* Max size == 3DES */
216  U8 tdea;
217  #else
218 
219  #if (SHARKSSL_USE_CAU || SHARKSSL_USE_MMCAU)
220  #if SHARKSSL_USE_3DES
221  U32 key[6];
222  #else
223  U32 key[2];
224  #endif
225 
226  #else
227 
228  #if SHARKSSL_USE_3DES
229  U32 key[96];
230  #else
231  U32 key[32];
232  #endif
233  #endif
234 
235  #if (SHARKSSL_USE_DES && SHARKSSL_USE_3DES)
236  U8 tdea;
237  #endif
238 
239  #endif
241 
242 
243 /* Encrypt/decrypt type */
244 typedef enum
245 {
246  SharkSslDesCtx_Decrypt,
247  SharkSslDesCtx_Encrypt
248 } SharkSslDesCtx_Type;
249 #endif
250 
251 
252 #if (SHARKSSL_USE_AES_256 || SHARKSSL_USE_AES_192 || SHARKSSL_USE_AES_128)
253 
256 typedef struct SharkSslAesCtx
257 {
258  #if (SHARKSSL_USE_AES_256 || SHARKSSL_NOPACK)
259  U32 key[60];
260  #elif SHARKSSL_USE_AES_192
261  U32 key[52];
262  #else
263  U32 key[44];
264  #endif
265  U16 nr;
267 
268 typedef enum
269 {
270  SharkSslAesCtx_Decrypt,
271  SharkSslAesCtx_Encrypt
272 } SharkSslAesCtx_Type;
273 
274 #if SHARKSSL_ENABLE_AES_GCM
275 
278 typedef struct SharkSslAesGcmCtx
279 {
280  SharkSslAesCtx super;
281  U8 M0[16][16];
283 #endif
284 
285 #if SHARKSSL_ENABLE_AES_CCM
286 
289 typedef struct SharkSslAesCcmCtx
290 {
291  SharkSslAesCtx super;
292  U8 tagLen;
294 #endif
295 #endif /* SHARKSSL_USE_AES_256 || SHARKSSL_USE_AES_192 || SHARKSSL_USE_AES_128 */
296 
297 
298 #ifdef __cplusplus
299 extern "C" {
300 #endif
301 
302 /* SharkSslCrypto.c */
303 SHARKSSL_API int sharkssl_entropy(U32);
304 SHARKSSL_API int sharkssl_rng(U8*, U16);
305 SHARKSSL_API int sharkssl_kmemcmp(const void *a, const void *b, U32 n);
306 
307 
308 #if SHARKSSL_USE_MD5
309 
315 
319 SHARKSSL_API void SharkSslMd5Ctx_append(SharkSslMd5Ctx* ctx, const U8* data, U32 len);
320 
324 SHARKSSL_API void SharkSslMd5Ctx_finish(SharkSslMd5Ctx* ctx, U8 digest[SHARKSSL_MD5_HASH_LEN]);
325 
329 SHARKSSL_API int sharkssl_md5(const U8*, U16, U8*);
330 #endif
331 
332 #if SHARKSSL_USE_SHA1
333 
339 
343 SHARKSSL_API void SharkSslSha1Ctx_append(SharkSslSha1Ctx* ctx, const U8* data, U32 len);
344 
348 SHARKSSL_API void SharkSslSha1Ctx_finish(SharkSslSha1Ctx*, U8 digest[SHARKSSL_SHA1_HASH_LEN]);
349 
353 SHARKSSL_API int sharkssl_sha1(const U8*, U16, U8*);
354 #endif
355 
356 #if SHARKSSL_USE_SHA_256
357 
363 
367 SHARKSSL_API void SharkSslSha256Ctx_append(SharkSslSha256Ctx*, const U8* data, U32 len);
368 
372 SHARKSSL_API void SharkSslSha256Ctx_finish(SharkSslSha256Ctx*, U8 digest[SHARKSSL_SHA256_HASH_LEN]);
373 
377 SHARKSSL_API int sharkssl_sha256(const U8*, U16, U8*);
378 #endif
379 
380 #if SHARKSSL_USE_SHA_384
381 
387 
391 SHARKSSL_API void SharkSslSha384Ctx_append(SharkSslSha384Ctx*, const U8* data, U32 len);
392 
396 SHARKSSL_API void SharkSslSha384Ctx_finish(SharkSslSha384Ctx*, U8 digest[SHARKSSL_SHA384_HASH_LEN]);
397 
401 SHARKSSL_API int sharkssl_sha384(const U8*, U16, U8*);
402 #endif
403 
404 #if SHARKSSL_USE_SHA_512
405 
411 
415 #define SharkSslSha512Ctx_append(ctx, d, l) \
416  SharkSslSha384Ctx_append((SharkSslSha384Ctx*)ctx, d, l)
417 
421 SHARKSSL_API void SharkSslSha512Ctx_finish(SharkSslSha512Ctx*, U8 digest[SHARKSSL_SHA512_HASH_LEN]);
422 
426 SHARKSSL_API int sharkssl_sha512(const U8*, U16, U8*);
427 #endif
428 
429 #if SHARKSSL_HMAC_API && (SHARKSSL_USE_SHA_512 || SHARKSSL_USE_SHA_384 || SHARKSSL_USE_SHA_256 || SHARKSSL_USE_SHA1 || SHARKSSL_USE_MD5)
430 
439 SHARKSSL_API void SharkSslHMACCtx_constructor(SharkSslHMACCtx* ctx, U8 hashID, const U8* key, U16 keyLen);
440 
444 SHARKSSL_API void SharkSslHMACCtx_append(SharkSslHMACCtx*, const U8* data, U32 len);
445 
449 SHARKSSL_API void SharkSslHMACCtx_finish(SharkSslHMACCtx*, U8 *HMAC);
450 
451 #define SharkSslHMACCtx_destructor(o) memset(o, 0, sizeof(SharkSslHMACCtx))
452 
464 SHARKSSL_API int sharkssl_HMAC(const U8 hashID, const U8 *data, U16 len, const U8 *key, U16 keyLen, U8 *digest);
465 #endif
466 
467 #if ((SHARKSSL_SSL_CLIENT_CODE && (SHARKSSL_ENABLE_RSA || SHARKSSL_ENABLE_ECDSA)) || \
468  (SHARKSSL_SSL_SERVER_CODE) || \
469  ((SHARKSSL_HMAC_API || SHARKSSL_CSR_API) && (SHARKSSL_USE_SHA_512 || SHARKSSL_USE_SHA_384 || SHARKSSL_USE_SHA_256 || SHARKSSL_USE_SHA1 || SHARKSSL_USE_MD5)))
470 U16 sharkssl_getHashLen(U8 hashID);
471 int sharkssl_hash(U8 *digest, U8 *data, U16 len, U8 hashID);
472 #endif
473 
474 
475 #if SHARKSSL_USE_POLY1305
476 
482 SHARKSSL_API void SharkSslPoly1305Ctx_constructor(SharkSslPoly1305Ctx *ctx, const U8 key[32]);
483 
484 #define SharkSslPoly1305Ctx_destructor(o) memset(o, 0, sizeof(SharkSslPoly1305Ctx))
485 
489 SHARKSSL_API void SharkSslPoly1305Ctx_append(SharkSslPoly1305Ctx *ctx, const U8 *in, U32 len);
490 
494 SHARKSSL_API void SharkSslPoly1305Ctx_finish(SharkSslPoly1305Ctx *ctx, U8 digest[SHARKSSL_POLY1305_HASH_LEN]);
495 
499 SHARKSSL_API int sharkssl_poly1305(const U8 *data, U16 len, U8 *digest, const U8 key[32]);
500 #endif
501 
502 #if SHARKSSL_USE_CHACHA20
503 
511  const U8 *key, U8 keyLen);
512 
513 #define SharkSslChaChaCtx_destructor(ctx) memset(ctx, 0, sizeof(SharkSslChaChaCtx))
514 
521 SHARKSSL_API void SharkSslChaChaCtx_setIV(SharkSslChaChaCtx *ctx, const U8 IV[12]);
522 
526 SHARKSSL_API void SharkSslChaChaCtx_crypt(
527  SharkSslChaChaCtx *ctx, const U8 *input, U8 *output, U32 len);
528 #endif
529 
530 #if SHARKSSL_USE_ARC4
531 
535 SHARKSSL_API void SharkSslArc4Ctx_constructor(SharkSslArc4Ctx *ctx,
536  const U8 *key, U8 keyLen);
537 
538 #define SharkSslArc4Ctx_destructor(ctx) memset(ctx, 0, sizeof(SharkSslArc4Ctx))
539 
543 SHARKSSL_API void SharkSslArc4Ctx_crypt(
544  SharkSslArc4Ctx *ctx, U8 *input, U8 *output, U16 len);
545 #endif
546 
547 #if (SHARKSSL_USE_DES || SHARKSSL_USE_3DES)
548 
557  SharkSslDesCtx_Type type,
558  const U8 *key, U8 keyLen);
559 #define SharkSslDesCtx_destructor(ctx) memset(ctx, 0, sizeof(SharkSslDesCtx))
560 
564 SHARKSSL_API void SharkSslDesCtx_encrypt(
565  SharkSslDesCtx *ctx, const U8 input[8], U8 output[8]);
566 #if (SHARKSSL_USE_CAU || SHARKSSL_USE_MMCAU)
567 
571 SHARKSSL_API void SharkSslDesCtx_decrypt(
572  SharkSslDesCtx *ctx, U8 input[8], U8 output[8]);
573 #else
574 #define SharkSslDesCtx_decrypt(ctx,i,o) SharkSslDesCtx_encrypt((ctx),(i),(o))
575 #endif
576 
580 SHARKSSL_API void SharkSslDesCtx_cbc_encrypt(SharkSslDesCtx *ctx, U8 vect[8],
581  const U8 *input, U8 *output, U16 len);
582 
586 SHARKSSL_API void SharkSslDesCtx_cbc_decrypt(SharkSslDesCtx *ctx, U8 vect[8],
587  const U8 *input, U8 *output, U16 len);
588 #endif
589 
590 #if (SHARKSSL_USE_AES_256 || SHARKSSL_USE_AES_192 || SHARKSSL_USE_AES_128)
591 
600  SharkSslAesCtx_Type type,
601  const U8 *key, U8 keyLen);
602 #define SharkSslAesCtx_destructor(ctx) memset(ctx, 0, sizeof(SharkSslAesCtx))
603 
604 #if (!SHARKSSL_DISABLE_AES_ECB_DECRYPT)
605 
608 SHARKSSL_API void SharkSslAesCtx_decrypt(SharkSslAesCtx *ctx, const U8 input[16], U8 output[16]);
609 #endif
610 
614 SHARKSSL_API void SharkSslAesCtx_encrypt(SharkSslAesCtx *ctx, U8 input[16], U8 output[16]);
615 
616 #if (!SHARKSSL_DISABLE_AES_CBC_MODE)
617 
620 SHARKSSL_API void SharkSslAesCtx_cbc_encrypt(SharkSslAesCtx *ctx, U8 vect[16],
621  const U8 *input, U8 *output, U16 len);
622 
626 SHARKSSL_API void SharkSslAesCtx_cbc_decrypt(SharkSslAesCtx *ctx, U8 vect[16],
627  const U8 *input, U8 *output, U16 len);
628 #endif
629 #if SHARKSSL_ENABLE_AES_CTR_MODE
630 
634 SHARKSSL_API void SharkSslAesCtx_ctr_mode(SharkSslAesCtx *ctx, U8 ctr[16],
635  const U8 *input, U8 *output, U16 len);
636 #endif
637 #if SHARKSSL_ENABLE_AES_GCM
638 
646  const U8 *key, U8 keyLen);
647 
648 #define SharkSslAesGcmCtx_destructor(ctx) \
649  memset(ctx, 0, sizeof(SharkSslAesGcmCtx))
650 
681  const U8 vect[12], U8 tagout[16],
682  const U8 *auth, U16 authlen,
683  const U8 *input, U8 *output, U16 len);
684 
685 
701  const U8 vect[12], U8 tagin[16],
702  const U8 *auth, U16 authlen,
703  U8 *input, U8 *output, U16 len);
704 #endif
705 #if SHARKSSL_ENABLE_AES_CCM
706 
715  const U8 *key, U8 keyLen, U8 tagLen);
716 
717 #define SharkSslAesCcmCtx_destructor(ctx) memset(ctx, 0, sizeof(SharkSslAesCcmCtx))
718 
723  const U8 vect[12], U8 *tagout,
724  const U8 *auth, U16 authlen,
725  const U8 *input, U8 *output, U16 len);
726 
727 
732  const U8 vect[12], U8 *tagin,
733  const U8 *auth, U16 authlen,
734  const U8 *input, U8 *output, U16 len);
735 #endif
736 #endif
737 
738 #ifdef __cplusplus
739 }
740 #endif
741 
742 
743 #endif /* _SharkSslCrypto_h */
SharkSslSha384Ctx_append
SHARKSSL_API void SharkSslSha384Ctx_append(SharkSslSha384Ctx *, const U8 *data, U32 len)
append
SharkSslSha384Ctx_constructor
SHARKSSL_API void SharkSslSha384Ctx_constructor(SharkSslSha384Ctx *ctx)
Initialize.
SharkSslDesCtx
struct SharkSslDesCtx SharkSslDesCtx
DES.
SharkSslAesCcmCtx_constructor
SHARKSSL_API void SharkSslAesCcmCtx_constructor(SharkSslAesCcmCtx *ctx, const U8 *key, U8 keyLen, U8 tagLen)
Initialize.
SharkSslMd5Ctx_constructor
SHARKSSL_API void SharkSslMd5Ctx_constructor(SharkSslMd5Ctx *ctx)
Initialize.
SharkSslAesCcmCtx_decrypt
SHARKSSL_API int SharkSslAesCcmCtx_decrypt(SharkSslAesCcmCtx *ctx, const U8 vect[12], U8 *tagin, const U8 *auth, U16 authlen, const U8 *input, U8 *output, U16 len)
Decrypt.
SharkSslAesGcmCtx
AesGcmCtx.
Definition: SharkSslCrypto.h:279
SharkSslAesCtx_decrypt
SHARKSSL_API void SharkSslAesCtx_decrypt(SharkSslAesCtx *ctx, const U8 input[16], U8 output[16])
Decrypt.
SharkSslChaChaCtx_setIV
SHARKSSL_API void SharkSslChaChaCtx_setIV(SharkSslChaChaCtx *ctx, const U8 IV[12])
Initialize.
SharkSslAesCtx
struct SharkSslAesCtx SharkSslAesCtx
AES.
SharkSslSha1Ctx
struct SharkSslSha1Ctx SharkSslSha1Ctx
SHA1.
SharkSslSha1Ctx
SHA1.
Definition: SharkSslCrypto.h:84
SharkSslSha384Ctx_finish
SHARKSSL_API void SharkSslSha384Ctx_finish(SharkSslSha384Ctx *, U8 digest[SHARKSSL_SHA384_HASH_LEN])
finish
SharkSslPoly1305Ctx
struct SharkSslPoly1305Ctx SharkSslPoly1305Ctx
POLY1305.
SharkSslAesCtx_cbc_decrypt
SHARKSSL_API void SharkSslAesCtx_cbc_decrypt(SharkSslAesCtx *ctx, U8 vect[16], const U8 *input, U8 *output, U16 len)
Decrypt.
SharkSslMd5Ctx_finish
SHARKSSL_API void SharkSslMd5Ctx_finish(SharkSslMd5Ctx *ctx, U8 digest[SHARKSSL_MD5_HASH_LEN])
finish
SharkSslAesCcmCtx
AesCcmCtx.
Definition: SharkSslCrypto.h:290
SharkSslPoly1305Ctx_finish
SHARKSSL_API void SharkSslPoly1305Ctx_finish(SharkSslPoly1305Ctx *ctx, U8 digest[SHARKSSL_POLY1305_HASH_LEN])
finish
SharkSslSha384Ctx
struct SharkSslSha384Ctx SharkSslSha384Ctx
SHA384.
SharkSslAesGcmCtx_encrypt
SHARKSSL_API int SharkSslAesGcmCtx_encrypt(SharkSslAesGcmCtx *ctx, const U8 vect[12], U8 tagout[16], const U8 *auth, U16 authlen, const U8 *input, U8 *output, U16 len)
Encrypt data or a chunk of a large data set.
SharkSslSha1Ctx_constructor
SHARKSSL_API void SharkSslSha1Ctx_constructor(SharkSslSha1Ctx *ctx)
Initialize.
SharkSslSha256Ctx
SHA256.
Definition: SharkSslCrypto.h:97
SharkSslHMACCtx_append
SHARKSSL_API void SharkSslHMACCtx_append(SharkSslHMACCtx *, const U8 *data, U32 len)
append
SharkSslAesCtx_constructor
SHARKSSL_API void SharkSslAesCtx_constructor(SharkSslAesCtx *ctx, SharkSslAesCtx_Type type, const U8 *key, U8 keyLen)
Initialize.
SharkSslSha1Ctx_append
SHARKSSL_API void SharkSslSha1Ctx_append(SharkSslSha1Ctx *ctx, const U8 *data, U32 len)
append
SharkSslAesCtx_encrypt
SHARKSSL_API void SharkSslAesCtx_encrypt(SharkSslAesCtx *ctx, U8 input[16], U8 output[16])
Encrypt.
SharkSslPoly1305Ctx_constructor
SHARKSSL_API void SharkSslPoly1305Ctx_constructor(SharkSslPoly1305Ctx *ctx, const U8 key[32])
Initialize.
SharkSslHMACCtx
HMAC.
Definition: SharkSslCrypto.h:131
SharkSslHMACCtx
struct SharkSslHMACCtx SharkSslHMACCtx
HMAC.
SharkSslPoly1305Ctx_append
SHARKSSL_API void SharkSslPoly1305Ctx_append(SharkSslPoly1305Ctx *ctx, const U8 *in, U32 len)
append
SharkSslAesCcmCtx
struct SharkSslAesCcmCtx SharkSslAesCcmCtx
AesCcmCtx.
SharkSslPoly1305Ctx
POLY1305.
Definition: SharkSslCrypto.h:174
SharkSslMd5Ctx
struct SharkSslMd5Ctx SharkSslMd5Ctx
MD5.
sharkssl_HMAC
SHARKSSL_API int sharkssl_HMAC(const U8 hashID, const U8 *data, U16 len, const U8 *key, U16 keyLen, U8 *digest)
HMAC.
SharkSslDesCtx_decrypt
SHARKSSL_API void SharkSslDesCtx_decrypt(SharkSslDesCtx *ctx, U8 input[8], U8 output[8])
Decrypt.
SharkSslAesGcmCtx_constructor
SHARKSSL_API void SharkSslAesGcmCtx_constructor(SharkSslAesGcmCtx *ctx, const U8 *key, U8 keyLen)
Initialize.
SharkSslMd5Ctx
MD5.
Definition: SharkSslCrypto.h:71
sharkssl_sha1
SHARKSSL_API int sharkssl_sha1(const U8 *, U16, U8 *)
sha1
SharkSslAesCtx_cbc_encrypt
SHARKSSL_API void SharkSslAesCtx_cbc_encrypt(SharkSslAesCtx *ctx, U8 vect[16], const U8 *input, U8 *output, U16 len)
Encrypt.
sharkssl_sha512
SHARKSSL_API int sharkssl_sha512(const U8 *, U16, U8 *)
sha512
SharkSslAesCtx
AES.
Definition: SharkSslCrypto.h:257
SharkSslDesCtx
DES.
Definition: SharkSslCrypto.h:213
sharkssl_sha384
SHARKSSL_API int sharkssl_sha384(const U8 *, U16, U8 *)
sha384
SharkSslDesCtx_encrypt
SHARKSSL_API void SharkSslDesCtx_encrypt(SharkSslDesCtx *ctx, const U8 input[8], U8 output[8])
Encrypt.
SharkSslChaChaCtx_constructor
SHARKSSL_API void SharkSslChaChaCtx_constructor(SharkSslChaChaCtx *ctx, const U8 *key, U8 keyLen)
Initialize.
SharkSslChaChaCtx
CHACHA20.
Definition: SharkSslCrypto.h:189
sharkssl_poly1305
SHARKSSL_API int sharkssl_poly1305(const U8 *data, U16 len, U8 *digest, const U8 key[32])
poly1305
SharkSslHMACCtx_constructor
SHARKSSL_API void SharkSslHMACCtx_constructor(SharkSslHMACCtx *ctx, U8 hashID, const U8 *key, U16 keyLen)
Initialize.
SharkSslAesGcmCtx_decrypt
SHARKSSL_API int SharkSslAesGcmCtx_decrypt(SharkSslAesGcmCtx *ctx, const U8 vect[12], U8 tagin[16], const U8 *auth, U16 authlen, U8 *input, U8 *output, U16 len)
Decrypt data or a chunk of a large data set.
SharkSslHMACCtx_finish
SHARKSSL_API void SharkSslHMACCtx_finish(SharkSslHMACCtx *, U8 *HMAC)
finish
SharkSslDesCtx_cbc_encrypt
SHARKSSL_API void SharkSslDesCtx_cbc_encrypt(SharkSslDesCtx *ctx, U8 vect[8], const U8 *input, U8 *output, U16 len)
Encrypt.
SharkSslMd5Ctx_append
SHARKSSL_API void SharkSslMd5Ctx_append(SharkSslMd5Ctx *ctx, const U8 *data, U32 len)
append
SharkSslSha256Ctx_finish
SHARKSSL_API void SharkSslSha256Ctx_finish(SharkSslSha256Ctx *, U8 digest[SHARKSSL_SHA256_HASH_LEN])
finish
SharkSslSha1Ctx_finish
SHARKSSL_API void SharkSslSha1Ctx_finish(SharkSslSha1Ctx *, U8 digest[SHARKSSL_SHA1_HASH_LEN])
finish
sharkssl_sha256
SHARKSSL_API int sharkssl_sha256(const U8 *, U16, U8 *)
sha256
SharkSslAesCcmCtx_encrypt
SHARKSSL_API int SharkSslAesCcmCtx_encrypt(SharkSslAesCcmCtx *ctx, const U8 vect[12], U8 *tagout, const U8 *auth, U16 authlen, const U8 *input, U8 *output, U16 len)
Encrypt.
SharkSslSha512Ctx_constructor
SHARKSSL_API void SharkSslSha512Ctx_constructor(SharkSslSha512Ctx *ctx)
Initialize.
SharkSslDesCtx_constructor
SHARKSSL_API void SharkSslDesCtx_constructor(SharkSslDesCtx *ctx, SharkSslDesCtx_Type type, const U8 *key, U8 keyLen)
Initialize.
sharkssl_md5
SHARKSSL_API int sharkssl_md5(const U8 *, U16, U8 *)
md5
SharkSslSha512Ctx_finish
SHARKSSL_API void SharkSslSha512Ctx_finish(SharkSslSha512Ctx *, U8 digest[SHARKSSL_SHA512_HASH_LEN])
finish
SharkSslSha256Ctx_constructor
SHARKSSL_API void SharkSslSha256Ctx_constructor(SharkSslSha256Ctx *ctx)
Initialize.
SharkSslDesCtx_cbc_decrypt
SHARKSSL_API void SharkSslDesCtx_cbc_decrypt(SharkSslDesCtx *ctx, U8 vect[8], const U8 *input, U8 *output, U16 len)
Decrypt.
SharkSslAesGcmCtx
struct SharkSslAesGcmCtx SharkSslAesGcmCtx
AesGcmCtx.
SharkSslSha384Ctx
SHA384.
Definition: SharkSslCrypto.h:110
SharkSslSha256Ctx
struct SharkSslSha256Ctx SharkSslSha256Ctx
SHA256.
SharkSslSha256Ctx_append
SHARKSSL_API void SharkSslSha256Ctx_append(SharkSslSha256Ctx *, const U8 *data, U32 len)
append
SharkSslChaChaCtx_crypt
SHARKSSL_API void SharkSslChaChaCtx_crypt(SharkSslChaChaCtx *ctx, const U8 *input, U8 *output, U32 len)
Encrypt or decrypt.