add the se-backend for db encryption
[platform/core/security/key-manager.git] / src / manager / crypto / se-backend / internals.h
1 /*
2  *  Copyright (c) 2017-2022 Samsung Electronics Co., Ltd All Rights Reserved
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  * @file       internals.h
18  * @author     isaac2.lee (isaac2.lee@samsung.com)
19  * @version    1.0
20  */
21 #pragma once
22
23 #include <ckm/ckm-type.h>
24 #include <data-type.h>
25 #include <generic-backend/gstore.h>
26
27 namespace CKM {
28 namespace Crypto {
29 namespace SE {
30 namespace Internals {
31
32 void generateSKey(const CryptoAlgorithm &alg, const uint32_t key_idx);
33
34 void generateAKey(const CryptoAlgorithm &alg, const uint32_t key_idx);
35
36 // encrypt key data using SE api
37 RawBuffer encryptWithDbpKey(const unsigned char* key, const uint32_t key_len,
38                                                 const unsigned char* iv, const uint32_t iv_len);
39
40 RawBuffer symmetricEncrypt(const uint32_t key_idx,
41                                                 const CryptoAlgorithm &alg,
42                                                 RawBuffer &data);
43 RawBuffer symmetricDecrypt(const uint32_t key_idx,
44                                                 const CryptoAlgorithm &alg,
45                                                 RawBuffer &data);
46
47 RawBuffer asymmetricEncrypt(const uint32_t key_idx,
48                                                         const CryptoAlgorithm &alg,
49                                                         RawBuffer &data);
50
51 RawBuffer asymmetricDecrypt(const uint32_t key_idx,
52                                                         const CryptoAlgorithm &alg,
53                                                         RawBuffer &data);
54
55 RawBuffer sign(const uint32_t key_idx, const CryptoAlgorithm &alg,
56                                 RawBuffer &message);
57
58 int verify(const uint32_t key_idx, const CryptoAlgorithm &alg,
59                         RawBuffer &hash, RawBuffer &signature);
60
61 } // namespace Internals
62 } // namespace SE
63 } // namespace Crypto
64 } // namespace CKM