2 * Copyright (c) 1999-2002,2005-2014 Apple Inc. All Rights Reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
25 * SecureTransport.h - Public API for Apple SSL/TLS Implementation
28 #ifndef _SECURITY_SECURETRANSPORT_H_
29 #define _SECURITY_SECURETRANSPORT_H_
32 * This file describes the public API for an implementation of the
33 * Secure Socket Layer, V. 3.0, Transport Layer Security, V. 1.0 to V. 1.2
34 * and Datagram Transport Layer Security V. 1.0
36 * There are no transport layer dependencies in this library;
37 * it can be used with sockets, Open Transport, etc. Applications using
38 * this library provide callback functions which do the actual I/O
39 * on underlying network connections. Applications are also responsible
40 * for setting up raw network connections; the application passes in
41 * an opaque reference to the underlying (connected) entity at the
42 * start of an SSL session in the form of an SSLConnectionRef.
46 * A "client" is the initiator of an SSL Session. The canonical example
47 * of a client is a web browser, when it's talking to an https URL.
49 * A "server" is an entity which accepts requests for SSL sessions made
50 * by clients. E.g., a secure web server.
52 * An "SSL Session", or "session", is bounded by calls to SSLHandshake()
53 * and SSLClose(). An "Active session" is in some state between these
54 * two calls, inclusive.
56 * An SSL Session Context, or SSLContextRef, is an opaque reference in this
57 * library to the state associated with one session. A SSLContextRef cannot
58 * be reused for multiple sessions.
61 #include <CoreFoundation/CFArray.h>
62 #include <Security/CipherSuite.h>
63 #include <Security/SecTrust.h>
64 #include <sys/types.h>
65 #include <Availability.h>
71 CF_ASSUME_NONNULL_BEGIN
72 CF_IMPLICIT_BRIDGING_ENABLED
74 /***********************
75 *** Common typedefs ***
76 ***********************/
78 /* Opaque reference to an SSL session context */
80 typedef struct CF_BRIDGED_TYPE(id
) SSLContext
*SSLContextRef
;
82 /* Opaque reference to an I/O connection (socket, endpoint, etc.) */
83 typedef const void * SSLConnectionRef
;
85 /* SSL Protocol version */
86 typedef CF_ENUM(int, SSLProtocol
) {
87 kSSLProtocolUnknown
= 0, /* no protocol negotiated/specified; use default */
88 kSSLProtocol3
= 2, /* SSL 3.0 */
89 kTLSProtocol1
= 4, /* TLS 1.0 */
90 kTLSProtocol11
= 7, /* TLS 1.1 */
91 kTLSProtocol12
= 8, /* TLS 1.2 */
92 kDTLSProtocol1
= 9, /* DTLS 1.0 */
94 /* DEPRECATED on iOS */
95 kSSLProtocol2
= 1, /* SSL 2.0 */
96 kSSLProtocol3Only
= 3, /* SSL 3.0 Only */
97 kTLSProtocol1Only
= 5, /* TLS 1.0 Only */
98 kSSLProtocolAll
= 6, /* All TLS supported protocols */
102 /* SSL session options */
103 typedef CF_ENUM(int, SSLSessionOption
) {
105 * Set this option to enable returning from SSLHandshake (with a result of
106 * errSSLServerAuthCompleted) when the server authentication portion of the
107 * handshake is complete. This disable certificate verification and
108 * provides an opportunity to perform application-specific server
109 * verification before deciding to continue.
111 kSSLSessionOptionBreakOnServerAuth
= 0,
113 * Set this option to enable returning from SSLHandshake (with a result of
114 * errSSLClientCertRequested) when the server requests a client certificate.
116 kSSLSessionOptionBreakOnCertRequested
= 1,
118 * This option is the same as kSSLSessionOptionBreakOnServerAuth but applies
119 * to the case where SecureTransport is the server and the client has presented
120 * its certificates allowing the server to verify whether these should be
121 * allowed to authenticate.
123 kSSLSessionOptionBreakOnClientAuth
= 2,
125 * Enable/Disable TLS False Start
126 * When enabled, False Start will only be performed if a adequate cipher-suite is
129 kSSLSessionOptionFalseStart
= 3,
131 * Enable/Disable 1/n-1 record splitting for BEAST attack mitigation.
132 * When enabled, record splitting will only be performed for TLS 1.0 connections
133 * using a block cipher.
135 kSSLSessionOptionSendOneByteRecord
= 4,
137 * Allow/Disallow server identity change on renegotiation. Disallow by default
138 * to avoid Triple Handshake attack.
140 kSSLSessionOptionAllowServerIdentityChange
= 5,
142 * Enable fallback countermeasures. Use this option when retyring a SSL connection
143 * with a lower protocol version because of failure to connect.
145 kSSLSessionOptionFallback
= 6,
147 * Set this option to break from a client hello in order to check for SNI
149 kSSLSessionOptionBreakOnClientHello
= 7,
153 /* State of an SSLSession */
154 typedef CF_ENUM(int, SSLSessionState
) {
155 kSSLIdle
, /* no I/O performed yet */
156 kSSLHandshake
, /* SSL handshake in progress */
157 kSSLConnected
, /* Handshake complete, ready for normal I/O */
158 kSSLClosed
, /* connection closed normally */
159 kSSLAborted
/* connection aborted */
163 * Status of client certificate exchange (which is optional
164 * for both server and client).
166 typedef CF_ENUM(int, SSLClientCertificateState
) {
167 /* Server hasn't asked for a cert. Client hasn't sent one. */
169 /* Server has asked for a cert, but client didn't send it. */
170 kSSLClientCertRequested
,
172 * Server side: We asked for a cert, client sent one, we validated
173 * it OK. App can inspect the cert via
174 * SSLGetPeerCertificates().
175 * Client side: server asked for one, we sent it.
179 * Client sent a cert but failed validation. Server side only.
180 * Server app can inspect the cert via SSLGetPeerCertificates().
182 kSSLClientCertRejected
186 * R/W functions. The application using this library provides
187 * these functions via SSLSetIOFuncs().
189 * Data's memory is allocated by caller; on entry to these two functions
190 * the *length argument indicates both the size of the available data and the
191 * requested byte count. Number of bytes actually transferred is returned in
194 * The application may configure the underlying connection to operate
195 * in a non-blocking manner; in such a case, a read operation may
196 * well return errSSLWouldBlock, indicating "I transferred less data than
197 * you requested (maybe even zero bytes), nothing is wrong, except
198 * requested I/O hasn't completed". This will be returned back up to
199 * the application as a return from SSLRead(), SSLWrite(), SSLHandshake(),
203 (*SSLReadFunc
) (SSLConnectionRef connection
,
204 void *data
, /* owned by
207 size_t *dataLength
); /* IN/OUT */
209 (*SSLWriteFunc
) (SSLConnectionRef connection
,
211 size_t *dataLength
); /* IN/OUT */
213 /*************************************************
214 *** OSStatus values unique to SecureTransport ***
215 *************************************************/
218 Note: the comments that appear after these errors are used to create SecErrorMessages.strings.
219 The comments must not be multi-line, and should be in a form meaningful to an end user. If
220 a different or additional comment is needed, it can be put in the header doc format, or on a
221 line that does not start with errZZZ.
225 errSSLProtocol
= -9800, /* SSL protocol error */
226 errSSLNegotiation
= -9801, /* Cipher Suite negotiation failure */
227 errSSLFatalAlert
= -9802, /* Fatal alert */
228 errSSLWouldBlock
= -9803, /* I/O would block (not fatal) */
229 errSSLSessionNotFound
= -9804, /* attempt to restore an unknown session */
230 errSSLClosedGraceful
= -9805, /* connection closed gracefully */
231 errSSLClosedAbort
= -9806, /* connection closed via error */
232 errSSLXCertChainInvalid
= -9807, /* invalid certificate chain */
233 errSSLBadCert
= -9808, /* bad certificate format */
234 errSSLCrypto
= -9809, /* underlying cryptographic error */
235 errSSLInternal
= -9810, /* Internal error */
236 errSSLModuleAttach
= -9811, /* module attach failure */
237 errSSLUnknownRootCert
= -9812, /* valid cert chain, untrusted root */
238 errSSLNoRootCert
= -9813, /* cert chain not verified by root */
239 errSSLCertExpired
= -9814, /* chain had an expired cert */
240 errSSLCertNotYetValid
= -9815, /* chain had a cert not yet valid */
241 errSSLClosedNoNotify
= -9816, /* server closed session with no notification */
242 errSSLBufferOverflow
= -9817, /* insufficient buffer provided */
243 errSSLBadCipherSuite
= -9818, /* bad SSLCipherSuite */
245 /* fatal errors detected by peer */
246 errSSLPeerUnexpectedMsg
= -9819, /* unexpected message received */
247 errSSLPeerBadRecordMac
= -9820, /* bad MAC */
248 errSSLPeerDecryptionFail
= -9821, /* decryption failed */
249 errSSLPeerRecordOverflow
= -9822, /* record overflow */
250 errSSLPeerDecompressFail
= -9823, /* decompression failure */
251 errSSLPeerHandshakeFail
= -9824, /* handshake failure */
252 errSSLPeerBadCert
= -9825, /* misc. bad certificate */
253 errSSLPeerUnsupportedCert
= -9826, /* bad unsupported cert format */
254 errSSLPeerCertRevoked
= -9827, /* certificate revoked */
255 errSSLPeerCertExpired
= -9828, /* certificate expired */
256 errSSLPeerCertUnknown
= -9829, /* unknown certificate */
257 errSSLIllegalParam
= -9830, /* illegal parameter */
258 errSSLPeerUnknownCA
= -9831, /* unknown Cert Authority */
259 errSSLPeerAccessDenied
= -9832, /* access denied */
260 errSSLPeerDecodeError
= -9833, /* decoding error */
261 errSSLPeerDecryptError
= -9834, /* decryption error */
262 errSSLPeerExportRestriction
= -9835, /* export restriction */
263 errSSLPeerProtocolVersion
= -9836, /* bad protocol version */
264 errSSLPeerInsufficientSecurity
= -9837, /* insufficient security */
265 errSSLPeerInternalError
= -9838, /* internal error */
266 errSSLPeerUserCancelled
= -9839, /* user canceled */
267 errSSLPeerNoRenegotiation
= -9840, /* no renegotiation allowed */
269 /* non-fatal result codes */
270 errSSLPeerAuthCompleted
= -9841, /* peer cert is valid, or was ignored if verification disabled */
271 errSSLClientCertRequested
= -9842, /* server has requested a client cert */
273 /* more errors detected by us */
274 errSSLHostNameMismatch
= -9843, /* peer host name mismatch */
275 errSSLConnectionRefused
= -9844, /* peer dropped connection before responding */
276 errSSLDecryptionFail
= -9845, /* decryption failure */
277 errSSLBadRecordMac
= -9846, /* bad MAC */
278 errSSLRecordOverflow
= -9847, /* record overflow */
279 errSSLBadConfiguration
= -9848, /* configuration error */
280 errSSLUnexpectedRecord
= -9849, /* unexpected (skipped) record in DTLS */
281 errSSLWeakPeerEphemeralDHKey
= -9850, /* weak ephemeral dh key */
283 /* non-fatal result codes */
284 errSSLClientHelloReceived
= -9851, /* SNI */
287 /* DEPRECATED aliases for errSSLPeerAuthCompleted */
288 #define errSSLServerAuthCompleted errSSLPeerAuthCompleted
289 #define errSSLClientAuthCompleted errSSLPeerAuthCompleted
291 /* DEPRECATED alias for the end of the error range */
292 #define errSSLLast errSSLUnexpectedRecord
294 typedef CF_ENUM(int, SSLProtocolSide
)
300 typedef CF_ENUM(int, SSLConnectionType
)
306 typedef CF_ENUM(int, SSLSessionStrengthPolicy
)
308 kSSLSessionStrengthPolicyDefault
,
309 kSSLSessionStrengthPolicyATSv1
317 * Secure Transport APIs require a SSLContextRef, which is an opaque
318 * reference to the SSL session and its parameters. On Mac OS X 10.7
319 * and earlier versions, a new context is created using SSLNewContext,
320 * and is disposed by calling SSLDisposeContext.
322 * On i0S 5.0 and later, as well as Mac OS X versions after 10.7, the
323 * SSLContextRef is a true CFType object with retain-release semantics.
324 * New code should create a new context using SSLCreateContext (instead
325 * of SSLNewContext), and dispose the context by calling CFRelease
326 * (instead of SSLDisposeContext) when finished with it.
330 * Return the CFTypeID for SSLContext objects.
333 SSLContextGetTypeID(void)
334 __OSX_AVAILABLE_STARTING(__MAC_10_8
, __IPHONE_5_0
);
337 * Create a new instance of an SSLContextRef using the specified allocator.
341 SSLCreateContext(CFAllocatorRef __nullable alloc
, SSLProtocolSide protocolSide
, SSLConnectionType connectionType
)
342 __OSX_AVAILABLE_STARTING(__MAC_10_8
, __IPHONE_5_0
);
345 #if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE))
347 * Create a new session context.
349 * ==========================
350 * MAC OS X ONLY (DEPRECATED)
351 * ==========================
352 * NOTE: this function is not available on iOS, and should be considered
353 * deprecated on Mac OS X. Your code should use SSLCreateContext instead.
356 SSLNewContext (Boolean isServer
,
357 SSLContextRef
* __nonnull CF_RETURNS_RETAINED contextPtr
) /* RETURNED */
358 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2
,__MAC_10_9
,__IPHONE_NA
,__IPHONE_NA
);
361 * Dispose of a session context.
363 * ==========================
364 * MAC OS X ONLY (DEPRECATED)
365 * ==========================
366 * NOTE: this function is not available on iOS, and should be considered
367 * deprecated on Mac OS X. Your code should use CFRelease to dispose a session
368 * created with SSLCreateContext.
371 SSLDisposeContext (SSLContextRef context
)
372 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2
,__MAC_10_9
,__IPHONE_NA
,__IPHONE_NA
);
374 #endif /* MAC OS X */
377 * Determine the state of an SSL/DTLS session.
380 SSLGetSessionState (SSLContextRef context
,
381 SSLSessionState
*state
) /* RETURNED */
382 __OSX_AVAILABLE_STARTING(__MAC_10_2
, __IPHONE_5_0
);
385 * Set options for an SSL session. Must be called prior to SSLHandshake();
386 * subsequently cannot be called while session is active.
389 SSLSetSessionOption (SSLContextRef context
,
390 SSLSessionOption option
,
392 __OSX_AVAILABLE_STARTING(__MAC_10_6
, __IPHONE_5_0
);
395 * Determine current value for the specified option in a given SSL session.
398 SSLGetSessionOption (SSLContextRef context
,
399 SSLSessionOption option
,
401 __OSX_AVAILABLE_STARTING(__MAC_10_6
, __IPHONE_5_0
);
403 /********************************************************************
404 *** Session context configuration, common to client and servers. ***
405 ********************************************************************/
408 * Specify functions which do the network I/O. Must be called prior
409 * to SSLHandshake(); subsequently cannot be called while a session is
413 SSLSetIOFuncs (SSLContextRef context
,
414 SSLReadFunc readFunc
,
415 SSLWriteFunc writeFunc
)
416 __OSX_AVAILABLE_STARTING(__MAC_10_2
, __IPHONE_5_0
);
419 * Set the minimum SSL protocol version allowed. Optional.
420 * The default is the lower supported protocol.
422 * This can only be called when no session is active.
424 * For TLS contexts, legal values for minVersion are :
430 * For DTLS contexts, legal values for minVersion are :
434 SSLSetProtocolVersionMin (SSLContextRef context
,
435 SSLProtocol minVersion
)
436 __OSX_AVAILABLE_STARTING(__MAC_10_8
, __IPHONE_5_0
);
439 * Get minimum protocol version allowed
442 SSLGetProtocolVersionMin (SSLContextRef context
,
443 SSLProtocol
*minVersion
)
444 __OSX_AVAILABLE_STARTING(__MAC_10_8
, __IPHONE_5_0
);
447 * Set the maximum SSL protocol version allowed. Optional.
448 * The default is the highest supported protocol.
450 * This can only be called when no session is active.
452 * For TLS contexts, legal values for minVersion are :
458 * For DTLS contexts, legal values for minVersion are :
462 SSLSetProtocolVersionMax (SSLContextRef context
,
463 SSLProtocol maxVersion
)
464 __OSX_AVAILABLE_STARTING(__MAC_10_8
, __IPHONE_5_0
);
467 * Get maximum protocol version allowed
470 SSLGetProtocolVersionMax (SSLContextRef context
,
471 SSLProtocol
*maxVersion
)
472 __OSX_AVAILABLE_STARTING(__MAC_10_8
, __IPHONE_5_0
);
475 #if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE))
477 * Set allowed SSL protocol versions. Optional.
478 * Specifying kSSLProtocolAll for SSLSetProtocolVersionEnabled results in
479 * specified 'enable' boolean to be applied to all supported protocols.
480 * The default is "all supported protocols are enabled".
481 * This can only be called when no session is active.
483 * Legal values for protocol are :
489 * ==========================
490 * MAC OS X ONLY (DEPRECATED)
491 * ==========================
492 * NOTE: this function is not available on iOS, and should be considered
493 * deprecated on Mac OS X. You can use SSLSetProtocolVersionMin and/or
494 * SSLSetProtocolVersionMax to specify which protocols are enabled.
497 SSLSetProtocolVersionEnabled (SSLContextRef context
,
498 SSLProtocol protocol
,
500 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2
,__MAC_10_9
,__IPHONE_NA
,__IPHONE_NA
);
503 * Obtain a value specified in SSLSetProtocolVersionEnabled.
505 * ==========================
506 * MAC OS X ONLY (DEPRECATED)
507 * ==========================
508 * NOTE: this function is not available on iOS, and should be considered
509 * deprecated on Mac OS X. You can use SSLGetProtocolVersionMin and/or
510 * SSLGetProtocolVersionMax to check whether a protocol is enabled.
513 SSLGetProtocolVersionEnabled(SSLContextRef context
,
514 SSLProtocol protocol
,
515 Boolean
*enable
) /* RETURNED */
516 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2
,__MAC_10_9
,__IPHONE_NA
,__IPHONE_NA
);
519 * Get/set SSL protocol version; optional. Default is kSSLProtocolUnknown,
520 * in which case the highest possible version is attempted, but a lower
521 * version is accepted if the peer requires it.
522 * SSLSetProtocolVersion cannot be called when a session is active.
524 * ==========================
525 * MAC OS X ONLY (DEPRECATED)
526 * ==========================
527 * NOTE: this function is not available on iOS, and deprecated on Mac OS X 10.8.
528 * Use SSLSetProtocolVersionMin and/or SSLSetProtocolVersionMax to specify
529 * which protocols are enabled.
532 SSLSetProtocolVersion (SSLContextRef context
,
534 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2
,__MAC_10_8
,__IPHONE_NA
,__IPHONE_NA
);
537 * Obtain the protocol version specified in SSLSetProtocolVersion.
538 * If SSLSetProtocolVersionEnabled() has been called for this session,
539 * SSLGetProtocolVersion() may return errSecParam if the protocol enable
540 * state can not be represented by the SSLProtocol enums (e.g.,
541 * SSL2 and TLS1 enabled, SSL3 disabled).
543 * ==========================
544 * MAC OS X ONLY (DEPRECATED)
545 * ==========================
546 * NOTE: this function is not available on iOS, and deprecated on Mac OS X 10.8.
547 * Use SSLGetProtocolVersionMin and/or SSLGetProtocolVersionMax to check
548 * whether a protocol is enabled.
551 SSLGetProtocolVersion (SSLContextRef context
,
552 SSLProtocol
*protocol
) /* RETURNED */
553 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2
,__MAC_10_8
,__IPHONE_NA
,__IPHONE_NA
);
555 #endif /* MAC OS X */
558 * Specify this connection's certificate(s). This is mandatory for
559 * server connections, optional for clients. Specifying a certificate
560 * for a client enables SSL client-side authentication. The end-entity
561 * cert is in certRefs[0]. Specifying a root cert is optional; if it's
562 * not specified, the root cert which verifies the cert chain specified
563 * here must be present in the system-wide set of trusted anchor certs.
565 * The certRefs argument is a CFArray containing SecCertificateRefs,
566 * except for certRefs[0], which is a SecIdentityRef.
568 * Must be called prior to SSLHandshake(), or immediately after
569 * SSLHandshake has returned errSSLClientCertRequested (i.e. before the
570 * handshake is resumed by calling SSLHandshake again.)
572 * SecureTransport assumes the following:
574 * -- The certRef references remain valid for the lifetime of the session.
575 * -- The certificate specified in certRefs[0] is capable of signing.
576 * -- The required capabilities of the certRef[0], and of the optional cert
577 * specified in SSLSetEncryptionCertificate (see below), are highly
578 * dependent on the application. For example, to work as a server with
579 * Netscape clients, the cert specified here must be capable of both
580 * signing and encrypting.
583 SSLSetCertificate (SSLContextRef context
,
585 __OSX_AVAILABLE_STARTING(__MAC_10_2
, __IPHONE_5_0
);
588 * Specify I/O connection - a socket, endpoint, etc., which is
589 * managed by caller. On the client side, it's assumed that communication
590 * has been established with the desired server on this connection.
591 * On the server side, it's assumed that an incoming client request
592 * has been established.
594 * Must be called prior to SSLHandshake(); subsequently can only be
595 * called when no session is active.
598 SSLSetConnection (SSLContextRef context
,
599 SSLConnectionRef __nullable connection
)
600 __OSX_AVAILABLE_STARTING(__MAC_10_2
, __IPHONE_5_0
);
603 SSLGetConnection (SSLContextRef context
,
604 SSLConnectionRef
* __nonnull CF_RETURNS_NOT_RETAINED connection
)
605 __OSX_AVAILABLE_STARTING(__MAC_10_2
, __IPHONE_5_0
);
608 * Specify the fully qualified doman name of the peer, e.g., "store.apple.com."
609 * Optional; used to verify the common name field in peer's certificate.
610 * Name is in the form of a C string; NULL termination optional, i.e.,
611 * peerName[peerNameLen+1] may or may not have a NULL. In any case peerNameLen
612 * is the number of bytes of the peer domain name.
615 SSLSetPeerDomainName (SSLContextRef context
,
616 const char * __nullable peerName
,
618 __OSX_AVAILABLE_STARTING(__MAC_10_2
, __IPHONE_5_0
);
621 * Determine the buffer size needed for SSLGetPeerDomainName().
624 SSLGetPeerDomainNameLength (SSLContextRef context
,
625 size_t *peerNameLen
) // RETURNED
626 __OSX_AVAILABLE_STARTING(__MAC_10_2
, __IPHONE_5_0
);
629 * Obtain the value specified in SSLSetPeerDomainName().
632 SSLGetPeerDomainName (SSLContextRef context
,
633 char *peerName
, // returned here
634 size_t *peerNameLen
) // IN/OUT
635 __OSX_AVAILABLE_STARTING(__MAC_10_2
, __IPHONE_5_0
);
638 * Specify the Datagram TLS Hello Cookie.
639 * This is to be called for server side only and is optional.
640 * The default is a zero len cookie. The maximum cookieLen is 32 bytes.
643 SSLSetDatagramHelloCookie (SSLContextRef dtlsContext
,
644 const void * __nullable cookie
,
646 __OSX_AVAILABLE_STARTING(__MAC_10_8
, __IPHONE_5_0
);
649 * Specify the maximum record size, including all DTLS record headers.
650 * This should be set appropriately to avoid fragmentation
651 * of Datagrams during handshake, as fragmented datagrams may
652 * be dropped by some network.
653 * This is for Datagram TLS only
656 SSLSetMaxDatagramRecordSize (SSLContextRef dtlsContext
,
658 __OSX_AVAILABLE_STARTING(__MAC_10_8
, __IPHONE_5_0
);
661 * Get the maximum record size, including all Datagram TLS record headers.
662 * This is for Datagram TLS only
665 SSLGetMaxDatagramRecordSize (SSLContextRef dtlsContext
,
667 __OSX_AVAILABLE_STARTING(__MAC_10_8
, __IPHONE_5_0
);
670 * Obtain the actual negotiated protocol version of the active
671 * session, which may be different that the value specified in
672 * SSLSetProtocolVersion(). Returns kSSLProtocolUnknown if no
673 * SSL session is in progress.
676 SSLGetNegotiatedProtocolVersion (SSLContextRef context
,
677 SSLProtocol
*protocol
) /* RETURNED */
678 __OSX_AVAILABLE_STARTING(__MAC_10_2
, __IPHONE_5_0
);
681 * Determine number and values of all of the SSLCipherSuites we support.
682 * Caller allocates output buffer for SSLGetSupportedCiphers() and passes in
683 * its size in *numCiphers. If supplied buffer is too small, errSSLBufferOverflow
687 SSLGetNumberSupportedCiphers (SSLContextRef context
,
689 __OSX_AVAILABLE_STARTING(__MAC_10_2
, __IPHONE_5_0
);
692 SSLGetSupportedCiphers (SSLContextRef context
,
693 SSLCipherSuite
*ciphers
, /* RETURNED */
694 size_t *numCiphers
) /* IN/OUT */
695 __OSX_AVAILABLE_STARTING(__MAC_10_2
, __IPHONE_5_0
);
698 * Specify a (typically) restricted set of SSLCipherSuites to be enabled by
699 * the current SSLContext. Can only be called when no session is active. Default
700 * set of enabled SSLCipherSuites is the same as the complete set of supported
701 * SSLCipherSuites as obtained by SSLGetSupportedCiphers().
704 SSLSetEnabledCiphers (SSLContextRef context
,
705 const SSLCipherSuite
*ciphers
,
707 __OSX_AVAILABLE_STARTING(__MAC_10_2
, __IPHONE_5_0
);
710 * Determine number and values of all of the SSLCipherSuites currently enabled.
711 * Caller allocates output buffer for SSLGetEnabledCiphers() and passes in
712 * its size in *numCiphers. If supplied buffer is too small, errSSLBufferOverflow
716 SSLGetNumberEnabledCiphers (SSLContextRef context
,
718 __OSX_AVAILABLE_STARTING(__MAC_10_2
, __IPHONE_5_0
);
721 SSLGetEnabledCiphers (SSLContextRef context
,
722 SSLCipherSuite
*ciphers
, /* RETURNED */
723 size_t *numCiphers
) /* IN/OUT */
724 __OSX_AVAILABLE_STARTING(__MAC_10_2
, __IPHONE_5_0
);
727 #if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE))
729 * Enable/disable peer certificate chain validation. Default is enabled.
730 * If caller disables, it is the caller's responsibility to call
731 * SSLCopyPeerCertificates() upon successful completion of the handshake
732 * and then to perform external validation of the peer certificate
733 * chain before proceeding with data transfer.
735 * ==========================
736 * MAC OS X ONLY (DEPRECATED)
737 * ==========================
738 * NOTE: this function is not available on iOS, and should be considered
739 * deprecated on Mac OS X. To disable peer certificate chain validation, you
740 * can instead use SSLSetSessionOption to set kSSLSessionOptionBreakOnServerAuth
741 * to true. This will disable verification and cause SSLHandshake to return with
742 * an errSSLServerAuthCompleted result when the peer certificates have been
743 * received; at that time, you can choose to evaluate peer trust yourself, or
744 * simply call SSLHandshake again to proceed with the handshake.
747 SSLSetEnableCertVerify (SSLContextRef context
,
748 Boolean enableVerify
)
749 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2
,__MAC_10_9
,__IPHONE_NA
,__IPHONE_NA
);
752 * Check whether peer certificate chain validation is enabled.
754 * ==========================
755 * MAC OS X ONLY (DEPRECATED)
756 * ==========================
757 * NOTE: this function is not available on iOS, and should be considered
758 * deprecated on Mac OS X. To check whether peer certificate chain validation
759 * is enabled in a context, call SSLGetSessionOption to obtain the value of
760 * the kSSLSessionOptionBreakOnServerAuth session option flag. If the value
761 * of this option flag is true, then verification is disabled.
764 SSLGetEnableCertVerify (SSLContextRef context
,
765 Boolean
*enableVerify
) /* RETURNED */
766 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2
,__MAC_10_9
,__IPHONE_NA
,__IPHONE_NA
);
769 * Specify the option of ignoring certificates' "expired" times.
770 * This is a common failure in the real SSL world. Default setting for this
771 * flag is false, meaning expired certs result in an errSSLCertExpired error.
773 * ==========================
774 * MAC OS X ONLY (DEPRECATED)
775 * ==========================
776 * NOTE: this function is not available on iOS, and should be considered
777 * deprecated on Mac OS X. To ignore expired certificate errors, first disable
778 * Secure Transport's automatic verification of peer certificates by calling
779 * SSLSetSessionOption to set kSSLSessionOptionBreakOnServerAuth to true. When
780 * SSLHandshake subsequently returns an errSSLServerAuthCompleted result,
781 * your code should obtain the SecTrustRef for the peer's certificates and
782 * perform a custom trust evaluation with SecTrust APIs (see SecTrust.h).
783 * The SecTrustSetOptions function allows you to specify that the expiration
784 * status of certificates should be ignored for this evaluation.
788 * status = SSLSetSessionOption(ctx, kSSLSessionOptionBreakOnServerAuth, true);
790 * status = SSLHandshake(ctx);
792 * if (status == errSSLServerAuthCompleted) {
793 * SecTrustRef peerTrust = NULL;
794 * status = SSLCopyPeerTrust(ctx, &peerTrust);
795 * if (status == errSecSuccess) {
796 * SecTrustResultType trustResult;
797 * // set flag to allow expired certificates
798 * SecTrustSetOptions(peerTrust, kSecTrustOptionAllowExpired);
799 * status = SecTrustEvaluate(peerTrust, &trustResult);
800 * if (status == errSecSuccess) {
801 * // A "proceed" result means the cert is explicitly trusted,
802 * // e.g. "Always Trust" was clicked;
803 * // "Unspecified" means the cert has no explicit trust settings,
804 * // but is implicitly OK since it chains back to a trusted root.
805 * // Any other result means the cert is not trusted.
807 * if (trustResult == kSecTrustResultProceed ||
808 * trustResult == kSecTrustResultUnspecified) {
809 * // certificate is trusted
810 * status = errSSLWouldBlock; // so we call SSLHandshake again
811 * } else if (trustResult == kSecTrustResultRecoverableTrustFailure) {
812 * // not trusted, for some reason other than being expired;
813 * // could ask the user whether to allow the connection here
815 * status = errSSLXCertChainInvalid;
817 * // cannot use this certificate (fatal)
818 * status = errSSLBadCert;
822 * CFRelease(peerTrust);
825 * } // errSSLServerAuthCompleted
827 * } while (status == errSSLWouldBlock);
831 SSLSetAllowsExpiredCerts (SSLContextRef context
,
832 Boolean allowsExpired
)
833 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2
,__MAC_10_9
,__IPHONE_NA
,__IPHONE_NA
);
836 * Obtain the current value of an SSLContext's "allowExpiredCerts" flag.
838 * ==========================
839 * MAC OS X ONLY (DEPRECATED)
840 * ==========================
841 * NOTE: this function is not available on iOS, and should be considered
842 * deprecated on Mac OS X.
845 SSLGetAllowsExpiredCerts (SSLContextRef context
,
846 Boolean
*allowsExpired
) /* RETURNED */
847 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2
,__MAC_10_9
,__IPHONE_NA
,__IPHONE_NA
);
850 * Similar to SSLSetAllowsExpiredCerts, SSLSetAllowsExpiredRoots allows the
851 * option of ignoring "expired" status for root certificates only.
852 * Default setting is false, i.e., expired root certs result in an
853 * errSSLCertExpired error.
855 * ==========================
856 * MAC OS X ONLY (DEPRECATED)
857 * ==========================
858 * NOTE: this function is not available on iOS, and should be considered
859 * deprecated on Mac OS X. To ignore expired certificate errors, first disable
860 * Secure Transport's automatic verification of peer certificates by calling
861 * SSLSetSessionOption to set kSSLSessionOptionBreakOnServerAuth to true. When
862 * SSLHandshake subsequently returns an errSSLServerAuthCompleted result,
863 * your code should obtain the SecTrustRef for the peer's certificates and
864 * perform a custom trust evaluation with SecTrust APIs (see SecTrust.h).
865 * The SecTrustSetOptions function allows you to specify that the expiration
866 * status of certificates should be ignored for this evaluation.
868 * See the description of the SSLSetAllowsExpiredCerts function (above)
869 * for a code example. The kSecTrustOptionAllowExpiredRoot option can be used
870 * instead of kSecTrustOptionAllowExpired to allow expired roots only.
873 SSLSetAllowsExpiredRoots (SSLContextRef context
,
874 Boolean allowsExpired
)
875 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2
,__MAC_10_9
,__IPHONE_NA
,__IPHONE_NA
);
878 * Obtain the current value of an SSLContext's "allow expired roots" flag.
880 * ==========================
881 * MAC OS X ONLY (DEPRECATED)
882 * ==========================
883 * NOTE: this function is not available on iOS, and should be considered
884 * deprecated on Mac OS X.
887 SSLGetAllowsExpiredRoots (SSLContextRef context
,
888 Boolean
*allowsExpired
) /* RETURNED */
889 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2
,__MAC_10_9
,__IPHONE_NA
,__IPHONE_NA
);
892 * Specify option of allowing for an unknown root cert, i.e., one which
893 * this software can not verify as one of a list of known good root certs.
894 * Default for this flag is false, in which case one of the following two
896 * -- The peer returns a cert chain with a root cert, and the chain
897 * verifies to that root, but the root is not one of our trusted
898 * roots. This results in errSSLUnknownRootCert on handshake.
899 * -- The peer returns a cert chain which does not contain a root cert,
900 * and we can't verify the chain to one of our trusted roots. This
901 * results in errSSLNoRootCert on handshake.
903 * Both of these error conditions are ignored when the AllowAnyRoot flag is
904 * true, allowing connection to a totally untrusted peer.
906 * ==========================
907 * MAC OS X ONLY (DEPRECATED)
908 * ==========================
909 * NOTE: this function is not available on iOS, and should be considered
910 * deprecated on Mac OS X. To ignore unknown root cert errors, first disable
911 * Secure Transport's automatic verification of peer certificates by calling
912 * SSLSetSessionOption to set kSSLSessionOptionBreakOnServerAuth to true. When
913 * SSLHandshake subsequently returns an errSSLServerAuthCompleted result,
914 * your code should obtain the SecTrustRef for the peer's certificates and
915 * perform a custom trust evaluation with SecTrust APIs (see SecTrust.h).
917 * See the description of the SSLSetAllowsExpiredCerts function (above)
918 * for a code example. Note that an unknown root certificate will cause
919 * SecTrustEvaluate to report kSecTrustResultRecoverableTrustFailure as the
923 SSLSetAllowsAnyRoot (SSLContextRef context
,
925 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2
,__MAC_10_9
,__IPHONE_NA
,__IPHONE_NA
);
928 * Obtain the current value of an SSLContext's "allow any root" flag.
930 * ==========================
931 * MAC OS X ONLY (DEPRECATED)
932 * ==========================
933 * NOTE: this function is not available on iOS, and should be considered
934 * deprecated on Mac OS X.
937 SSLGetAllowsAnyRoot (SSLContextRef context
,
938 Boolean
*anyRoot
) /* RETURNED */
939 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2
,__MAC_10_9
,__IPHONE_NA
,__IPHONE_NA
);
942 * Augment or replace the system's default trusted root certificate set
943 * for this session. If replaceExisting is true, the specified roots will
944 * be the only roots which are trusted during this session. If replaceExisting
945 * is false, the specified roots will be added to the current set of trusted
946 * root certs. If this function has never been called, the current trusted
947 * root set is the same as the system's default trusted root set.
948 * Successive calls with replaceExisting false result in accumulation
949 * of additional root certs.
951 * The trustedRoots array contains SecCertificateRefs.
953 * ==========================
954 * MAC OS X ONLY (DEPRECATED)
955 * ==========================
956 * NOTE: this function is not available on iOS, and should be considered
957 * deprecated on Mac OS X. To trust specific roots in a session, first disable
958 * Secure Transport's automatic verification of peer certificates by calling
959 * SSLSetSessionOption to set kSSLSessionOptionBreakOnServerAuth to true. When
960 * SSLHandshake subsequently returns an errSSLServerAuthCompleted result,
961 * your code should obtain the SecTrustRef for the peer's certificates and
962 * perform a custom trust evaluation with SecTrust APIs (see SecTrust.h).
964 * See the description of the SSLSetAllowsExpiredCerts function (above)
965 * for a code example. You can call SecTrustSetAnchorCertificates to
966 * augment the system's trusted root set, or SecTrustSetAnchorCertificatesOnly
967 * to make these the only trusted roots, prior to calling SecTrustEvaluate.
970 SSLSetTrustedRoots (SSLContextRef context
,
971 CFArrayRef trustedRoots
,
972 Boolean replaceExisting
)
973 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2
,__MAC_10_9
,__IPHONE_NA
,__IPHONE_NA
);
976 * Obtain an array of SecCertificateRefs representing the current
977 * set of trusted roots. If SSLSetTrustedRoots() has never been called
978 * for this session, this returns the system's default root set.
980 * Caller must CFRelease the returned CFArray.
982 * ==========================
983 * MAC OS X ONLY (DEPRECATED)
984 * ==========================
985 * NOTE: this function is not available on iOS, and should be considered
986 * deprecated on Mac OS X. To get the current set of trusted roots, call the
987 * SSLCopyPeerTrust function to obtain the SecTrustRef for the peer certificate
988 * chain, then SecTrustCopyCustomAnchorCertificates (see SecTrust.h).
991 SSLCopyTrustedRoots (SSLContextRef context
,
992 CFArrayRef
* __nonnull CF_RETURNS_RETAINED trustedRoots
) /* RETURNED */
993 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5
,__MAC_10_9
,__IPHONE_NA
,__IPHONE_NA
);
996 * Request peer certificates. Valid anytime, subsequent to a handshake attempt.
998 * The certs argument is a CFArray containing SecCertificateRefs.
999 * Caller must CFRelease the returned array.
1001 * The cert at index 0 of the returned array is the subject (end
1002 * entity) cert; the root cert (or the closest cert to it) is at
1003 * the end of the returned array.
1005 * ==========================
1006 * MAC OS X ONLY (DEPRECATED)
1007 * ==========================
1008 * NOTE: this function is not available on iOS, and should be considered
1009 * deprecated on Mac OS X. To get peer certificates, call SSLCopyPeerTrust
1010 * to obtain the SecTrustRef for the peer certificate chain, then use the
1011 * SecTrustGetCertificateCount and SecTrustGetCertificateAtIndex functions
1012 * to retrieve individual certificates in the chain (see SecTrust.h).
1015 SSLCopyPeerCertificates (SSLContextRef context
,
1016 CFArrayRef
* __nonnull CF_RETURNS_RETAINED certs
) /* RETURNED */
1017 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5
,__MAC_10_9
,__IPHONE_NA
,__IPHONE_NA
);
1019 #endif /* MAC OS X */
1022 * Obtain a SecTrustRef representing peer certificates. Valid anytime,
1023 * subsequent to a handshake attempt. Caller must CFRelease the returned
1026 * The returned trust reference will have already been evaluated for you,
1027 * unless one of the following is true:
1028 * - Your code has disabled automatic certificate verification, by calling
1029 * SSLSetSessionOption to set kSSLSessionOptionBreakOnServerAuth to true.
1030 * - Your code has called SSLSetPeerID, and this session has been resumed
1031 * from an earlier cached session.
1033 * In these cases, your code should call SecTrustEvaluate prior to
1034 * examining the peer certificate chain or trust results (see SecTrust.h).
1036 * NOTE: if you have not called SSLHandshake at least once prior to
1037 * calling this function, the returned trust reference will be NULL.
1040 SSLCopyPeerTrust (SSLContextRef context
,
1041 SecTrustRef
* __nonnull CF_RETURNS_RETAINED trust
) /* RETURNED */
1042 __OSX_AVAILABLE_STARTING(__MAC_10_6
, __IPHONE_5_0
);
1045 * Specify some data, opaque to this library, which is sufficient
1046 * to uniquely identify the peer of the current session. An example
1047 * would be IP address and port, stored in some caller-private manner.
1048 * To be optionally called prior to SSLHandshake for the current
1049 * session. This is mandatory if this session is to be resumable.
1051 * SecureTransport allocates its own copy of the incoming peerID. The
1052 * data provided in *peerID, while opaque to SecureTransport, is used
1053 * in a byte-for-byte compare to other previous peerID values set by the
1054 * current application. Matching peerID blobs result in SecureTransport
1055 * attempting to resume an SSL session with the same parameters as used
1056 * in the previous session which specified the same peerID bytes.
1059 SSLSetPeerID (SSLContextRef context
,
1060 const void * __nullable peerID
,
1062 __OSX_AVAILABLE_STARTING(__MAC_10_2
, __IPHONE_5_0
);
1065 * Obtain current PeerID. Returns NULL pointer, zero length if
1066 * SSLSetPeerID has not been called for this context.
1069 SSLGetPeerID (SSLContextRef context
,
1070 const void * __nullable
* __nonnull peerID
,
1072 __OSX_AVAILABLE_STARTING(__MAC_10_2
, __IPHONE_5_0
);
1075 * Obtain the SSLCipherSuite (e.g., SSL_RSA_WITH_DES_CBC_SHA) negotiated
1076 * for this session. Only valid when a session is active.
1079 SSLGetNegotiatedCipher (SSLContextRef context
,
1080 SSLCipherSuite
*cipherSuite
)
1081 __OSX_AVAILABLE_STARTING(__MAC_10_2
, __IPHONE_5_0
);
1084 /********************************************************
1085 *** Session context configuration, server side only. ***
1086 ********************************************************/
1089 * This function is deprecated in OSX 10.11 and iOS 9.0 and
1090 * has no effect on the TLS handshake since OSX 10.10 and
1091 * iOS 8.0. Using separate RSA certificates for encryption
1092 * and signing is no longer supported.
1095 SSLSetEncryptionCertificate (SSLContextRef context
,
1096 CFArrayRef certRefs
)
1097 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2
, __MAC_10_11
, __IPHONE_5_0
, __IPHONE_9_0
);
1100 * Specify requirements for client-side authentication.
1101 * Optional; Default is kNeverAuthenticate.
1103 * Can only be called when no session is active.
1105 typedef CF_ENUM(int, SSLAuthenticate
) {
1106 kNeverAuthenticate
, /* skip client authentication */
1107 kAlwaysAuthenticate
, /* require it */
1108 kTryAuthenticate
/* try to authenticate, but not an error
1109 * if client doesn't have a cert */
1113 SSLSetClientSideAuthenticate (SSLContextRef context
,
1114 SSLAuthenticate auth
)
1115 __OSX_AVAILABLE_STARTING(__MAC_10_2
, __IPHONE_5_0
);
1118 * Add a DER-encoded distinguished name to list of acceptable names
1119 * to be specified in requests for client certificates.
1122 SSLAddDistinguishedName (SSLContextRef context
,
1123 const void * __nullable derDN
,
1125 __OSX_AVAILABLE_STARTING(__MAC_10_4
, __IPHONE_5_0
);
1128 #if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE))
1130 * Add a SecCertificateRef, or a CFArray of them, to a server's list
1131 * of acceptable Certificate Authorities (CAs) to present to the client
1132 * when client authentication is performed.
1134 * If replaceExisting is true, the specified certificate(s) will replace
1135 * a possible existing list of acceptable CAs. If replaceExisting is
1136 * false, the specified certificate(s) will be appended to the existing
1137 * list of acceptable CAs, if any.
1139 * Returns errSecParam if this is called on a SSLContextRef which
1140 * is configured as a client, or when a session is active.
1142 * NOTE: this function is currently not available on iOS.
1145 SSLSetCertificateAuthorities(SSLContextRef context
,
1146 CFTypeRef certificateOrArray
,
1147 Boolean replaceExisting
)
1148 __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_NA
);
1151 * Obtain the certificates specified in SSLSetCertificateAuthorities(),
1152 * if any. Returns a NULL array if SSLSetCertificateAuthorities() has not
1154 * Caller must CFRelease the returned array.
1156 * NOTE: this function is currently not available on iOS.
1159 SSLCopyCertificateAuthorities(SSLContextRef context
,
1160 CFArrayRef
* __nonnull CF_RETURNS_RETAINED certificates
) /* RETURNED */
1161 __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_NA
);
1163 #endif /* MAC OS X */
1166 * Obtain the list of acceptable distinguished names as provided by
1167 * a server (if the SSLContextRef is configured as a client), or as
1168 * specified by SSLSetCertificateAuthorities (if the SSLContextRef
1169 * is configured as a server).
1170 * The returned array contains CFDataRefs, each of which represents
1171 * one DER-encoded RDN.
1173 * Caller must CFRelease the returned array.
1176 SSLCopyDistinguishedNames (SSLContextRef context
,
1177 CFArrayRef
* __nonnull CF_RETURNS_RETAINED names
)
1178 __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_5_0
);
1181 * Obtain client certificate exchange status. Can be called
1182 * any time. Reflects the *last* client certificate state change;
1183 * subsequent to a renegotiation attempt by either peer, the state
1184 * is reset to kSSLClientCertNone.
1187 SSLGetClientCertificateState (SSLContextRef context
,
1188 SSLClientCertificateState
*clientState
)
1189 __OSX_AVAILABLE_STARTING(__MAC_10_3
, __IPHONE_5_0
);
1192 #if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE))
1194 * Specify Diffie-Hellman parameters. Optional; if we are configured to allow
1195 * for D-H ciphers and a D-H cipher is negotiated, and this function has not
1196 * been called, a set of process-wide parameters will be calculated. However
1197 * that can take a long time (30 seconds).
1199 * NOTE: this function is currently not available on iOS.
1201 OSStatus
SSLSetDiffieHellmanParams (SSLContextRef context
,
1202 const void * __nullable dhParams
,
1204 __OSX_AVAILABLE_STARTING(__MAC_10_2
, __IPHONE_NA
);
1207 * Return parameter block specified in SSLSetDiffieHellmanParams.
1208 * Returned data is not copied and belongs to the SSLContextRef.
1210 * NOTE: this function is currently not available on iOS.
1212 OSStatus
SSLGetDiffieHellmanParams (SSLContextRef context
,
1213 const void * __nullable
* __nonnull dhParams
,
1214 size_t *dhParamsLen
)
1215 __OSX_AVAILABLE_STARTING(__MAC_10_2
, __IPHONE_NA
);
1218 * Enable/Disable RSA blinding. This feature thwarts a known timing
1219 * attack to which RSA keys are vulnerable; enabling it is a tradeoff
1220 * between performance and security. The default for RSA blinding is
1223 * ==========================
1224 * MAC OS X ONLY (DEPRECATED)
1225 * ==========================
1226 * NOTE: this function is not available on iOS, and should be considered
1227 * deprecated on Mac OS X. RSA blinding is enabled unconditionally, as
1228 * it prevents a known way for an attacker to recover the private key,
1229 * and the performance gain of disabling it is negligible.
1231 OSStatus
SSLSetRsaBlinding (SSLContextRef context
,
1233 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2
,__MAC_10_9
,__IPHONE_NA
,__IPHONE_NA
);
1235 OSStatus
SSLGetRsaBlinding (SSLContextRef context
,
1237 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2
,__MAC_10_9
,__IPHONE_NA
,__IPHONE_NA
);
1239 #endif /* MAC OS X */
1241 /*******************************
1242 ******** I/O Functions ********
1243 *******************************/
1246 * Note: depending on the configuration of the underlying I/O
1247 * connection, all SSL I/O functions can return errSSLWouldBlock,
1248 * indicating "not complete, nothing is wrong, except required
1249 * I/O hasn't completed". Caller may need to repeat I/Os as necessary
1250 * if the underlying connection has been configured to behave in
1251 * a non-blocking manner.
1255 * Perform the SSL handshake. On successful return, session is
1256 * ready for normal secure application I/O via SSLWrite and SSLRead.
1258 * Interesting error returns:
1260 * errSSLUnknownRootCert: Peer had a valid cert chain, but the root of
1261 * the chain is unknown.
1263 * errSSLNoRootCert: Peer had a cert chain which did not end in a root.
1265 * errSSLCertExpired: Peer's cert chain had one or more expired certs.
1267 * errSSLXCertChainInvalid: Peer had an invalid cert chain (i.e.,
1268 * signature verification within the chain failed, or no certs
1271 * In all of the above errors, the handshake was aborted; the peer's
1272 * cert chain is available via SSLCopyPeerTrust or SSLCopyPeerCertificates.
1274 * Other interesting result codes:
1276 * errSSLPeerAuthCompleted: Peer's cert chain is valid, or was ignored if
1277 * cert verification was disabled via SSLSetEnableCertVerify. The application
1278 * may decide to continue with the handshake (by calling SSLHandshake
1279 * again), or close the connection at this point.
1281 * errSSLClientCertRequested: The server has requested a client certificate.
1282 * The client may choose to examine the server's certificate and
1283 * distinguished name list, then optionally call SSLSetCertificate prior
1284 * to resuming the handshake by calling SSLHandshake again.
1286 * A return value of errSSLWouldBlock indicates that SSLHandshake has to be
1287 * called again (and again and again until something else is returned).
1290 SSLHandshake (SSLContextRef context
)
1291 __OSX_AVAILABLE_STARTING(__MAC_10_2
, __IPHONE_5_0
);
1294 * Normal application-level read/write. On both of these, a errSSLWouldBlock
1295 * return and a partially completed transfer - or even zero bytes transferred -
1296 * are NOT mutually exclusive.
1299 SSLWrite (SSLContextRef context
,
1300 const void * __nullable data
,
1302 size_t *processed
) /* RETURNED */
1303 __OSX_AVAILABLE_STARTING(__MAC_10_2
, __IPHONE_5_0
);
1306 * data is mallocd by caller; available size specified in
1307 * dataLength; actual number of bytes read returned in
1311 SSLRead (SSLContextRef context
,
1312 void * data
, /* RETURNED */
1314 size_t *processed
) /* RETURNED */
1315 __OSX_AVAILABLE_STARTING(__MAC_10_2
, __IPHONE_5_0
);
1318 * Determine how much data the client can be guaranteed to
1319 * obtain via SSLRead() without blocking or causing any low-level
1320 * read operations to occur.
1323 SSLGetBufferedReadSize (SSLContextRef context
,
1324 size_t *bufSize
) /* RETURNED */
1325 __OSX_AVAILABLE_STARTING(__MAC_10_2
, __IPHONE_5_0
);
1328 * Determine how much data the application can be guaranteed to write
1329 * with SSLWrite() without causing fragmentation. The value is based on
1330 * the maximum Datagram Record size defined by the application with
1331 * SSLSetMaxDatagramRecordSize(), minus the DTLS Record header size.
1334 SSLGetDatagramWriteSize (SSLContextRef dtlsContext
,
1336 __OSX_AVAILABLE_STARTING(__MAC_10_8
, __IPHONE_5_0
);
1339 * Terminate current SSL session.
1342 SSLClose (SSLContextRef context
)
1343 __OSX_AVAILABLE_STARTING(__MAC_10_2
, __IPHONE_5_0
);
1346 * Set the minimum acceptable strength of policy to be negotiated for an
1350 SSLSetSessionStrengthPolicy(SSLContextRef context
,
1351 SSLSessionStrengthPolicy policyStrength
);
1353 CF_IMPLICIT_BRIDGING_DISABLED
1354 CF_ASSUME_NONNULL_END
1360 #endif /* !_SECURITY_SECURETRANSPORT_H_ */