2 * Copyright (c) 2017 - 2019 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();
42 AlgoType generateAKey(const CryptoAlgorithm &alg,
43 const Password &pubPwd,
44 const Password &privPwd,
45 const RawBuffer &pubPwdIv,
46 const RawBuffer &privPwdIv,
49 const RawBuffer &hashPriv,
50 const RawBuffer &hashPub);
52 void generateSKey(const CryptoAlgorithm &alg,
56 const RawBuffer &hash);
58 void importData(const Data &key,
59 const EncryptionParams &encData,
61 const RawBuffer &pwdIV,
63 const RawBuffer &hash);
65 RawBuffer getData(const RawBuffer &dataId,
68 void destroyData(const RawBuffer &dataId);
70 void destroyKey(const RawBuffer &key);
72 RawBuffer symmetricEncrypt(
75 const CryptoAlgorithm &alg,
76 const RawBuffer &data);
78 RawBuffer symmetricDecrypt(
81 const CryptoAlgorithm &alg,
82 const RawBuffer &cipher);
84 RawBuffer asymmetricEncrypt(
87 const CryptoAlgorithm &alg,
88 const RawBuffer &data);
90 RawBuffer asymmetricDecrypt(
93 const CryptoAlgorithm &alg,
94 const RawBuffer &cipher);
96 BufferPair encryptDataAesGcm(const RawBuffer &key,
100 const RawBuffer &data,
101 const RawBuffer &aad = RawBuffer());
103 RawBuffer decryptDataAesGcm(const RawBuffer &key,
106 const RawBuffer &tag,
107 const RawBuffer &data,
108 const RawBuffer &aad = RawBuffer());
110 RawBuffer sign(const RawBuffer &pkey,
112 const CryptoAlgorithm &alg,
113 const RawBuffer &message);
115 int verify(const RawBuffer &pkey,
117 const CryptoAlgorithm &alg,
118 const RawBuffer &message,
119 const RawBuffer &signature);
121 } // namespace Internals
123 } // namespace Crypto