Virgil IoT KIT
Macros | Functions
secmodule-helpers.h File Reference

Security module helper functions. More...

#include <virgil/iot/secmodule/secmodule.h>

Go to the source code of this file.

Macros

#define VS_PUBKEY_SECP192_LEN   (49)
 
#define VS_PUBKEY_SECP224_LEN   (57)
 
#define VS_PUBKEY_SECP256_LEN   (65)
 
#define VS_PUBKEY_SECP384_LEN   (97)
 
#define VS_PUBKEY_SECP521_LEN   (133)
 
#define VS_PUBKEY_25519_LEN   (32)
 
#define VS_SIGNATURE_SECP192_LEN   (48)
 
#define VS_SIGNATURE_SECP224_LEN   (56)
 
#define VS_SIGNATURE_SECP256_LEN   (64)
 
#define VS_SIGNATURE_SECP384_LEN   (96)
 
#define VS_SIGNATURE_SECP521_LEN   (132)
 
#define VS_SIGNATURE_25519_LEN   (64)
 
#define VS_HASH_SHA256_LEN   (32)
 
#define VS_HASH_SHA384_LEN   (48)
 
#define VS_HASH_SHA512_LEN   (64)
 
#define VS_AES_256_KEY_SIZE   (32)
 
#define VS_AES_256_KEY_BITLEN   (VS_AES_256_KEY_SIZE * 8)
 
#define VS_AES_256_BLOCK_SIZE   (16)
 
#define VS_AES_256_GCM_IV_SIZE   (12)
 
#define VS_AES_256_GCM_AUTH_TAG_SIZE   (16)
 
#define VS_AES_256_CBC_IV_SIZE   (16)
 

Functions

int vs_secmodule_get_pubkey_len (vs_secmodule_keypair_type_e keypair_type)
 Get public key length. More...
 
int vs_secmodule_get_signature_len (vs_secmodule_keypair_type_e keypair_type)
 Get signature length. More...
 
int vs_secmodule_get_hash_len (vs_secmodule_hash_type_e hash_type)
 Get hash length. More...
 
const char * vs_secmodule_keypair_type_descr (vs_secmodule_keypair_type_e type)
 Get key pair type description. More...
 
const char * vs_secmodule_hash_type_descr (vs_secmodule_hash_type_e type)
 Get hash type description. More...
 
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. More...
 
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. More...
 

Detailed Description

Security module helper functions.

This header contains different helper functions for performing cryptographic operations

Macro Definition Documentation

◆ VS_AES_256_BLOCK_SIZE

#define VS_AES_256_BLOCK_SIZE   (16)

◆ VS_AES_256_CBC_IV_SIZE

#define VS_AES_256_CBC_IV_SIZE   (16)

◆ VS_AES_256_GCM_AUTH_TAG_SIZE

#define VS_AES_256_GCM_AUTH_TAG_SIZE   (16)

◆ VS_AES_256_GCM_IV_SIZE

#define VS_AES_256_GCM_IV_SIZE   (12)

◆ VS_AES_256_KEY_BITLEN

#define VS_AES_256_KEY_BITLEN   (VS_AES_256_KEY_SIZE * 8)

◆ VS_AES_256_KEY_SIZE

#define VS_AES_256_KEY_SIZE   (32)

◆ VS_HASH_SHA256_LEN

#define VS_HASH_SHA256_LEN   (32)

◆ VS_HASH_SHA384_LEN

#define VS_HASH_SHA384_LEN   (48)

◆ VS_HASH_SHA512_LEN

#define VS_HASH_SHA512_LEN   (64)

◆ VS_PUBKEY_25519_LEN

#define VS_PUBKEY_25519_LEN   (32)

◆ VS_PUBKEY_SECP192_LEN

#define VS_PUBKEY_SECP192_LEN   (49)

◆ VS_PUBKEY_SECP224_LEN

#define VS_PUBKEY_SECP224_LEN   (57)

◆ VS_PUBKEY_SECP256_LEN

#define VS_PUBKEY_SECP256_LEN   (65)

◆ VS_PUBKEY_SECP384_LEN

#define VS_PUBKEY_SECP384_LEN   (97)

◆ VS_PUBKEY_SECP521_LEN

#define VS_PUBKEY_SECP521_LEN   (133)

◆ VS_SIGNATURE_25519_LEN

#define VS_SIGNATURE_25519_LEN   (64)

◆ VS_SIGNATURE_SECP192_LEN

#define VS_SIGNATURE_SECP192_LEN   (48)

◆ VS_SIGNATURE_SECP224_LEN

#define VS_SIGNATURE_SECP224_LEN   (56)

◆ VS_SIGNATURE_SECP256_LEN

#define VS_SIGNATURE_SECP256_LEN   (64)

◆ VS_SIGNATURE_SECP384_LEN

#define VS_SIGNATURE_SECP384_LEN   (96)

◆ VS_SIGNATURE_SECP521_LEN

#define VS_SIGNATURE_SECP521_LEN   (132)

Function Documentation

◆ vs_secmodule_get_hash_len()

int vs_secmodule_get_hash_len ( vs_secmodule_hash_type_e  hash_type)

Get hash length.

This function returns hash length for supported and enabled hash types.

Parameters
[in]hash_typeHash type. Cannot be VS_HASH_SHA_INVALID.
Returns
Hash length

◆ vs_secmodule_get_pubkey_len()

int vs_secmodule_get_pubkey_len ( vs_secmodule_keypair_type_e  keypair_type)

Get public key length.

This function returns public key length for supported and enabled key pair types.

Parameters
[in]keypair_typeKey pair type. Cannot be VS_KEYPAIR_INVALID or VS_KEYPAIR_MAX.
Returns
Public key length

◆ vs_secmodule_get_signature_len()

int vs_secmodule_get_signature_len ( vs_secmodule_keypair_type_e  keypair_type)

Get signature length.

This function returns signature length for supported and enabled signature types.

Parameters
[in]keypair_typeKey pair type. Cannot be VS_KEYPAIR_INVALID or VS_KEYPAIR_MAX.
Returns
Signature length

◆ vs_secmodule_hash_type_descr()

const char* vs_secmodule_hash_type_descr ( vs_secmodule_hash_type_e  type)

Get hash type description.

This function returns hash ASCIIZ description for supported and enable hash types

Parameters
[in]hash_typeHash type. Cannot be VS_HASH_SHA_INVALID.
Returns
Hash type description in static buffer

◆ vs_secmodule_keypair_type_descr()

const char* vs_secmodule_keypair_type_descr ( vs_secmodule_keypair_type_e  type)

Get key pair type description.

This function returns key pair ASCIIZ description for supported and enable key pair types

Parameters
[in]typeKey pair type. Cannot be VS_KEYPAIR_INVALID or VS_KEYPAIR_MAX.
Returns
Key pair description in static buffer

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

Parameters
[in]raw_signaturePointer to the signature in raw format. Cannot be NULL.
[in]virgil_signPointer to the signature in Virgil format. Cannot be NULL.
[in]buf_szSize of buffer for raw signature
[out]virgil_sign_szPointer to size of the signature in Virgil format. Cannot be NULL.
Returns
VS_CODE_OK in case of success or error code.

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

Parameters
[in]virgil_signPointer to the signature in Virgil format. Cannot be NULL.
[in]virgil_sign_szSize of the signature in Virgil format.
[out]raw_signaturePointer to the signature in raw format. Cannot be NULL.
[in]buf_szSize of buffer for raw signature
Returns
VS_CODE_OK in case of success or error code.