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: #ifndef __PKCS12_MACDATA_H__ sl@0: #define __PKCS12_MACDATA_H__ sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: namespace PKCS12 sl@0: { sl@0: /** Default Iteration Count */ sl@0: const TInt KDefaultIterationCount = 1; sl@0: sl@0: /** SHA-1 HMAC 160 bit Key length for key derivation. */ sl@0: const TInt KSha1HmacKeyLength = 20; sl@0: sl@0: /** sl@0: This class decodes the MacData sl@0: It has methods to return the PKCS#12 MACDATA structure. sl@0: */ sl@0: class CDecPkcs12MacData : public CBase sl@0: { sl@0: public: sl@0: /** sl@0: Creates a new PKCS#12MacData object. sl@0: sl@0: @param aMacData contains a PKCS#12 MacData Structure. sl@0: @param aAuthSafeData is the ContentData present in the authSafe Sequence sl@0: of PKCS#12 PFX Structure. sl@0: @return A pointer to the newly allocated object. sl@0: @leave KErrArgument if the data is not Pkcs12 macData structure. sl@0: */ sl@0: IMPORT_C static CDecPkcs12MacData* NewL(const TDesC8& aMacData, const TDesC8& aAuthSafeData); sl@0: sl@0: /** sl@0: The DigestInfo present in the MacData. sl@0: It has the DigestAlgorithmIdentifier, and the Digest. sl@0: @return A reference to the CPKCS7DigestInfo object containing sl@0: the decoded DigestInfo sl@0: */ sl@0: IMPORT_C const CPKCS7DigestInfo& DigestInfo() const; sl@0: sl@0: /** sl@0: This method returns the MacSalt. sl@0: MacSalt is used as input to the key generation mechanism. sl@0: @return A value indicating the MacSalt sl@0: */ sl@0: IMPORT_C const TDesC8& MacSalt() const; sl@0: sl@0: /** sl@0: This method returns the Iteration Count. It is used in creating the key. sl@0: @return An integer value indicating the IterationCount. sl@0: */ sl@0: IMPORT_C TInt IterationCount() const; sl@0: sl@0: /** sl@0: This method does the Integrity Check for Password Integrity Mode sl@0: by comparing the Digest present in the MacData of the PKCS#12 Structure sl@0: with the hash generated from the content field of the authenticated Safe, sl@0: password, the Iteration Count and the Salt present in the MacData. sl@0: @param aPassword contains the password to derive the key. sl@0: @return Returns ETrue, if the Integrity verification passes. sl@0: Returns EFalse, if the Integrity verification fails. sl@0: @leave KErrNotSupported if the Pkcs7 digest algorithm is otherthan MD2, sl@0: MD5 and SHA-1 sl@0: @see PKCS12KDF, CMessageDigest, sl@0: */ sl@0: IMPORT_C TBool VerifyIntegrityL(const TDesC& aPassword) const; sl@0: sl@0: /** sl@0: Destructor. sl@0: */ sl@0: virtual ~CDecPkcs12MacData(); sl@0: sl@0: private: sl@0: /** sl@0: This decodes the entire MacData structure. sl@0: @param aMacData contains a PKCS#12 MacData Structure. sl@0: @param aAuthSafeData is the ContentData present in the authSafe Sequence sl@0: of PKCS#12 PFX Structure. sl@0: @leave KErrArgument if the data is not Pkcs12 macData structure. sl@0: @see CPKCS7DigestInfo sl@0: */ sl@0: void ConstructL(const TDesC8& aMacData, const TDesC8& aAuthSafeData); sl@0: sl@0: /** sl@0: Constructor. sl@0: */ sl@0: CDecPkcs12MacData(); sl@0: sl@0: /** sl@0: Copy Constructor. sl@0: @param aDecPkcs12MacData A CDecPkcs12MacData object. sl@0: */ sl@0: CDecPkcs12MacData(const CDecPkcs12MacData& aDecPkcs12MacData); sl@0: sl@0: /** sl@0: Assignment operator. sl@0: @param aDecPkcs12MacData A CDecPkcs12MacData object. sl@0: @return A reference to CDecPkcs12MacData class. sl@0: */ sl@0: CDecPkcs12MacData& operator=(const CDecPkcs12MacData& aDecPkcs12MacData); sl@0: sl@0: private: sl@0: /** DigestInfo(PKCS#7 structure) present in the PKCS#12 MacData structure */ sl@0: CPKCS7DigestInfo* iDigestInfo; sl@0: sl@0: /** MacSalt present in the PKCS#12 MacData structure */ sl@0: TPtrC8 iMacSalt; sl@0: sl@0: /** Iteration Count present in the PKCS#12 MacData structure */ sl@0: TInt iIterationCount; sl@0: sl@0: /** authSafe sequence present in PKCS#12 PFX structure.*/ sl@0: TPtrC8 iAuthSafeDataPtr; sl@0: sl@0: }; sl@0: } // namespace PKCS12 sl@0: #endif // __PKCS12_MACDATA_H__ sl@0: