|
1 /* |
|
2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * hashshim.cpp |
|
16 * hash shim implementation |
|
17 * hash shim implementation |
|
18 * |
|
19 */ |
|
20 |
|
21 |
|
22 /** |
|
23 @file |
|
24 */ |
|
25 |
|
26 #include "sha1shim.h" |
|
27 #include "sha1impl.h" |
|
28 #include <cryptospi/cryptospidef.h> |
|
29 #include <cryptospi/plugincharacteristics.h> |
|
30 |
|
31 |
|
32 using namespace CryptoSpi; |
|
33 using namespace SoftwareCrypto; |
|
34 |
|
35 // |
|
36 // Implementation of SHA1 shim |
|
37 // |
|
38 |
|
39 CSHA1Shim* CSHA1Shim::NewL() |
|
40 { |
|
41 CSHA1Shim* self=CSHA1Shim::NewLC(); |
|
42 CleanupStack::Pop(); |
|
43 return self; |
|
44 } |
|
45 |
|
46 CSHA1Shim* CSHA1Shim::NewLC() |
|
47 { |
|
48 CSHA1Shim* self=new(ELeave) CSHA1Shim(); |
|
49 CleanupStack::PushL(self); |
|
50 self->ConstructL(); |
|
51 return self; |
|
52 } |
|
53 |
|
54 CSHA1Shim::CSHA1Shim() |
|
55 { |
|
56 } |
|
57 |
|
58 CSHA1Shim::~CSHA1Shim() |
|
59 { |
|
60 iHashImpl->Close(); |
|
61 } |
|
62 |
|
63 void CSHA1Shim::ConstructL() |
|
64 { |
|
65 iHashImpl=CSHA1Impl::NewL(); |
|
66 } |
|
67 |
|
68 TInt CSHA1Shim::HashSize() |
|
69 { |
|
70 const TCharacteristics* ptr(NULL); |
|
71 TRAPD(err, iHashImpl->GetCharacteristicsL(ptr);) |
|
72 if (err) |
|
73 { |
|
74 return err; |
|
75 } |
|
76 const THashCharacteristics* hashPtr=static_cast<const THashCharacteristics*>(ptr); |
|
77 return hashPtr->iOutputSize/8; |
|
78 } |
|
79 |
|
80 TPtrC8 CSHA1Shim::Hash(const TDesC8& aMessage) |
|
81 { |
|
82 return iHashImpl->Hash(aMessage); |
|
83 } |
|
84 |
|
85 // The following methods are kept for linkage compatibility |
|
86 // but are not used by randsvr.exe. Turn off coverage for these |
|
87 #ifdef _BullseyeCoverage |
|
88 #pragma suppress_warnings on |
|
89 #pragma BullseyeCoverage off |
|
90 #pragma suppress_warnings off |
|
91 #endif |
|
92 |
|
93 void CSHA1Shim::Reset() |
|
94 { |
|
95 // Provide a stub for compatibility; not used in random server |
|
96 ASSERT(EFalse); |
|
97 } |
|
98 |
|
99 void CSHA1Shim::RestoreState() |
|
100 { |
|
101 // Provide a stub for compatibility; not used in random server |
|
102 ASSERT(EFalse); |
|
103 } |
|
104 |
|
105 void CSHA1Shim::StoreState() |
|
106 { |
|
107 // Provide a stub for compatibility; not used in random server |
|
108 ASSERT(EFalse); |
|
109 } |
|
110 |
|
111 CMessageDigest* CSHA1Shim::CopyL() |
|
112 { |
|
113 // Provide a stub for compatibility; not used in random server |
|
114 User::Leave(KErrNotSupported); |
|
115 return NULL; |
|
116 } |
|
117 |
|
118 CMessageDigest* CSHA1Shim::ReplicateL() |
|
119 { |
|
120 // Provide a stub for compatibility; not used in random server |
|
121 User::Leave(KErrNotSupported); |
|
122 return NULL; |
|
123 } |
|
124 |
|
125 TInt CSHA1Shim::BlockSize() |
|
126 { |
|
127 // Provide a stub for compatibility; not used in random server |
|
128 ASSERT(EFalse); |
|
129 return 0; |
|
130 } |
|
131 |
|
132 TPtrC8 CSHA1Shim::Final(const TDesC8& /*aMessage*/) |
|
133 { |
|
134 // Provide a stub for compatibility; not used in random server |
|
135 ASSERT(EFalse); |
|
136 return NULL; |
|
137 } |
|
138 |
|
139 TPtrC8 CSHA1Shim::Final() |
|
140 { |
|
141 // Provide a stub for compatibility; not used in random server |
|
142 ASSERT(EFalse); |
|
143 return NULL; |
|
144 } |
|
145 |
|
146 void CSHA1Shim::Update(const TDesC8& /*aMessage*/) |
|
147 { |
|
148 // Provide a stub for compatibility; not used in random server |
|
149 ASSERT(EFalse); |
|
150 } |
|
151 |