• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "stub.h"
17 
18 namespace stub {
19 class MD5 : public MessageDigest {
20 public:
21     static constexpr size_t MD5_LENGTH = 16;
22 
23     static MD5 &GetInstance();
24     virtual std::vector<uint8_t> Digest(const uint8_t *input, const size_t length) override;
25 
26 private:
27     MD5() = default;
28     ~MD5() = default;
29 };
30 
GetInstance()31 MD5 &MD5::GetInstance()
32 {
33     static MD5 instance;
34     return instance;
35 }
36 
Digest(const uint8_t * input,const size_t length)37 std::vector<uint8_t> MD5::Digest(const uint8_t *input, const size_t length)
38 {
39     std::vector<uint8_t> digest(MD5_LENGTH, 0);
40     return digest;
41 }
42 
GetInstance(const std::string & type)43 MessageDigest *MessageDigestFactory::GetInstance(const std::string &type)
44 {
45     if (type.compare(DIGEST_TYPE_MD5) == 0) {
46         return &MD5::GetInstance();
47     } else {
48         return nullptr;
49     }
50 }
51 
GetInstance()52 MapService *MapService::GetInstance()
53 {
54     static MapService instance;
55     return &instance;
56 }
57 
GetInstance()58 MediaService *MediaService::GetInstance()
59 {
60     static MediaService instance;
61     return &instance;
62 }
63 
GetInstance()64 TelePhoneClientService &TelePhoneClientService::GetInstance()
65 {
66     static TelePhoneClientService instance;
67     return instance;
68 }
69 
GetInstance()70 TelephoneService *TelephoneService::GetInstance()
71 {
72     static TelephoneService instance;
73     return &instance;
74 }
75 
GetInstance()76 A2dpService *A2dpService::GetInstance()
77 {
78     static A2dpService instance;
79     return &instance;
80 }
81 } // namespace stub