1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/security/crypto/weakcryptospi/source/pbe/pbencryptor.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,126 @@
1.4 +/*
1.5 +* Copyright (c) 2002-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 +*
1.19 +*/
1.20 +
1.21 +
1.22 +#include <e32std.h>
1.23 +#include <random.h>
1.24 +#include <pbencryptor.h>
1.25 +#include "pbesymmetricfactory.h"
1.26 +
1.27 +EXPORT_C CPBEncryptorElement* CPBEncryptorElement::NewL(
1.28 + const TPBECipher aCipher, const TDesC8& aKey, const TDesC8& aIV)
1.29 + {
1.30 + CPBEncryptorElement* self = NewLC(aCipher, aKey, aIV);
1.31 + CleanupStack::Pop();
1.32 + return self;
1.33 + }
1.34 +
1.35 +EXPORT_C CPBEncryptorElement* CPBEncryptorElement::NewLC(
1.36 + const TPBECipher aCipher, const TDesC8& aKey, const TDesC8& aIV)
1.37 + {
1.38 + CPBEncryptorElement* self = new(ELeave) CPBEncryptorElement;
1.39 + CleanupStack::PushL(self);
1.40 + self->ConstructL(aCipher, aKey, aIV);
1.41 + return self;
1.42 + }
1.43 +
1.44 +void CPBEncryptorElement::Process(const TDesC8& aInput, TDes8& aOutput)
1.45 + {
1.46 + iCipher->Process(aInput, aOutput);
1.47 + }
1.48 +
1.49 +void CPBEncryptorElement::ProcessFinalL(const TDesC8& aInput, TDes8& aOutput)
1.50 + {
1.51 + iCipher->ProcessFinalL(aInput, aOutput);
1.52 + }
1.53 +
1.54 +void CPBEncryptorElement::ConstructL(const TPBECipher aCipher,
1.55 + const TDesC8& aKey, const TDesC8& aIV)
1.56 + {
1.57 + iCipher = PBE::MakeEncryptorL(aCipher, aKey, aIV);
1.58 + }
1.59 +
1.60 +CPBEncryptorElement::CPBEncryptorElement()
1.61 + {
1.62 + }
1.63 +
1.64 +CPBEncryptorElement::~CPBEncryptorElement()
1.65 + {
1.66 + delete iCipher;
1.67 + }
1.68 +
1.69 +TInt CPBEncryptorElement::MaxOutputLength(TUint aMaxInputLength) const
1.70 + {
1.71 + return iCipher->MaxOutputLength(aMaxInputLength);
1.72 + }
1.73 +
1.74 +TInt CPBEncryptorElement::MaxFinalOutputLength(TUint aMaxInputLength) const
1.75 + {
1.76 + return iCipher->MaxFinalOutputLength(aMaxInputLength);
1.77 + }
1.78 +
1.79 +EXPORT_C CPBDecryptorElement* CPBDecryptorElement::NewL(
1.80 + const TPBECipher aCipher, const TDesC8& aKey, const TDesC8& aIV)
1.81 + {
1.82 + CPBDecryptorElement* self = NewLC(aCipher, aKey, aIV);
1.83 + CleanupStack::Pop();
1.84 + return self;
1.85 + }
1.86 +
1.87 +EXPORT_C CPBDecryptorElement* CPBDecryptorElement::NewLC(
1.88 + const TPBECipher aCipher, const TDesC8& aKey, const TDesC8& aIV)
1.89 + {
1.90 + CPBDecryptorElement* self = new(ELeave) CPBDecryptorElement;
1.91 + CleanupStack::PushL(self);
1.92 + self->ConstructL(aCipher, aKey, aIV);
1.93 + return self;
1.94 + }
1.95 +
1.96 +void CPBDecryptorElement::Process(const TDesC8& aInput, TDes8& aOutput)
1.97 + {
1.98 + iCipher->Process(aInput, aOutput);
1.99 + }
1.100 +
1.101 +void CPBDecryptorElement::ProcessFinalL(const TDesC8& aInput, TDes8& aOutput)
1.102 + {
1.103 + iCipher->ProcessFinalL(aInput, aOutput);
1.104 + }
1.105 +
1.106 +void CPBDecryptorElement::ConstructL(const TPBECipher aCipher,
1.107 + const TDesC8& aKey, const TDesC8& aIV)
1.108 + {
1.109 + iCipher = PBE::MakeDecryptorL(aCipher, aKey, aIV);
1.110 + }
1.111 +
1.112 +CPBDecryptorElement::CPBDecryptorElement()
1.113 + {
1.114 + }
1.115 +
1.116 +CPBDecryptorElement::~CPBDecryptorElement()
1.117 + {
1.118 + delete iCipher;
1.119 + }
1.120 +
1.121 +TInt CPBDecryptorElement::MaxOutputLength(TUint aMaxInputLength) const
1.122 + {
1.123 + return iCipher->MaxOutputLength(aMaxInputLength);
1.124 + }
1.125 +
1.126 +TInt CPBDecryptorElement::MaxFinalOutputLength(TUint aMaxInputLength) const
1.127 + {
1.128 + return iCipher->MaxFinalOutputLength(aMaxInputLength);
1.129 + }