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