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