2 * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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
18 * @author Krzysztof Dynowski (k.dynowski@samsung.com)
19 * @author Lukasz Kostyra (l.kostyra@samsung.com)
24 #include <ckm/ckm-type.h>
25 #include <data-type.h>
26 #include <tz-backend/obj.h>
27 #include <generic-backend/gstore.h>
34 using DataPair = std::pair<Data, Data>;
35 using BufferPair = std::pair<RawBuffer, RawBuffer>;
37 // encryption schema + buffer pair
38 using KeyIdPair = std::pair<int, RawBuffer>;
40 RawBuffer generateIV();
41 DataPair generateAKey(const CryptoAlgorithm &alg,
44 Data generateSKey(const CryptoAlgorithm &alg,
48 RawBuffer importKey(const Data &key,
53 RawBuffer importData(const Data &data,
58 RawBuffer getData(const RawBuffer &dataId,
61 void destroyData(const RawBuffer &dataId);
63 void destroyKey(const RawBuffer &key);
65 RawBuffer symmetricEncrypt(
68 const CryptoAlgorithm &alg,
69 const RawBuffer &data);
70 RawBuffer symmetricDecrypt(
73 const CryptoAlgorithm &alg,
74 const RawBuffer &cipher);
76 RawBuffer asymmetricEncrypt(
79 const CryptoAlgorithm &alg,
80 const RawBuffer &data);
81 RawBuffer asymmetricDecrypt(
84 const CryptoAlgorithm &alg,
85 const RawBuffer &cipher);
87 BufferPair encryptDataAesGcm(const RawBuffer &key,
91 const RawBuffer &data,
92 const RawBuffer &aad = RawBuffer());
94 RawBuffer decryptDataAesGcm(const RawBuffer &key,
98 const RawBuffer &data,
99 const RawBuffer &aad = RawBuffer());
101 RawBuffer sign(const RawBuffer &pkey,
103 const CryptoAlgorithm &alg,
104 const RawBuffer &message);
106 int verify(const RawBuffer &pkey,
108 const CryptoAlgorithm &alg,
109 const RawBuffer &message,
110 const RawBuffer &signature);
112 } // namespace Internals
114 } // namespace Crypto