1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/security/cryptoservices/certificateandkeymgmt/inc/pkcs12.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,224 @@
1.4 +/*
1.5 +* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of the License "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +/**
1.23 + @file
1.24 + @publishedPartner
1.25 + @released
1.26 +*/
1.27 +
1.28 +#ifndef __PKCS12_H__
1.29 +#define __PKCS12_H__
1.30 +
1.31 +#include <s32strm.h>
1.32 +#include <asn1dec.h>
1.33 +#include <x509cert.h>
1.34 +#include <asnpkcs.h>
1.35 +#include <pkcs7contentinfo_v2.h>
1.36 +#include <pkcs7digestinfo.h>
1.37 +#include <pkcs7encrypteddataobject.h>
1.38 +#include <pkcs12macdata.h>
1.39 +#include <pkcs12safebag.h>
1.40 +
1.41 +#ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
1.42 +#include <pkcs7signedobject.h>
1.43 +#endif
1.44 +
1.45 +namespace PKCS12
1.46 +{
1.47 +class CDecPkcs12MacData;
1.48 +
1.49 +/** PKCS12 Version */
1.50 +const TInt KPkcs12Version = 3;
1.51 +
1.52 +/**
1.53 + Contains methods to decode and return the PFX structure.
1.54 + The structure contains the Version, MacData and AuthSafe.
1.55 + MacData is OPTIONAL.
1.56 + */
1.57 +class CDecPkcs12 : public CBase
1.58 + {
1.59 +public:
1.60 + enum TIntegrityMode
1.61 + /**
1.62 + Identifies the type of Integrity Mode used in the PKCS12 PFX Structure
1.63 + */
1.64 + {
1.65 + /** Password Integrity Mode used in the PKCS12 PFX Structure */
1.66 + EPasswordIntegrityMode = 1,
1.67 +
1.68 + /** Public Key Integrity Mode used in the PKCS12 PFX Structure */
1.69 + EPublicKeyIntegrityMode
1.70 + };
1.71 + /**
1.72 + Creates a new PKCS#12 object.
1.73 +
1.74 + @param aRawData Contains a PKCS#12 PFX structure
1.75 + @return A pointer to the newly allocated object.
1.76 + @leave KErrArgument if the aRawData is not Pkcs12 PFX Structure.
1.77 + */
1.78 + IMPORT_C static CDecPkcs12* NewL(const TDesC8& aRawData);
1.79 +
1.80 + /**
1.81 + Creates a new PKCS#12 object.
1.82 +
1.83 + @param aRawData Contains a PKCS#12 PFX structure
1.84 + @return A pointer to the newly allocated object.
1.85 + @leave KErrArgument if the aRawData is not Pkcs12 PFX Structure.
1.86 + */
1.87 + IMPORT_C static CDecPkcs12* NewLC(const TDesC8& aRawData);
1.88 +
1.89 + /**
1.90 + Creates a new PKCS#12 object.
1.91 +
1.92 + @param aStream contains a PKCS#12 PFX structure
1.93 + @return A pointer to the newly allocated object.
1.94 + @leave KErrArgument if the aRawData is not Pkcs12 PFX Structure.
1.95 + */
1.96 + IMPORT_C static CDecPkcs12* NewL(RReadStream& aStream);
1.97 +
1.98 + /**
1.99 + Creates a new PKCS#12 object.
1.100 +
1.101 + @param aStream Contains a PKCS#12 PFX structure
1.102 + @return A pointer to the newly allocated object.
1.103 + @leave KErrArgument if the aRawData is not Pkcs12 PFX Structure.
1.104 + */
1.105 + IMPORT_C static CDecPkcs12* NewLC(RReadStream& aStream);
1.106 +
1.107 + /**
1.108 + Identifies the type of integrity mode used.
1.109 + In the case of Password Integrity mode, OID is 1.2.840.113549.1.7.1.
1.110 + In the case of Public Key Integrity mode, OID is 1.2.840.113549.1.7.2.
1.111 +
1.112 + @return An enum that identifies the type of integrity mode used.
1.113 + */
1.114 + IMPORT_C TIntegrityMode IntegrityMode() const;
1.115 +
1.116 + /**
1.117 + Returns the Version number contained in the PKCS12 PFX Structure.
1.118 + @return Returns the Version number contained in the PKCS12 PFX Structure..
1.119 + */
1.120 + IMPORT_C TInt Version() const;
1.121 +
1.122 + /**
1.123 + Returns the authenticated safe.
1.124 + This authenticated safe is used to find the integrity mode used
1.125 + and to verify the integrity of the packet.
1.126 +
1.127 + @return A reference to the CPKCS7ContentInfo object.
1.128 + */
1.129 + IMPORT_C const CPKCS7ContentInfo& AuthenticatedSafe() const;
1.130 +
1.131 + /**
1.132 + The MacData, which contains:
1.133 + - The Mac, that is the PKCS#7 digest info structure.
1.134 + - The MacSalt.
1.135 + - The iteration count.
1.136 +
1.137 + @return Returns CDecPKCS12MacData object pointer if the MacData is present in the PFX Structure
1.138 + Returns NULL pointer if the MacData is absent in the PFX Structure.
1.139 + Returned pointer ownership retains with the object.
1.140 + */
1.141 + IMPORT_C const CDecPkcs12MacData* MacData() const;
1.142 +
1.143 + /**
1.144 + These objects represents the ContentInfo Sequences present in the
1.145 + AuthenticatedSafe Sequence.
1.146 +
1.147 + @return An array of ContentInfo objects
1.148 + @see CPKCS7ContentInfo
1.149 + */
1.150 + IMPORT_C const RPointerArray<CPKCS7ContentInfo>& AuthenticatedSafeContents() const;
1.151 +
1.152 + /**
1.153 + Destructor.
1.154 + */
1.155 + virtual ~CDecPkcs12();
1.156 +
1.157 +private:
1.158 + /**
1.159 + This decodes the entire PFX structure
1.160 +
1.161 + Main PKCS12 Structure.
1.162 + PFX ::= SEQUENCE
1.163 + {
1.164 + version INTEGER {v3(3)}(v3,...),
1.165 + authSafe ContentInfo,
1.166 + macData MacData OPTIONAL
1.167 + }
1.168 +
1.169 + @param aRawData Contains a PKCS#12 PFX Structure.
1.170 + @leave KErrArgument if the aRawData is not a Valid Pkcs12 PFX Structure.
1.171 + @see CPKCS7ContentInfo, CDecPkcs12MacData, CPKCS7SignedObject.
1.172 + */
1.173 + void ConstructL(const TDesC8& aRawData);
1.174 +
1.175 + /**
1.176 + This method is used to internalise that object and takes a reference
1.177 + to an RReadStream as the interface to the read stream.
1.178 + @param aStream Contains a PKCS#12 PFX Structure.
1.179 + @leave KErrArgument if the aStream is not Pkcs12 PFX Structure.
1.180 + */
1.181 + void InternalizeL(RReadStream& aStream);
1.182 +
1.183 + /**
1.184 + Constructor.
1.185 + */
1.186 + CDecPkcs12();
1.187 +
1.188 + /**
1.189 + Construtor.
1.190 + */
1.191 + CDecPkcs12(RPointerArray<CPKCS7ContentInfo> aContentInfo);
1.192 +
1.193 + /**
1.194 + Copy Constructor.
1.195 + @param aDecPkcs12 A CDecPkcs12 object
1.196 + */
1.197 + CDecPkcs12(const CDecPkcs12& aDecPkcs12);
1.198 +
1.199 + /**
1.200 + Assignment operator.
1.201 + @param aDecPkcs12 A CDecPkcs12 object.
1.202 + @return A reference to CDecPkcs12 class.
1.203 + */
1.204 + CDecPkcs12& operator=(const CDecPkcs12& aDecPkcs12);
1.205 +
1.206 +private:
1.207 + /** PKCS12 PFX Structure Version number */
1.208 + TInt iVersion;
1.209 +
1.210 + /** Integrity Mode used in PKCS12 PFX Structure*/
1.211 + TIntegrityMode iMode;
1.212 +
1.213 + /** Contains the macData structure present
1.214 + in the PKCS12 PFX Structure*/
1.215 + CDecPkcs12MacData* iMacData;
1.216 +
1.217 + /** This contains the entire AuthenticatedSafe Data
1.218 + present in the PKCS12 PFX Structure*/
1.219 + CPKCS7ContentInfo* iAuthenticatedSafeData;
1.220 +
1.221 + /** This Contains an Array of ContentInfos present
1.222 + within the AuthenticatedSafe of PKCS12 PFX Structure*/
1.223 + RPointerArray<CPKCS7ContentInfo> iContentInfos;
1.224 + };
1.225 +} // namespace PKCS12
1.226 +
1.227 +#endif // __PKCS12_H__