1 | /** @file
|
---|
2 | * IPRT - Secure Socket Layer (SSL) / Transport Security Layer (TLS)
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2006-2017 Oracle Corporation
|
---|
7 | *
|
---|
8 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
9 | * available from http://www.virtualbox.org. This file is free software;
|
---|
10 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
11 | * General Public License (GPL) as published by the Free Software
|
---|
12 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
13 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
14 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
15 | *
|
---|
16 | * The contents of this file may alternatively be used under the terms
|
---|
17 | * of the Common Development and Distribution License Version 1.0
|
---|
18 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
19 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
20 | * CDDL are applicable instead of those of the GPL.
|
---|
21 | *
|
---|
22 | * You may elect to license modified versions of this file under the
|
---|
23 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
24 | */
|
---|
25 |
|
---|
26 | #ifndef ___iprt_ssl_h
|
---|
27 | #define ___iprt_ssl_h
|
---|
28 |
|
---|
29 | #include <iprt/cdefs.h>
|
---|
30 | #include <iprt/types.h>
|
---|
31 | #include <iprt/sg.h>
|
---|
32 |
|
---|
33 |
|
---|
34 | RT_C_DECLS_BEGIN
|
---|
35 |
|
---|
36 | /** @defgroup grp_rt_crssl RTCrSsl - Secure Socket Layer (SSL) / Transport Security Layer (TLS)
|
---|
37 | * @ingroup grp_rt_crypto
|
---|
38 | * @{
|
---|
39 | */
|
---|
40 |
|
---|
41 | /** SSL handle. */
|
---|
42 | typedef R3PTRTYPE(struct RTCRSSLINT *) RTCRSSL;
|
---|
43 | /** Pointer to a SSL handle. */
|
---|
44 | typedef RTCRSSL *PRTCRSSL;
|
---|
45 | /** Nil SSL handle. */
|
---|
46 | #define NIL_RTCRSSL ((RTCRSSL)0)
|
---|
47 |
|
---|
48 | /** SSL session handle. */
|
---|
49 | typedef R3PTRTYPE(struct RTCRSSLSESSIONINT *) RTCRSSLSESSION;
|
---|
50 | /** Pointer to a SSL session handle. */
|
---|
51 | typedef RTCRSSLSESSION *PRTCRSSLSESSION;
|
---|
52 | /** Nil SSL session handle. */
|
---|
53 | #define NIL_RTCRSSLSESSION ((RTCRSSLSESSION)0)
|
---|
54 |
|
---|
55 |
|
---|
56 | RTDECL(int) RTCrSslCreate(PRTCRSSL phSsl, uint32_t fFlags);
|
---|
57 |
|
---|
58 | /**
|
---|
59 | * Retains a reference to the SSL handle.
|
---|
60 | *
|
---|
61 | * @returns New reference count, UINT32_MAX on invalid handle (asserted).
|
---|
62 | *
|
---|
63 | * @param hSsl The SSL handle.
|
---|
64 | */
|
---|
65 | RTDECL(uint32_t) RTCrSslRetain(RTCRSSL hSsl);
|
---|
66 |
|
---|
67 | /**
|
---|
68 | * Release a reference to the SSL handle.
|
---|
69 | *
|
---|
70 | * @returns New reference count, UINT32_MAX on invalid handle (asserted).
|
---|
71 | *
|
---|
72 | * @param hSsl The SSL handle. The NIL handle is quietly
|
---|
73 | * ignored and 0 is returned.
|
---|
74 | */
|
---|
75 | RTDECL(uint32_t) RTCrSslRelease(RTCRSSL hSsl);
|
---|
76 |
|
---|
77 | #define RTCRSSL_FILE_F_PEM 0
|
---|
78 | #define RTCRSSL_FILE_F_ASN1 RT_BIT_32(1)
|
---|
79 |
|
---|
80 | RTDECL(int) RTCrSslSetCertificateFile(RTCRSSL hSsl, const char *pszFile, uint32_t fFlags);
|
---|
81 | RTDECL(int) RTCrSslSetPrivateKeyFile(RTCRSSL hSsl, const char *pszFile, uint32_t fFlags);
|
---|
82 | RTDECL(int) RTCrSslLoadTrustedRootCerts(RTCRSSL hSsl, const char *pszFile, const char *pszDir);
|
---|
83 | RTDECL(int) RTCrSslSetNoPeerVerify(RTCRSSL hSsl);
|
---|
84 | /** @todo Min/max protocol setters. */
|
---|
85 |
|
---|
86 |
|
---|
87 |
|
---|
88 | RTDECL(int) RTCrSslCreateSession(RTCRSSL hSsl, RTSOCKET hSocket, uint32_t fFlags, PRTCRSSLSESSION phSslSession);
|
---|
89 | RTDECL(int) RTCrSslCreateSessionForNativeSocket(RTCRSSL hSsl, RTHCINTPTR hNativeSocket, uint32_t fFlags,
|
---|
90 | PRTCRSSLSESSION phSslSession);
|
---|
91 | /** @name RTCRSSLSESSION_F_XXX - Flags for RTCrSslCreateSession and RTCrSslCreateSessionForNativeSocket.
|
---|
92 | * @{ */
|
---|
93 | /** The socket is non-blocking. */
|
---|
94 | #define RTCRSSLSESSION_F_NON_BLOCKING RT_BIT_32(0)
|
---|
95 | /** @} */
|
---|
96 |
|
---|
97 | /**
|
---|
98 | * Retains a reference to the SSL session handle.
|
---|
99 | *
|
---|
100 | * @returns New reference count, UINT32_MAX on invalid handle (asserted).
|
---|
101 | *
|
---|
102 | * @param hSslSession The SSL session handle.
|
---|
103 | */
|
---|
104 | RTDECL(uint32_t) RTCrSslSessionRetain(RTCRSSLSESSION hSslSession);
|
---|
105 |
|
---|
106 | /**
|
---|
107 | * Release a reference to the SSL handle.
|
---|
108 | *
|
---|
109 | * @returns New reference count, UINT32_MAX on invalid handle (asserted).
|
---|
110 | *
|
---|
111 | * @param hSslSession The SSL session handle. The NIL handle is quietly
|
---|
112 | * ignored and 0 is returned.
|
---|
113 | */
|
---|
114 | RTDECL(uint32_t) RTCrSslSessionRelease(RTCRSSLSESSION hSslSession);
|
---|
115 |
|
---|
116 | RTDECL(int) RTCrSslSessionAccept(RTCRSSLSESSION hSslSession, uint32_t fFlags);
|
---|
117 | RTDECL(int) RTCrSslSessionConnect(RTCRSSLSESSION hSslSession, uint32_t fFlags);
|
---|
118 |
|
---|
119 | RTDECL(const char *) RTCrSslSessionGetVersion(RTCRSSLSESSION hSslSession);
|
---|
120 | RTDECL(int) RTCrSslSessionGetCertIssuerNameAsString(RTCRSSLSESSION hSslSession, char *pszBuf, size_t cbBuf, size_t *pcbActual);
|
---|
121 | RTDECL(bool) RTCrSslSessionPending(RTCRSSLSESSION hSslSession);
|
---|
122 | RTDECL(ssize_t) RTCrSslSessionRead(RTCRSSLSESSION hSslSession, void *pvBuf, size_t cbToRead);
|
---|
123 | RTDECL(ssize_t) RTCrSslSessionWrite(RTCRSSLSESSION hSslSession, void const *pvBuf, size_t cbToWrite);
|
---|
124 |
|
---|
125 |
|
---|
126 | /** @} */
|
---|
127 | RT_C_DECLS_END
|
---|
128 |
|
---|
129 | #endif
|
---|
130 |
|
---|