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