Update contrib.
2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
25 #ifndef __PKCS7_ENCRYPTED_DATA_OBJECT_H__
26 #define __PKCS7_ENCRYPTED_DATA_OBJECT_H__
32 #include <pkcs7contentinfo_v2.h>
33 #include <pkcs12kdf.h>
36 A representation of a PKCS7 (Encrypted data) entity
37 This class decodes the PKCS7 Encrypted Data content.
38 It provides various exported methods which will
39 return the values present in the EncryptedData ::= SEQUENCE.
41 class CPKCS7EncryptedDataObject : public CBase
46 Identifies the type of ContentType present in the EncryptedContentInfo ::= SEQUENCE
53 Creates a new PKCS#7 EncryptedData object.
54 @param aContentInfo contains a reference to CPKCS7ContentInfo.
55 @return A pointer to the newly allocated object.
57 IMPORT_C static CPKCS7EncryptedDataObject* NewL(const CPKCS7ContentInfo& aContentInfo);
62 virtual ~CPKCS7EncryptedDataObject();
64 Provides access to the version number within the EncryptedData SEQUENCE.
65 Version is the syntax version number.It shall be 0 for this version of the standard
66 @return The version number
68 IMPORT_C TInt Version() const;
71 Provides access to the ContentType present within the EncryptedContentInfo.
72 ContentType indicates the type of content.This is represented using the OID.
73 @return ContentType present in the EncryptedContentInfo structure.
75 IMPORT_C CPKCS7EncryptedDataObject::TContentType ContentType() const;
78 Provides access to the encryptedContent within the EncryptedContentInfo SEQUENCE.
79 encryptedContent is OPTIONAL in EncryptedContentInfo SEQUENCE
80 This will return a NULL pointer in case there is no encryptedContent
81 @return The encryptedContent
83 IMPORT_C const TDesC8& EncryptedContentInfoData() const;
86 Provides access to the contentEncryptionAlgorithm within the
87 EncryptedContentInfo SEQUENCE.
88 @return A CPBEncryptParms object which has the Encrypt Parameters
89 EncryptedContent present in EncryptedContentInfo Sequence
91 IMPORT_C const CPBEncryptParms& EncryptParams() const;
94 This method decrypts the encrypted information. The caller assumes
95 ownership of the returned object.
96 @param aPassword is the password used for decryption.
97 @return The plaintext data obtained after decryption.
98 @leave KErrNotSupported if otherthan pkcs12 pbeIds used.
99 @leave KErrGeneral if decrypt descriptor length is less than 0.
100 @see PKCS12KDF, TPBPassword, CPBEncryptElement, CPBDecryptor.
102 IMPORT_C HBufC8* DecryptDataL(const TDesC& aPassword) const;
108 CPKCS7EncryptedDataObject(void);
112 @param aEncryptedDataObject A CPKCS7EncryptedDataObject object.
114 CPKCS7EncryptedDataObject(const CPKCS7EncryptedDataObject& aEncryptedDataObject);
118 @param aEncryptedDataObject A CPKCS7EncryptedDataObject object.
119 @return A reference to CPKCS7EncryptedDataObject class.
121 CPKCS7EncryptedDataObject& operator=(const CPKCS7EncryptedDataObject& aEncryptedDataObject);
124 This decrypt the encrypted data. Below is the ASN1 syntax.
126 EncryptedData ::= SEQUENCE
129 encryptedContentInfo EncryptedContentInfo
131 EncryptedContentInfo ::= SEQUENCE
133 contentType PKCS7-CONTENT-TYPE.&id({PKCS7ContentTable}),
134 contentEncryptionAlgorithm ContentEncryptionAlgorithmIdentifier,
135 encryptedContent [0] ENCRYPTED{PKCS7-CONTENT-TYPE.&Type({PKCS7ContentTable}{@.contentType})} OPTIONAL
137 EncryptedContent ::= OCTET STRING
139 ContentInfo ::= SEQUENCE
141 contentType ContentType,
142 content[0] EXPLICIT ANY DEFINED BY contentType OPTIONAL
144 ContentType ::= OBJECT IDENTIFIER
146 @param aContentInfo Contains a reference to CPKCS7ContentInfo
147 @leave KErrArgument if the data is not valid PKCS#7 EncryptedData Structure.
148 @see CPKCS7ContentInfo
150 void ConstructL(const CPKCS7ContentInfo& aContentInfo);
153 Provides access to the Encrypt Parameters present within the
154 ContentEncryptionAlgorithm Sequence. Below is the ASN1 Syntax.
156 ContentEncryptionAlgorithmIdentifier ::= AlgorithmIdentifier
157 AlgorithmIdentifier: A type that identifies an algorithm (by object identifier) and associated parameters
158 AlgorithmIdentifier ::= SEQUENCE
160 algorithm ALGORITHM.&id({SupportedAlgorithms}),
161 parameters ALGORITHM.&Type({SupportedAlgorithms}{@ algorithm}) OPTIONAL
164 @param aBinaryData which is the ContentEncryptionAlgorithmIdentifier
165 and is AlgorithIdentifier Type.
166 AlgorithmIdentifier: A type that identifies an
167 algorithm (by object identifier) and associated parameters.
168 @return Encrypt Parameters. This Identifies the
169 content-encryption algorithm (and any associated parameters)
170 under which the content is encrypted.
171 @leave KErrArgument if the data is not valid PKCS#7 ContentEncryptionAlgorithm
173 @see CPBEncryptParms, TASN1DecPKCS5.
175 CPBEncryptParms* DecodeContentEncryptionAlgorithmL(const TDesC8& aBinaryData) const;
179 /** version is the syntax version number in PKCS#7 EncryptedData ::= SEQUENCE*/
182 /** Indicates the type of content in PKCS7 EncryptedContentInfo Sequence */
183 TContentType iContentType;
185 /** Identifies the content-encryption algorithm (and any associated parameters)
186 under which the content is encrypted */
187 CPBEncryptParms* iEncryptParams;
189 /** Contains the encrypted content */
190 TPtrC8 iEncryptedContent;
193 #endif //__PKCS7_ENCRYPTED_DATA_OBJECT_H__