|
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 * csymmetriccipher.h |
|
16 * ** IMPORTANT ** PublishedPartner API's in this file are published to 3rd party developers via the |
|
17 * Symbian website. Changes to these API's should be treated as PublishedAll API changes and the Security TA should be consulted. |
|
18 * CSymmetricCipher class implementation |
|
19 * |
|
20 */ |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 /** |
|
26 @file |
|
27 @publishedPartner |
|
28 @released |
|
29 */ |
|
30 |
|
31 #ifndef __CSYMMETRICCIPHER_H__ |
|
32 #define __CSYMMETRICCIPHER_H__ |
|
33 |
|
34 #include <e32base.h> |
|
35 |
|
36 /** |
|
37 * Top-level interface designed to collate the behaviour of all symmetric |
|
38 * ciphers under one interface. |
|
39 * |
|
40 * See the Cryptography api-guide documentation. |
|
41 * |
|
42 * @publishedPartner |
|
43 * @released |
|
44 */ |
|
45 class CSymmetricCipher : public CBase |
|
46 { |
|
47 public: |
|
48 /** |
|
49 * Runs the underlying transformation on aInput and appends the result to |
|
50 * aOutput. |
|
51 * |
|
52 * For incremental buffering rules see the Cryptography api-guide documentation. |
|
53 * |
|
54 * @param aInput The input data to be processed. |
|
55 * @param aOutput The resulting processed data appended to aOutput. aOutput must |
|
56 * have MaxOutputLength() empty bytes remaining in its length. |
|
57 */ |
|
58 virtual void Process(const TDesC8& aInput, TDes8& aOutput) = 0; |
|
59 |
|
60 /** |
|
61 * Pads aInput to be block aligned using the underlying padding system, if any, |
|
62 * and then runs the underlying transformation on aInput, and appends the result |
|
63 * to aOutput. |
|
64 * |
|
65 * For incremental buffering rules see the Cryptography api-guide documentation. |
|
66 * |
|
67 * @param aInput The input data to be processed. |
|
68 * @param aOutput The resulting, possibly padded, processed data appended to |
|
69 * aOutput. aOutput must have MaxFinalOutputLength() empty bytes |
|
70 * remaining in its length. |
|
71 */ |
|
72 virtual void ProcessFinalL(const TDesC8& aInput, TDes8& aOutput) = 0; |
|
73 |
|
74 /** |
|
75 * Gets a tight upper bound on the number of bytes that would be returned by a |
|
76 * call to Process() with aInputLength bytes of data. |
|
77 * |
|
78 * @param aInputLength The length of data to be supplied to Process() in bytes. |
|
79 * @return The length of data which would result from a call to |
|
80 * Process() with an aInputLength number of bytes. |
|
81 */ |
|
82 virtual TInt MaxOutputLength(TInt aInputLength) const = 0; |
|
83 |
|
84 /** |
|
85 * Gets as tight an upper bound as possible on the number of bytes that would |
|
86 * be returned by a call to ProcessFinalL() with aInputLength bytes of data. |
|
87 * |
|
88 * @param aInputLength The length of data to be supplied to Process() in bytes. |
|
89 * @return An upper bound on the length of data which would result from |
|
90 * a call to ProcessFinalL() with an aInputLength number of bytes. |
|
91 */ |
|
92 virtual TInt MaxFinalOutputLength(TInt aInputLength) const = 0; |
|
93 |
|
94 /** |
|
95 * Resets the cipher back to its original state. Clears all its buffers. |
|
96 */ |
|
97 virtual void Reset() = 0; |
|
98 |
|
99 /** |
|
100 * Gets the block size in bytes (1 for stream ciphers). |
|
101 * |
|
102 * @return Block size of underlying cipher in bytes. |
|
103 */ |
|
104 virtual TInt BlockSize() const = 0; |
|
105 |
|
106 /** |
|
107 * Gets the key size in bits. |
|
108 * |
|
109 * @return Key size in bits. |
|
110 */ |
|
111 virtual TInt KeySize() const = 0; |
|
112 }; |
|
113 |
|
114 |
|
115 #endif // __CSYMMETRICCIPHER_H__ |