9
#include <rutil/ssl/OpenSSLInit.hxx>
11
#include <openssl/e_os2.h>
12
#include <openssl/rand.h>
13
#include <openssl/err.h>
14
#include <openssl/crypto.h>
15
#include <openssl/ssl.h>
17
#include "DtlsFactory.hxx"
18
#include "DtlsSocket.hxx"
21
const char* DtlsFactory::DefaultSrtpProfile = "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32";
23
DtlsFactory::DtlsFactory(std::auto_ptr<DtlsTimerContext> tc,X509 *cert, EVP_PKEY *privkey):
29
mContext=SSL_CTX_new(DTLSv1_method());
32
r=SSL_CTX_use_certificate(mContext, cert);
35
r=SSL_CTX_use_PrivateKey(mContext, privkey);
39
r=SSL_CTX_set_tlsext_use_srtp(mContext, DefaultSrtpProfile);
43
DtlsFactory::~DtlsFactory()
45
SSL_CTX_free(mContext);
50
DtlsFactory::createClient(std::auto_ptr<DtlsSocketContext> context)
52
return new DtlsSocket(context,this,DtlsSocket::Client);
56
DtlsFactory::createServer(std::auto_ptr<DtlsSocketContext> context)
58
return new DtlsSocket(context,this,DtlsSocket::Server);
62
DtlsFactory::getMyCertFingerprint(char *fingerprint)
64
DtlsSocket::computeFingerprint(mCert,fingerprint);
68
DtlsFactory::setSrtpProfiles(const char *str)
72
r=SSL_CTX_set_tlsext_use_srtp(mContext,str);
78
DtlsFactory::setCipherSuites(const char *str)
82
r=SSL_CTX_set_cipher_list(mContext,str);
86
DtlsFactory::PacketType
87
DtlsFactory::demuxPacket(const unsigned char *data, unsigned int len)
91
if((data[0]==0) || (data[0]==1))
93
if((data[0]>=128) && (data[0]<=191))
95
if((data[0]>=20) && (data[0]<=64))
104
/* ====================================================================
106
Copyright (c) 2007-2008, Eric Rescorla and Derek MacDonald
109
Redistribution and use in source and binary forms, with or without
110
modification, are permitted provided that the following conditions are
113
1. Redistributions of source code must retain the above copyright
114
notice, this list of conditions and the following disclaimer.
116
2. Redistributions in binary form must reproduce the above copyright
117
notice, this list of conditions and the following disclaimer in the
118
documentation and/or other materials provided with the distribution.
120
3. None of the contributors names may be used to endorse or promote
121
products derived from this software without specific prior written
124
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
125
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
126
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
127
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
128
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
129
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
130
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
131
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
132
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
133
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
134
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
136
==================================================================== */