os/security/crypto/weakcryptospi/inc/pbebase.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
/*
sl@0
     2
* Copyright (c) 2002-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
* ** IMPORTANT ** PublishedPartner API's in this file are published to 3rd party developers via the 
sl@0
    16
* Symbian website. Changes to these API's should be treated as PublishedAll API changes and the Security TA should be consulted.
sl@0
    17
*
sl@0
    18
*/
sl@0
    19
sl@0
    20
sl@0
    21
/**
sl@0
    22
 @file
sl@0
    23
 @publishedPartner
sl@0
    24
 @released
sl@0
    25
*/
sl@0
    26
sl@0
    27
#ifndef __PBEBASE_H__
sl@0
    28
#define __PBEBASE_H__
sl@0
    29
sl@0
    30
#include <e32base.h>
sl@0
    31
sl@0
    32
class CPBEncryptParms;
sl@0
    33
class CPBEncryptionData;
sl@0
    34
class CPBEncryptSet;
sl@0
    35
class TPBPassword;
sl@0
    36
sl@0
    37
/** 
sl@0
    38
 * Abstract class defining the interface required to allow the actual
sl@0
    39
 * transformation of plaintext to ciphertext.
sl@0
    40
 *
sl@0
    41
 * Generally this class' descendants are constructed using the
sl@0
    42
 * functions CPBEncryptElement::NewEncryptLC() or CPBEncryptSet::NewEncryptLC().
sl@0
    43
 *
sl@0
    44
 * @see CPBEncryptorElement and CPBEncryptorSet
sl@0
    45
 */
sl@0
    46
class CPBEncryptor : public CBase
sl@0
    47
	{
sl@0
    48
public:
sl@0
    49
	/** 
sl@0
    50
	 * Transforms aInput into its encrypted form, aOutput.
sl@0
    51
	 *
sl@0
    52
	 *	See the Cryptography api-guide documentation for an explanation of
sl@0
    53
	 *	how buffering of data supplied to this function is handled.
sl@0
    54
	 *
sl@0
    55
	 * @param aInput	The plaintext.
sl@0
    56
	 * @param aOutput	On return, the ciphertext.
sl@0
    57
	 */
sl@0
    58
	virtual void Process(const TDesC8& aInput, TDes8& aOutput) = 0;
sl@0
    59
sl@0
    60
	/** 
sl@0
    61
	 * Transforms aInput into its encrypted form, aOutput, and applies a
sl@0
    62
	 * padding scheme to ensure a block aligned result.
sl@0
    63
	 *
sl@0
    64
	 *	See the Cryptography api-guide documentation for an explanation of
sl@0
    65
	 *	how buffering of data supplied to this function is handled.
sl@0
    66
	 * 
sl@0
    67
	 * @param aInput	The plaintext.
sl@0
    68
	 * @param aOutput	On return, the ciphertext.
sl@0
    69
	 */
sl@0
    70
	virtual void ProcessFinalL(const TDesC8& aInput, TDes8& aOutput) = 0;
sl@0
    71
sl@0
    72
	/** 
sl@0
    73
	 * Gets the maximum length of the output resulting from calling Process() with a
sl@0
    74
	 * given input length.
sl@0
    75
	 *
sl@0
    76
	 * @param aMaxInputLength	The maximum input length in bytes.
sl@0
    77
	 * @return					The maximum output length in bytes.
sl@0
    78
	 */
sl@0
    79
	virtual TInt MaxOutputLength(TUint aMaxInputLength) const = 0;
sl@0
    80
	
sl@0
    81
	/** 
sl@0
    82
	 * Gets the maximum length of the output resulting from calling ProcessFinalL()
sl@0
    83
	 * with a given input length.
sl@0
    84
	 *
sl@0
    85
	 * @param aMaxInputLength	The maximum input length in bytes.
sl@0
    86
	 * @return					The maximum output length in bytes.
sl@0
    87
	 */
sl@0
    88
	virtual TInt MaxFinalOutputLength(TUint aMaxInputLength) const = 0;
sl@0
    89
};
sl@0
    90
sl@0
    91
/** 
sl@0
    92
 * Abstract class defining the interface required to allow the actual
sl@0
    93
 * transformation of ciphertext to plaintext.
sl@0
    94
 *  
sl@0
    95
 * Generally this class' descendants are constructed using the
sl@0
    96
 * functions CPBEncryptElement::NewDecryptLC() or CPBEncryptSet::NewDecryptLC().
sl@0
    97
 */
sl@0
    98
class CPBDecryptor : public CBase
sl@0
    99
	{
sl@0
   100
public:
sl@0
   101
	/** 
sl@0
   102
	 * Transforms aInput into its decrypted form, aOutput, and unpads.
sl@0
   103
	 *
sl@0
   104
	 *	See the Cryptography api-guide documentation for an explanation of
sl@0
   105
	 *	how buffering of data supplied to this function is handled.
sl@0
   106
	 * 
sl@0
   107
	 * @param aInput	The ciphertext.
sl@0
   108
	 * @param aOutput	On return, the plaintext.
sl@0
   109
	 */
sl@0
   110
	virtual void Process(const TDesC8& aInput, TDes8& aOutput) = 0;
sl@0
   111
sl@0
   112
	/** 
sl@0
   113
	 * Transforms aInput into its decrypted form, aOutput, and unpads.
sl@0
   114
	 * 
sl@0
   115
	 * @param aInput	The ciphertext.
sl@0
   116
	 * @param aOutput	On return, the plaintext.
sl@0
   117
	 */
sl@0
   118
	virtual void ProcessFinalL(const TDesC8& aInput, TDes8& aOutput) = 0;
sl@0
   119
sl@0
   120
	/** 
sl@0
   121
	 * Gets the maximum length of the output given a certain input length.
sl@0
   122
	 * 
sl@0
   123
	 * @param aMaxInputLength	The maximum input length in bytes.
sl@0
   124
	 * @return					The maximum output length in bytes.
sl@0
   125
	 */
sl@0
   126
	virtual TInt MaxOutputLength(TUint aMaxInputLength) const = 0;
sl@0
   127
	
sl@0
   128
	/** 
sl@0
   129
	 * Gets the maximum length of the output given a certain input length.
sl@0
   130
	 * 
sl@0
   131
	 * @param aMaxInputLength	The maximum input length in bytes.
sl@0
   132
	 * @return					The maximum output length in bytes.
sl@0
   133
	 */
sl@0
   134
	virtual TInt MaxFinalOutputLength(TUint aMaxInputLength) const = 0;
sl@0
   135
	};
sl@0
   136
sl@0
   137
/** 
sl@0
   138
 * Abstract base class defining the interface required to allow the password
sl@0
   139
 * based encryption and decryption of single or multiple items or elements.
sl@0
   140
 * 
sl@0
   141
 * @see CPBEncryptElement and CPBEncryptSet
sl@0
   142
 * @since v8.0
sl@0
   143
 */
sl@0
   144
class CPBEncryptionBase : public CBase
sl@0
   145
	{
sl@0
   146
public:
sl@0
   147
	/** 
sl@0
   148
	 * Gets the parameters allowing one to re-create the object with the
sl@0
   149
	 * same state at another point in the future.  
sl@0
   150
	 * 
sl@0
   151
	 * In order to decrypt any information previously encrypted with this object, 
sl@0
   152
	 * you <B><I>must</I></B> store this encryption data along with it. Failure 
sl@0
   153
	 * to do this will result in the permanent loss of the encrypted information.
sl@0
   154
	 * 
sl@0
   155
	 * @return	The data allowing one to re-create this object at a later time.
sl@0
   156
	 */
sl@0
   157
	virtual const CPBEncryptionData& EncryptionData(void) const = 0;
sl@0
   158
sl@0
   159
	/** 
sl@0
   160
	 * Constructs a CPBEncryptor object allowing the encryption of data.
sl@0
   161
	 *
sl@0
   162
	 * @return	A pointer to a CPBEncryptor object.
sl@0
   163
	 *			The caller assumes ownership of the returned object. 
sl@0
   164
	 */
sl@0
   165
	virtual CPBEncryptor* NewEncryptL(void) const = 0;
sl@0
   166
sl@0
   167
	/** 
sl@0
   168
	 * Constructs a CPBEncryptor object allowing the encryption of data.
sl@0
   169
	 * 
sl@0
   170
	 * @return	A pointer to a CPBEncryptor object.
sl@0
   171
	 *			The caller assumes ownership of the returned object.
sl@0
   172
	 *			The returned pointer is left on the cleanup stack.
sl@0
   173
	 */
sl@0
   174
	virtual CPBEncryptor* NewEncryptLC(void) const = 0;
sl@0
   175
sl@0
   176
	/** 
sl@0
   177
	 * Constructs a CPBDecryptor object allowing the decryption of data.
sl@0
   178
	 * 
sl@0
   179
	 * @return	A pointer to a CPBDecryptor object.
sl@0
   180
	 *			The caller assumes ownership of the returned object.
sl@0
   181
	 */
sl@0
   182
	virtual CPBDecryptor* NewDecryptL(void) const = 0;
sl@0
   183
sl@0
   184
	/** 
sl@0
   185
	 * Constructs a CPBDecryptor object allowing the decryption of data.
sl@0
   186
	 * 
sl@0
   187
	 * @return	A pointer to a CPBDecryptor object.
sl@0
   188
	 *			The caller assumes ownership of the returned object.
sl@0
   189
	 *			The returned pointer is left on the cleanup stack.
sl@0
   190
	 */
sl@0
   191
	virtual CPBDecryptor* NewDecryptLC(void) const = 0;
sl@0
   192
sl@0
   193
	/** 
sl@0
   194
	 * Gets the maximum output ciphertext length given a specified input plaintext length.  
sl@0
   195
	 * 
sl@0
   196
	 * @param aPlaintextLength	The plaintext length 
sl@0
   197
	 * @return					The maximum ciphertext length given a plaintext length.
sl@0
   198
	 */
sl@0
   199
	virtual TInt MaxCiphertextLength(TInt aPlaintextLength) const = 0;
sl@0
   200
sl@0
   201
	/** 
sl@0
   202
	 * Gets the maximum output plaintext length given a specified input ciphertext length.
sl@0
   203
	 *
sl@0
   204
	 * @param aCiphertextLength	The ciphertext length
sl@0
   205
	 * @return					The maximum plaintext length given a ciphertext length.
sl@0
   206
	 */
sl@0
   207
	virtual TInt MaxPlaintextLength(TInt aCiphertextLength) const = 0;
sl@0
   208
sl@0
   209
	};
sl@0
   210
sl@0
   211
#endif