/* * Copyright (c) 2024-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "params.h" namespace OHOS { namespace SignatureTools { Params::Params() : options(new Options) { } Params::~Params() { if (options) { delete options; options = NULL; } } std::string Params::GetMethod() { return method; } void Params::SetMethod(const std::string& method) { this->method = method; } Options* Params::GetOptions() { return options; } std::unordered_set Params::InitParamField(const std::vector& paramFields) { return std::unordered_set(paramFields.begin(), paramFields.end()); } bool Params::GetSignatureAlgorithm(const std::string& signatureAlgorithm, SignatureAlgorithmHelper& out) { if (signatureAlgorithm == ParamConstants::HAP_SIG_ALGORITHM_SHA256_ECDSA) { out = SignatureAlgorithmHelper::ECDSA_WITH_SHA256_INSTANCE; return true; } else if (signatureAlgorithm == ParamConstants::HAP_SIG_ALGORITHM_SHA384_ECDSA) { out = SignatureAlgorithmHelper::ECDSA_WITH_SHA384_INSTANCE; return true; } else { SIGNATURE_TOOLS_LOGE("get Signature Algorithm failed not support %s", signatureAlgorithm.c_str()); return false; } return true; } } // namespace SignatureTools } // namespace OHOS