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