Update contrib.
2 * Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
22 #include <cryptospi/cryptosymmetriccipherapi.h>
23 #include <cryptospi/cryptospidef.h>
24 #include <cryptospi/plugincharacteristics.h>
25 #include <cryptostrength.h>
26 #include "../common/inlines.h"
27 #include <cryptospi/keys.h>
29 using namespace CryptoSpi;
31 CArc4Shim* CArc4Shim::NewL(const TDesC8& aKey, TUint aDiscardBytes)
33 CArc4Shim* self = NewLC(aKey, aDiscardBytes);
34 CleanupStack::Pop(self);
38 CArc4Shim* CArc4Shim::NewLC(const TDesC8& aKey, TUint aDiscardBytes)
40 CArc4Shim* self = new (ELeave) CArc4Shim();
41 CleanupStack::PushL(self);
42 self->ConstructL(aKey, aDiscardBytes);
43 TCrypto::IsSymmetricWeakEnoughL(BytesToBits(aKey.Size()));
47 void CArc4Shim::ConstructL(const TDesC8& aKey, TUint aDiscardBytes)
49 TKeyProperty keyProperty = {KArc4Uid, KNullUid, KSymmetricKey, KNonEmbeddedKeyUid};
50 CCryptoParams* keyParam =CCryptoParams::NewLC();
51 keyParam->AddL(aKey, KSymmetricKeyParameterUid);
52 iKey=CKey::NewL(keyProperty, *keyParam);
53 CleanupStack::PopAndDestroy(keyParam);
55 iAlgorithmParams = CCryptoParams::NewL();
56 iAlgorithmParams->AddL(aDiscardBytes, KARC4DiscardBytes);
58 CSymmetricCipherFactory::CreateSymmetricCipherL(
63 KOperationModeNoneUid,
68 CArc4Shim::~CArc4Shim()
70 delete iSymmetricCipherImpl;
72 delete iAlgorithmParams;
75 void CArc4Shim::Reset()
77 iSymmetricCipherImpl->Reset();
80 TInt CArc4Shim::BlockSize() const
82 return iSymmetricCipherImpl->BlockSize() >> 3; // Convert to bits
85 TInt CArc4Shim::KeySize() const
87 return iSymmetricCipherImpl->KeySize();
90 void CArc4Shim::Process(const TDesC8& aInput, TDes8& aOutput)
92 TRAP_IGNORE(iSymmetricCipherImpl->ProcessL(aInput, aOutput);)
95 void CArc4Shim::ProcessFinalL(const TDesC8& aInput, TDes8& aOutput)
97 iSymmetricCipherImpl->ProcessFinalL(aInput, aOutput);
100 TInt CArc4Shim::MaxOutputLength(TInt aInputLength) const
102 return iSymmetricCipherImpl->MaxOutputLength(aInputLength);
105 TInt CArc4Shim::MaxFinalOutputLength(TInt aInputLength) const
107 return iSymmetricCipherImpl->MaxFinalOutputLength(aInputLength);
110 CArc4Shim::CArc4Shim()