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