VirtualBox

source: vbox/trunk/include/iprt/crypto/ssl.h@ 95929

Last change on this file since 95929 was 93115, checked in by vboxsync, 3 years ago

scm --update-copyright-year

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.7 KB
Line 
1/** @file
2 * IPRT - Secure Socket Layer (SSL) / Transport Security Layer (TLS)
3 */
4
5/*
6 * Copyright (C) 2006-2022 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_INCLUDED_crypto_ssl_h
27#define IPRT_INCLUDED_crypto_ssl_h
28#ifndef RT_WITHOUT_PRAGMA_ONCE
29# pragma once
30#endif
31
32#include <iprt/cdefs.h>
33#include <iprt/types.h>
34#include <iprt/sg.h>
35
36
37RT_C_DECLS_BEGIN
38
39/** @defgroup grp_rt_crssl RTCrSsl - Secure Socket Layer (SSL) / Transport Security Layer (TLS)
40 * @ingroup grp_rt_crypto
41 * @{
42 */
43
44/** SSL handle. */
45typedef R3PTRTYPE(struct RTCRSSLINT *) RTCRSSL;
46/** Pointer to a SSL handle. */
47typedef RTCRSSL *PRTCRSSL;
48/** Nil SSL handle. */
49#define NIL_RTCRSSL ((RTCRSSL)0)
50
51/** SSL session handle. */
52typedef R3PTRTYPE(struct RTCRSSLSESSIONINT *) RTCRSSLSESSION;
53/** Pointer to a SSL session handle. */
54typedef RTCRSSLSESSION *PRTCRSSLSESSION;
55/** Nil SSL session handle. */
56#define NIL_RTCRSSLSESSION ((RTCRSSLSESSION)0)
57
58
59RTDECL(int) RTCrSslCreate(PRTCRSSL phSsl, uint32_t fFlags);
60
61/**
62 * Retains a reference to the SSL handle.
63 *
64 * @returns New reference count, UINT32_MAX on invalid handle (asserted).
65 *
66 * @param hSsl The SSL handle.
67 */
68RTDECL(uint32_t) RTCrSslRetain(RTCRSSL hSsl);
69
70/**
71 * Release a reference to the SSL handle.
72 *
73 * @returns New reference count, UINT32_MAX on invalid handle (asserted).
74 *
75 * @param hSsl The SSL handle. The NIL handle is quietly
76 * ignored and 0 is returned.
77 */
78RTDECL(uint32_t) RTCrSslRelease(RTCRSSL hSsl);
79
80#define RTCRSSL_FILE_F_PEM 0
81#define RTCRSSL_FILE_F_ASN1 RT_BIT_32(1)
82
83RTDECL(int) RTCrSslSetCertificateFile(RTCRSSL hSsl, const char *pszFile, uint32_t fFlags);
84RTDECL(int) RTCrSslSetPrivateKeyFile(RTCRSSL hSsl, const char *pszFile, uint32_t fFlags);
85RTDECL(int) RTCrSslLoadTrustedRootCerts(RTCRSSL hSsl, const char *pszFile, const char *pszDir);
86RTDECL(int) RTCrSslSetNoPeerVerify(RTCRSSL hSsl);
87/** @todo Min/max protocol setters. */
88
89
90
91RTDECL(int) RTCrSslCreateSession(RTCRSSL hSsl, RTSOCKET hSocket, uint32_t fFlags, PRTCRSSLSESSION phSslSession);
92RTDECL(int) RTCrSslCreateSessionForNativeSocket(RTCRSSL hSsl, RTHCINTPTR hNativeSocket, uint32_t fFlags,
93 PRTCRSSLSESSION phSslSession);
94/** @name RTCRSSLSESSION_F_XXX - Flags for RTCrSslCreateSession and RTCrSslCreateSessionForNativeSocket.
95 * @{ */
96/** The socket is non-blocking. */
97#define RTCRSSLSESSION_F_NON_BLOCKING RT_BIT_32(0)
98/** @} */
99
100/**
101 * Retains a reference to the SSL session handle.
102 *
103 * @returns New reference count, UINT32_MAX on invalid handle (asserted).
104 *
105 * @param hSslSession The SSL session handle.
106 */
107RTDECL(uint32_t) RTCrSslSessionRetain(RTCRSSLSESSION hSslSession);
108
109/**
110 * Release a reference to the SSL handle.
111 *
112 * @returns New reference count, UINT32_MAX on invalid handle (asserted).
113 *
114 * @param hSslSession The SSL session handle. The NIL handle is quietly
115 * ignored and 0 is returned.
116 */
117RTDECL(uint32_t) RTCrSslSessionRelease(RTCRSSLSESSION hSslSession);
118
119RTDECL(int) RTCrSslSessionAccept(RTCRSSLSESSION hSslSession, uint32_t fFlags);
120RTDECL(int) RTCrSslSessionConnect(RTCRSSLSESSION hSslSession, uint32_t fFlags);
121
122RTDECL(const char *) RTCrSslSessionGetVersion(RTCRSSLSESSION hSslSession);
123RTDECL(int) RTCrSslSessionGetCertIssuerNameAsString(RTCRSSLSESSION hSslSession, char *pszBuf, size_t cbBuf, size_t *pcbActual);
124RTDECL(bool) RTCrSslSessionPending(RTCRSSLSESSION hSslSession);
125RTDECL(ssize_t) RTCrSslSessionRead(RTCRSSLSESSION hSslSession, void *pvBuf, size_t cbToRead);
126RTDECL(ssize_t) RTCrSslSessionWrite(RTCRSSLSESSION hSslSession, void const *pvBuf, size_t cbToWrite);
127
128
129/** @} */
130RT_C_DECLS_END
131
132#endif /* !IPRT_INCLUDED_crypto_ssl_h */
133
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette