#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.
|
| 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...
|
| |
| #define KAA_SESSION_KEY_LENGTH 16 |
| 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] | mode | Mode of encryption |
| [in] | input | Pointer to input data |
| [in] | input_size | Size of input data |
| [out] | output | Pointer to output data |
| [in] | key | Pointer 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] | mode | Mode of encryption. MBEDTLS_AES_ENCRYPT to encryption and MBEDTLS_AES_DECTYPT to decryption. |
| [in] | input | Pointer to input data (of size KAA_SESSION_KEY_LENGTH) |
| [out] | output | Pointer to output data |
| [in] | key | Pointer to AES key |
| int init_aes_key |
( |
unsigned char * |
key, |
|
|
size_t |
bytes |
|
) |
| |
Generate AES key.
- Parameters
-
| [out] | key | Generated AES key |
| [in] | bytes | Size of the AES key |
- Returns
- The error code.
- Return values
-
| 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] | key | Public RSA key. |
| [in] | key_size | Size of public RSA key. |
| [in] | input | Input data. |
| [in] | input_len | Size of input_data. |
| [out] | output | Pointer to buffer where the encrypted data will be stored. |
- Returns
- The error code.
- Return values
-
| KAA_ERR_NONE | Success |
| KAA_ERR_INVALID_PUBKEY | The key is invalid. |
| KAA_ERR_GENERIC | Encryption 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] | pk | Pointer to a pk structure |
| [in] | input | Pointer to input data |
| [in] | input_size | Size of input data |
| [out] | output | Pointer to RSA signature |
| [out] | output_size | Size of RSA signature |