sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
*
|
sl@0
|
16 |
*/
|
sl@0
|
17 |
|
sl@0
|
18 |
|
sl@0
|
19 |
/**
|
sl@0
|
20 |
@file
|
sl@0
|
21 |
@publishedPartner
|
sl@0
|
22 |
@released
|
sl@0
|
23 |
*/
|
sl@0
|
24 |
#ifndef __PKCS12_MACDATA_H__
|
sl@0
|
25 |
#define __PKCS12_MACDATA_H__
|
sl@0
|
26 |
|
sl@0
|
27 |
#include <e32base.h>
|
sl@0
|
28 |
#include <asn1dec.h>
|
sl@0
|
29 |
#include <hash.h>
|
sl@0
|
30 |
#include <pkcs12kdf.h>
|
sl@0
|
31 |
#include <pkcs7digestinfo.h>
|
sl@0
|
32 |
|
sl@0
|
33 |
namespace PKCS12
|
sl@0
|
34 |
{
|
sl@0
|
35 |
/** Default Iteration Count */
|
sl@0
|
36 |
const TInt KDefaultIterationCount = 1;
|
sl@0
|
37 |
|
sl@0
|
38 |
/** SHA-1 HMAC 160 bit Key length for key derivation. */
|
sl@0
|
39 |
const TInt KSha1HmacKeyLength = 20;
|
sl@0
|
40 |
|
sl@0
|
41 |
/**
|
sl@0
|
42 |
This class decodes the MacData
|
sl@0
|
43 |
It has methods to return the PKCS#12 MACDATA structure.
|
sl@0
|
44 |
*/
|
sl@0
|
45 |
class CDecPkcs12MacData : public CBase
|
sl@0
|
46 |
{
|
sl@0
|
47 |
public:
|
sl@0
|
48 |
/**
|
sl@0
|
49 |
Creates a new PKCS#12MacData object.
|
sl@0
|
50 |
|
sl@0
|
51 |
@param aMacData contains a PKCS#12 MacData Structure.
|
sl@0
|
52 |
@param aAuthSafeData is the ContentData present in the authSafe Sequence
|
sl@0
|
53 |
of PKCS#12 PFX Structure.
|
sl@0
|
54 |
@return A pointer to the newly allocated object.
|
sl@0
|
55 |
@leave KErrArgument if the data is not Pkcs12 macData structure.
|
sl@0
|
56 |
*/
|
sl@0
|
57 |
IMPORT_C static CDecPkcs12MacData* NewL(const TDesC8& aMacData, const TDesC8& aAuthSafeData);
|
sl@0
|
58 |
|
sl@0
|
59 |
/**
|
sl@0
|
60 |
The DigestInfo present in the MacData.
|
sl@0
|
61 |
It has the DigestAlgorithmIdentifier, and the Digest.
|
sl@0
|
62 |
@return A reference to the CPKCS7DigestInfo object containing
|
sl@0
|
63 |
the decoded DigestInfo
|
sl@0
|
64 |
*/
|
sl@0
|
65 |
IMPORT_C const CPKCS7DigestInfo& DigestInfo() const;
|
sl@0
|
66 |
|
sl@0
|
67 |
/**
|
sl@0
|
68 |
This method returns the MacSalt.
|
sl@0
|
69 |
MacSalt is used as input to the key generation mechanism.
|
sl@0
|
70 |
@return A value indicating the MacSalt
|
sl@0
|
71 |
*/
|
sl@0
|
72 |
IMPORT_C const TDesC8& MacSalt() const;
|
sl@0
|
73 |
|
sl@0
|
74 |
/**
|
sl@0
|
75 |
This method returns the Iteration Count. It is used in creating the key.
|
sl@0
|
76 |
@return An integer value indicating the IterationCount.
|
sl@0
|
77 |
*/
|
sl@0
|
78 |
IMPORT_C TInt IterationCount() const;
|
sl@0
|
79 |
|
sl@0
|
80 |
/**
|
sl@0
|
81 |
This method does the Integrity Check for Password Integrity Mode
|
sl@0
|
82 |
by comparing the Digest present in the MacData of the PKCS#12 Structure
|
sl@0
|
83 |
with the hash generated from the content field of the authenticated Safe,
|
sl@0
|
84 |
password, the Iteration Count and the Salt present in the MacData.
|
sl@0
|
85 |
@param aPassword contains the password to derive the key.
|
sl@0
|
86 |
@return Returns ETrue, if the Integrity verification passes.
|
sl@0
|
87 |
Returns EFalse, if the Integrity verification fails.
|
sl@0
|
88 |
@leave KErrNotSupported if the Pkcs7 digest algorithm is otherthan MD2,
|
sl@0
|
89 |
MD5 and SHA-1
|
sl@0
|
90 |
@see PKCS12KDF, CMessageDigest,
|
sl@0
|
91 |
*/
|
sl@0
|
92 |
IMPORT_C TBool VerifyIntegrityL(const TDesC& aPassword) const;
|
sl@0
|
93 |
|
sl@0
|
94 |
/**
|
sl@0
|
95 |
Destructor.
|
sl@0
|
96 |
*/
|
sl@0
|
97 |
virtual ~CDecPkcs12MacData();
|
sl@0
|
98 |
|
sl@0
|
99 |
private:
|
sl@0
|
100 |
/**
|
sl@0
|
101 |
This decodes the entire MacData structure.
|
sl@0
|
102 |
@param aMacData contains a PKCS#12 MacData Structure.
|
sl@0
|
103 |
@param aAuthSafeData is the ContentData present in the authSafe Sequence
|
sl@0
|
104 |
of PKCS#12 PFX Structure.
|
sl@0
|
105 |
@leave KErrArgument if the data is not Pkcs12 macData structure.
|
sl@0
|
106 |
@see CPKCS7DigestInfo
|
sl@0
|
107 |
*/
|
sl@0
|
108 |
void ConstructL(const TDesC8& aMacData, const TDesC8& aAuthSafeData);
|
sl@0
|
109 |
|
sl@0
|
110 |
/**
|
sl@0
|
111 |
Constructor.
|
sl@0
|
112 |
*/
|
sl@0
|
113 |
CDecPkcs12MacData();
|
sl@0
|
114 |
|
sl@0
|
115 |
/**
|
sl@0
|
116 |
Copy Constructor.
|
sl@0
|
117 |
@param aDecPkcs12MacData A CDecPkcs12MacData object.
|
sl@0
|
118 |
*/
|
sl@0
|
119 |
CDecPkcs12MacData(const CDecPkcs12MacData& aDecPkcs12MacData);
|
sl@0
|
120 |
|
sl@0
|
121 |
/**
|
sl@0
|
122 |
Assignment operator.
|
sl@0
|
123 |
@param aDecPkcs12MacData A CDecPkcs12MacData object.
|
sl@0
|
124 |
@return A reference to CDecPkcs12MacData class.
|
sl@0
|
125 |
*/
|
sl@0
|
126 |
CDecPkcs12MacData& operator=(const CDecPkcs12MacData& aDecPkcs12MacData);
|
sl@0
|
127 |
|
sl@0
|
128 |
private:
|
sl@0
|
129 |
/** DigestInfo(PKCS#7 structure) present in the PKCS#12 MacData structure */
|
sl@0
|
130 |
CPKCS7DigestInfo* iDigestInfo;
|
sl@0
|
131 |
|
sl@0
|
132 |
/** MacSalt present in the PKCS#12 MacData structure */
|
sl@0
|
133 |
TPtrC8 iMacSalt;
|
sl@0
|
134 |
|
sl@0
|
135 |
/** Iteration Count present in the PKCS#12 MacData structure */
|
sl@0
|
136 |
TInt iIterationCount;
|
sl@0
|
137 |
|
sl@0
|
138 |
/** authSafe sequence present in PKCS#12 PFX structure.*/
|
sl@0
|
139 |
TPtrC8 iAuthSafeDataPtr;
|
sl@0
|
140 |
|
sl@0
|
141 |
};
|
sl@0
|
142 |
} // namespace PKCS12
|
sl@0
|
143 |
#endif // __PKCS12_MACDATA_H__
|
sl@0
|
144 |
|