1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/security/cryptoservices/certificateandkeymgmt/inc/cmscontentinfo.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,256 @@
1.4 +/*
1.5 +* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of the License "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +/**
1.23 + @file
1.24 + @publishedPartner
1.25 + @released
1.26 +*/
1.27 +
1.28 +#ifndef CMSCONTENTINFO_H
1.29 +#define CMSCONTENTINFO_H
1.30 +
1.31 +#include "cmsdefs.h"
1.32 +
1.33 +class CASN1EncSequence;
1.34 +
1.35 +/**
1.36 +The RFC2630 EncapsulatedContentInfo entity.
1.37 +This class provides details about the Content Type in the Content Info,
1.38 +provides access to the Content Data when the Content Type is Data and
1.39 +provides access to the entire ContentInfo sequence.
1.40 +*/
1.41 +class CEncapsulatedContentInfo : public CBase
1.42 + {
1.43 +public:
1.44 +
1.45 + /**
1.46 + * @internalComponent
1.47 + *
1.48 + * Creates an EncapsulatedContentInfo as defined in RFC2630.
1.49 + * @param aRawData the encoded encapsulated data.
1.50 + * @return The fully constructed object
1.51 + **/
1.52 + static CEncapsulatedContentInfo* NewL(const TDesC8& aRawData);
1.53 +
1.54 + /**
1.55 + * @internalComponent
1.56 + *
1.57 + * Creates an EncapsulatedContentInfo as defined in RFC2630, and leaves the instance on the cleanup stack.
1.58 + * @param aRawData The encoded encapsulated data.
1.59 + * @return The fully constructed object.
1.60 + **/
1.61 + static CEncapsulatedContentInfo* NewLC(const TDesC8& aRawData);
1.62 +
1.63 + /**
1.64 + * @internalComponent
1.65 + *
1.66 + * Creates an EncapsulatedContentInfo as defined in RFC2630.
1.67 + * @param aContentInfoType The type of the encapsulated content.
1.68 + * @param aIsEContentDataPresent Indicates whether the encapsulated data is present.
1.69 + * @param aContentData The encapsulated data.
1.70 + * @return The fully constructed object.
1.71 + **/
1.72 + static CEncapsulatedContentInfo* NewL(TCmsContentInfoType aContentInfoType, TBool aIsEContentDataPresent, const TDesC8& aContentData);
1.73 +
1.74 + /**
1.75 + * @internalComponent
1.76 + *
1.77 + * Creates an EncapsulatedContentInfo as defined in RFC2630, and leaves the instance on the cleanup stack.
1.78 + * @param aContentInfoType The type of the encapsulated content.
1.79 + * @param aIsEContentDataPresent Indicates whether the encapsulated data is present.
1.80 + * @param aContentData The encapsulated data.
1.81 + * @return The fully constructed object
1.82 + **/
1.83 + static CEncapsulatedContentInfo* NewLC(TCmsContentInfoType aContentInfoType, TBool aIsEContentDataPresent, const TDesC8& aContentData);
1.84 +
1.85 + /**
1.86 + * @internalComponent
1.87 + *
1.88 + * Creates the DER sequence of the ContentInfo and leaves the DER sequence on the cleanup stack.
1.89 + * @return The ASN.1 sequence of the ContentInfo.
1.90 + **/
1.91 + CASN1EncSequence* EncodeASN1DERLC() const;
1.92 +
1.93 + /**
1.94 + Provides information about the ContentType in the ContentInfo sequence.
1.95 + It returns the last number in the ObjectIdentifier.
1.96 + @return The ContentType. This is:
1.97 +
1.98 + - 1 for Data
1.99 +
1.100 + - 2 for SignedData
1.101 +
1.102 + - 3 for EnvelopedData
1.103 +
1.104 + - 5 for DigestedData
1.105 +
1.106 + - 6 for EncryptedData
1.107 + */
1.108 + IMPORT_C TCmsContentInfoType ContentType() const;
1.109 +
1.110 + /**
1.111 + Returns whether the ContentInfo is present or not.
1.112 + ContentData present in EncapsulatedContentInfo is OPTIONAL.
1.113 + @return A boolean value that indicates whether or not the ContentInfo is present.
1.114 + */
1.115 + IMPORT_C TBool IsContentDataPresent() const;
1.116 +
1.117 + /**
1.118 + Provides access to the Content Data present in CMS. ContentData present
1.119 + in EncapsulatedContentInfo is OPTIONAL. The client has to check for
1.120 + data length 0 or if the data content is present in case there is no ContentData.
1.121 + @return The ContentData.
1.122 + */
1.123 + IMPORT_C const TPtrC8 ContentData() const;
1.124 +
1.125 +private:
1.126 + /*
1.127 + Constuctor and second phase constructor.
1.128 + */
1.129 + CEncapsulatedContentInfo();
1.130 + CEncapsulatedContentInfo(TCmsContentInfoType aContentInfoType, TBool aIsEContentDataPresent, const TDesC8& aContentData);
1.131 + void ConstructL(const TDesC8& aRawData);
1.132 +
1.133 +private:
1.134 + /**
1.135 + The Type of the ContentInfo
1.136 + */
1.137 + TCmsContentInfoType iContentType;
1.138 +
1.139 + /**
1.140 + Represents whether the Content is present or not.
1.141 + */
1.142 + TBool iIsContentDataPresent;
1.143 +
1.144 + /**
1.145 + The Content Data.
1.146 + */
1.147 + TPtrC8 iContentData;
1.148 + };
1.149 +
1.150 +
1.151 +/**
1.152 +The RFC2630 ContentInfo entity.
1.153 +This class provides details about the content type in the ContentInfo,
1.154 +provides access to the content data when the content type is Data and
1.155 +provides access to the entire ContentInfo sequence.
1.156 +At present, only data content type and signed data type are supported.
1.157 +*/
1.158 +class CCmsContentInfo : public CBase
1.159 + {
1.160 +public:
1.161 + /**
1.162 + Creates a ContentInfo as defined in RFC2630.
1.163 + @param aRawData The encoded encapsulated data.
1.164 + @return The fully constructed object.
1.165 + */
1.166 + IMPORT_C static CCmsContentInfo* NewL(const TDesC8& aRawData);
1.167 + /**
1.168 + Creates a ContentInfo as defined in RFC2630,
1.169 + and leaves the instance on the cleanup stack.
1.170 + @param aRawData The encoded encapsulated data.
1.171 + @return The fully constructed object.
1.172 + */
1.173 + IMPORT_C static CCmsContentInfo* NewLC(const TDesC8& aRawData);
1.174 +
1.175 + /**
1.176 + Creates a ContentInfo as defined in RFC2630.
1.177 + @param aContentInfoType The type of the encapsulated content.
1.178 + @param aContentData The encapsulated data.
1.179 + @return The fully constructed object.
1.180 + */
1.181 + IMPORT_C static CCmsContentInfo* NewL(TCmsContentInfoType aContentInfoType, const TDesC8& aContentData);
1.182 +
1.183 + /**
1.184 + Creates a ContentInfo as defined in RFC2630 and leaves the object on the cleanup stack.
1.185 + @param aContentInfoType The type of the encapsulated content.
1.186 + @param aContentData The encapsulated data.
1.187 + @return The fully constructed object.
1.188 + */
1.189 + IMPORT_C static CCmsContentInfo* NewLC(TCmsContentInfoType aContentInfoType, const TDesC8& aContentData);
1.190 +
1.191 + /**
1.192 + Creates the DER sequence of the ContentInfo and leaves the DER sequence on the cleanup stack.
1.193 + @return The ASN.1 sequence of the ContentInfo.
1.194 + */
1.195 + IMPORT_C CASN1EncSequence* EncodeASN1DERLC() const;
1.196 +
1.197 + /**
1.198 + Destructor
1.199 + */
1.200 + IMPORT_C ~CCmsContentInfo();
1.201 +
1.202 + /**
1.203 + Provides the information about the ContentType in the ContentInfo sequence.
1.204 + It returns the last number in the Object Identifier.
1.205 + @return The ContentType. This is:
1.206 +
1.207 + - 1 for Data
1.208 +
1.209 + - 2 for SignedData
1.210 +
1.211 + - 3 for EnvelopedData
1.212 +
1.213 + - 5 for DigestedData
1.214 +
1.215 + - 6 for EncryptedData
1.216 + */
1.217 + IMPORT_C TCmsContentInfoType ContentType() const;
1.218 +
1.219 + /**
1.220 + Provides access to the content data.
1.221 + @return The content data.
1.222 + */
1.223 + IMPORT_C const TPtrC8 ContentData() const;
1.224 +
1.225 +
1.226 +private:
1.227 + /**
1.228 + default constructor
1.229 + */
1.230 + CCmsContentInfo();
1.231 +
1.232 + /**
1.233 + constructor to build the CMS content info from the given parameters
1.234 + @param aContentInfoType the type of data contained in the CMS content info
1.235 + @param aContentData the descriptor which contains the encoded CMS oject
1.236 + */
1.237 + CCmsContentInfo(TCmsContentInfoType aContentInfoType, const TDesC8& aContentData);
1.238 +
1.239 + /**
1.240 + constructor to build the CMS content info from the raw data.
1.241 + @param aContentInfoType the type of data contained in the CMS content info
1.242 + @param aContentData the descriptor which contains the encoded CMS oject
1.243 + */
1.244 + void ConstructL(const TDesC8& aRawData);
1.245 +
1.246 +private:
1.247 + /**
1.248 + The Type of the ContentInfo
1.249 + */
1.250 + TCmsContentInfoType iContentType;
1.251 +
1.252 + /**
1.253 + The Content Data
1.254 + */
1.255 + TPtrC8 iContentData;
1.256 + };
1.257 +
1.258 +#endif // CMSCONTENTINFO_H
1.259 +