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  * $Revision: 20393 $
00030  * $Author: rjongbloed $
00031  * $Date: 2008-06-05 01:55:57 +0000 (Thu, 05 Jun 2008) $
00032  */
00033 
00034 #ifndef __OPAL_SRTP_H
00035 #define __OPAL_SRTP_H
00036 
00037 #ifdef P_USE_PRAGMA
00038 #pragma interface
00039 #endif
00040 
00041 #ifndef _PTLIB_H
00042 #include <ptlib.h>
00043 #endif
00044 
00045 #include <opal/buildopts.h>
00046 #include <rtp/rtp.h>
00047 #include <opal/rtpconn.h>
00048 
00049 #if OPAL_SRTP
00050 
00051 namespace PWLibStupidLinkerHacks {
00052   extern int libSRTPLoader;
00053 };
00054 
00056 //
00057 //  this class holds the parameters required for an SRTP session
00058 //
00059 //  Crypto modes are identified by key strings that are contained in PFactory<OpalSRTPParms>
00060 //  The following strings should be implemented:
00061 //
00062 //     AES_CM_128_HMAC_SHA1_80,
00063 //     AES_CM_128_HMAC_SHA1_32,
00064 //     AES_CM_128_NULL_AUTH,   
00065 //     NULL_CIPHER_HMAC_SHA1_80
00066 //     STRONGHOLD
00067 //
00068 
00069 class OpalSRTPSecurityMode : public OpalSecurityMode
00070 {
00071   PCLASSINFO(OpalSRTPSecurityMode, OpalSecurityMode);
00072   public:
00073     struct KeySalt {
00074       KeySalt()                                                       { }
00075       KeySalt(const PBYTEArray & data)           : key(data)          { }
00076       KeySalt(const BYTE * data, PINDEX dataLen) : key(data, dataLen) { }
00077       PBYTEArray key;
00078       PBYTEArray salt;
00079     };
00080     virtual PBoolean SetOutgoingKey(const KeySalt & key) = 0;
00081     virtual PBoolean GetOutgoingKey(KeySalt & key) const = 0;
00082     virtual PBoolean SetOutgoingSSRC(DWORD ssrc) = 0;
00083     virtual PBoolean GetOutgoingSSRC(DWORD & ssrc) const = 0;
00084 
00085     virtual PBoolean SetIncomingKey(const KeySalt & key) = 0;
00086     virtual PBoolean GetIncomingKey(KeySalt & key) const = 0;
00087     virtual PBoolean SetIncomingSSRC(DWORD ssrc) = 0;
00088     virtual PBoolean GetIncomingSSRC(DWORD & ssrc) const = 0;
00089 };
00090 
00092 //
00093 //  this class implements SRTP over UDP
00094 //
00095 
00096 class OpalSRTP_UDP : public SecureRTP_UDP
00097 {
00098   PCLASSINFO(OpalSRTP_UDP, SecureRTP_UDP);
00099   public:
00100     OpalSRTP_UDP(
00101       const PString & encoding,          
00102 #if OPAL_RTP_AGGREGATE
00103       PHandleAggregator * _aggregator,   
00104 #endif
00105       unsigned id,                       
00106       PBoolean remoteIsNAT               
00107     );
00108 
00109     virtual SendReceiveStatus OnSendData   (RTP_DataFrame & frame) = 0;
00110     virtual SendReceiveStatus OnReceiveData(RTP_DataFrame & frame) = 0;
00111     virtual SendReceiveStatus OnSendControl(RTP_ControlFrame & frame, PINDEX & len) = 0;
00112     virtual SendReceiveStatus OnReceiveControl(RTP_ControlFrame & frame) = 0;
00113 };
00114 
00115 
00117 //
00118 //  this class implements SRTP using libSRTP
00119 //
00120 
00121 class LibSRTP_UDP : public OpalSRTP_UDP
00122 {
00123   PCLASSINFO(LibSRTP_UDP, OpalSRTP_UDP);
00124   public:
00125     LibSRTP_UDP(
00126       const PString & encoding,          
00127 #if OPAL_RTP_AGGREGATE
00128       PHandleAggregator * _aggregator,   
00129 #endif
00130       unsigned int id,                   
00131       PBoolean remoteIsNAT               
00132     );
00133 
00134     ~LibSRTP_UDP();
00135 
00136     PBoolean Open(
00137       PIPSocket::Address localAddress,  
00138       WORD portBase,                    
00139       WORD portMax,                     
00140       BYTE ipTypeOfService,             
00141       PNatMethod * natMethod = NULL,    
00142       RTP_QOS * rtpqos = NULL           
00143     );
00144 
00145     virtual SendReceiveStatus OnSendData   (RTP_DataFrame & frame);
00146     virtual SendReceiveStatus OnReceiveData(RTP_DataFrame & frame);
00147     virtual SendReceiveStatus OnSendControl(RTP_ControlFrame & frame, PINDEX & len);
00148     virtual SendReceiveStatus OnReceiveControl(RTP_ControlFrame & frame);
00149 };
00150 
00151 
00152 #endif // OPAL_SRTP
00153 
00154 #endif // __OPAL_SRTP_H

Generated on Mon Sep 15 11:49:15 2008 for OPAL by  doxygen 1.5.1