1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/security/cryptoservices/certificateandkeymgmt/inc/pkcs7contentinfo_v2.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,161 @@
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 __PKCS7_CONTENT_INFO_V2_H__
1.29 +#define __PKCS7_CONTENT_INFO_V2_H__
1.30 +
1.31 +#include <asn1dec.h>
1.32 +
1.33 +/** pkcs7-1 data */
1.34 +_LIT(KPkcs7DataOID, "1.2.840.113549.1.7.1");
1.35 +
1.36 +/** pkcs7-2 SignedData */
1.37 +_LIT(KPkcs7SignedDataOID, "1.2.840.113549.1.7.2");
1.38 +
1.39 +/** pkcs7-3 EnvelopedData */
1.40 +_LIT(KPkcs7EnvelopedDataOID, "1.2.840.113549.1.7.3");
1.41 +
1.42 +/** pkcs7-4 SignedAndEnvelopedData */
1.43 +_LIT(KPkcs7SignedAndEnvelopedDataOID, "1.2.840.113549.1.7.4");
1.44 +
1.45 +/** pkcs7-5 DigestedData */
1.46 +_LIT(KPkcs7DigestedDataOID, "1.2.840.113549.1.7.5");
1.47 +
1.48 +/** pkcs7-6 EncryptedData */
1.49 +_LIT(KPkcs7EncryptedDataOID, "1.2.840.113549.1.7.6");
1.50 +
1.51 +/** The numeric value of last element in the PKCS7 Data OID */
1.52 +const TInt KPkcs7Data = 1;
1.53 +
1.54 +/** The numeric value of last element in the PKCS7 Signed OID */
1.55 +const TInt KPkcs7SignedData = 2;
1.56 +
1.57 +/**
1.58 + The RFC2315 ContentInfo entity
1.59 + This class provides details about the Content Type in the Content Info,
1.60 + Provides access to the Content Data when the Content Type is Data and
1.61 + provides access to the Entire ContentInfo Sequence.
1.62 + */
1.63 +class CPKCS7ContentInfo : public CBase
1.64 + {
1.65 +public:
1.66 + /**
1.67 + Identifies the type of Content Type present in the PKCS7 ContentInfo Structure.
1.68 + */
1.69 + enum TContentInfoType
1.70 + {
1.71 + /** The numeric value of last element in the PKCS7 ContentType Data OID */
1.72 + EContentTypeData = 1,
1.73 + /** The numeric value of last element in the PKCS7 ContentType SignedData OID */
1.74 + EContentTypeSignedData,
1.75 + /** The numeric value of last element in the PKCS7 ContentType EnvelopedData OID */
1.76 + EContentTypeEnvelopedData,
1.77 + /** The numeric value of last element in the PKCS7 ContentType SignedAndEnvelopedData OID */
1.78 + EContentTypeSignedAndEnvelopedData,
1.79 + /** The numeric value of last element in the PKCS7 ContentType DigestedData OID */
1.80 + EContentTypeDigestedData,
1.81 + /** The numeric value of last element in the PKCS7 ContentType EncryptedData OID */
1.82 + EContentTypeEncryptedData
1.83 + };
1.84 + /**
1.85 + Creates a new PKCS#7 ContentInfo object.
1.86 + @param aRawData contains a PKCS#7 ContentInfo Structure
1.87 + @return A pointer to the newly allocated object.
1.88 + @leave KErrNotSupported if the OID value is otherthan enum TContentInfoType.
1.89 + @leave KErrArgument if the data is not PKCS7 contentInfo structure.
1.90 + @see TContentInfoType
1.91 + */
1.92 + IMPORT_C static CPKCS7ContentInfo* NewL(const TDesC8& aRawData);
1.93 +
1.94 + /**
1.95 + Destructor.
1.96 + */
1.97 + virtual ~CPKCS7ContentInfo();
1.98 +
1.99 +public:
1.100 + /**
1.101 + Provides the information about the ContentType in the
1.102 + ContentInfo Sequence.
1.103 + It returns the last number in the ObjectIdentifier
1.104 + @return The ContentType. This is
1.105 + 1 for Data
1.106 + 2 for SignedData
1.107 + 3 for EnvelopedData
1.108 + 4 for SignedAndEnvelopedData
1.109 + 5 for DigestedData
1.110 + 6 for EncryptedData
1.111 + */
1.112 + IMPORT_C TContentInfoType ContentType() const;
1.113 +
1.114 + /**
1.115 + Provides access to the Content Data present in PKCS#7 ContentInfo
1.116 + ContentData present in PKCS#7 ContentInfo is OPTIONAL
1.117 + The client has to check for data length 0 in case there is no ContentData.
1.118 + @return The ContentData
1.119 + */
1.120 + IMPORT_C const TPtrC8 ContentData() const;
1.121 +
1.122 +private:
1.123 + /**
1.124 + Constructor.
1.125 + */
1.126 + CPKCS7ContentInfo(void);
1.127 +
1.128 + /**
1.129 + Copy Constructor.
1.130 + @param aContentinfo A CPKCS7ContentInfo object.
1.131 + */
1.132 + CPKCS7ContentInfo(const CPKCS7ContentInfo& aContentInfo);
1.133 +
1.134 + /**
1.135 + Assignment operator.
1.136 + @param aContentinfo A CPKCS7ContentInfo object.
1.137 + @return A reference to CPKCS7ContentInfo class.
1.138 + */
1.139 + CPKCS7ContentInfo& operator=(const CPKCS7ContentInfo& aContentInfo);
1.140 +
1.141 + /**
1.142 + Decodes the PKCS#7 ContentInfo object.
1.143 + @param aRawData contains a PKCS#7 ContentInfo Structure.
1.144 + @leave KErrNotSupported if the OID val is otherthan 1 - 6
1.145 + i,e the last part of the OID.
1.146 + @leave KErrArgument if the data is not PKCS7 contentInfo structure.
1.147 + @ see TASN1DecObjectIdentifier,
1.148 + */
1.149 + void ConstructL(const TDesC8& aRawData);
1.150 +
1.151 +private:
1.152 + /**
1.153 + Indicates the type of content. Here it is the last Character
1.154 + in the OID which identifies the Content Type.
1.155 + */
1.156 + TContentInfoType iContentType;
1.157 +
1.158 + /** The ContentData present in PKCS7 ContentInfo*/
1.159 + TPtrC8 iContentData;
1.160 + };
1.161 +
1.162 +#endif // __PKCS7_CONTENT_INFO_V2_H__
1.163 +
1.164 +