sl@0: /* sl@0: * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of the License "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: sl@0: /** sl@0: @file sl@0: @publishedPartner sl@0: @released sl@0: */ sl@0: sl@0: #ifndef __PKCS12_H__ sl@0: #define __PKCS12_H__ sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS sl@0: #include sl@0: #endif sl@0: sl@0: namespace PKCS12 sl@0: { sl@0: class CDecPkcs12MacData; sl@0: sl@0: /** PKCS12 Version */ sl@0: const TInt KPkcs12Version = 3; sl@0: sl@0: /** sl@0: Contains methods to decode and return the PFX structure. sl@0: The structure contains the Version, MacData and AuthSafe. sl@0: MacData is OPTIONAL. sl@0: */ sl@0: class CDecPkcs12 : public CBase sl@0: { sl@0: public: sl@0: enum TIntegrityMode sl@0: /** sl@0: Identifies the type of Integrity Mode used in the PKCS12 PFX Structure sl@0: */ sl@0: { sl@0: /** Password Integrity Mode used in the PKCS12 PFX Structure */ sl@0: EPasswordIntegrityMode = 1, sl@0: sl@0: /** Public Key Integrity Mode used in the PKCS12 PFX Structure */ sl@0: EPublicKeyIntegrityMode sl@0: }; sl@0: /** sl@0: Creates a new PKCS#12 object. sl@0: sl@0: @param aRawData Contains a PKCS#12 PFX structure sl@0: @return A pointer to the newly allocated object. sl@0: @leave KErrArgument if the aRawData is not Pkcs12 PFX Structure. sl@0: */ sl@0: IMPORT_C static CDecPkcs12* NewL(const TDesC8& aRawData); sl@0: sl@0: /** sl@0: Creates a new PKCS#12 object. sl@0: sl@0: @param aRawData Contains a PKCS#12 PFX structure sl@0: @return A pointer to the newly allocated object. sl@0: @leave KErrArgument if the aRawData is not Pkcs12 PFX Structure. sl@0: */ sl@0: IMPORT_C static CDecPkcs12* NewLC(const TDesC8& aRawData); sl@0: sl@0: /** sl@0: Creates a new PKCS#12 object. sl@0: sl@0: @param aStream contains a PKCS#12 PFX structure sl@0: @return A pointer to the newly allocated object. sl@0: @leave KErrArgument if the aRawData is not Pkcs12 PFX Structure. sl@0: */ sl@0: IMPORT_C static CDecPkcs12* NewL(RReadStream& aStream); sl@0: sl@0: /** sl@0: Creates a new PKCS#12 object. sl@0: sl@0: @param aStream Contains a PKCS#12 PFX structure sl@0: @return A pointer to the newly allocated object. sl@0: @leave KErrArgument if the aRawData is not Pkcs12 PFX Structure. sl@0: */ sl@0: IMPORT_C static CDecPkcs12* NewLC(RReadStream& aStream); sl@0: sl@0: /** sl@0: Identifies the type of integrity mode used. sl@0: In the case of Password Integrity mode, OID is 1.2.840.113549.1.7.1. sl@0: In the case of Public Key Integrity mode, OID is 1.2.840.113549.1.7.2. sl@0: sl@0: @return An enum that identifies the type of integrity mode used. sl@0: */ sl@0: IMPORT_C TIntegrityMode IntegrityMode() const; sl@0: sl@0: /** sl@0: Returns the Version number contained in the PKCS12 PFX Structure. sl@0: @return Returns the Version number contained in the PKCS12 PFX Structure.. sl@0: */ sl@0: IMPORT_C TInt Version() const; sl@0: sl@0: /** sl@0: Returns the authenticated safe. sl@0: This authenticated safe is used to find the integrity mode used sl@0: and to verify the integrity of the packet. sl@0: sl@0: @return A reference to the CPKCS7ContentInfo object. sl@0: */ sl@0: IMPORT_C const CPKCS7ContentInfo& AuthenticatedSafe() const; sl@0: sl@0: /** sl@0: The MacData, which contains: sl@0: - The Mac, that is the PKCS#7 digest info structure. sl@0: - The MacSalt. sl@0: - The iteration count. sl@0: sl@0: @return Returns CDecPKCS12MacData object pointer if the MacData is present in the PFX Structure sl@0: Returns NULL pointer if the MacData is absent in the PFX Structure. sl@0: Returned pointer ownership retains with the object. sl@0: */ sl@0: IMPORT_C const CDecPkcs12MacData* MacData() const; sl@0: sl@0: /** sl@0: These objects represents the ContentInfo Sequences present in the sl@0: AuthenticatedSafe Sequence. sl@0: sl@0: @return An array of ContentInfo objects sl@0: @see CPKCS7ContentInfo sl@0: */ sl@0: IMPORT_C const RPointerArray& AuthenticatedSafeContents() const; sl@0: sl@0: /** sl@0: Destructor. sl@0: */ sl@0: virtual ~CDecPkcs12(); sl@0: sl@0: private: sl@0: /** sl@0: This decodes the entire PFX structure sl@0: sl@0: Main PKCS12 Structure. sl@0: PFX ::= SEQUENCE sl@0: { sl@0: version INTEGER {v3(3)}(v3,...), sl@0: authSafe ContentInfo, sl@0: macData MacData OPTIONAL sl@0: } sl@0: sl@0: @param aRawData Contains a PKCS#12 PFX Structure. sl@0: @leave KErrArgument if the aRawData is not a Valid Pkcs12 PFX Structure. sl@0: @see CPKCS7ContentInfo, CDecPkcs12MacData, CPKCS7SignedObject. sl@0: */ sl@0: void ConstructL(const TDesC8& aRawData); sl@0: sl@0: /** sl@0: This method is used to internalise that object and takes a reference sl@0: to an RReadStream as the interface to the read stream. sl@0: @param aStream Contains a PKCS#12 PFX Structure. sl@0: @leave KErrArgument if the aStream is not Pkcs12 PFX Structure. sl@0: */ sl@0: void InternalizeL(RReadStream& aStream); sl@0: sl@0: /** sl@0: Constructor. sl@0: */ sl@0: CDecPkcs12(); sl@0: sl@0: /** sl@0: Construtor. sl@0: */ sl@0: CDecPkcs12(RPointerArray aContentInfo); sl@0: sl@0: /** sl@0: Copy Constructor. sl@0: @param aDecPkcs12 A CDecPkcs12 object sl@0: */ sl@0: CDecPkcs12(const CDecPkcs12& aDecPkcs12); sl@0: sl@0: /** sl@0: Assignment operator. sl@0: @param aDecPkcs12 A CDecPkcs12 object. sl@0: @return A reference to CDecPkcs12 class. sl@0: */ sl@0: CDecPkcs12& operator=(const CDecPkcs12& aDecPkcs12); sl@0: sl@0: private: sl@0: /** PKCS12 PFX Structure Version number */ sl@0: TInt iVersion; sl@0: sl@0: /** Integrity Mode used in PKCS12 PFX Structure*/ sl@0: TIntegrityMode iMode; sl@0: sl@0: /** Contains the macData structure present sl@0: in the PKCS12 PFX Structure*/ sl@0: CDecPkcs12MacData* iMacData; sl@0: sl@0: /** This contains the entire AuthenticatedSafe Data sl@0: present in the PKCS12 PFX Structure*/ sl@0: CPKCS7ContentInfo* iAuthenticatedSafeData; sl@0: sl@0: /** This Contains an Array of ContentInfos present sl@0: within the AuthenticatedSafe of PKCS12 PFX Structure*/ sl@0: RPointerArray iContentInfos; sl@0: }; sl@0: } // namespace PKCS12 sl@0: sl@0: #endif // __PKCS12_H__