os/security/crypto/weakcryptospi/source/symmetric/arc4shim.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/security/crypto/weakcryptospi/source/symmetric/arc4shim.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,107 @@
     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 +* ARC4 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 ARC4SHIM_H
    1.30 +#define ARC4SHIM_H
    1.31 +
    1.32 +#include <arc4.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(CArc4Shim) : public CARC4
    1.42 +{
    1.43 +public:
    1.44 +	/**
    1.45 +	Creates a CArc4Shim object which has the same interface as CARC4 
    1.46 +	but delegates all work to a Crypto SPI plug-in.
    1.47 +	@param aKey					The key to use. aKey must be less 
    1.48 +								than or equal to KRC4MaxKeySizeBytes.  
    1.49 +	@param aDiscardBytes		The number of bytes to drop from the 
    1.50 +								beginning of the key stream.
    1.51 +	@return						A pointer to a CArc4Shim instance
    1.52 +	@leave KErrKeyNotWeakEnough	If the key size is larger than that 
    1.53 +								allowed by the cipher strength 
    1.54 +								restrictions of the crypto library.
    1.55 +								See TCrypto::IsSymmetricWeakEnoughL()
    1.56 +	*/
    1.57 +	static CArc4Shim* NewL(const TDesC8& aKey, TUint aDiscardBytes);
    1.58 +	
    1.59 +	/**
    1.60 +	Creates a CArc4Shim object which has the same interface as CARC4,
    1.61 +	and leave it on the cleanup stack. but delegates all work to a 
    1.62 +	Crypto SPI plug-in.
    1.63 +	@param aKey					The key to use. aKey must be less 
    1.64 +								than or equal to KRC4MaxKeySizeBytes.  
    1.65 +	@param aDiscardBytes		The number of bytes to drop from the 
    1.66 +								beginning of the key stream.
    1.67 +	@return						A pointer to a CArc4Shim instance
    1.68 +	@leave KErrKeyNotWeakEnough	If the key size is larger than that 
    1.69 +								allowed by the cipher strength 
    1.70 +								restrictions of the crypto library.
    1.71 +								See TCrypto::IsSymmetricWeakEnoughL()
    1.72 +	*/
    1.73 +	static CArc4Shim* NewLC(const TDesC8& aKey, TUint aDiscardBytes);
    1.74 +
    1.75 +	/**
    1.76 +	Destructor
    1.77 +	*/
    1.78 +	~CArc4Shim();
    1.79 +
    1.80 +	// From CSymmetricCipher class
    1.81 +	void Reset();
    1.82 +	TInt BlockSize() const;
    1.83 +	TInt KeySize() const;		
    1.84 +	void Process(const TDesC8& aInput, TDes8& aOutput);
    1.85 +	void ProcessFinalL(const TDesC8& aInput, TDes8& aOutput);
    1.86 +	TInt MaxOutputLength(TInt aInputLength) const;
    1.87 +	TInt MaxFinalOutputLength(TInt aInputLength) const;
    1.88 +
    1.89 +private:
    1.90 +	/** 
    1.91 +	Constructor
    1.92 +	*/
    1.93 +	CArc4Shim();
    1.94 +
    1.95 +	/**
    1.96 +	Second Phase Constructor
    1.97 +	*/
    1.98 +	void ConstructL(const TDesC8& aKey, TUint aDiscardBytes);
    1.99 +		
   1.100 +private:
   1.101 +	/// SPI delegate
   1.102 +	CryptoSpi::CSymmetricCipher* iSymmetricCipherImpl;
   1.103 +		
   1.104 +	/// SPI requires all key to passed as key-objects
   1.105 +	CryptoSpi::CKey* iKey;
   1.106 +	
   1.107 +	CryptoSpi::CCryptoParams* iAlgorithmParams;
   1.108 +};
   1.109 +
   1.110 +#endif // ARC4SHIM_H