Kaa client C SDK
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Macros | Functions
kaa_aes_rsa.h File Reference
#include <kaa_error.h>
#include <mbedtls/pk.h>
#include <mbedtls/entropy.h>
#include <mbedtls/ctr_drbg.h>
#include <mbedtls/md.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>

Go to the source code of this file.

Macros

#define KAA_SESSION_KEY_LENGTH   16
 

Functions

int init_aes_key (unsigned char *key, size_t bytes)
 Generate AES key. More...
 
kaa_error_t aes_encrypt_decrypt (int mode, const uint8_t *input, size_t input_size, uint8_t *output, const uint8_t *key)
 Encrypt or decrypt with AES key. More...
 
kaa_error_t aes_encrypt_decrypt_block (int mode, const uint8_t *input, uint8_t *output, const uint8_t *key)
 Encrypt or decrypt block of size KAA_SESSION_KEY_LENGTH with AES key. More...
 
int rsa_sign (mbedtls_pk_context *pk, const uint8_t *input, size_t input_size, uint8_t *output, size_t *output_size)
 Create RSA signature. More...
 
kaa_error_t rsa_encrypt (const uint8_t *key, size_t key_size, const uint8_t *input, size_t input_len, uint8_t *output)
 Encrypt data with pubcic RSA key. More...
 

Macro Definition Documentation

#define KAA_SESSION_KEY_LENGTH   16

Function Documentation

kaa_error_t aes_encrypt_decrypt ( int  mode,
const uint8_t *  input,
size_t  input_size,
uint8_t *  output,
const uint8_t *  key 
)

Encrypt or decrypt with AES key.

Parameters
[in]modeMode of encryption
[in]inputPointer to input data
[in]input_sizeSize of input data
[out]outputPointer to output data
[in]keyPointer to AES key
kaa_error_t aes_encrypt_decrypt_block ( int  mode,
const uint8_t *  input,
uint8_t *  output,
const uint8_t *  key 
)

Encrypt or decrypt block of size KAA_SESSION_KEY_LENGTH with AES key.

Parameters
[in]modeMode of encryption. MBEDTLS_AES_ENCRYPT to encryption and MBEDTLS_AES_DECTYPT to decryption.
[in]inputPointer to input data (of size KAA_SESSION_KEY_LENGTH)
[out]outputPointer to output data
[in]keyPointer to AES key
int init_aes_key ( unsigned char *  key,
size_t  bytes 
)

Generate AES key.

Parameters
[out]keyGenerated AES key
[in]bytesSize of the AES key
Returns
The error code.
Return values
0Success.
kaa_error_t rsa_encrypt ( const uint8_t *  key,
size_t  key_size,
const uint8_t *  input,
size_t  input_len,
uint8_t *  output 
)

Encrypt data with pubcic RSA key.

Parameters
[in]keyPublic RSA key.
[in]key_sizeSize of public RSA key.
[in]inputInput data.
[in]input_lenSize of input_data.
[out]outputPointer to buffer where the encrypted data will be stored.
Returns
The error code.
Return values
KAA_ERR_NONESuccess
KAA_ERR_INVALID_PUBKEYThe key is invalid.
KAA_ERR_GENERICEncryption has failed.
int rsa_sign ( mbedtls_pk_context *  pk,
const uint8_t *  input,
size_t  input_size,
uint8_t *  output,
size_t *  output_size 
)

Create RSA signature.

Parameters
[in]pkPointer to a pk structure
[in]inputPointer to input data
[in]input_sizeSize of input data
[out]outputPointer to RSA signature
[out]output_sizeSize of RSA signature