wickr-crypto-c
digest.h
1 /*
2  * Copyright © 2012-2020 Wickr Inc. All rights reserved.
3  *
4  * This code is being released for EDUCATIONAL, ACADEMIC, AND CODE REVIEW PURPOSES
5  * ONLY. COMMERCIAL USE OF THE CODE IS EXPRESSLY PROHIBITED. For additional details,
6  * please see LICENSE
7  *
8  * THE CODE IS MADE AVAILABLE "AS-IS" AND WITHOUT ANY EXPRESS OR
9  * IMPLIED GUARANTEES AS TO FITNESS, MERCHANTABILITY, NON-
10  * INFRINGEMENT OR OTHERWISE. IT IS NOT BEING PROVIDED IN TRADE BUT ON
11  * A VOLUNTARY BASIS ON BEHALF OF THE AUTHOR’S PART FOR THE BENEFIT
12  * OF THE LICENSEE AND IS NOT MADE AVAILABLE FOR CONSUMER USE OR ANY
13  * OTHER USE OUTSIDE THE TERMS OF THIS LICENSE. ANYONE ACCESSING THE
14  * CODE SHOULD HAVE THE REQUISITE EXPERTISE TO SECURE THEIR SYSTEM
15  * AND DEVICES AND TO ACCESS AND USE THE CODE FOR REVIEW PURPOSES
16  * ONLY. LICENSEE BEARS THE RISK OF ACCESSING AND USING THE CODE. IN
17  * PARTICULAR, AUTHOR BEARS NO LIABILITY FOR ANY INTERFERENCE WITH OR
18  * ADVERSE EFFECT THAT MAY OCCUR AS A RESULT OF THE LICENSEE
19  * ACCESSING AND/OR USING THE CODE ON LICENSEE’S SYSTEM.
20  */
21 
22 #ifndef digest_h
23 #define digest_h
24 
25 #include <stdlib.h>
26 #include <stdint.h>
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 typedef enum { DIGEST_SHA2 } wickr_digest_type;
33 typedef enum { DIGEST_ID_SHA256 = 1, DIGEST_ID_SHA384, DIGEST_ID_SHA512 } wickr_digest_id;
34 
54 struct wickr_digest {
55  wickr_digest_type type;
56  wickr_digest_id digest_id;
57  uint8_t size;
58 };
59 
60 typedef struct wickr_digest wickr_digest_t;
61 
62 #define SHA256_DIGEST_SIZE 32
63 #define SHA384_DIGEST_SIZE 48
64 #define SHA512_DIGEST_SIZE 64
65 
66 static const wickr_digest_t DIGEST_SHA_256 = { DIGEST_SHA2, DIGEST_ID_SHA256, SHA256_DIGEST_SIZE };
67 static const wickr_digest_t DIGEST_SHA_384 = { DIGEST_SHA2, DIGEST_ID_SHA384, SHA384_DIGEST_SIZE };
68 static const wickr_digest_t DIGEST_SHA_512 = { DIGEST_SHA2, DIGEST_ID_SHA512, SHA512_DIGEST_SIZE };
69 
80 
81 #ifdef __cplusplus
82 }
83 #endif
84 
85 #endif /* digest_h */
wickr_digest::digest_id
wickr_digest_id digest_id
Definition: digest.h:56
wickr_digest::type
wickr_digest_type type
Definition: digest.h:55
wickr_digest
Digest function parameters.
Definition: digest.h:54
wickr_digest::size
uint8_t size
Definition: digest.h:57
wickr_digest_find_with_id
const wickr_digest_t * wickr_digest_find_with_id(uint8_t digest_id)