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: 22444 $
00030  * $Author: rjongbloed $
00031  * $Date: 2009-04-20 18:49:06 -0500 (Mon, 20 Apr 2009) $
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 
00054 //
00055 //  this class holds the parameters required for an SRTP session
00056 //
00057 //  Crypto modes are identified by key strings that are contained in PFactory<OpalSRTPParms>
00058 //  The following strings should be implemented:
00059 //
00060 //     AES_CM_128_HMAC_SHA1_80,
00061 //     AES_CM_128_HMAC_SHA1_32,
00062 //     AES_CM_128_NULL_AUTH,   
00063 //     NULL_CIPHER_HMAC_SHA1_80
00064 //     STRONGHOLD
00065 //
00066 
00067 class OpalSRTPSecurityMode : public OpalSecurityMode
00068 {
00069   PCLASSINFO(OpalSRTPSecurityMode, OpalSecurityMode);
00070   public:
00071     struct KeySalt {
00072       KeySalt()                                                       { }
00073       KeySalt(const PBYTEArray & data)           : key(data)          { }
00074       KeySalt(const BYTE * data, PINDEX dataLen) : key(data, dataLen) { }
00075       PBYTEArray key;
00076       PBYTEArray salt;
00077     };
00078     virtual PBoolean SetOutgoingKey(const KeySalt & key) = 0;
00079     virtual PBoolean GetOutgoingKey(KeySalt & key) const = 0;
00080     virtual PBoolean SetOutgoingSSRC(DWORD ssrc) = 0;
00081     virtual PBoolean GetOutgoingSSRC(DWORD & ssrc) const = 0;
00082 
00083     virtual PBoolean SetIncomingKey(const KeySalt & key) = 0;
00084     virtual PBoolean GetIncomingKey(KeySalt & key) const = 0;
00085     virtual PBoolean SetIncomingSSRC(DWORD ssrc) = 0;
00086     virtual PBoolean GetIncomingSSRC(DWORD & ssrc) const = 0;
00087 };
00088 
00090 //
00091 //  this class implements SRTP over UDP
00092 //
00093 
00094 class OpalSRTP_UDP : public SecureRTP_UDP
00095 {
00096   PCLASSINFO(OpalSRTP_UDP, SecureRTP_UDP);
00097   public:
00098     OpalSRTP_UDP(
00099       const Params & options 
00100     );
00101 
00102     virtual SendReceiveStatus OnSendData   (RTP_DataFrame & frame) = 0;
00103     virtual SendReceiveStatus OnReceiveData(RTP_DataFrame & frame) = 0;
00104     virtual SendReceiveStatus OnSendControl(RTP_ControlFrame & frame, PINDEX & len) = 0;
00105     virtual SendReceiveStatus OnReceiveControl(RTP_ControlFrame & frame) = 0;
00106 };
00107 
00108 
00110 //
00111 //  this class implements SRTP using libSRTP
00112 //
00113 
00114 class LibSRTP_UDP : public OpalSRTP_UDP
00115 {
00116   PCLASSINFO(LibSRTP_UDP, OpalSRTP_UDP);
00117   public:
00118     LibSRTP_UDP(
00119       const Params & options 
00120     );
00121 
00122     ~LibSRTP_UDP();
00123 
00124     PBoolean Open(
00125       PIPSocket::Address localAddress,  
00126       WORD portBase,                    
00127       WORD portMax,                     
00128       BYTE ipTypeOfService,             
00129       PNatMethod * natMethod = NULL,    
00130       RTP_QOS * rtpqos = NULL           
00131     );
00132 
00133     virtual SendReceiveStatus OnSendData   (RTP_DataFrame & frame);
00134     virtual SendReceiveStatus OnReceiveData(RTP_DataFrame & frame);
00135     virtual SendReceiveStatus OnSendControl(RTP_ControlFrame & frame, PINDEX & len);
00136     virtual SendReceiveStatus OnReceiveControl(RTP_ControlFrame & frame);
00137 };
00138 
00139 PFACTORY_LOAD(LibSRTPSecurityMode_STRONGHOLD);
00140 
00141 
00142 #endif // OPAL_SRTP
00143 
00144 #endif // OPAL_RTP_SRTP_H

Generated on Mon Feb 21 20:19:21 2011 for OPAL by  doxygen 1.4.7