First public contribution.
2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
32 #include <pkcs7contentinfo_v2.h>
33 #include <pkcs7digestinfo.h>
34 #include <pkcs7encrypteddataobject.h>
35 #include <pkcs12macdata.h>
36 #include <pkcs12safebag.h>
38 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
39 #include <pkcs7signedobject.h>
44 class CDecPkcs12MacData;
47 const TInt KPkcs12Version = 3;
50 Contains methods to decode and return the PFX structure.
51 The structure contains the Version, MacData and AuthSafe.
54 class CDecPkcs12 : public CBase
59 Identifies the type of Integrity Mode used in the PKCS12 PFX Structure
62 /** Password Integrity Mode used in the PKCS12 PFX Structure */
63 EPasswordIntegrityMode = 1,
65 /** Public Key Integrity Mode used in the PKCS12 PFX Structure */
66 EPublicKeyIntegrityMode
69 Creates a new PKCS#12 object.
71 @param aRawData Contains a PKCS#12 PFX structure
72 @return A pointer to the newly allocated object.
73 @leave KErrArgument if the aRawData is not Pkcs12 PFX Structure.
75 IMPORT_C static CDecPkcs12* NewL(const TDesC8& aRawData);
78 Creates a new PKCS#12 object.
80 @param aRawData Contains a PKCS#12 PFX structure
81 @return A pointer to the newly allocated object.
82 @leave KErrArgument if the aRawData is not Pkcs12 PFX Structure.
84 IMPORT_C static CDecPkcs12* NewLC(const TDesC8& aRawData);
87 Creates a new PKCS#12 object.
89 @param aStream contains a PKCS#12 PFX structure
90 @return A pointer to the newly allocated object.
91 @leave KErrArgument if the aRawData is not Pkcs12 PFX Structure.
93 IMPORT_C static CDecPkcs12* NewL(RReadStream& aStream);
96 Creates a new PKCS#12 object.
98 @param aStream Contains a PKCS#12 PFX structure
99 @return A pointer to the newly allocated object.
100 @leave KErrArgument if the aRawData is not Pkcs12 PFX Structure.
102 IMPORT_C static CDecPkcs12* NewLC(RReadStream& aStream);
105 Identifies the type of integrity mode used.
106 In the case of Password Integrity mode, OID is 1.2.840.113549.1.7.1.
107 In the case of Public Key Integrity mode, OID is 1.2.840.113549.1.7.2.
109 @return An enum that identifies the type of integrity mode used.
111 IMPORT_C TIntegrityMode IntegrityMode() const;
114 Returns the Version number contained in the PKCS12 PFX Structure.
115 @return Returns the Version number contained in the PKCS12 PFX Structure..
117 IMPORT_C TInt Version() const;
120 Returns the authenticated safe.
121 This authenticated safe is used to find the integrity mode used
122 and to verify the integrity of the packet.
124 @return A reference to the CPKCS7ContentInfo object.
126 IMPORT_C const CPKCS7ContentInfo& AuthenticatedSafe() const;
129 The MacData, which contains:
130 - The Mac, that is the PKCS#7 digest info structure.
132 - The iteration count.
134 @return Returns CDecPKCS12MacData object pointer if the MacData is present in the PFX Structure
135 Returns NULL pointer if the MacData is absent in the PFX Structure.
136 Returned pointer ownership retains with the object.
138 IMPORT_C const CDecPkcs12MacData* MacData() const;
141 These objects represents the ContentInfo Sequences present in the
142 AuthenticatedSafe Sequence.
144 @return An array of ContentInfo objects
145 @see CPKCS7ContentInfo
147 IMPORT_C const RPointerArray<CPKCS7ContentInfo>& AuthenticatedSafeContents() const;
152 virtual ~CDecPkcs12();
156 This decodes the entire PFX structure
158 Main PKCS12 Structure.
161 version INTEGER {v3(3)}(v3,...),
162 authSafe ContentInfo,
163 macData MacData OPTIONAL
166 @param aRawData Contains a PKCS#12 PFX Structure.
167 @leave KErrArgument if the aRawData is not a Valid Pkcs12 PFX Structure.
168 @see CPKCS7ContentInfo, CDecPkcs12MacData, CPKCS7SignedObject.
170 void ConstructL(const TDesC8& aRawData);
173 This method is used to internalise that object and takes a reference
174 to an RReadStream as the interface to the read stream.
175 @param aStream Contains a PKCS#12 PFX Structure.
176 @leave KErrArgument if the aStream is not Pkcs12 PFX Structure.
178 void InternalizeL(RReadStream& aStream);
188 CDecPkcs12(RPointerArray<CPKCS7ContentInfo> aContentInfo);
192 @param aDecPkcs12 A CDecPkcs12 object
194 CDecPkcs12(const CDecPkcs12& aDecPkcs12);
198 @param aDecPkcs12 A CDecPkcs12 object.
199 @return A reference to CDecPkcs12 class.
201 CDecPkcs12& operator=(const CDecPkcs12& aDecPkcs12);
204 /** PKCS12 PFX Structure Version number */
207 /** Integrity Mode used in PKCS12 PFX Structure*/
208 TIntegrityMode iMode;
210 /** Contains the macData structure present
211 in the PKCS12 PFX Structure*/
212 CDecPkcs12MacData* iMacData;
214 /** This contains the entire AuthenticatedSafe Data
215 present in the PKCS12 PFX Structure*/
216 CPKCS7ContentInfo* iAuthenticatedSafeData;
218 /** This Contains an Array of ContentInfos present
219 within the AuthenticatedSafe of PKCS12 PFX Structure*/
220 RPointerArray<CPKCS7ContentInfo> iContentInfos;
222 } // namespace PKCS12
224 #endif // __PKCS12_H__