os/security/crypto/weakcryptospi/source/pbe/pbencryptor.cpp
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 *
    16 */
    17 
    18 
    19 #include <e32std.h>
    20 #include <random.h>
    21 #include <pbencryptor.h>
    22 #include "pbesymmetricfactory.h"
    23 
    24 EXPORT_C CPBEncryptorElement* CPBEncryptorElement::NewL(
    25 	const TPBECipher aCipher, const TDesC8& aKey, const TDesC8& aIV)
    26 	{
    27 	CPBEncryptorElement* self = NewLC(aCipher, aKey, aIV);
    28 	CleanupStack::Pop();
    29 	return self;
    30 	}
    31 
    32 EXPORT_C CPBEncryptorElement* CPBEncryptorElement::NewLC(
    33 	const TPBECipher aCipher, const TDesC8& aKey, const TDesC8& aIV)
    34 	{
    35 	CPBEncryptorElement* self = new(ELeave) CPBEncryptorElement;
    36 	CleanupStack::PushL(self);
    37 	self->ConstructL(aCipher, aKey, aIV);
    38 	return self;
    39 	}
    40 
    41 void CPBEncryptorElement::Process(const TDesC8& aInput, TDes8& aOutput)
    42 	{
    43 	iCipher->Process(aInput, aOutput);
    44 	}
    45 
    46 void CPBEncryptorElement::ProcessFinalL(const TDesC8& aInput, TDes8& aOutput)
    47 	{
    48 	iCipher->ProcessFinalL(aInput, aOutput);
    49 	}
    50 
    51 void CPBEncryptorElement::ConstructL(const TPBECipher aCipher,
    52 	const TDesC8& aKey, const TDesC8& aIV)
    53 	{
    54 	iCipher = PBE::MakeEncryptorL(aCipher, aKey, aIV);
    55 	}
    56 
    57 CPBEncryptorElement::CPBEncryptorElement()
    58 	{
    59 	}
    60 
    61 CPBEncryptorElement::~CPBEncryptorElement()
    62 	{
    63 	delete iCipher;
    64 	}
    65 
    66 TInt CPBEncryptorElement::MaxOutputLength(TUint aMaxInputLength) const
    67 	{
    68 	return iCipher->MaxOutputLength(aMaxInputLength);
    69 	}
    70 
    71 TInt CPBEncryptorElement::MaxFinalOutputLength(TUint aMaxInputLength) const
    72 	{
    73 	return iCipher->MaxFinalOutputLength(aMaxInputLength);
    74 	}
    75 
    76 EXPORT_C CPBDecryptorElement* CPBDecryptorElement::NewL(
    77 	const TPBECipher aCipher, const TDesC8& aKey, const TDesC8& aIV)
    78 	{
    79 	CPBDecryptorElement* self = NewLC(aCipher, aKey, aIV);
    80 	CleanupStack::Pop();
    81 	return self;
    82 	}
    83 
    84 EXPORT_C CPBDecryptorElement* CPBDecryptorElement::NewLC(
    85 	const TPBECipher aCipher, const TDesC8& aKey, const TDesC8& aIV)
    86 	{
    87 	CPBDecryptorElement* self = new(ELeave) CPBDecryptorElement;
    88 	CleanupStack::PushL(self);
    89 	self->ConstructL(aCipher, aKey, aIV);
    90 	return self;
    91 	}
    92 
    93 void CPBDecryptorElement::Process(const TDesC8& aInput, TDes8& aOutput)
    94 	{
    95 	iCipher->Process(aInput, aOutput);
    96 	}
    97 
    98 void CPBDecryptorElement::ProcessFinalL(const TDesC8& aInput, TDes8& aOutput)
    99 	{
   100 	iCipher->ProcessFinalL(aInput, aOutput);
   101 	}
   102 
   103 void CPBDecryptorElement::ConstructL(const TPBECipher aCipher, 
   104 	const TDesC8& aKey, const TDesC8& aIV)
   105 	{
   106 	iCipher = PBE::MakeDecryptorL(aCipher, aKey, aIV);
   107 	}
   108 
   109 CPBDecryptorElement::CPBDecryptorElement()
   110 	{
   111 	}
   112 
   113 CPBDecryptorElement::~CPBDecryptorElement()
   114 	{
   115 	delete iCipher;
   116 	}
   117 
   118 TInt CPBDecryptorElement::MaxOutputLength(TUint aMaxInputLength) const
   119 	{
   120 	return iCipher->MaxOutputLength(aMaxInputLength);
   121 	}
   122 
   123 TInt CPBDecryptorElement::MaxFinalOutputLength(TUint aMaxInputLength) const
   124 	{
   125 	return iCipher->MaxFinalOutputLength(aMaxInputLength);
   126 	}