sl@0: // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0: // All rights reserved.
sl@0: // This component and the accompanying materials are made available
sl@0: // under the terms of the License "Eclipse Public License v1.0"
sl@0: // which accompanies this distribution, and is available
sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0: //
sl@0: // Initial Contributors:
sl@0: // Nokia Corporation - initial contribution.
sl@0: //
sl@0: // Contributors:
sl@0: //
sl@0: // Description:
sl@0: //
sl@0: 
sl@0: /**
sl@0:  @file
sl@0:  @publishedPartner
sl@0:  @released
sl@0: */
sl@0: 
sl@0: #ifndef KEYSTREAMSINK_H
sl@0: #define KEYSTREAMSINK_H
sl@0: 
sl@0: #include <e32base.h>
sl@0: #include <caf/streaming/keyassociation.h>
sl@0: 
sl@0: class RWriteStream;
sl@0: 
sl@0: namespace StreamAccess
sl@0: 	{
sl@0: 	enum TEncryptionAlgorithm
sl@0: 		{
sl@0: 		ENoEncryption = 0,
sl@0: 		EAES_128_CBC,
sl@0: 		EAES_128_CTR
sl@0: 		};
sl@0: 	
sl@0: 	enum TAuthenticationAlgorithm
sl@0: 		{
sl@0: 		ENoAuthentication = 0,
sl@0: 		EHMAC_SHA1		 
sl@0: 		};
sl@0: 	/**
sl@0:  	Defines the key stream sink abstraction. Key stream sink is used for applying keys decrypted by the CAF streaming agent
sl@0: 	to their correct destination.
sl@0:  
sl@0:  	Typical implementations would be CIpSecKeyStreamSink, CSrtpKeyStreamSink etc.
sl@0:  	*/
sl@0: 	class CKeyStreamSink : public CBase
sl@0: 		{
sl@0: 	public:
sl@0: 
sl@0: 		/**  Clone the key stream sink. Required to support copying of key stream sinks without knowing their runtime type. 
sl@0: 		*/
sl@0: 		virtual CKeyStreamSink *CloneLC() const = 0;
sl@0: 
sl@0: 		/**  Push a decrypted key association to its sink. This function should be called only by CAgentKeyStreamDecoder
sl@0: 		instances. Please note that this interface is synchronous, i.e. the function returns when the key is implemented.
sl@0: 						 
sl@0: 		@see CAgentKeyStreamDecoder
sl@0: 
sl@0: 		@param aKeyAssociation The key association extracted from the short-term key message. 
sl@0: 		@leave One of the system-wide error codes.
sl@0: 		*/
sl@0: 		virtual void ProcessNewKeyAssociationL(const CKeyAssociation& aKeyAssociation) = 0;
sl@0: 		 
sl@0: 		/**  Set the encryption algorithm. If encryption is used, the encryption algorithm must be set before processing any key associations. 
sl@0: 		Please note that changing the encryption algorithm once key associations have been processed is not supported. 
sl@0: 		 
sl@0: 		@param aEncryptionAlgorithm The encryption algorithm
sl@0: 		@leave One of the system-wide error codes.
sl@0: 		*/		 
sl@0: 		virtual void SetEncryptionAlgorithmL(const TEncryptionAlgorithm& aEncryptionAlgorithm) = 0;
sl@0: 		 
sl@0: 		/**  Set the authentication algorithm. If authentication is used, the authetication algorithm must be set before processing any key associations. 
sl@0: 		Please note that changing the authentication algorithm once key associations have been processed is not supported. 
sl@0: 		 
sl@0: 		@param aAuthenticationAlgorithm The authentication algorithm
sl@0: 		@leave One of the system-wide error codes.
sl@0: 		*/		 		 
sl@0: 		virtual void SetAuthenticationAlgorithmL(const TAuthenticationAlgorithm& aAuthenticationAlgorithm) = 0;
sl@0: 
sl@0: 		/**  Externalize the key stream sink to a buffer. Leaves the allocated buffer on the cleanup stack.
sl@0: 		 
sl@0: 		@return Pointer to the buffer
sl@0: 		@leave One of the system-wide error codes.
sl@0: 		*/		 		 
sl@0: 		IMPORT_C TPtr8 ExternalizeLC() const;
sl@0: 
sl@0: 		/**  Internalize the key stream sink from a buffer. Leaves the allocated key stream sink on the cleanup stack.
sl@0: 		
sl@0: 		@param aBuf Buffer with the externalized key stream sink
sl@0: 		@return Pointer to the key stream sink
sl@0: 		@leave One of the system-wide error codes.
sl@0: 		*/		 		 
sl@0: 		IMPORT_C static CKeyStreamSink *InternalizeLC(const TDesC8 &aBuf);
sl@0: 		 
sl@0: 		virtual ~CKeyStreamSink() {}
sl@0: 	protected:
sl@0: 		virtual void DoExternalizeL(RWriteStream &aStream) const = 0;
sl@0: 	protected:
sl@0: 		// Used for serialization
sl@0: 		enum TSinksEnum
sl@0: 			{
sl@0: 			EIpSecSinkId = 1
sl@0: 			};
sl@0: 		};
sl@0: 	} // namespace StreamAccess
sl@0: #endif // KEYSTREAMSINK_H
sl@0: