OFFIS DCMTK  Version 3.6.0
tlslayer.h
1 /*
2  *
3  * Copyright (C) 1998-2010, OFFIS e.V.
4  * All rights reserved. See COPYRIGHT file for details.
5  *
6  * This software and supporting documentation were developed by
7  *
8  * OFFIS e.V.
9  * R&D Division Health
10  * Escherweg 2
11  * D-26121 Oldenburg, Germany
12  *
13  *
14  * Module: dcmtls
15  *
16  * Author: Marco Eichelberg
17  *
18  * Purpose:
19  * classes: DcmTLSTransportLayer
20  *
21  * Last Update: $Author: joergr $
22  * Update Date: $Date: 2010-10-14 13:17:27 $
23  * CVS/RCS Revision: $Revision: 1.9 $
24  * Status: $State: Exp $
25  *
26  * CVS/RCS Log at end of file
27  *
28  */
29 
30 #ifndef TLSLAYER_H
31 #define TLSLAYER_H
32 
33 #include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */
34 #include "dcmtk/dcmnet/dcmlayer.h" /* for DcmTransportLayer */
35 #include "dcmtk/ofstd/ofstream.h" /* for ostream */
36 #include "dcmtk/oflog/oflog.h"
37 
38 #ifdef WITH_OPENSSL
39 BEGIN_EXTERN_C
40 #include <openssl/ssl.h>
41 END_EXTERN_C
42 
43 OFLogger DCM_dcmtlsGetLogger();
44 
45 #define DCMTLS_TRACE(msg) OFLOG_TRACE(DCM_dcmtlsGetLogger(), msg)
46 #define DCMTLS_DEBUG(msg) OFLOG_DEBUG(DCM_dcmtlsGetLogger(), msg)
47 #define DCMTLS_INFO(msg) OFLOG_INFO(DCM_dcmtlsGetLogger(), msg)
48 #define DCMTLS_WARN(msg) OFLOG_WARN(DCM_dcmtlsGetLogger(), msg)
49 #define DCMTLS_ERROR(msg) OFLOG_ERROR(DCM_dcmtlsGetLogger(), msg)
50 #define DCMTLS_FATAL(msg) OFLOG_FATAL(DCM_dcmtlsGetLogger(), msg)
51 
56 enum DcmCertificateVerification
57 {
60  DCV_requireCertificate,
61 
64  DCV_checkCertificate,
65 
68  DCV_ignoreCertificate
69 };
70 
71 
80 {
81 public:
82 
88  DcmTLSTransportLayer(int networkRole, const char *randFile);
89 
91  virtual ~DcmTLSTransportLayer();
92 
104  virtual DcmTransportConnection *createConnection(int openSocket, OFBool useSecureLayer);
105 
111  DcmTransportLayerStatus setPrivateKeyFile(const char *fileName, int fileType);
112 
118  DcmTransportLayerStatus setCertificateFile(const char *fileName, int fileType);
119 
125 
131  DcmTransportLayerStatus addTrustedCertificateFile(const char *fileName, int fileType);
132 
139  DcmTransportLayerStatus addTrustedCertificateDir(const char *pathName, int fileType);
140 
148  DcmTransportLayerStatus setCipherSuites(const char *suites);
149 
153  static unsigned long getNumberOfCipherSuites();
154 
159  static const char *getTLSCipherSuiteName(unsigned long idx);
160 
165  static const char *getOpenSSLCipherSuiteName(unsigned long idx);
166 
171  static const char *findOpenSSLCipherSuiteName(const char *tlsCipherSuiteName);
172 
178 
183  OFBool writeRandomSeed(const char *randFile);
184 
193  void seedPRNG(const char *randFile);
194 
200  void addPRNGseed(void *buf, size_t bufSize);
201 
206  void setCertificateVerification(DcmCertificateVerification vtype);
207 
214  void setPrivateKeyPasswd(const char *thePasswd);
215 
220 
226  OFBool setTempDHParameters(const char *filename);
227 
232  static OFString dumpX509Certificate(X509 *peerCertificate);
233 
234 private:
235 
238 
241 
244 
247 
250 
251 };
252 
253 #endif /* WITH_OPENSSL */
254 
255 #endif
256 
257 /*
258  * $Log: tlslayer.h,v $
259  * Revision 1.9 2010-10-14 13:17:27 joergr
260  * Updated copyright header. Added reference to COPYRIGHT file.
261  *
262  * Revision 1.8 2009-11-18 12:11:19 uli
263  * Switched to logging mechanism provided by the "new" oflog module.
264  *
265  * Revision 1.7 2006-08-15 16:02:55 meichel
266  * Updated the code in module dcmtls to correctly compile when
267  * all standard C++ classes remain in namespace std.
268  *
269  * Revision 1.6 2005/12/08 16:05:38 meichel
270  * Changed include path schema for all DCMTK header files
271  *
272  * Revision 1.5 2003/12/05 10:38:55 joergr
273  * Removed leading underscore characters from preprocessor symbols (reserved
274  * symbols).
275  *
276  * Revision 1.4 2003/07/04 13:28:32 meichel
277  * Added include for ofstream.h, to make sure ofstream is correctly defined
278  *
279  * Revision 1.3 2001/06/01 15:51:12 meichel
280  * Updated copyright header
281  *
282  * Revision 1.2 2000/10/10 12:13:31 meichel
283  * Added routines for printing certificates and connection parameters.
284  *
285  * Revision 1.1 2000/08/10 14:50:26 meichel
286  * Added initial OpenSSL support.
287  *
288  *
289  */
290 
OFBool checkPrivateKeyMatchesCertificate()
checks if the private key and the certificate set using setPrivateKeyFile() and setCertificateFile() ...
void setPrivateKeyPasswdFromConsole()
sets the password string to be used when loading an encrypted private key file to be read from the co...
OFBool setTempDHParameters(const char *filename)
loads a set of Diffie-Hellman parameters from file.
this class represents a TCP/IP based transport connection which can be a transparent TCP/IP socket co...
Definition: dcmtrans.h:45
void seedPRNG(const char *randFile)
adds the contents of a file to the seed for the cryptographic pseudo-random number generator...
factory class which creates transport layer connections.
Definition: dcmlayer.h:74
DcmTLSTransportLayer & operator=(const DcmTLSTransportLayer &)
private undefined assignment operator
static const char * getOpenSSLCipherSuiteName(unsigned long idx)
returns a ciphersuite name in OpenSSL form
virtual DcmTransportConnection * createConnection(int openSocket, OFBool useSecureLayer)
factory method that returns a new transport connection for the given socket.
OFBool canWriteRandomSeed()
checks if enough entropy data is available to write back a modified random seed file.
Definition: tlslayer.h:177
void setPrivateKeyPasswd(const char *thePasswd)
sets the password string to be used when loading an encrypted private key file.
void addPRNGseed(void *buf, size_t bufSize)
modifies the PRNG by adding random data from the given buffer to the PRNG state.
factory class which creates secure TLS transport layer connections and maintains the parameters commo...
Definition: tlslayer.h:79
DcmTLSTransportLayer(int networkRole, const char *randFile)
constructor.
OFBool canWriteRandseed
true if there is enough random data to write a new random seed file
Definition: tlslayer.h:246
virtual ~DcmTLSTransportLayer()
destructor
DcmTransportLayerStatus addTrustedCertificateFile(const char *fileName, int fileType)
loads a certificate from a file and adds it to the pool of trusted certificates.
DcmTransportLayerStatus addTrustedCertificateDir(const char *pathName, int fileType)
loads all files as certificates from the specified directory and adds them to the pool of trusted cer...
DcmTransportLayerStatus setPrivateKeyFile(const char *fileName, int fileType)
loads the private key used for authentication of this application from a file.
static const char * getTLSCipherSuiteName(unsigned long idx)
returns a ciphersuite name in RFC 2246 (TLS) form
static OFString dumpX509Certificate(X509 *peerCertificate)
gets the most important attributes of the given X.509 certificate.
static const char * findOpenSSLCipherSuiteName(const char *tlsCipherSuiteName)
finds the OpenSSL ciphersuite name for a given RFC 2246 ciphersuite name.
static unsigned long getNumberOfCipherSuites()
returns the number of known ciphersuites.
simple wrapper around the "low-level" Logger object to make it easier to switch to a different system...
Definition: oflog.h:49
DcmTransportLayerStatus setCipherSuites(const char *suites)
sets the list of ciphersuites to negotiate.
a simple string class that implements a subset of std::string.
Definition: ofstring.h:86
DcmTransportLayerStatus setCertificateFile(const char *fileName, int fileType)
loads the certificate (public key) used for authentication of this application from a file...
void setCertificateVerification(DcmCertificateVerification vtype)
defines how peer certificates should be treated when negotiating a TLS connection.
OFString privateKeyPasswd
contains the password for the private key if set on command line
Definition: tlslayer.h:249
SSL_CTX * transportLayerContext
OpenSSL context data, needed only once per application.
Definition: tlslayer.h:243
OFBool writeRandomSeed(const char *randFile)
writes a modified random seed to file.


Generated on Wed Dec 14 2016 for OFFIS DCMTK Version 3.6.0 by Doxygen 1.8.11