1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef OHOS_DISTRIBUTED_DATA_SERVICES_FRAMEWORK_METADATA_SECRET_KEY_META_DATA_H
17 #define OHOS_DISTRIBUTED_DATA_SERVICES_FRAMEWORK_METADATA_SECRET_KEY_META_DATA_H
18 #include "serializable/serializable.h"
19 namespace OHOS {
20 namespace DistributedData {
21 struct API_EXPORT SecretKeyMetaData final : public Serializable {
22     std::vector<uint8_t> time {};
23     std::vector<uint8_t> sKey {};
24     int32_t storeType = 0;
25     API_EXPORT SecretKeyMetaData();
26     API_EXPORT ~SecretKeyMetaData();
27     API_EXPORT bool Marshal(json &node) const override;
28     API_EXPORT bool Unmarshal(const json &node) override;
29 
30     API_EXPORT static std::string GetKey(const std::initializer_list<std::string> &fields);
31     API_EXPORT static std::string GetBackupKey(const std::initializer_list<std::string> &fields);
32     API_EXPORT static std::string GetPrefix(const std::initializer_list<std::string> &fields);
33     API_EXPORT static std::string GetBackupPrefix(const std::initializer_list<std::string> &fields);
34 private:
35     static constexpr const char *KEY_PREFIX = "SecretKey";
36     static constexpr const char *BACKUP_KEY_PREFIX = "BackupSecretKey";
37 };
38 } // namespace DistributedData
39 } // namespace OHOS
40 #endif // OHOS_DISTRIBUTED_DATA_SERVICES_FRAMEWORK_METADATA_SECRET_KEY_META_DATA_H
41