os/security/cryptoservices/certificateandkeymgmt/inc/cmscontentinfo.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 CMSCONTENTINFO_H
    26 #define CMSCONTENTINFO_H
    27 
    28 #include "cmsdefs.h"
    29 
    30 class CASN1EncSequence;
    31 
    32 /**
    33 The RFC2630 EncapsulatedContentInfo entity.
    34 This class provides details about the Content Type in the Content Info,
    35 provides access to the Content Data when the Content Type is Data and
    36 provides access to the entire ContentInfo sequence.
    37 */
    38 class CEncapsulatedContentInfo : public CBase
    39 	{
    40 public:
    41 
    42 	/**
    43 	 * @internalComponent
    44 	 *
    45 	 * Creates an EncapsulatedContentInfo as defined in RFC2630.
    46 	 * @param aRawData the encoded encapsulated data.
    47 	 * @return	The fully constructed object
    48 	 **/
    49 	static CEncapsulatedContentInfo* NewL(const TDesC8& aRawData);
    50 	
    51 	/**
    52 	 * @internalComponent
    53 	 * 
    54 	 * Creates an EncapsulatedContentInfo as defined in RFC2630, and leaves the instance on the cleanup stack.
    55 	 * @param aRawData The encoded encapsulated data.
    56 	 * @return	The fully constructed object.
    57 	 **/
    58 	static CEncapsulatedContentInfo* NewLC(const TDesC8& aRawData);
    59 	
    60 	/**
    61 	 * @internalComponent
    62 	 *
    63 	 * Creates an EncapsulatedContentInfo as defined in RFC2630.
    64 	 * @param aContentInfoType The type of the encapsulated content.
    65 	 * @param aIsEContentDataPresent Indicates whether the encapsulated data is present.
    66 	 * @param aContentData The encapsulated data.
    67 	 * @return	The fully constructed object.
    68 	 **/
    69 	static CEncapsulatedContentInfo* NewL(TCmsContentInfoType aContentInfoType, TBool aIsEContentDataPresent, const TDesC8& aContentData);
    70 
    71 	/**
    72 	 * @internalComponent
    73 	 * 
    74 	 * Creates an EncapsulatedContentInfo as defined in RFC2630, and leaves the instance on the cleanup stack.
    75 	 * @param aContentInfoType The type of the encapsulated content.
    76 	 * @param aIsEContentDataPresent Indicates whether the encapsulated data is present.
    77 	 * @param aContentData The encapsulated data.
    78 	 * @return	The fully constructed object
    79 	 **/	
    80 	static CEncapsulatedContentInfo* NewLC(TCmsContentInfoType aContentInfoType, TBool aIsEContentDataPresent, const TDesC8& aContentData);
    81 
    82 	/**
    83 	 * @internalComponent
    84 	 *
    85 	 * Creates the DER sequence of the ContentInfo and leaves the DER sequence on the cleanup stack.
    86 	 * @return The ASN.1 sequence of the ContentInfo.
    87 	 **/
    88 	CASN1EncSequence* EncodeASN1DERLC() const;
    89 
    90 	/**
    91 	Provides information about the ContentType in the ContentInfo sequence.
    92 	It returns the last number in the ObjectIdentifier.
    93 	@return    The ContentType. This is:
    94 
    95 	- 1 for Data
    96 
    97 	- 2 for SignedData
    98 
    99 	- 3 for EnvelopedData
   100 
   101 	- 5 for DigestedData
   102 
   103 	- 6 for EncryptedData
   104 	*/
   105     IMPORT_C TCmsContentInfoType ContentType() const;
   106 	
   107 	/**
   108 	Returns whether the ContentInfo is present or not.
   109 	ContentData present in EncapsulatedContentInfo is OPTIONAL.
   110 	@return  A boolean value that indicates whether or not the ContentInfo is present.
   111 	*/
   112 	IMPORT_C TBool IsContentDataPresent() const;
   113 
   114 	/**
   115 	Provides access to the Content Data present in CMS. ContentData present
   116 	in EncapsulatedContentInfo is OPTIONAL. The client has to check for
   117 	data length 0 or if the data content is present in case there is no ContentData.
   118 	@return  The ContentData.
   119 	*/    
   120 	IMPORT_C const TPtrC8 ContentData() const;
   121 
   122 private:
   123 	/*
   124 	Constuctor and second phase constructor.
   125 	*/
   126 	CEncapsulatedContentInfo();	
   127 	CEncapsulatedContentInfo(TCmsContentInfoType aContentInfoType, TBool aIsEContentDataPresent, const TDesC8& aContentData);
   128 	void ConstructL(const TDesC8& aRawData);
   129 	
   130 private:
   131 	/**
   132 	The Type of the ContentInfo
   133 	*/
   134 	TCmsContentInfoType iContentType;
   135 
   136 	/**
   137 	Represents whether the Content is present or not.
   138 	*/
   139 	TBool iIsContentDataPresent;
   140 
   141 	/**
   142 	The Content Data.
   143 	*/
   144 	TPtrC8 iContentData;
   145 	};
   146 
   147 
   148 /**
   149 The RFC2630 ContentInfo entity.
   150 This class provides details about the content type in the ContentInfo,
   151 provides access to the content data when the content type is Data and
   152 provides access to the entire ContentInfo sequence.
   153 At present, only data content type and signed data type are supported.
   154 */
   155 class CCmsContentInfo : public CBase
   156 	{
   157 public:
   158 	/**
   159 	Creates a ContentInfo as defined in RFC2630.
   160 	@param aRawData The encoded encapsulated data.
   161 	@return	The fully constructed object.
   162 	*/
   163 	IMPORT_C static CCmsContentInfo* NewL(const TDesC8& aRawData);
   164 	/**
   165 	Creates a ContentInfo as defined in RFC2630,
   166 	and leaves the instance on the cleanup stack.
   167 	@param aRawData The encoded encapsulated data.
   168 	@return	The fully constructed object.
   169 	*/
   170 	IMPORT_C static CCmsContentInfo* NewLC(const TDesC8& aRawData);
   171 
   172 	/**
   173 	Creates a ContentInfo as defined in RFC2630.
   174 	@param aContentInfoType The type of the encapsulated content.
   175 	@param aContentData The encapsulated data.
   176 	@return	The fully constructed object.
   177 	*/
   178 	IMPORT_C static CCmsContentInfo* NewL(TCmsContentInfoType aContentInfoType, const TDesC8& aContentData);
   179 
   180 	/**
   181 	Creates a ContentInfo as defined in RFC2630 and leaves the object on the cleanup stack.
   182 	@param aContentInfoType The type of the encapsulated content.
   183 	@param aContentData The encapsulated data.
   184 	@return	The fully constructed object.
   185 	*/
   186 	IMPORT_C static CCmsContentInfo* NewLC(TCmsContentInfoType aContentInfoType, const TDesC8& aContentData);
   187 
   188 	/**
   189 	Creates the DER sequence of the ContentInfo and leaves the DER sequence on the cleanup stack.
   190 	@return The ASN.1 sequence of the ContentInfo.
   191 	*/
   192 	IMPORT_C CASN1EncSequence* EncodeASN1DERLC() const;
   193 	
   194 	/**
   195 	Destructor
   196 	*/
   197 	IMPORT_C ~CCmsContentInfo();
   198 	
   199 	/**
   200 	Provides the information about the ContentType in the ContentInfo sequence.
   201 	It returns the last number in the Object Identifier.
   202 	@return The ContentType. This is:
   203 
   204 	- 1 for Data
   205 
   206 	- 2 for SignedData
   207 
   208 	- 3 for EnvelopedData
   209 
   210 	- 5 for DigestedData
   211 
   212 	- 6 for EncryptedData
   213 	*/
   214 	IMPORT_C TCmsContentInfoType ContentType() const;
   215 
   216 	/**
   217 	Provides access to the content data.
   218 	@return  The content data.
   219 	*/
   220 	IMPORT_C const TPtrC8 ContentData() const;
   221 
   222 
   223 private:
   224 	/**
   225 	default constructor
   226 	*/
   227 	CCmsContentInfo();
   228 	
   229 	/**
   230 	constructor to build the CMS content info from the given parameters
   231 	@param aContentInfoType the type of data contained in the CMS content info
   232 	@param aContentData the descriptor which contains the encoded CMS oject
   233 	*/	
   234 	CCmsContentInfo(TCmsContentInfoType aContentInfoType, const TDesC8& aContentData);
   235 	
   236 	/**
   237 	constructor to build the CMS content info from the raw data.
   238 	@param aContentInfoType the type of data contained in the CMS content info
   239 	@param aContentData the descriptor which contains the encoded CMS oject
   240 	*/		
   241 	void ConstructL(const TDesC8& aRawData);
   242 	
   243 private:
   244 	/**
   245 	The Type of the ContentInfo
   246 	*/
   247 	TCmsContentInfoType iContentType;
   248 
   249 	/**
   250 	The Content Data
   251 	*/	
   252 	TPtrC8 iContentData;
   253 	};
   254 
   255 #endif // CMSCONTENTINFO_H
   256