NVIDIA DRIVE OS Linux API Reference

5.1.0.2 Release

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages

Detailed Description

Defines APIs for Trusted Little Kernel (TLK) crypto services.

Data Structures

struct  te_crypto_operation_info_t
 Holds a crypto operation info object. More...
 
struct  __te_crypto_operation_t
 Internal data structure for te_crypto_operation_t. More...
 
struct  te_crypto_rsa_key_t
 Holds internal data for RSA keys. More...
 
struct  hwrng_cache
 

Macros

#define AES_BLOCK_SIZE   16
 
#define AES_ENCRYPTION_PADDED_SIZE(clearlen)   ((((clearlen) + AES_BLOCK_SIZE) / AES_BLOCK_SIZE) * AES_BLOCK_SIZE)
 
#define OTE_AES_MODE_NEEDS_PADDING(algo)
 
#define HWRNG_CACHE_SIZE_BYTES   1024
 
#define HWRNG_CACHE_ENTROPY_SIZE_BYTES   256
 

Typedefs

typedef struct __te_crypto_object * te_crypto_object_t
 
typedef struct
__te_crypto_operation_t
te_crypto_operation_t
 

Enumerations

enum  te_oper_crypto_algo_t {
  OTE_ALG_AES_ECB_NOPAD = 0x10000010,
  OTE_ALG_AES_CBC_NOPAD = 0x10000110,
  OTE_ALG_AES_CTR = 0x10000210,
  OTE_ALG_AES_CTS = 0x10000310,
  OTE_ALG_AES_ECB = 0x10000510,
  OTE_ALG_AES_CBC = 0x10000610,
  OTE_ALG_AES_CBC_256 = 0x10000710,
  OTE_ALG_AES_CBC_256_NOPAD = 0x10000810,
  OTE_ALG_AES_CMAC_128 = 0x20000110,
  OTE_ALG_AES_CMAC_192 = 0x20000120,
  OTE_ALG_AES_CMAC_256 = 0x20000130,
  OTE_ALG_SHA_HMAC_224 = 0x20000210,
  OTE_ALG_SHA_HMAC_256 = 0x20000220,
  OTE_ALG_SHA_HMAC_384 = 0x20000230,
  OTE_ALG_SHA_HMAC_512 = 0x20000240,
  OTE_ALG_SHA_HMAC_1 = 0x20000250,
  OTE_ALG_RSA_PKCS_OAEP = 0x30000100,
  OTE_ALG_RSA_PSS = 0x30000200,
  OTE_ALG_PKCS1_Block1 = 0x30000300,
  OTE_ALG_DRNG = 0x50000000
}
 Defines algorithm types. More...
 
enum  te_oper_crypto_algo_mode_t {
  OTE_ALG_MODE_ENCRYPT,
  OTE_ALG_MODE_DECRYPT,
  OTE_ALG_MODE_SIGN,
  OTE_ALG_MODE_VERIFY,
  OTE_ALG_MODE_DIGEST,
  OTE_ALG_MODE_DERIVE
}
 Defines algrorithm modes. More...
 

Functions

te_error_t te_allocate_object (te_crypto_object_t *obj)
 Allocates memory for a te_crypto_object_t. More...
 
te_error_t te_populate_object (te_crypto_object_t obj, te_attribute_t *attrs, uint32_t attr_count)
 Populates crypto object from a list of attributes. More...
 
void te_free_object (te_crypto_object_t obj)
 Frees allocated memory within crypto object. More...
 
te_error_t te_allocate_operation (te_crypto_operation_t *oper, te_oper_crypto_algo_t algorithm, te_oper_crypto_algo_mode_t mode)
 Allocates memory for crypto operation. More...
 
te_error_t te_set_operation_key (te_crypto_operation_t oper, te_crypto_object_t obj)
 Allocates memory in the crypto operation and copies the key from the crypto object to the operation object. More...
 
te_error_t te_cipher_init (te_crypto_operation_t oper, void *iv, size_t iv_size)
 Initializes the operation cipher. More...
 
te_error_t te_cipher_update (te_crypto_operation_t oper, const void *src_data, size_t src_size, void *dst_data, size_t *dst_size)
 Updates the cipher by calling the operation update function with the supplied parameters. More...
 
te_error_t te_cipher_do_final (te_crypto_operation_t oper, const void *src_data, size_t src_len, void *dst_data, size_t *dst_len)
 Calls operation do_final with supplied parameters. More...
 
te_error_t te_rsa_init (te_crypto_operation_t oper)
 Initializes the RSA operation. More...
 
te_error_t te_rsa_get_modulus_size (te_crypto_operation_t oper, size_t *modulus_size_bytes)
 Returns the RSA modulus size in bytes. More...
 
te_error_t te_rsa_handle_request (te_crypto_operation_t oper, const void *src_data, size_t src_size, void *dst_data, size_t *dst_size)
 Executes the specified RSA operations. More...
 
void te_free_operation (te_crypto_operation_t oper)
 Frees operation internal memory. More...
 
void te_generate_random (void *buffer, size_t size)
 Generates random data. More...
 
te_error_t te_get_attribute_by_id (te_crypto_object_t object, te_attribute_id_t id, te_attribute_t **ret)
 Finds the first attribute in the crypto object that matches ID. More...
 
te_error_t te_crypt_data (te_oper_crypto_algo_mode_t mode, te_oper_crypto_algo_t algo, unsigned char *key, unsigned int keysize, unsigned char *iv, unsigned int ivsize, unsigned char *in, unsigned int insize, unsigned char *out, unsigned int *outsize)
 Crypto wrapper around software crypto library. More...
 

Macro Definition Documentation

#define AES_BLOCK_SIZE   16

Definition at line 179 of file ote_crypto.h.

#define AES_ENCRYPTION_PADDED_SIZE (   clearlen)    ((((clearlen) + AES_BLOCK_SIZE) / AES_BLOCK_SIZE) * AES_BLOCK_SIZE)

Definition at line 180 of file ote_crypto.h.

#define HWRNG_CACHE_ENTROPY_SIZE_BYTES   256

Definition at line 310 of file ote_crypto.h.

#define HWRNG_CACHE_SIZE_BYTES   1024

Definition at line 309 of file ote_crypto.h.

#define OTE_AES_MODE_NEEDS_PADDING (   algo)
Value:

Definition at line 183 of file ote_crypto.h.

Typedef Documentation

typedef struct __te_crypto_object* te_crypto_object_t

Definition at line 48 of file ote_crypto.h.

Definition at line 50 of file ote_crypto.h.

Enumeration Type Documentation

Defines algrorithm modes.

Enumerator
OTE_ALG_MODE_ENCRYPT 
OTE_ALG_MODE_DECRYPT 
OTE_ALG_MODE_SIGN 
OTE_ALG_MODE_VERIFY 
OTE_ALG_MODE_DIGEST 
OTE_ALG_MODE_DERIVE 

Definition at line 188 of file ote_crypto.h.

Defines algorithm types.

Enumerator
OTE_ALG_AES_ECB_NOPAD 
OTE_ALG_AES_CBC_NOPAD 
OTE_ALG_AES_CTR 
OTE_ALG_AES_CTS 
OTE_ALG_AES_ECB 
OTE_ALG_AES_CBC 
OTE_ALG_AES_CBC_256 
OTE_ALG_AES_CBC_256_NOPAD 
OTE_ALG_AES_CMAC_128 
OTE_ALG_AES_CMAC_192 
OTE_ALG_AES_CMAC_256 
OTE_ALG_SHA_HMAC_224 
OTE_ALG_SHA_HMAC_256 
OTE_ALG_SHA_HMAC_384 
OTE_ALG_SHA_HMAC_512 
OTE_ALG_SHA_HMAC_1 
OTE_ALG_RSA_PKCS_OAEP 
OTE_ALG_RSA_PSS 
OTE_ALG_PKCS1_Block1 
OTE_ALG_DRNG 

Definition at line 155 of file ote_crypto.h.

Function Documentation

te_error_t te_allocate_object ( te_crypto_object_t obj)

Allocates memory for a te_crypto_object_t.

Parameters
[in,out]objA pointer to new crypto object.
Return values
OTE_SUCCESSIndicates the operation was successful.
OTE_ERROR_OUT_OF_MEMORYIndicates the system ran out of resources.
te_error_t te_allocate_operation ( te_crypto_operation_t oper,
te_oper_crypto_algo_t  algorithm,
te_oper_crypto_algo_mode_t  mode 
)

Allocates memory for crypto operation.

Allocates crypto operation internal memory. Initializes operation based on algo/mode.

Parameters
[in,out]operA pointer to a crypto operation object.
[in]algorithmCrypto algorithm.
[in]modeCrypto algorithm mode.
Return values
OTE_SUCCESSIndicates the operation was successful.
te_error_t te_cipher_do_final ( te_crypto_operation_t  oper,
const void *  src_data,
size_t  src_len,
void *  dst_data,
size_t *  dst_len 
)

Calls operation do_final with supplied parameters.

Parameters
[in]operCrypto operation object.
[in]src_dataNULL expected.
[in]src_lenZero expected.
[in,out]dst_dataA pointer to the destination data buffer supplied to do_final.
[in,out]dst_lenA pointer to the destination buffer size supplied to do_final.
Return values
OTE_SUCCESSIndicates the operation was successful.
OTE_ERROR_BAD_PARAMETERSIndicates src_len was not 0 or dst_data/dst_len was NULL.
te_error_t te_cipher_init ( te_crypto_operation_t  oper,
void *  iv,
size_t  iv_size 
)

Initializes the operation cipher.

Sets the initialization vector and calls the init function.

Parameters
[in,out]operCrypto operation object.
[in]ivInitialization vector.
[in]iv_sizeInitialization vector size.
Return values
OTE_SUCCESSIndicates the operation was successful.
te_error_t te_cipher_update ( te_crypto_operation_t  oper,
const void *  src_data,
size_t  src_size,
void *  dst_data,
size_t *  dst_size 
)

Updates the cipher by calling the operation update function with the supplied parameters.

Parameters
[in]operCrypto operation object
[in]src_dataA pointer to the source data buffer supplied to init.
[in]src_sizeSource buffer size supplied to init.
[in,out]dst_dataA pointer to the destination data buffer supplied to init.
[in,out]dst_sizeA pointer to the destination buffer size supplied to init.
Return values
OTE_SUCCESSIndicates the operation was successful.
te_error_t te_crypt_data ( te_oper_crypto_algo_mode_t  mode,
te_oper_crypto_algo_t  algo,
unsigned char *  key,
unsigned int  keysize,
unsigned char *  iv,
unsigned int  ivsize,
unsigned char *  in,
unsigned int  insize,
unsigned char *  out,
unsigned int *  outsize 
)

Crypto wrapper around software crypto library.

This calls te_cipher_init, te_cipher_update and te_cipher_do_final on the supplied input buffer and returns the resulting output.

Return values
OTE_SUCCESSIndicates the operation was successful.
Parameters
[in]modeMode to use, e.g. decrypt/encrypt.
[in]algoAlgorithm to be used.
[in]keyKey to be used.
[in]keysizeThe length of the key in bytes.
[in]ivInitialization Vector.
[in]ivsizeThe length of initialization vector in bytes.
[in]inInput buffer.
[in]insizeThe length of the input buffer in bytes.
[out]outOutput Buffer.
[in,out]outsizeThe length of the output buffer in bytes.
void te_free_object ( te_crypto_object_t  obj)

Frees allocated memory within crypto object.

Parameters
[in]objCrypto object.
void te_free_operation ( te_crypto_operation_t  oper)

Frees operation internal memory.

void te_generate_random ( void *  buffer,
size_t  size 
)

Generates random data.

Parameters
[in,out]bufferA pointer to the buffer to be filled.
[in]sizeLength of the buffer.
te_error_t te_get_attribute_by_id ( te_crypto_object_t  object,
te_attribute_id_t  id,
te_attribute_t **  ret 
)

Finds the first attribute in the crypto object that matches ID.

Parameters
[in]objectCrypto object.
[in]idAttribute ID to match.
[out]retA double pointer to the attribute found.
Return values
OTE_SUCCESSIndicates the operation was successful.
OTE_ERROR_ITEM_NOT_FOUNDIndicates the requested data item was not found.
te_error_t te_populate_object ( te_crypto_object_t  obj,
te_attribute_t attrs,
uint32_t  attr_count 
)

Populates crypto object from a list of attributes.

Allocates obj internal memory and copies attributes to obj.

Parameters
[in,out]objCrypto object to store attributes.
[in]attrsArray of attributes.
[in]attr_countArray length.
Return values
OTE_SUCCESSIndicates the operation was successful.
te_error_t te_rsa_get_modulus_size ( te_crypto_operation_t  oper,
size_t *  modulus_size_bytes 
)

Returns the RSA modulus size in bytes.

Parameters
[in]operCrypto operation object.
[out]modulus_size_bytesSize of the modulus in Bytes.
Return values
OTE_SUCCESSIndicates the operation was successful.
te_error_t te_rsa_handle_request ( te_crypto_operation_t  oper,
const void *  src_data,
size_t  src_size,
void *  dst_data,
size_t *  dst_size 
)

Executes the specified RSA operations.

Parameters
[in]operCrypto operation object.
[in]src_dataA pointer to the source data buffer supplied to init.
[in]src_sizeSource buffer size supplied to init.
[in,out]dst_dataA pointer to the destination data buffer supplied to init.
[in,out]dst_sizeA pointer to the destination buffer size supplied to init.
Return values
OTE_SUCCESSIndicates the operation was successful.
te_error_t te_rsa_init ( te_crypto_operation_t  oper)

Initializes the RSA operation.

Parameters
[in,out]operCrypto operation object.
Return values
OTE_SUCCESSIndicates the operation was successful.
te_error_t te_set_operation_key ( te_crypto_operation_t  oper,
te_crypto_object_t  obj 
)

Allocates memory in the crypto operation and copies the key from the crypto object to the operation object.

Parameters
[in,out]operCrypto operation object.
[in]objKey crypto object.
Return values
OTE_SUCCESSIndicates the operation was successful.