cryptoservices/certificateandkeymgmt/inc/pkcs7digestinfo.h
changeset 0 2c201484c85f
child 8 35751d3474b7
equal deleted inserted replaced
-1:000000000000 0:2c201484c85f
       
     1 /*
       
     2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     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".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 /**
       
    22  @file
       
    23  @publishedPartner
       
    24  @released
       
    25 */
       
    26 
       
    27 #ifndef __PKCS7_DIGEST_INFO_H__
       
    28 #define __PKCS7_DIGEST_INFO_H__
       
    29 
       
    30 #include <e32base.h>
       
    31 #include <x509cert.h>
       
    32 #include <signed.h>
       
    33 #include <asn1dec.h>
       
    34 
       
    35 /**
       
    36  Provides the means to decode PKCS#7 encoded DigestInfo Structure.
       
    37  */
       
    38 class CPKCS7DigestInfo : public CBase
       
    39 	{
       
    40 public:	
       
    41 	/**
       
    42 	 Creates a new PKCS#7 DigestInfo object. 
       
    43 	 @param     aRawData contains a PKCS#7 DigestInfo Structure
       
    44 	 @return    A pointer to the newly allocated object.
       
    45 	 @leave 	KErrArgument if digestAlgorithm and digest is not present.
       
    46 	 @leave 	KErrNotSupported if algorithm is other than MD2, MD5 and SHA1.
       
    47 	 */
       
    48     IMPORT_C static CPKCS7DigestInfo* NewL(const TDesC8& aRawData);
       
    49     
       
    50     /**
       
    51 	 An Algorithm present DigestAlgorithmIdentifier.
       
    52      @return    The enum which identifies the type of Algorithm
       
    53                 used to obtain the hash.
       
    54      */   
       
    55 	IMPORT_C TAlgorithmId Algorithm() const;
       
    56 	
       
    57 	/**
       
    58 	 Encoded Parameters present in the DigestAlgorithmIdentifier.
       
    59 	 The client has to check for data length. It is 0 in case there are no EncodedParams
       
    60 	 @return    The Encoded Parameters which is in the DigestAlgorithmIdentifier.
       
    61      */     
       
    62 	IMPORT_C const TPtrC8& EncodedParams() const;
       
    63 	
       
    64 	/**
       
    65 	 The Digest which is in the DigestInfo.
       
    66 	 @return    The Digest which is in the DigestInfo and is an Octet String.
       
    67      */
       
    68 	IMPORT_C const TDesC8& Digest() const;
       
    69 	
       
    70 	/**
       
    71 	 Destructor.
       
    72 	 */
       
    73 	virtual ~CPKCS7DigestInfo();
       
    74 	
       
    75 private:
       
    76 	/**
       
    77 	 Constructor.
       
    78 	 */
       
    79     CPKCS7DigestInfo(); 
       
    80     
       
    81     /**
       
    82 	 Copy Constructor.
       
    83 	 @param aDigestInfo A CPKCS7DigestInfo object.
       
    84 	 */
       
    85 	CPKCS7DigestInfo(const CPKCS7DigestInfo& aDigestInfo);
       
    86 	
       
    87 	/**
       
    88 	 Assignment operator.
       
    89 	 @param aDigestInfo A CPKCS7DigestInfo object.
       
    90 	 @return A reference to CPKCS7DigestInfo class.
       
    91 	 */
       
    92 	CPKCS7DigestInfo& operator=(const CPKCS7DigestInfo& aDigestInfo);
       
    93     
       
    94 	/**
       
    95 	 Decodes the given ASN1 DigestInfo. Below is the ASN1 syntax
       
    96 	
       
    97 	 DigestInfo ::= SEQUENCE
       
    98 	 	{
       
    99 	    digestAlgorithm  DigestAlgorithmIdentifier,
       
   100 	    digest           Digest
       
   101 	    }
       
   102 	 Digest ::= OCTET String	 
       
   103 	 DigestAlgorithmIdentifier ::= AlgorithmIdentifier
       
   104 	 AlgorithmIdentifier ::= SEQUENCE 
       
   105 	 	{
       
   106 	    algorithm   ALGORITHM.&id({SupportedAlgorithms}),
       
   107 	    parameters  ALGORITHM.&Type({SupportedAlgorithms}{@ algorithm}) OPTIONAL
       
   108 	    }
       
   109 	    
       
   110 	 @param     aRawData A descriptor containing the PKCS7 DigestInfo Sequence.
       
   111 	 @leave KErrArgument if digestAlgorithm and digest is not present.
       
   112 	 @leave KErrNotSupported if algorithm is other than MD2, MD5 and SHA1.
       
   113 	 @see TASN1DecGeneric, CX509AlgorithmIdentifier.
       
   114 	 */
       
   115     void ConstructL(const TDesC8& aRawData);
       
   116     
       
   117 private:
       
   118     /** 
       
   119      The object identifier which identifies the message-digest algorithm.
       
   120 	 A message-digest algorithm maps an octet string (the message) to 
       
   121 	 another octet string (the message digest) 
       
   122 	 */
       
   123 	TAlgorithmId iAlgorithmId;
       
   124 	
       
   125 	/** Encoded Parameters which is in the DigestAlgorithmIdentifier */
       
   126     TPtrC8 iEncodedParams;
       
   127 	
       
   128 	/** 
       
   129 	 The Digest is present in the DigestInfo. 
       
   130 	 It is the result of the message-digesting process 
       
   131 	 */
       
   132 	TPtrC8 iDigest;
       
   133 	};
       
   134 	
       
   135 #endif //__PKCS7_DIGEST_INFO_H__