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: 21293 $
00030  * $Author: rjongbloed $
00031  * $Date: 2008-10-12 23:24:41 +0000 (Sun, 12 Oct 2008) $
00032  */
00033 
00034 #ifndef OPAL_RTP_SRTP_H
00035 #define OPAL_RTP_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 
00047 #include <rtp/rtp.h>
00048 #include <opal/rtpconn.h>
00049 
00050 #if OPAL_SRTP
00051 
00052 namespace PWLibStupidLinkerHacks {
00053   extern int libSRTPLoader;
00054 };
00055 
00057 //
00058 //  this class holds the parameters required for an SRTP session
00059 //
00060 //  Crypto modes are identified by key strings that are contained in PFactory<OpalSRTPParms>
00061 //  The following strings should be implemented:
00062 //
00063 //     AES_CM_128_HMAC_SHA1_80,
00064 //     AES_CM_128_HMAC_SHA1_32,
00065 //     AES_CM_128_NULL_AUTH,   
00066 //     NULL_CIPHER_HMAC_SHA1_80
00067 //     STRONGHOLD
00068 //
00069 
00070 class OpalSRTPSecurityMode : public OpalSecurityMode
00071 {
00072   PCLASSINFO(OpalSRTPSecurityMode, OpalSecurityMode);
00073   public:
00074     struct KeySalt {
00075       KeySalt()                                                       { }
00076       KeySalt(const PBYTEArray & data)           : key(data)          { }
00077       KeySalt(const BYTE * data, PINDEX dataLen) : key(data, dataLen) { }
00078       PBYTEArray key;
00079       PBYTEArray salt;
00080     };
00081     virtual PBoolean SetOutgoingKey(const KeySalt & key) = 0;
00082     virtual PBoolean GetOutgoingKey(KeySalt & key) const = 0;
00083     virtual PBoolean SetOutgoingSSRC(DWORD ssrc) = 0;
00084     virtual PBoolean GetOutgoingSSRC(DWORD & ssrc) const = 0;
00085 
00086     virtual PBoolean SetIncomingKey(const KeySalt & key) = 0;
00087     virtual PBoolean GetIncomingKey(KeySalt & key) const = 0;
00088     virtual PBoolean SetIncomingSSRC(DWORD ssrc) = 0;
00089     virtual PBoolean GetIncomingSSRC(DWORD & ssrc) const = 0;
00090 };
00091 
00093 //
00094 //  this class implements SRTP over UDP
00095 //
00096 
00097 class OpalSRTP_UDP : public SecureRTP_UDP
00098 {
00099   PCLASSINFO(OpalSRTP_UDP, SecureRTP_UDP);
00100   public:
00101     OpalSRTP_UDP(
00102       const Params & options 
00103     );
00104 
00105     virtual SendReceiveStatus OnSendData   (RTP_DataFrame & frame) = 0;
00106     virtual SendReceiveStatus OnReceiveData(RTP_DataFrame & frame) = 0;
00107     virtual SendReceiveStatus OnSendControl(RTP_ControlFrame & frame, PINDEX & len) = 0;
00108     virtual SendReceiveStatus OnReceiveControl(RTP_ControlFrame & frame) = 0;
00109 };
00110 
00111 
00113 //
00114 //  this class implements SRTP using libSRTP
00115 //
00116 
00117 class LibSRTP_UDP : public OpalSRTP_UDP
00118 {
00119   PCLASSINFO(LibSRTP_UDP, OpalSRTP_UDP);
00120   public:
00121     LibSRTP_UDP(
00122       const Params & options 
00123     );
00124 
00125     ~LibSRTP_UDP();
00126 
00127     PBoolean Open(
00128       PIPSocket::Address localAddress,  
00129       WORD portBase,                    
00130       WORD portMax,                     
00131       BYTE ipTypeOfService,             
00132       PNatMethod * natMethod = NULL,    
00133       RTP_QOS * rtpqos = NULL           
00134     );
00135 
00136     virtual SendReceiveStatus OnSendData   (RTP_DataFrame & frame);
00137     virtual SendReceiveStatus OnReceiveData(RTP_DataFrame & frame);
00138     virtual SendReceiveStatus OnSendControl(RTP_ControlFrame & frame, PINDEX & len);
00139     virtual SendReceiveStatus OnReceiveControl(RTP_ControlFrame & frame);
00140 };
00141 
00142 
00143 #endif // OPAL_SRTP
00144 
00145 #endif // OPAL_RTP_SRTP_H

Generated on Mon Feb 1 00:25:54 2010 for OPAL by  doxygen 1.5.1