Virgil IoT KIT
Functions
crypto_format_converters.h File Reference

Cryptographic converters. More...

#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <virgil/iot/secmodule/secmodule.h>

Go to the source code of this file.

Functions

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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 

Detailed Description

Cryptographic converters.

This file covers the following conversion cases :

Function Documentation

◆ 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.

Parameters
[in]keypair_typeKeypair type.
[in]mbedtls_signSource signature in MbedTLS format. Must not be NULL.
[in]mbedtls_sign_szSource signature size. Must not be zero.
[out]raw_signDestination buffer for signature in raw format. Must not be NULL.
[in]buf_szOutput buffer size. Must not be zero.
[in]raw_szPointer to saved signature size. Must not be NULL.
Returns
true in case of success and false otherwise

◆ 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.

Parameters
[in]keypair_typeKeypair type.
[in]public_keySource public key in Virgil format. Must not be NULL.
[in]public_key_szSource public key size. Must not be zero.
[out]pubkey_rawDestination buffer for public key in raw format. Must not be NULL.
[in]buf_szOutput buffer size. Must not be zero.
[in]pubkey_raw_szPointer for saved public key size. Must not be NULL.
Returns
true in case of success or false otherwise

◆ 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.

Parameters
[in]keypair_typeKeypair type.
[in]public_key_inSource public key in raw format. Must not be NULL.
[in]public_key_in_szSource public key size. Must not be zero.
[out]public_key_outDestination buffer for public key in Virgil format. Must not be NULL.
[in]buf_szOutput buffer size. Must not be zero.
[in]public_key_out_szPointer for saved public key size. Must not be NULL.
Returns
true in case of success or false otherwise

◆ 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.

Parameters
[in]keypair_typeKeypair type.
[in]rawSource signature in raw format. Must not be NULL.
[in]raw_szSource signature size. Must not be zero.
[out]signatureDestination buffer for signature in MbedTLS format. Must not be NULL.
[in]buf_szOutput buffer size. Must not be zero.
[in]signature_szPointer to saved signature size. Must not be NULL.
Returns
true in case of success and false otherwise

◆ 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.

Parameters
[in]keypair_typeKeypair type.
[in]hash_typeHash type.
[in]raw_signSource signature in raw format. Must not be NULL.
[in]raw_sign_szSource signature size. Must not be zero.
[out]virgil_signDestination buffer for signature in Virgil format. Must not be NULL.
[in]buf_szOutput buffer size. Must not be zero.
[in]virgil_sign_szPointer to saved signature size. Must not be NULL.
Returns
true in case of success and false otherwise

◆ 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.

Parameters
[in]keypair_typeKeypair type.
[in]virgil_signSource signature in Virgil format. Must not be NULL.
[in]virgil_sign_szSource signature size. Must not be zero.
[out]signDestination buffer for signature in raw format. Must not be NULL.
[in]buf_szOutput buffer size. Must not be zero.
[in]sign_szPointer to saved signature size. Must not be NULL.
Returns
true in case of success and false otherwise