2 * Copyright (c) 2015 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 Lukasz Kostyra (l.kostyra@samsung.com)
23 #include <generic-backend/gobj.h>
24 #include <data-type.h>
32 Pwd(Password pwd, RawBuffer iv, RawBuffer tag)
33 : m_password(pwd.begin(), pwd.end())
35 , m_tag(std::move(tag))
38 const RawBuffer& getPassword() const
43 const RawBuffer& getIV() const
48 const RawBuffer& getTag() const
60 class BData : public GObj {
62 explicit BData(CryptoBackend backendId, RawBuffer buffer) :
63 GObj(backendId), m_raw(std::move(buffer)) {}
65 RawBuffer getBinary() const override
74 class Key : public BData {
76 Key(CryptoBackend backendId, int scheme, RawBuffer buffer, Pwd pwd, DataType dataType) :
77 BData(backendId, std::move(buffer)),
79 m_password(std::move(pwd)),
82 virtual int getScheme() const
87 virtual Pwd getPassword() const
98 class SKey : public Key {
100 SKey(CryptoBackend backendId, int scheme, RawBuffer buffer, Pwd pwd, DataType dataType) :
101 Key(backendId, scheme, std::move(buffer), std::move(pwd), dataType) {}
103 virtual RawBuffer encrypt(const CryptoAlgorithm &, const RawBuffer &);
104 virtual RawBuffer decrypt(const CryptoAlgorithm &, const RawBuffer &);
107 class AKey : public Key {
109 AKey(CryptoBackend backendId, int scheme, RawBuffer buffer, Pwd pwd, DataType dataType) :
110 Key(backendId, scheme, std::move(buffer), std::move(pwd), dataType) {}
112 virtual RawBuffer sign(const CryptoAlgorithm &alg, const RawBuffer &message);
113 virtual int verify(const CryptoAlgorithm &alg, const RawBuffer &message,
114 const RawBuffer &sign);
115 virtual RawBuffer encrypt(const CryptoAlgorithm &, const RawBuffer &);
116 virtual RawBuffer decrypt(const CryptoAlgorithm &, const RawBuffer &);
120 class Cert : public AKey {
122 Cert(CryptoBackend backendId, int scheme, RawBuffer buffer, Pwd pwd, DataType dataType) :
123 AKey(backendId, scheme, std::move(buffer), std::move(pwd), dataType) {}
129 } // namespace Crypto