1 /* 2 * Copyright (c) 2024-2024 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 #ifndef SIGNATURETOOLS_SIGNATUR_ALGORITHM_H 16 #define SIGNATURETOOLS_SIGNATUR_ALGORITHM_H 17 #include <string> 18 #include <utility> // for std::pair 19 20 #include "content_digest_algorithm.h" 21 22 namespace OHOS { 23 namespace SignatureTools { 24 enum class SignatureAlgorithmId { 25 ECDSA_WITH_SHA256 = 0x201, 26 ECDSA_WITH_SHA384 = 0x202, 27 ECDSA_WITH_SHA512 = 0x203, 28 DSA_WITH_SHA256 = 0x301, 29 DSA_WITH_SHA384 = 0x302, 30 DSA_WITH_SHA512 = 0x303 31 }; 32 33 class SignatureAlgorithmHelper { 34 public: 35 static const SignatureAlgorithmHelper ECDSA_WITH_SHA256_INSTANCE; 36 static const SignatureAlgorithmHelper ECDSA_WITH_SHA384_INSTANCE; 37 38 SignatureAlgorithmHelper(); 39 SignatureAlgorithmHelper(const SignatureAlgorithmHelper& other); 40 SignatureAlgorithmHelper(const SignatureAlgorithmId &id_, const std::string &keyAlg_, 41 const ContentDigestAlgorithm& digestAlg_, 42 const std::pair<std::string, void*>& sigParams_); 43 SignatureAlgorithmHelper& operator=(const SignatureAlgorithmHelper& other); 44 ~SignatureAlgorithmHelper(); 45 46 static const SignatureAlgorithmHelper* FindById(const SignatureAlgorithmId id); 47 48 SignatureAlgorithmId m_id; 49 std::string m_keyAlgorithm; 50 ContentDigestAlgorithm m_contentDigestAlgorithm; 51 std::pair<std::string, void*> m_signatureAlgAndParams; 52 }; 53 } // namespace SignatureTools 54 } // namespace OHOS 55 #endif // SIGNATRUETOOLS_SIGNER_CONFIG_H