Virgil IoT KIT
secmodule-helpers.h
Go to the documentation of this file.
1 // Copyright (C) 2015-2020 Virgil Security, Inc.
2 //
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // (1) Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 //
12 // (2) Redistributions in binary form must reproduce the above copyright
13 // notice, this list of conditions and the following disclaimer in
14 // the documentation and/or other materials provided with the
15 // distribution.
16 //
17 // (3) Neither the name of the copyright holder nor the names of its
18 // contributors may be used to endorse or promote products derived from
19 // this software without specific prior written permission.
20 //
21 // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR
22 // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 // DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
25 // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
29 // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
30 // IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 // POSSIBILITY OF SUCH DAMAGE.
32 //
33 // Lead Maintainer: Virgil Security Inc. <support@virgilsecurity.com>
34 
42 #ifndef VS_SECMODULE_HELPERS_H_
43 #define VS_SECMODULE_HELPERS_H_
44 
45 #ifdef __cplusplus
46 namespace VirgilIoTKit {
47 extern "C" {
48 #endif
49 
51 
52 #define VS_PUBKEY_SECP192_LEN (49)
53 #define VS_PUBKEY_SECP224_LEN (57)
54 #define VS_PUBKEY_SECP256_LEN (65)
55 #define VS_PUBKEY_SECP384_LEN (97)
56 #define VS_PUBKEY_SECP521_LEN (133)
57 #define VS_PUBKEY_25519_LEN (32)
58 
59 #define VS_SIGNATURE_SECP192_LEN (48)
60 #define VS_SIGNATURE_SECP224_LEN (56)
61 #define VS_SIGNATURE_SECP256_LEN (64)
62 #define VS_SIGNATURE_SECP384_LEN (96)
63 #define VS_SIGNATURE_SECP521_LEN (132)
64 #define VS_SIGNATURE_25519_LEN (64)
65 
66 #define VS_HASH_SHA256_LEN (32)
67 #define VS_HASH_SHA384_LEN (48)
68 #define VS_HASH_SHA512_LEN (64)
69 
70 #define VS_AES_256_KEY_SIZE (32)
71 #define VS_AES_256_KEY_BITLEN (VS_AES_256_KEY_SIZE * 8)
72 #define VS_AES_256_BLOCK_SIZE (16)
73 
74 #define VS_AES_256_GCM_IV_SIZE (12)
75 #define VS_AES_256_GCM_AUTH_TAG_SIZE (16)
76 
77 #define VS_AES_256_CBC_IV_SIZE (16)
78 
87 int
89 
98 int
100 
109 int
111 
120 const char *
122 
131 const char *
133 
144 vs_secmodule_virgil_secp256_signature_to_tiny(const uint8_t *virgil_sign,
145  uint16_t virgil_sign_sz,
146  uint8_t *raw_signature,
147  uint16_t buf_sz);
148 
160  uint8_t *virgil_sign,
161  uint16_t buf_sz,
162  uint16_t *virgil_sign_sz);
163 
164 #ifdef __cplusplus
165 } // extern "C"
166 } // namespace VirgilIoTKit
167 #endif
168 
169 #endif // VS_SECMODULE_HELPERS_H_
vs_secmodule_tiny_secp256_signature_to_virgil
vs_status_e vs_secmodule_tiny_secp256_signature_to_virgil(const uint8_t raw_signature[VS_SIGNATURE_SECP256_LEN], uint8_t *virgil_sign, uint16_t buf_sz, uint16_t *virgil_sign_sz)
Convert a NIST-256 signature from raw format to Virgil format.
vs_status_e
vs_status_e
Status code.
Definition: status_code.h:77
vs_secmodule_keypair_type_descr
const char * vs_secmodule_keypair_type_descr(vs_secmodule_keypair_type_e type)
Get key pair type description.
VS_SIGNATURE_SECP256_LEN
#define VS_SIGNATURE_SECP256_LEN
Definition: secmodule-helpers.h:61
vs_secmodule_get_signature_len
int vs_secmodule_get_signature_len(vs_secmodule_keypair_type_e keypair_type)
Get signature length.
vs_secmodule_hash_type_e
vs_secmodule_hash_type_e
Hash types.
Definition: secmodule.h:94
vs_secmodule_keypair_type_e
vs_secmodule_keypair_type_e
Keypair types.
Definition: secmodule.h:76
vs_secmodule_hash_type_descr
const char * vs_secmodule_hash_type_descr(vs_secmodule_hash_type_e type)
Get hash type description.
vs_secmodule_get_hash_len
int vs_secmodule_get_hash_len(vs_secmodule_hash_type_e hash_type)
Get hash length.
vs_secmodule_virgil_secp256_signature_to_tiny
vs_status_e vs_secmodule_virgil_secp256_signature_to_tiny(const uint8_t *virgil_sign, uint16_t virgil_sign_sz, uint8_t *raw_signature, uint16_t buf_sz)
Convert a NIST256 signature from a Virgil format to raw.
vs_secmodule_get_pubkey_len
int vs_secmodule_get_pubkey_len(vs_secmodule_keypair_type_e keypair_type)
Get public key length.
secmodule.h
Security Module implementations signatures.