1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/security/crypto/weakcryptospi/source/symmetric/rc2shim.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,154 @@
1.4 +/*
1.5 +* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of the License "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +* RC2 shim classes definition
1.19 +*
1.20 +*/
1.21 +
1.22 +
1.23 +/**
1.24 + @file
1.25 + @internalComponent
1.26 + @released
1.27 +*/
1.28 +
1.29 +#ifndef __RC2SHIM_H__
1.30 +#define __RC2SHIM_H__
1.31 +
1.32 +#include <rc2.h>
1.33 +
1.34 +namespace CryptoSpi
1.35 + {
1.36 + class CCryptoParams;
1.37 + class CSymmetricCipher;
1.38 + class CKey;
1.39 + }
1.40 +
1.41 +NONSHARABLE_CLASS(CRC2EncryptorShim) : public CRC2Encryptor
1.42 +{
1.43 +public:
1.44 + /**
1.45 + Creates an CRC2EncryptorShim object which has the same interface
1.46 + as RC2 Encryptor but delegates all work to a Crypto SPI plug-in.
1.47 +
1.48 + @param aKey The encryption key
1.49 + @return A pointer to a CRC2EncryptorShim instance
1.50 + */
1.51 + static CRC2EncryptorShim* NewL(const TDesC8& aKey, TInt aEffectiveKeyLenBits);
1.52 +
1.53 + /**
1.54 + Creates an CRC2EncryptorShim object which has the same interface
1.55 + as RC2 Encryptor but delegates all work to a Crypto SPI plug-in.
1.56 +
1.57 + A pointer to the new object is placed on the cleanup stack
1.58 +
1.59 + @param aKey The encryption key
1.60 + @return A pointer to a CRC2EncryptorShim instance
1.61 + */
1.62 + static CRC2EncryptorShim* NewLC(const TDesC8& aKey, TInt aEffectiveKeyLenBits);
1.63 +
1.64 + // From CBlockTransform
1.65 + TInt BlockSize() const;
1.66 + void Transform(TDes8& aBlock);
1.67 + void Reset(void);
1.68 + TInt KeySize(void) const;
1.69 +
1.70 + /// Destructor
1.71 + ~CRC2EncryptorShim();
1.72 +
1.73 +private:
1.74 + /// Constructor
1.75 + CRC2EncryptorShim();
1.76 + void ConstructL(const TDesC8& aKey, TInt aEffectiveKeyLenBits);
1.77 +
1.78 + // From CBase
1.79 + TInt Extension_(TUint aExtensionId, TAny*& a0, TAny* a1);
1.80 +
1.81 +private:
1.82 + /// SPI delegate
1.83 + CryptoSpi::CSymmetricCipher* iSymmetricCipherImpl;
1.84 +
1.85 + /// SPI requires all key to passed as key-objects
1.86 + CryptoSpi::CKey* iKey;
1.87 +
1.88 + /// Temporary output block, SPI does not overwrite input
1.89 + /// RC2 uses 64bit blocks
1.90 + TBuf8<16> iOutputBlock;
1.91 +
1.92 + /// The effective key length is passed as an algorithm
1.93 + /// parameter. This allows it to be externalised.
1.94 + CryptoSpi::CCryptoParams* iAlgorithmParams;
1.95 +};
1.96 +
1.97 +NONSHARABLE_CLASS(CRC2DecryptorShim) : public CRC2Decryptor
1.98 +{
1.99 +public:
1.100 + /**
1.101 + Creates an CRC2DecryptorShim object which has the same interface
1.102 + as RC2 Decryptor but delegates all work to a Crypto SPI plug-in.
1.103 +
1.104 + @param aKey The decryption key
1.105 + @return A pointer to a CRC2DecryptorShim instance
1.106 + */
1.107 + static CRC2DecryptorShim* NewL(const TDesC8& aKey, TInt aEffectiveKeyLenBits);
1.108 +
1.109 + /**
1.110 + Creates an CRC2DecryptorShim object which has the same interface
1.111 + as RC2 Decryptor but delegates all work to a Crypto SPI plug-in.
1.112 +
1.113 + A pointer to the new object is placed on the cleanup stack
1.114 +
1.115 + @param aKey The decryption key
1.116 + @return A pointer to a CRC2DecryptorShim instance
1.117 + */
1.118 + static CRC2DecryptorShim* NewLC(const TDesC8& aKey, TInt aEffectiveKeyLenBits);
1.119 +
1.120 + // From CBlockTransform
1.121 + TInt BlockSize() const;
1.122 + void Transform(TDes8& aBlock);
1.123 + void Reset(void);
1.124 + TInt KeySize(void) const;
1.125 +
1.126 + /// Destructor
1.127 + ~CRC2DecryptorShim();
1.128 +
1.129 +private:
1.130 + /// Constructor
1.131 + CRC2DecryptorShim();
1.132 + void ConstructL(const TDesC8& aKey, TInt aEffectiveKeyLenBits);
1.133 +
1.134 + /**
1.135 + From CBase, to allow CBufferedTransform & CBlockChainingMode
1.136 + to determine whether the functionality may be delegated to
1.137 + the SPI object.
1.138 + */
1.139 + TInt Extension_(TUint aExtensionId, TAny*& a0, TAny* a1);
1.140 +
1.141 +private:
1.142 + /// SPI delegate
1.143 + CryptoSpi::CSymmetricCipher* iSymmetricCipherImpl;
1.144 +
1.145 + /// SPI requires all key to passed as key-objects
1.146 + CryptoSpi::CKey* iKey;
1.147 +
1.148 + /// Temporary output block, SPI does not overwrite input
1.149 + /// RC2 uses 64bit blocks
1.150 + TBuf8<16> iOutputBlock;
1.151 +
1.152 + /// The effective key length is passed as an algorithm
1.153 + /// parameter. This allows it to be externalised.
1.154 + CryptoSpi::CCryptoParams* iAlgorithmParams;
1.155 +};
1.156 +
1.157 +#endif // __RC2SHIM_H__