2 * Copyright (c) 2015 - 2020 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 Jackiewicz (k.jackiewicz@samsung.com)
24 #include <ckm/ckm-type.h>
25 #include <exception.h>
26 #include <symbol-visibility.h>
27 #include <dpl/serialization.h>
31 class COMMON_API DataType final : public ISerializable {
60 // Special types to support database,
61 DB_KEY_FIRST = KEY_RSA_PUBLIC,
62 DB_KEY_LAST = KEY_AES,
63 DB_CHAIN_FIRST = CHAIN_CERT_0,
64 DB_CHAIN_LAST = CHAIN_CERT_15,
65 DB_FIRST = KEY_RSA_PUBLIC,
66 DB_LAST = CHAIN_CERT_15,
72 explicit DataType(IStream &stream);
73 void Serialize(IStream &stream) const override;
75 explicit DataType(KeyType key);
76 DataType(const DataType &) = default;
77 DataType &operator=(const DataType &) = default;
84 * Number of times someone mistook it for isKey() (or the opposite): 3
85 * Increase the counter if it happened to you.
86 * I will rename this function if the counter reaches 4.
89 bool isChainCert() const;
90 bool isKeyPrivate() const;
91 bool isKeyPublic() const;
92 bool isCertificate() const;
93 bool isBinaryData() const;
94 bool isEllipticCurve() const;
96 static DataType getChainDatatype(unsigned int index);
99 void checkRange() const;