Virgil IoT KIT
crypto_format_converters.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2016 Virgil Security Inc.
3 //
4 // Lead Maintainer: Virgil Security Inc. <support@virgilsecurity.com>
5 //
6 // All rights reserved.
7 //
8 // Redistribution and use in source and binary forms, with or without
9 // modification, are permitted provided that the following conditions are
10 // met:
11 //
12 // (1) Redistributions of source code must retain the above copyright
13 // notice, this list of conditions and the following disclaimer.
14 //
15 // (2) Redistributions in binary form must reproduce the above copyright
16 // notice, this list of conditions and the following disclaimer in
17 // the documentation and/or other materials provided with the
18 // distribution.
19 //
20 // (3) Neither the name of the copyright holder nor the names of its
21 // contributors may be used to endorse or promote products derived from
22 // this software without specific prior written permission.
23 //
24 // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR
25 // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 // DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
28 // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
32 // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
33 // IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 // POSSIBILITY OF SUCH DAMAGE.
35 //
36 
55 #ifndef VS_CRYPTO_CONVERTERS_H
56 #define VS_CRYPTO_CONVERTERS_H
57 
58 #include <stdbool.h>
59 #include <stdint.h>
60 #include <stdlib.h>
62 
63 #ifdef __cplusplus
64 namespace VirgilIoTKit {
65 extern "C" {
66 #endif
67 
79 bool
81  const uint8_t *public_key,
82  uint16_t public_key_sz,
83  uint8_t *pubkey_raw,
84  uint16_t buf_sz,
85  uint16_t *pubkey_raw_sz);
86 
98 bool
100  const uint8_t *public_key_in,
101  uint16_t public_key_in_sz,
102  uint8_t *public_key_out,
103  uint16_t buf_sz,
104  uint16_t *public_key_out_sz);
105 
117 bool
119  const uint8_t *virgil_sign,
120  uint16_t virgil_sign_sz,
121  uint8_t *sign,
122  uint16_t buf_sz,
123  uint16_t *sign_sz);
124 
137 bool
139  vs_secmodule_hash_type_e hash_type,
140  const uint8_t *raw_sign,
141  uint16_t raw_sign_sz,
142  uint8_t *virgil_sign,
143  uint16_t buf_sz,
144  uint16_t *virgil_sign_sz);
145 
157 bool
159  uint8_t *mbedtls_sign,
160  uint16_t mbedtls_sign_sz,
161  uint8_t *raw_sign,
162  uint16_t buf_sz,
163  uint16_t *raw_sz);
164 
176 bool
178  const unsigned char *raw,
179  uint16_t raw_sz,
180  unsigned char *signature,
181  uint16_t buf_sz,
182  uint16_t *signature_sz);
183 
184 #ifdef __cplusplus
185 } // extern "C"
186 } // namespace VirgilIoTKit
187 #endif
188 
189 #endif // VS_CRYPTO_CONVERTERS_H
vs_converters_virgil_sign_to_raw
bool vs_converters_virgil_sign_to_raw(vs_secmodule_keypair_type_e keypair_type, const uint8_t *virgil_sign, uint16_t virgil_sign_sz, uint8_t *sign, uint16_t buf_sz, uint16_t *sign_sz)
Convert signature from Virgil format to raw format.
vs_converters_raw_sign_to_virgil
bool vs_converters_raw_sign_to_virgil(vs_secmodule_keypair_type_e keypair_type, vs_secmodule_hash_type_e hash_type, const uint8_t *raw_sign, uint16_t raw_sign_sz, uint8_t *virgil_sign, uint16_t buf_sz, uint16_t *virgil_sign_sz)
Convert signature from raw format to Virgil format.
vs_converters_mbedtls_sign_to_raw
bool vs_converters_mbedtls_sign_to_raw(vs_secmodule_keypair_type_e keypair_type, uint8_t *mbedtls_sign, uint16_t mbedtls_sign_sz, uint8_t *raw_sign, uint16_t buf_sz, uint16_t *raw_sz)
Convert signature from MbedTLS format to raw format.
vs_converters_pubkey_to_raw
bool vs_converters_pubkey_to_raw(vs_secmodule_keypair_type_e keypair_type, const uint8_t *public_key, uint16_t public_key_sz, uint8_t *pubkey_raw, uint16_t buf_sz, uint16_t *pubkey_raw_sz)
Convert public key from Virgil format to raw format.
vs_converters_raw_sign_to_mbedtls
bool vs_converters_raw_sign_to_mbedtls(vs_secmodule_keypair_type_e keypair_type, const unsigned char *raw, uint16_t raw_sz, unsigned char *signature, uint16_t buf_sz, uint16_t *signature_sz)
Convert signature from raw format to MbedTLS format.
vs_secmodule_hash_type_e
vs_secmodule_hash_type_e
Hash types.
Definition: secmodule.h:94
vs_converters_pubkey_to_virgil
bool vs_converters_pubkey_to_virgil(vs_secmodule_keypair_type_e keypair_type, const uint8_t *public_key_in, uint16_t public_key_in_sz, uint8_t *public_key_out, uint16_t buf_sz, uint16_t *public_key_out_sz)
Convert public key from raw format to Virgil format.
vs_secmodule_keypair_type_e
vs_secmodule_keypair_type_e
Keypair types.
Definition: secmodule.h:76
secmodule.h
Security Module implementations signatures.