• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "content_digest_algorithm.h"
16 namespace OHOS {
17 namespace SignatureTools {
18 const ContentDigestAlgorithm ContentDigestAlgorithm::SHA256("SHA-256", 256 / 8);
19 const ContentDigestAlgorithm ContentDigestAlgorithm::SHA384("SHA-384", 384 / 8);
20 const ContentDigestAlgorithm ContentDigestAlgorithm::SHA512("SHA-512", 512 / 8);
21 
ContentDigestAlgorithm()22 ContentDigestAlgorithm::ContentDigestAlgorithm()
23     : m_digestAlgorithm(""),
24     m_digestOutputByteSize(0)
25 {
26 }
27 
ContentDigestAlgorithm(const std::string & digestAlgorithm,const int digestOutputByteSize)28 ContentDigestAlgorithm::ContentDigestAlgorithm(const std::string& digestAlgorithm,
29                                                const int digestOutputByteSize)
30     : m_digestAlgorithm(digestAlgorithm), m_digestOutputByteSize(digestOutputByteSize)
31 {
32 }
33 
ContentDigestAlgorithm(const ContentDigestAlgorithm & other)34 ContentDigestAlgorithm::ContentDigestAlgorithm(const ContentDigestAlgorithm& other)
35     : m_digestAlgorithm(other.m_digestAlgorithm),
36     m_digestOutputByteSize(other.m_digestOutputByteSize)
37 {
38 }
39 
operator =(const ContentDigestAlgorithm & other)40 ContentDigestAlgorithm& ContentDigestAlgorithm::operator=(const ContentDigestAlgorithm& other)
41 {
42     if (this != &other) {
43         m_digestAlgorithm = other.m_digestAlgorithm;
44         m_digestOutputByteSize = other.m_digestOutputByteSize;
45     }
46     return *this;
47 }
48 
GetDigestAlgorithm()49 std::string ContentDigestAlgorithm::GetDigestAlgorithm()
50 {
51     return m_digestAlgorithm;
52 }
53 
GetDigestOutputByteSize()54 int ContentDigestAlgorithm::GetDigestOutputByteSize()
55 {
56     return m_digestOutputByteSize;
57 }
58 } // namespace SignatureTools
59 } // namespace OHOS