|
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 * streamcipher.cpp |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #include "streamcipher.h" |
|
21 #include <cryptopanic.h> |
|
22 |
|
23 EXPORT_C void CStreamCipher::ProcessFinalL(const TDesC8& aInput, TDes8& aOutput) |
|
24 { |
|
25 Process(aInput, aOutput); |
|
26 } |
|
27 |
|
28 EXPORT_C void CStreamCipher::Process(const TDesC8& aInput, TDes8& aOutput) |
|
29 { |
|
30 TInt outputIndex = aOutput.Size(); |
|
31 |
|
32 // aOutput may already have outputIndex bytes of data in it |
|
33 // check there will still be enough space to process the result |
|
34 __ASSERT_DEBUG(aOutput.MaxLength() - outputIndex >= MaxOutputLength(aInput.Length()), User::Panic(KCryptoPanic, ECryptoPanicOutputDescriptorOverflow)); |
|
35 |
|
36 aOutput.Append(aInput); |
|
37 |
|
38 TPtr8 transformBuf((TUint8*)(aOutput.Ptr()) + outputIndex, aInput.Size(), |
|
39 aInput.Size()); |
|
40 DoProcess(transformBuf); |
|
41 } |
|
42 |
|
43 EXPORT_C TInt CStreamCipher::BlockSize() const |
|
44 { |
|
45 return (1); |
|
46 } |
|
47 |
|
48 EXPORT_C TInt CStreamCipher::MaxOutputLength(TInt aInputLength) const |
|
49 { |
|
50 return aInputLength; |
|
51 } |
|
52 |
|
53 EXPORT_C TInt CStreamCipher::MaxFinalOutputLength(TInt aInputLength) const |
|
54 { |
|
55 return aInputLength; |
|
56 } |