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 __PKCS7_DIGEST_INFO_H__ sl@0: #define __PKCS7_DIGEST_INFO_H__ sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: /** sl@0: Provides the means to decode PKCS#7 encoded DigestInfo Structure. sl@0: */ sl@0: class CPKCS7DigestInfo : public CBase sl@0: { sl@0: public: sl@0: /** sl@0: Creates a new PKCS#7 DigestInfo object. sl@0: @param aRawData contains a PKCS#7 DigestInfo Structure sl@0: @return A pointer to the newly allocated object. sl@0: @leave KErrArgument if digestAlgorithm and digest is not present. sl@0: @leave KErrNotSupported if algorithm is other than MD2, MD5 and SHA1. sl@0: */ sl@0: IMPORT_C static CPKCS7DigestInfo* NewL(const TDesC8& aRawData); sl@0: sl@0: /** sl@0: An Algorithm present DigestAlgorithmIdentifier. sl@0: @return The enum which identifies the type of Algorithm sl@0: used to obtain the hash. sl@0: */ sl@0: IMPORT_C TAlgorithmId Algorithm() const; sl@0: sl@0: /** sl@0: Encoded Parameters present in the DigestAlgorithmIdentifier. sl@0: The client has to check for data length. It is 0 in case there are no EncodedParams sl@0: @return The Encoded Parameters which is in the DigestAlgorithmIdentifier. sl@0: */ sl@0: IMPORT_C const TPtrC8& EncodedParams() const; sl@0: sl@0: /** sl@0: The Digest which is in the DigestInfo. sl@0: @return The Digest which is in the DigestInfo and is an Octet String. sl@0: */ sl@0: IMPORT_C const TDesC8& Digest() const; sl@0: sl@0: /** sl@0: Destructor. sl@0: */ sl@0: virtual ~CPKCS7DigestInfo(); sl@0: sl@0: private: sl@0: /** sl@0: Constructor. sl@0: */ sl@0: CPKCS7DigestInfo(); sl@0: sl@0: /** sl@0: Copy Constructor. sl@0: @param aDigestInfo A CPKCS7DigestInfo object. sl@0: */ sl@0: CPKCS7DigestInfo(const CPKCS7DigestInfo& aDigestInfo); sl@0: sl@0: /** sl@0: Assignment operator. sl@0: @param aDigestInfo A CPKCS7DigestInfo object. sl@0: @return A reference to CPKCS7DigestInfo class. sl@0: */ sl@0: CPKCS7DigestInfo& operator=(const CPKCS7DigestInfo& aDigestInfo); sl@0: sl@0: /** sl@0: Decodes the given ASN1 DigestInfo. Below is the ASN1 syntax sl@0: sl@0: DigestInfo ::= SEQUENCE sl@0: { sl@0: digestAlgorithm DigestAlgorithmIdentifier, sl@0: digest Digest sl@0: } sl@0: Digest ::= OCTET String sl@0: DigestAlgorithmIdentifier ::= AlgorithmIdentifier sl@0: AlgorithmIdentifier ::= SEQUENCE sl@0: { sl@0: algorithm ALGORITHM.&id({SupportedAlgorithms}), sl@0: parameters ALGORITHM.&Type({SupportedAlgorithms}{@ algorithm}) OPTIONAL sl@0: } sl@0: sl@0: @param aRawData A descriptor containing the PKCS7 DigestInfo Sequence. sl@0: @leave KErrArgument if digestAlgorithm and digest is not present. sl@0: @leave KErrNotSupported if algorithm is other than MD2, MD5 and SHA1. sl@0: @see TASN1DecGeneric, CX509AlgorithmIdentifier. sl@0: */ sl@0: void ConstructL(const TDesC8& aRawData); sl@0: sl@0: private: sl@0: /** sl@0: The object identifier which identifies the message-digest algorithm. sl@0: A message-digest algorithm maps an octet string (the message) to sl@0: another octet string (the message digest) sl@0: */ sl@0: TAlgorithmId iAlgorithmId; sl@0: sl@0: /** Encoded Parameters which is in the DigestAlgorithmIdentifier */ sl@0: TPtrC8 iEncodedParams; sl@0: sl@0: /** sl@0: The Digest is present in the DigestInfo. sl@0: It is the result of the message-digesting process sl@0: */ sl@0: TPtrC8 iDigest; sl@0: }; sl@0: sl@0: #endif //__PKCS7_DIGEST_INFO_H__