|
1 /* |
|
2 * Copyright (c) 2007-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 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 /** |
|
22 @file |
|
23 @internalComponent |
|
24 @released |
|
25 */ |
|
26 |
|
27 |
|
28 #ifndef __CRYPTOAPI_SOFTWARESHA384AND512IMPL_H_ |
|
29 #define __CRYPTOAPI_SOFTWARESHA384AND512IMPL_H_ |
|
30 |
|
31 |
|
32 #include "softwarehashbase.h" |
|
33 #include "shacommon.h" |
|
34 |
|
35 namespace SoftwareCrypto |
|
36 { |
|
37 using namespace CryptoSpi; |
|
38 |
|
39 const TInt KSHA512BlockSize = 128; |
|
40 const TInt KSHA384HashSize = 48; |
|
41 const TInt KSHA512HashSize = 64; |
|
42 |
|
43 NONSHARABLE_CLASS(CSHA384And512Impl) : public CBase, public MSHA2Impl |
|
44 { |
|
45 public: |
|
46 //NewL |
|
47 static CSHA384And512Impl* NewL(TInt aHashSize = KSHA512HashSize); |
|
48 CSHA384And512Impl(const CSHA384And512Impl& aSHA512Impl); |
|
49 |
|
50 //From MSHAImpl |
|
51 virtual void Reset(const TAny* aValueArr); |
|
52 virtual const TDesC8& Final(void); |
|
53 virtual void Update(const TUint8* aData,TUint aLength); |
|
54 virtual void StoreState(); |
|
55 virtual void RestoreState(); |
|
56 |
|
57 private: |
|
58 //Constructors |
|
59 CSHA384And512Impl(TInt aHashSize); |
|
60 |
|
61 private: |
|
62 // Private member functions |
|
63 /** |
|
64 * @param aLength - Length of message added in bytes. |
|
65 */ |
|
66 inline void AddLength(const TUint64 aLength); |
|
67 inline void CopyWordToHash(TUint64 aVal, TUint aIndex); |
|
68 void Block(); |
|
69 void PadMessage(); |
|
70 |
|
71 private: |
|
72 TBuf8<KSHA512HashSize> iHash; |
|
73 TUint64 iA; |
|
74 TUint64 iB; |
|
75 TUint64 iC; |
|
76 TUint64 iD; |
|
77 TUint64 iE; |
|
78 TUint64 iF; |
|
79 TUint64 iG; |
|
80 TUint64 iH; |
|
81 TUint64 iData[KSHA512BlockSize]; |
|
82 |
|
83 TUint64 iACopy; |
|
84 TUint64 iBCopy; |
|
85 TUint64 iCCopy; |
|
86 TUint64 iDCopy; |
|
87 TUint64 iECopy; |
|
88 TUint64 iFCopy; |
|
89 TUint64 iGCopy; |
|
90 TUint64 iHCopy; |
|
91 TUint64 iNlCopy; |
|
92 TUint64 iNhCopy; |
|
93 TUint iBlockIndexCopy; |
|
94 TUint64 iDataCopy[KSHA512BlockSize]; |
|
95 |
|
96 TUint64 iNl; // Lower word of Message Length |
|
97 TUint64 iNh; // Higher word of Message Length |
|
98 TUint iBlockIndex; // Message Length in the current block |
|
99 }; |
|
100 } |
|
101 |
|
102 #endif // __CRYPTOAPI_SOFTWARESHA384AND512IMPL_H_ |