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(RawBuffer buffer) : m_raw(std::move(buffer)) {}
64 virtual RawBuffer getBinary() const override
73 class Key : public BData {
75 Key(int scheme, RawBuffer buffer, Pwd pwd, DataType dataType) :
76 BData(std::move(buffer)),
78 m_password(std::move(pwd)),
81 virtual int getScheme() const
86 virtual Pwd getPassword() const
97 class SKey : public Key {
99 SKey(int scheme, RawBuffer buffer, Pwd pwd, DataType dataType) :
100 Key(scheme, std::move(buffer), std::move(pwd), dataType) {}
102 virtual RawBuffer encrypt(const CryptoAlgorithm &, const RawBuffer &);
103 virtual RawBuffer decrypt(const CryptoAlgorithm &, const RawBuffer &);
106 class AKey : public Key {
108 AKey(int scheme, RawBuffer buffer, Pwd pwd, DataType dataType) :
109 Key(scheme, std::move(buffer), std::move(pwd), dataType) {}
111 virtual RawBuffer sign(const CryptoAlgorithm &alg, const RawBuffer &message);
112 virtual int verify(const CryptoAlgorithm &alg, const RawBuffer &message,
113 const RawBuffer &sign);
114 virtual RawBuffer encrypt(const CryptoAlgorithm &, const RawBuffer &);
115 virtual RawBuffer decrypt(const CryptoAlgorithm &, const RawBuffer &);
119 class Cert : public AKey {
121 Cert(int scheme, RawBuffer buffer, Pwd pwd, DataType dataType) :
122 AKey(scheme, std::move(buffer), std::move(pwd), dataType) {}
128 } // namespace Crypto