|
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of the License "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 @publishedPartner |
|
19 @released |
|
20 */ |
|
21 |
|
22 #ifndef KEYSTREAMSINK_H |
|
23 #define KEYSTREAMSINK_H |
|
24 |
|
25 #include <e32base.h> |
|
26 #include <caf/streaming/keyassociation.h> |
|
27 |
|
28 class RWriteStream; |
|
29 |
|
30 namespace StreamAccess |
|
31 { |
|
32 enum TEncryptionAlgorithm |
|
33 { |
|
34 ENoEncryption = 0, |
|
35 EAES_128_CBC, |
|
36 EAES_128_CTR |
|
37 }; |
|
38 |
|
39 enum TAuthenticationAlgorithm |
|
40 { |
|
41 ENoAuthentication = 0, |
|
42 EHMAC_SHA1 |
|
43 }; |
|
44 /** |
|
45 Defines the key stream sink abstraction. Key stream sink is used for applying keys decrypted by the CAF streaming agent |
|
46 to their correct destination. |
|
47 |
|
48 Typical implementations would be CIpSecKeyStreamSink, CSrtpKeyStreamSink etc. |
|
49 */ |
|
50 class CKeyStreamSink : public CBase |
|
51 { |
|
52 public: |
|
53 |
|
54 /** Clone the key stream sink. Required to support copying of key stream sinks without knowing their runtime type. |
|
55 */ |
|
56 virtual CKeyStreamSink *CloneLC() const = 0; |
|
57 |
|
58 /** Push a decrypted key association to its sink. This function should be called only by CAgentKeyStreamDecoder |
|
59 instances. Please note that this interface is synchronous, i.e. the function returns when the key is implemented. |
|
60 |
|
61 @see CAgentKeyStreamDecoder |
|
62 |
|
63 @param aKeyAssociation The key association extracted from the short-term key message. |
|
64 @leave One of the system-wide error codes. |
|
65 */ |
|
66 virtual void ProcessNewKeyAssociationL(const CKeyAssociation& aKeyAssociation) = 0; |
|
67 |
|
68 /** Set the encryption algorithm. If encryption is used, the encryption algorithm must be set before processing any key associations. |
|
69 Please note that changing the encryption algorithm once key associations have been processed is not supported. |
|
70 |
|
71 @param aEncryptionAlgorithm The encryption algorithm |
|
72 @leave One of the system-wide error codes. |
|
73 */ |
|
74 virtual void SetEncryptionAlgorithmL(const TEncryptionAlgorithm& aEncryptionAlgorithm) = 0; |
|
75 |
|
76 /** Set the authentication algorithm. If authentication is used, the authetication algorithm must be set before processing any key associations. |
|
77 Please note that changing the authentication algorithm once key associations have been processed is not supported. |
|
78 |
|
79 @param aAuthenticationAlgorithm The authentication algorithm |
|
80 @leave One of the system-wide error codes. |
|
81 */ |
|
82 virtual void SetAuthenticationAlgorithmL(const TAuthenticationAlgorithm& aAuthenticationAlgorithm) = 0; |
|
83 |
|
84 /** Externalize the key stream sink to a buffer. Leaves the allocated buffer on the cleanup stack. |
|
85 |
|
86 @return Pointer to the buffer |
|
87 @leave One of the system-wide error codes. |
|
88 */ |
|
89 IMPORT_C TPtr8 ExternalizeLC() const; |
|
90 |
|
91 /** Internalize the key stream sink from a buffer. Leaves the allocated key stream sink on the cleanup stack. |
|
92 |
|
93 @param aBuf Buffer with the externalized key stream sink |
|
94 @return Pointer to the key stream sink |
|
95 @leave One of the system-wide error codes. |
|
96 */ |
|
97 IMPORT_C static CKeyStreamSink *InternalizeLC(const TDesC8 &aBuf); |
|
98 |
|
99 virtual ~CKeyStreamSink() {} |
|
100 protected: |
|
101 virtual void DoExternalizeL(RWriteStream &aStream) const = 0; |
|
102 protected: |
|
103 // Used for serialization |
|
104 enum TSinksEnum |
|
105 { |
|
106 EIpSecSinkId = 1 |
|
107 }; |
|
108 }; |
|
109 } // namespace StreamAccess |
|
110 #endif // KEYSTREAMSINK_H |
|
111 |