srtp.h

Go to the documentation of this file.
00001 /*
00002  * srtp.h
00003  *
00004  * SRTP protocol handler
00005  *
00006  * OPAL Library
00007  *
00008  * Copyright (C) 2006 Post Increment
00009  *
00010  * The contents of this file are subject to the Mozilla Public License
00011  * Version 1.0 (the "License"); you may not use this file except in
00012  * compliance with the License. You may obtain a copy of the License at
00013  * http://www.mozilla.org/MPL/
00014  *
00015  * Software distributed under the License is distributed on an "AS IS"
00016  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
00017  * the License for the specific language governing rights and limitations
00018  * under the License.
00019  *
00020  * The Original Code is OPAL Library.
00021  *
00022  * The Initial Developer of the Original Code is Post Increment
00023  *     Portions of this code were written with the assistance of funding from
00024  *     US Joint Forces Command Joint Concept Development & Experimentation (J9)
00025  *     http://www.jfcom.mil/about/abt_j9.htm
00026  *
00027  * Contributor(s): ______________________________________.
00028  *
00029  * $Log: srtp.h,v $
00030  * Revision 1.9  2007/04/19 06:17:21  csoutheren
00031  * Fixes for precompiled headers with gcc
00032  *
00033  * Revision 1.8  2007/04/17 23:45:08  csoutheren
00034  * Fix name of SRTP libraries on Windows
00035  *
00036  * Revision 1.7  2007/02/20 04:26:43  csoutheren
00037  * Ensure outgoing and incoming SSRC are set for SRTP sessions
00038  * Fixed problem with sending secure RTCP packets
00039  *
00040  * Revision 1.6  2007/02/12 02:44:27  csoutheren
00041  * Start of support for ZRTP
00042  *
00043  * Revision 1.6  2007/02/10 07:08:41  craigs
00044  * Start of support for ZRTP
00045  *
00046  * Revision 1.5  2006/11/20 03:37:12  csoutheren
00047  * Allow optional inclusion of RTP aggregation
00048  *
00049  * Revision 1.4  2006/10/24 04:18:28  csoutheren
00050  * Added support for encrypted RTCP
00051  *
00052  * Revision 1.3  2006/09/28 07:42:17  csoutheren
00053  * Merge of useful SRTP implementation
00054  *
00055  * Revision 1.2.2.3  2006/09/12 07:47:15  csoutheren
00056  * Changed to use seperate incoming and outgoing keys
00057  *
00058  * Revision 1.2.2.2  2006/09/12 07:06:58  csoutheren
00059  * More implementation of SRTP and general call security
00060  *
00061  * Revision 1.2.2.1  2006/09/08 06:23:28  csoutheren
00062  * Implement initial support for SRTP media encryption and H.235-SRTP support
00063  * This code currently inserts SRTP offers into outgoing H.323 OLC, but does not
00064  * yet populate capabilities or respond to negotiations. This code to follow
00065  *
00066  * Revision 1.2  2006/09/05 06:18:23  csoutheren
00067  * Start bringing in SRTP code for libSRTP
00068  *
00069  * Revision 1.1  2006/08/21 06:19:28  csoutheren
00070  * Added placeholders for SRTP implementation
00071  *
00072  */
00073 
00074 #ifndef __OPAL_SRTP_H
00075 #define __OPAL_SRTP_H
00076 
00077 #ifdef P_USE_PRAGMA
00078 #pragma interface
00079 #endif
00080 
00081 #ifndef _PTLIB_H
00082 #include <ptlib.h>
00083 #endif
00084 
00085 #include <opal/buildopts.h>
00086 #include <rtp/rtp.h>
00087 #include <opal/connection.h>
00088 
00089 #if OPAL_SRTP
00090 
00091 namespace PWLibStupidLinkerHacks {
00092   extern int libSRTPLoader;
00093 };
00094 
00096 //
00097 //  this class holds the parameters required for an SRTP session
00098 //
00099 //  Crypto modes are identified by key strings that are contained in PFactory<OpalSRTPParms>
00100 //  The following strings should be implemented:
00101 //
00102 //     AES_CM_128_HMAC_SHA1_80,
00103 //     AES_CM_128_HMAC_SHA1_32,
00104 //     AES_CM_128_NULL_AUTH,   
00105 //     NULL_CIPHER_HMAC_SHA1_80
00106 //     STRONGHOLD
00107 //
00108 
00109 class OpalSRTPSecurityMode : public OpalSecurityMode
00110 {
00111   PCLASSINFO(OpalSRTPSecurityMode, OpalSecurityMode);
00112   public:
00113     struct KeySalt {
00114       KeySalt()                                                       { }
00115       KeySalt(const PBYTEArray & data)           : key(data)          { }
00116       KeySalt(const BYTE * data, PINDEX dataLen) : key(data, dataLen) { }
00117       PBYTEArray key;
00118       PBYTEArray salt;
00119     };
00120     virtual BOOL SetOutgoingKey(const KeySalt & key) = 0;
00121     virtual BOOL GetOutgoingKey(KeySalt & key) const = 0;
00122     virtual BOOL SetOutgoingSSRC(DWORD ssrc) = 0;
00123     virtual BOOL GetOutgoingSSRC(DWORD & ssrc) const = 0;
00124 
00125     virtual BOOL SetIncomingKey(const KeySalt & key) = 0;
00126     virtual BOOL GetIncomingKey(KeySalt & key) const = 0;
00127     virtual BOOL SetIncomingSSRC(DWORD ssrc) = 0;
00128     virtual BOOL GetIncomingSSRC(DWORD & ssrc) const = 0;
00129 };
00130 
00132 //
00133 //  this class implements SRTP over UDP
00134 //
00135 
00136 class OpalSRTP_UDP : public SecureRTP_UDP
00137 {
00138   PCLASSINFO(OpalSRTP_UDP, SecureRTP_UDP);
00139   public:
00140     OpalSRTP_UDP(
00141       PHandleAggregator * _aggregator,   
00142       unsigned id,                       
00143       BOOL remoteIsNAT                  
00144     );
00145 
00146     virtual SendReceiveStatus OnSendData   (RTP_DataFrame & frame) = 0;
00147     virtual SendReceiveStatus OnReceiveData(RTP_DataFrame & frame) = 0;
00148     virtual SendReceiveStatus OnSendControl(RTP_ControlFrame & frame, PINDEX & len) = 0;
00149     virtual SendReceiveStatus OnReceiveControl(RTP_ControlFrame & frame) = 0;
00150 };
00151 
00152 
00154 //
00155 //  this class implements SRTP using libSRTP
00156 //
00157 
00158 #if HAS_LIBSRTP || HAS_LIBZRTP
00159 
00160 class LibSRTP_UDP : public OpalSRTP_UDP
00161 {
00162   PCLASSINFO(LibSRTP_UDP, OpalSRTP_UDP);
00163   public:
00164     LibSRTP_UDP(PHandleAggregator * _aggregator,   
00165                   unsigned int id,                 
00166                   BOOL remoteIsNAT                 
00167     );
00168 
00169     ~LibSRTP_UDP();
00170 
00171     BOOL Open(
00172       PIPSocket::Address localAddress,  
00173       WORD portBase,                    
00174       WORD portMax,                     
00175       BYTE ipTypeOfService,             
00176       PSTUNClient * stun = NULL,        
00177       RTP_QOS * rtpqos = NULL           
00178     );
00179 
00180     virtual SendReceiveStatus OnSendData   (RTP_DataFrame & frame);
00181     virtual SendReceiveStatus OnReceiveData(RTP_DataFrame & frame);
00182     virtual SendReceiveStatus OnSendControl(RTP_ControlFrame & frame, PINDEX & len);
00183     virtual SendReceiveStatus OnReceiveControl(RTP_ControlFrame & frame);
00184 };
00185 
00186 #endif // HAS_LIBSRTP
00187 
00188 
00189 #endif // OPAL_SRTP
00190 
00191 #endif // __OPAL_SRTP_H

Generated on Fri Mar 7 06:33:41 2008 for OPAL by  doxygen 1.5.1