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