First public contribution.
2 * Copyright (c) 2002-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.
15 * ** IMPORTANT ** PublishedPartner API's in this file are published to 3rd party developers via the
16 * Symbian website. Changes to these API's should be treated as PublishedAll API changes and the Security TA should be consulted.
32 class CPBEncryptParms;
33 class CPBEncryptionData;
38 * Abstract class defining the interface required to allow the actual
39 * transformation of plaintext to ciphertext.
41 * Generally this class' descendants are constructed using the
42 * functions CPBEncryptElement::NewEncryptLC() or CPBEncryptSet::NewEncryptLC().
44 * @see CPBEncryptorElement and CPBEncryptorSet
46 class CPBEncryptor : public CBase
50 * Transforms aInput into its encrypted form, aOutput.
52 * See the Cryptography api-guide documentation for an explanation of
53 * how buffering of data supplied to this function is handled.
55 * @param aInput The plaintext.
56 * @param aOutput On return, the ciphertext.
58 virtual void Process(const TDesC8& aInput, TDes8& aOutput) = 0;
61 * Transforms aInput into its encrypted form, aOutput, and applies a
62 * padding scheme to ensure a block aligned result.
64 * See the Cryptography api-guide documentation for an explanation of
65 * how buffering of data supplied to this function is handled.
67 * @param aInput The plaintext.
68 * @param aOutput On return, the ciphertext.
70 virtual void ProcessFinalL(const TDesC8& aInput, TDes8& aOutput) = 0;
73 * Gets the maximum length of the output resulting from calling Process() with a
76 * @param aMaxInputLength The maximum input length in bytes.
77 * @return The maximum output length in bytes.
79 virtual TInt MaxOutputLength(TUint aMaxInputLength) const = 0;
82 * Gets the maximum length of the output resulting from calling ProcessFinalL()
83 * with a given input length.
85 * @param aMaxInputLength The maximum input length in bytes.
86 * @return The maximum output length in bytes.
88 virtual TInt MaxFinalOutputLength(TUint aMaxInputLength) const = 0;
92 * Abstract class defining the interface required to allow the actual
93 * transformation of ciphertext to plaintext.
95 * Generally this class' descendants are constructed using the
96 * functions CPBEncryptElement::NewDecryptLC() or CPBEncryptSet::NewDecryptLC().
98 class CPBDecryptor : public CBase
102 * Transforms aInput into its decrypted form, aOutput, and unpads.
104 * See the Cryptography api-guide documentation for an explanation of
105 * how buffering of data supplied to this function is handled.
107 * @param aInput The ciphertext.
108 * @param aOutput On return, the plaintext.
110 virtual void Process(const TDesC8& aInput, TDes8& aOutput) = 0;
113 * Transforms aInput into its decrypted form, aOutput, and unpads.
115 * @param aInput The ciphertext.
116 * @param aOutput On return, the plaintext.
118 virtual void ProcessFinalL(const TDesC8& aInput, TDes8& aOutput) = 0;
121 * Gets the maximum length of the output given a certain input length.
123 * @param aMaxInputLength The maximum input length in bytes.
124 * @return The maximum output length in bytes.
126 virtual TInt MaxOutputLength(TUint aMaxInputLength) const = 0;
129 * Gets the maximum length of the output given a certain input length.
131 * @param aMaxInputLength The maximum input length in bytes.
132 * @return The maximum output length in bytes.
134 virtual TInt MaxFinalOutputLength(TUint aMaxInputLength) const = 0;
138 * Abstract base class defining the interface required to allow the password
139 * based encryption and decryption of single or multiple items or elements.
141 * @see CPBEncryptElement and CPBEncryptSet
144 class CPBEncryptionBase : public CBase
148 * Gets the parameters allowing one to re-create the object with the
149 * same state at another point in the future.
151 * In order to decrypt any information previously encrypted with this object,
152 * you <B><I>must</I></B> store this encryption data along with it. Failure
153 * to do this will result in the permanent loss of the encrypted information.
155 * @return The data allowing one to re-create this object at a later time.
157 virtual const CPBEncryptionData& EncryptionData(void) const = 0;
160 * Constructs a CPBEncryptor object allowing the encryption of data.
162 * @return A pointer to a CPBEncryptor object.
163 * The caller assumes ownership of the returned object.
165 virtual CPBEncryptor* NewEncryptL(void) const = 0;
168 * Constructs a CPBEncryptor object allowing the encryption of data.
170 * @return A pointer to a CPBEncryptor object.
171 * The caller assumes ownership of the returned object.
172 * The returned pointer is left on the cleanup stack.
174 virtual CPBEncryptor* NewEncryptLC(void) const = 0;
177 * Constructs a CPBDecryptor object allowing the decryption of data.
179 * @return A pointer to a CPBDecryptor object.
180 * The caller assumes ownership of the returned object.
182 virtual CPBDecryptor* NewDecryptL(void) const = 0;
185 * Constructs a CPBDecryptor object allowing the decryption of data.
187 * @return A pointer to a CPBDecryptor object.
188 * The caller assumes ownership of the returned object.
189 * The returned pointer is left on the cleanup stack.
191 virtual CPBDecryptor* NewDecryptLC(void) const = 0;
194 * Gets the maximum output ciphertext length given a specified input plaintext length.
196 * @param aPlaintextLength The plaintext length
197 * @return The maximum ciphertext length given a plaintext length.
199 virtual TInt MaxCiphertextLength(TInt aPlaintextLength) const = 0;
202 * Gets the maximum output plaintext length given a specified input ciphertext length.
204 * @param aCiphertextLength The ciphertext length
205 * @return The maximum plaintext length given a ciphertext length.
207 virtual TInt MaxPlaintextLength(TInt aCiphertextLength) const = 0;