os/security/cryptoservices/certificateandkeymgmt/inc/pkcs7contentinfo_v2.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 /*
     2 * Copyright (c) 2006-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_CONTENT_INFO_V2_H__
    26 #define __PKCS7_CONTENT_INFO_V2_H__
    27 
    28 #include <asn1dec.h>
    29 
    30 /** pkcs7-1 data */
    31 _LIT(KPkcs7DataOID, "1.2.840.113549.1.7.1");
    32 
    33 /** pkcs7-2 SignedData */
    34 _LIT(KPkcs7SignedDataOID, "1.2.840.113549.1.7.2"); 
    35 
    36 /** pkcs7-3 EnvelopedData */
    37 _LIT(KPkcs7EnvelopedDataOID, "1.2.840.113549.1.7.3"); 
    38 
    39 /** pkcs7-4 SignedAndEnvelopedData */
    40 _LIT(KPkcs7SignedAndEnvelopedDataOID, "1.2.840.113549.1.7.4"); 
    41 
    42 /** pkcs7-5 DigestedData */
    43 _LIT(KPkcs7DigestedDataOID, "1.2.840.113549.1.7.5");   
    44 
    45 /** pkcs7-6 EncryptedData */
    46 _LIT(KPkcs7EncryptedDataOID, "1.2.840.113549.1.7.6"); 
    47 
    48 /** The numeric value of last element in the PKCS7 Data OID */
    49 const TInt KPkcs7Data = 1;
    50 
    51 /** The numeric value of last element in the PKCS7 Signed OID */
    52 const TInt KPkcs7SignedData = 2;    
    53 
    54 /**
    55  The RFC2315 ContentInfo entity
    56  This class provides details about the Content Type in the Content Info, 
    57  Provides access to the Content Data when the Content Type is Data and 
    58  provides access to the Entire ContentInfo Sequence.
    59  */
    60 class CPKCS7ContentInfo : public CBase
    61 	{
    62 public:
    63 	/**
    64 	 Identifies the type of Content Type present in the PKCS7 ContentInfo Structure.
    65 	 */
    66 	enum TContentInfoType
    67 		{
    68 		/** The numeric value of last element in the PKCS7 ContentType Data OID */
    69 		EContentTypeData = 1,
    70 		/** The numeric value of last element in the PKCS7 ContentType SignedData OID */
    71 		EContentTypeSignedData,
    72 		/** The numeric value of last element in the PKCS7 ContentType EnvelopedData OID */
    73 		EContentTypeEnvelopedData,
    74 		/** The numeric value of last element in the PKCS7 ContentType SignedAndEnvelopedData OID */
    75 		EContentTypeSignedAndEnvelopedData,
    76 		/** The numeric value of last element in the PKCS7 ContentType DigestedData OID */
    77 		EContentTypeDigestedData,
    78 		/** The numeric value of last element in the PKCS7 ContentType EncryptedData OID */
    79 		EContentTypeEncryptedData
    80 		};
    81 	/**
    82 	 Creates a new PKCS#7 ContentInfo object.  
    83 	 @param     aRawData contains a PKCS#7 ContentInfo Structure
    84 	 @return    A pointer to the newly allocated object.
    85 	 @leave     KErrNotSupported if the OID value is otherthan enum TContentInfoType.
    86 	 @leave 	KErrArgument if the data is not PKCS7 contentInfo structure.
    87 	 @see		TContentInfoType
    88 	 */
    89 	IMPORT_C static CPKCS7ContentInfo* NewL(const TDesC8& aRawData);
    90 		
    91 	/**
    92 	 Destructor.
    93 	 */
    94 	virtual ~CPKCS7ContentInfo();
    95 	
    96 public:
    97     /**
    98      Provides the information about the ContentType in the 
    99      ContentInfo Sequence.
   100      It returns the last number in the ObjectIdentifier
   101      @return    The ContentType. This is
   102 			      1 for Data
   103 			      2 for SignedData
   104 			      3 for EnvelopedData
   105 			      4 for SignedAndEnvelopedData
   106 			      5 for DigestedData
   107 			      6 for EncryptedData
   108      */
   109 	IMPORT_C TContentInfoType ContentType() const;
   110 	
   111 	/**
   112      Provides access to the Content Data present in PKCS#7 ContentInfo
   113      ContentData present in PKCS#7 ContentInfo is OPTIONAL
   114      The client has to check for data length 0 in case there is no ContentData.
   115      @return    The ContentData 
   116      */
   117 	IMPORT_C const TPtrC8 ContentData() const; 
   118 	
   119 private:
   120 	/**
   121 	 Constructor.
   122 	 */
   123 	CPKCS7ContentInfo(void);
   124 	
   125     /**
   126 	 Copy Constructor.
   127 	 @param aContentinfo A CPKCS7ContentInfo object.
   128 	 */
   129 	CPKCS7ContentInfo(const CPKCS7ContentInfo& aContentInfo);
   130 	
   131 	/**
   132 	 Assignment operator.
   133 	 @param aContentinfo A CPKCS7ContentInfo object.
   134 	 @return A reference to CPKCS7ContentInfo class.
   135 	 */
   136 	CPKCS7ContentInfo& operator=(const CPKCS7ContentInfo& aContentInfo);
   137 	    
   138 	/**
   139 	 Decodes the PKCS#7 ContentInfo object.  
   140 	 @param     aRawData contains a PKCS#7 ContentInfo Structure.
   141 	 @leave     KErrNotSupported if the OID val is otherthan 1 - 6
   142 	 			i,e the last part of the OID.
   143 	 @leave 	KErrArgument if the data is not PKCS7 contentInfo structure.
   144 	 @ see		TASN1DecObjectIdentifier, 
   145 	 */
   146 	void ConstructL(const TDesC8& aRawData);
   147 	
   148 private:
   149 	/** 
   150 	 Indicates the type of content. Here it is the last Character
   151 	 in the OID which identifies the Content Type. 
   152 	 */
   153 	TContentInfoType iContentType;
   154 
   155 	/** The ContentData present in PKCS7 ContentInfo*/
   156 	TPtrC8 iContentData;
   157 	};
   158 
   159 #endif // __PKCS7_CONTENT_INFO_V2_H__
   160 
   161