|
1 /* |
|
2 * Copyright (c) 2006-2006 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 "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: Class with implementation of xmlenc padding. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "xmlsecc_padding.h" |
|
20 |
|
21 // --------------------------------------------------------------------------- |
|
22 // Two phase constructor |
|
23 // --------------------------------------------------------------------------- |
|
24 // |
|
25 CXmlSecPadding* CXmlSecPadding::NewLC(TInt aBlockBytes) |
|
26 { |
|
27 CXmlSecPadding* self = new (ELeave) CXmlSecPadding(aBlockBytes); |
|
28 CleanupStack::PushL(self); |
|
29 return self; |
|
30 } |
|
31 |
|
32 // --------------------------------------------------------------------------- |
|
33 // Two phase constructor |
|
34 // --------------------------------------------------------------------------- |
|
35 // |
|
36 CXmlSecPadding* CXmlSecPadding::NewL(TInt aBlockBytes) |
|
37 { |
|
38 CXmlSecPadding* self = CXmlSecPadding::NewLC(aBlockBytes); |
|
39 CleanupStack::Pop(self); |
|
40 return self; |
|
41 } |
|
42 |
|
43 // --------------------------------------------------------------------------- |
|
44 // Constructor |
|
45 // --------------------------------------------------------------------------- |
|
46 // |
|
47 CXmlSecPadding::CXmlSecPadding(TInt aBlockBytes) : CPadding(aBlockBytes) |
|
48 { |
|
49 } |
|
50 |
|
51 // --------------------------------------------------------------------------- |
|
52 // Constructor |
|
53 // --------------------------------------------------------------------------- |
|
54 // |
|
55 void CXmlSecPadding::DoPadL(const TDesC8& aInput,TDes8& aOutput) |
|
56 { |
|
57 TInt padLength = BlockSize() - aInput.Length(); |
|
58 aOutput.Append(aInput); |
|
59 aOutput.AppendFill( (TChar)padLength, padLength ); |
|
60 } |
|
61 |
|
62 // --------------------------------------------------------------------------- |
|
63 // Add pad to buffer |
|
64 // --------------------------------------------------------------------------- |
|
65 // |
|
66 void CXmlSecPadding::UnPadL(const TDesC8& aInput,TDes8& aOutput) |
|
67 { |
|
68 TInt padLength = (TInt) aInput[ BlockSize()-1 ]; |
|
69 aOutput.Copy( aInput.Left( BlockSize() - padLength ) ); |
|
70 } |
|
71 |
|
72 // --------------------------------------------------------------------------- |
|
73 // Remove pad |
|
74 // --------------------------------------------------------------------------- |
|
75 // |
|
76 TInt CXmlSecPadding::MinPaddingLength(void) const |
|
77 { |
|
78 return KMinPaddingLenght; |
|
79 } |