sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
*
|
sl@0
|
16 |
*/
|
sl@0
|
17 |
|
sl@0
|
18 |
|
sl@0
|
19 |
/**
|
sl@0
|
20 |
@file
|
sl@0
|
21 |
@publishedPartner
|
sl@0
|
22 |
@released
|
sl@0
|
23 |
*/
|
sl@0
|
24 |
|
sl@0
|
25 |
#ifndef __PKCS7_ENCRYPTED_DATA_OBJECT_H__
|
sl@0
|
26 |
#define __PKCS7_ENCRYPTED_DATA_OBJECT_H__
|
sl@0
|
27 |
|
sl@0
|
28 |
#include <asn1dec.h>
|
sl@0
|
29 |
#include <signed.h>
|
sl@0
|
30 |
#include <pbedata.h>
|
sl@0
|
31 |
#include <asnpkcs.h>
|
sl@0
|
32 |
#include <pkcs7contentinfo_v2.h>
|
sl@0
|
33 |
#include <pkcs12kdf.h>
|
sl@0
|
34 |
|
sl@0
|
35 |
/**
|
sl@0
|
36 |
A representation of a PKCS7 (Encrypted data) entity
|
sl@0
|
37 |
This class decodes the PKCS7 Encrypted Data content.
|
sl@0
|
38 |
It provides various exported methods which will
|
sl@0
|
39 |
return the values present in the EncryptedData ::= SEQUENCE.
|
sl@0
|
40 |
*/
|
sl@0
|
41 |
class CPKCS7EncryptedDataObject : public CBase
|
sl@0
|
42 |
{
|
sl@0
|
43 |
public:
|
sl@0
|
44 |
enum TContentType
|
sl@0
|
45 |
/**
|
sl@0
|
46 |
Identifies the type of ContentType present in the EncryptedContentInfo ::= SEQUENCE
|
sl@0
|
47 |
*/
|
sl@0
|
48 |
{
|
sl@0
|
49 |
EPkcs7Data = 1
|
sl@0
|
50 |
};
|
sl@0
|
51 |
|
sl@0
|
52 |
/**
|
sl@0
|
53 |
Creates a new PKCS#7 EncryptedData object.
|
sl@0
|
54 |
@param aContentInfo contains a reference to CPKCS7ContentInfo.
|
sl@0
|
55 |
@return A pointer to the newly allocated object.
|
sl@0
|
56 |
*/
|
sl@0
|
57 |
IMPORT_C static CPKCS7EncryptedDataObject* NewL(const CPKCS7ContentInfo& aContentInfo);
|
sl@0
|
58 |
|
sl@0
|
59 |
/**
|
sl@0
|
60 |
Destructor.
|
sl@0
|
61 |
*/
|
sl@0
|
62 |
virtual ~CPKCS7EncryptedDataObject();
|
sl@0
|
63 |
/**
|
sl@0
|
64 |
Provides access to the version number within the EncryptedData SEQUENCE.
|
sl@0
|
65 |
Version is the syntax version number.It shall be 0 for this version of the standard
|
sl@0
|
66 |
@return The version number
|
sl@0
|
67 |
*/
|
sl@0
|
68 |
IMPORT_C TInt Version() const;
|
sl@0
|
69 |
|
sl@0
|
70 |
/**
|
sl@0
|
71 |
Provides access to the ContentType present within the EncryptedContentInfo.
|
sl@0
|
72 |
ContentType indicates the type of content.This is represented using the OID.
|
sl@0
|
73 |
@return ContentType present in the EncryptedContentInfo structure.
|
sl@0
|
74 |
*/
|
sl@0
|
75 |
IMPORT_C CPKCS7EncryptedDataObject::TContentType ContentType() const;
|
sl@0
|
76 |
|
sl@0
|
77 |
/**
|
sl@0
|
78 |
Provides access to the encryptedContent within the EncryptedContentInfo SEQUENCE.
|
sl@0
|
79 |
encryptedContent is OPTIONAL in EncryptedContentInfo SEQUENCE
|
sl@0
|
80 |
This will return a NULL pointer in case there is no encryptedContent
|
sl@0
|
81 |
@return The encryptedContent
|
sl@0
|
82 |
*/
|
sl@0
|
83 |
IMPORT_C const TDesC8& EncryptedContentInfoData() const;
|
sl@0
|
84 |
|
sl@0
|
85 |
/**
|
sl@0
|
86 |
Provides access to the contentEncryptionAlgorithm within the
|
sl@0
|
87 |
EncryptedContentInfo SEQUENCE.
|
sl@0
|
88 |
@return A CPBEncryptParms object which has the Encrypt Parameters
|
sl@0
|
89 |
EncryptedContent present in EncryptedContentInfo Sequence
|
sl@0
|
90 |
*/
|
sl@0
|
91 |
IMPORT_C const CPBEncryptParms& EncryptParams() const;
|
sl@0
|
92 |
|
sl@0
|
93 |
/**
|
sl@0
|
94 |
This method decrypts the encrypted information. The caller assumes
|
sl@0
|
95 |
ownership of the returned object.
|
sl@0
|
96 |
@param aPassword is the password used for decryption.
|
sl@0
|
97 |
@return The plaintext data obtained after decryption.
|
sl@0
|
98 |
@leave KErrNotSupported if otherthan pkcs12 pbeIds used.
|
sl@0
|
99 |
@leave KErrGeneral if decrypt descriptor length is less than 0.
|
sl@0
|
100 |
@see PKCS12KDF, TPBPassword, CPBEncryptElement, CPBDecryptor.
|
sl@0
|
101 |
*/
|
sl@0
|
102 |
IMPORT_C HBufC8* DecryptDataL(const TDesC& aPassword) const;
|
sl@0
|
103 |
|
sl@0
|
104 |
private:
|
sl@0
|
105 |
/**
|
sl@0
|
106 |
Constructor.
|
sl@0
|
107 |
*/
|
sl@0
|
108 |
CPKCS7EncryptedDataObject(void);
|
sl@0
|
109 |
|
sl@0
|
110 |
/**
|
sl@0
|
111 |
Copy Constructor.
|
sl@0
|
112 |
@param aEncryptedDataObject A CPKCS7EncryptedDataObject object.
|
sl@0
|
113 |
*/
|
sl@0
|
114 |
CPKCS7EncryptedDataObject(const CPKCS7EncryptedDataObject& aEncryptedDataObject);
|
sl@0
|
115 |
|
sl@0
|
116 |
/**
|
sl@0
|
117 |
Assignment operator.
|
sl@0
|
118 |
@param aEncryptedDataObject A CPKCS7EncryptedDataObject object.
|
sl@0
|
119 |
@return A reference to CPKCS7EncryptedDataObject class.
|
sl@0
|
120 |
*/
|
sl@0
|
121 |
CPKCS7EncryptedDataObject& operator=(const CPKCS7EncryptedDataObject& aEncryptedDataObject);
|
sl@0
|
122 |
|
sl@0
|
123 |
/**
|
sl@0
|
124 |
This decrypt the encrypted data. Below is the ASN1 syntax.
|
sl@0
|
125 |
|
sl@0
|
126 |
EncryptedData ::= SEQUENCE
|
sl@0
|
127 |
{
|
sl@0
|
128 |
version Version,
|
sl@0
|
129 |
encryptedContentInfo EncryptedContentInfo
|
sl@0
|
130 |
}
|
sl@0
|
131 |
EncryptedContentInfo ::= SEQUENCE
|
sl@0
|
132 |
{
|
sl@0
|
133 |
contentType PKCS7-CONTENT-TYPE.&id({PKCS7ContentTable}),
|
sl@0
|
134 |
contentEncryptionAlgorithm ContentEncryptionAlgorithmIdentifier,
|
sl@0
|
135 |
encryptedContent [0] ENCRYPTED{PKCS7-CONTENT-TYPE.&Type({PKCS7ContentTable}{@.contentType})} OPTIONAL
|
sl@0
|
136 |
}
|
sl@0
|
137 |
EncryptedContent ::= OCTET STRING
|
sl@0
|
138 |
|
sl@0
|
139 |
ContentInfo ::= SEQUENCE
|
sl@0
|
140 |
{
|
sl@0
|
141 |
contentType ContentType,
|
sl@0
|
142 |
content[0] EXPLICIT ANY DEFINED BY contentType OPTIONAL
|
sl@0
|
143 |
}
|
sl@0
|
144 |
ContentType ::= OBJECT IDENTIFIER
|
sl@0
|
145 |
|
sl@0
|
146 |
@param aContentInfo Contains a reference to CPKCS7ContentInfo
|
sl@0
|
147 |
@leave KErrArgument if the data is not valid PKCS#7 EncryptedData Structure.
|
sl@0
|
148 |
@see CPKCS7ContentInfo
|
sl@0
|
149 |
*/
|
sl@0
|
150 |
void ConstructL(const CPKCS7ContentInfo& aContentInfo);
|
sl@0
|
151 |
|
sl@0
|
152 |
/**
|
sl@0
|
153 |
Provides access to the Encrypt Parameters present within the
|
sl@0
|
154 |
ContentEncryptionAlgorithm Sequence. Below is the ASN1 Syntax.
|
sl@0
|
155 |
|
sl@0
|
156 |
ContentEncryptionAlgorithmIdentifier ::= AlgorithmIdentifier
|
sl@0
|
157 |
AlgorithmIdentifier: A type that identifies an algorithm (by object identifier) and associated parameters
|
sl@0
|
158 |
AlgorithmIdentifier ::= SEQUENCE
|
sl@0
|
159 |
{
|
sl@0
|
160 |
algorithm ALGORITHM.&id({SupportedAlgorithms}),
|
sl@0
|
161 |
parameters ALGORITHM.&Type({SupportedAlgorithms}{@ algorithm}) OPTIONAL
|
sl@0
|
162 |
}
|
sl@0
|
163 |
|
sl@0
|
164 |
@param aBinaryData which is the ContentEncryptionAlgorithmIdentifier
|
sl@0
|
165 |
and is AlgorithIdentifier Type.
|
sl@0
|
166 |
AlgorithmIdentifier: A type that identifies an
|
sl@0
|
167 |
algorithm (by object identifier) and associated parameters.
|
sl@0
|
168 |
@return Encrypt Parameters. This Identifies the
|
sl@0
|
169 |
content-encryption algorithm (and any associated parameters)
|
sl@0
|
170 |
under which the content is encrypted.
|
sl@0
|
171 |
@leave KErrArgument if the data is not valid PKCS#7 ContentEncryptionAlgorithm
|
sl@0
|
172 |
sequence.
|
sl@0
|
173 |
@see CPBEncryptParms, TASN1DecPKCS5.
|
sl@0
|
174 |
*/
|
sl@0
|
175 |
CPBEncryptParms* DecodeContentEncryptionAlgorithmL(const TDesC8& aBinaryData) const;
|
sl@0
|
176 |
|
sl@0
|
177 |
|
sl@0
|
178 |
private:
|
sl@0
|
179 |
/** version is the syntax version number in PKCS#7 EncryptedData ::= SEQUENCE*/
|
sl@0
|
180 |
TInt iVersion;
|
sl@0
|
181 |
|
sl@0
|
182 |
/** Indicates the type of content in PKCS7 EncryptedContentInfo Sequence */
|
sl@0
|
183 |
TContentType iContentType;
|
sl@0
|
184 |
|
sl@0
|
185 |
/** Identifies the content-encryption algorithm (and any associated parameters)
|
sl@0
|
186 |
under which the content is encrypted */
|
sl@0
|
187 |
CPBEncryptParms* iEncryptParams;
|
sl@0
|
188 |
|
sl@0
|
189 |
/** Contains the encrypted content */
|
sl@0
|
190 |
TPtrC8 iEncryptedContent;
|
sl@0
|
191 |
};
|
sl@0
|
192 |
|
sl@0
|
193 |
#endif //__PKCS7_ENCRYPTED_DATA_OBJECT_H__
|