Kaa client C SDK
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
kaa_aes_rsa.h
Go to the documentation of this file.
1 /*
2  * Copyright 2014-2016 CyberVision, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef KAA_AES_RSA_H_
18 #define KAA_AES_RSA_H_
19 
20 #include <kaa_error.h>
21 
22 #include <mbedtls/pk.h>
23 #include <mbedtls/entropy.h>
24 #include <mbedtls/ctr_drbg.h>
25 #include <mbedtls/md.h>
26 #include <kaa_error.h>
27 #include <stdbool.h>
28 #include <stddef.h>
29 #include <stdint.h>
30 
31 #define KAA_SESSION_KEY_LENGTH 16
32 
42 int init_aes_key(unsigned char *key, size_t bytes);
43 
53 kaa_error_t aes_encrypt_decrypt(int mode, const uint8_t *input, size_t input_size,
54  uint8_t *output, const uint8_t *key);
55 
65 kaa_error_t aes_encrypt_decrypt_block(int mode, const uint8_t *input, uint8_t *output,
66  const uint8_t *key);
67 
77 int rsa_sign(mbedtls_pk_context *pk, const uint8_t *input, size_t input_size,
78  uint8_t *output, size_t *output_size);
79 
94 kaa_error_t rsa_encrypt(const uint8_t *key, size_t key_size, const uint8_t *input,
95  size_t input_len, uint8_t *output);
96 
97 #endif /* KAA_AES_RSA_H_ */
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.
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.
kaa_error_t
Definition: kaa_error.h:31
Kaa error codes.
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.
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.
int init_aes_key(unsigned char *key, size_t bytes)
Generate AES key.