1 //******************************************************************
3 // Copyright 2017 Samsung Electronics All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
11 // http://www.apache.org/licenses/LICENSE-2.0
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
21 #ifndef IOTVT_SRM_PSIUTILS_H
22 #define IOTVT_SRM_PSIUTILS_H
24 #define AES_KEY_SIZE 32
27 * @brief Generic Encryption function to encrypt data buffer in plaintext
28 * and update in ciphertext and len in ct_len. (AES-CBC-HMAC)
29 * @param[in] plaintext plaintext to be encrypted
30 * @param[in] pt_len length of plaintext
31 * @param[out] ciphertext ciphered text
32 * @param[out] ct_len is length of the ciphered text.
34 * @return ::0 for Success.
36 int psiEncrypt(const unsigned char *plaintext, size_t pt_len,
37 unsigned char **ciphertext, size_t *ct_len);
40 * @brief Generic Decryption function to decrypt data buffer in ciphertext
41 * and update in plaintext and len in pt_len. (AES-CBC-HMAC)
42 * @param[in] ciphertext ciphered to be decrypted
43 * @param[in] ct_len length of cipher text
44 * @param[out] plaintext plaintext text
45 * @param[out] pt_len is length of the plaintext text.
47 * @return ::0 for Success.
49 int psiDecrypt(const unsigned char *ciphertext, size_t ct_len,
50 unsigned char **plaintext, size_t *pt_len);
53 * @brief API to set key to psi
54 * @param[in] key key used for encryption
55 * @return ::OC_STACK_OK for Success, otherwise some error value.
57 OCStackResult psiSetKey(const unsigned char* key);
60 * @brief API to get key from psi
61 * @param[out] key key used for encryption
62 * @return ::OC_STACK_OK for Success, otherwise some error value.
64 OCStackResult psiGetKey(unsigned char* key);
67 * @brief It provides state to set key for encryption
68 * @return ::true for setting key.
72 #endif //IOTVT_SRM_PSIUTILS_H