2 * Copyright (c) 1999-2001,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 * SecureTransportPriv.h - Apple-private exported routines
28 #ifndef _SECURE_TRANSPORT_PRIV_H_
29 #define _SECURE_TRANSPORT_PRIV_H_ 1
31 #include <Security/SecureTransport.h>
32 #include <Security/SecTrust.h>
38 #include <Security/sslTypes.h>
40 /* Enum defining connection strength for TLS connections. */
41 typedef CF_ENUM(int, SSLConnectionStrength
) {
42 SSLConnectionStrengthStrong
,
43 SSLConnectionStrengthWeak
,
44 SSLConnectionStrengthNonsecure
,
47 /* See: https://tools.ietf.org/html/rfc8446#section-4.2.7 */
48 typedef CF_ENUM(uint16_t, SSLKeyExchangeGroup
) {
49 SSLKeyExchangeGroupSecp256r1
= 0x0017,
50 SSLKeyExchangeGroupSecp384r1
= 0x0018,
51 SSLKeyExchangeGroupSecp521r1
= 0x0019,
52 SSLKeyExchangeGroupX25519
= 0x001D,
53 SSLKeyExchangeGroupX448
= 0x001E,
54 SSLKeyExchangeGroupFFDHE2048
= 0x0100,
55 SSLKeyExchangeGroupFFDHE3072
= 0x0101,
56 SSLKeyExchangeGroupFFDHE4096
= 0x0102,
57 SSLKeyExchangeGroupFFDHE6144
= 0x0103,
58 SSLKeyExchangeGroupFFDHE8192
= 0x0104,
62 * Convenience key exchange groups that collate group identifiers of
63 * comparable security into a single alias.
65 typedef CF_ENUM(int, SSLKeyExchangeGroupSet
) {
66 kSSLKeyExchangeGroupSetDefault
,
67 kSSLKeyExchangeGroupSetCompatibility
,
68 kSSLKeyExchangeGroupSetLegacy
,
71 /* Determine if a ciphersuite belongs to a specific ciphersuite group */
72 bool SSLCiphersuiteGroupContainsCiphersuite(SSLCiphersuiteGroup group
, SSLCipherSuite suite
);
74 /* Return the list of ciphersuites associated with a SSLCiphersuiteGroup */
75 const SSLCipherSuite
*SSLCiphersuiteGroupToCiphersuiteList(SSLCiphersuiteGroup group
,
78 /* Determine minimum allowed TLS version for the given ciphersuite */
79 SSLProtocol
SSLCiphersuiteMinimumTLSVersion(SSLCipherSuite ciphersuite
);
81 /* Determine maximum allowed TLS version for the given ciphersuite */
82 SSLProtocol
SSLCiphersuiteMaximumTLSVersion(SSLCipherSuite ciphersuite
);
84 /* Get a human readable name for the given ciphersuite. */
85 const char *SSLCiphersuiteGetName(SSLCipherSuite ciphersuite
);
87 /* Get the 2-byte IANA codepoint representation of the given TLS protocol version. */
88 uint16_t SSLProtocolGetVersionCodepoint(SSLProtocol protocol_version
);
90 /* Get the internal SSLProtocol enumeration value from a 2-byte IANA TLS version codepoint. */
91 SSLProtocol
SSLProtocolFromVersionCodepoint(uint16_t protocol_version
);
93 /* Create an SSL Context with an external record layer - eg: kernel accelerated layer */
95 SSLCreateContextWithRecordFuncs(CFAllocatorRef alloc
,
96 SSLProtocolSide protocolSide
,
97 SSLConnectionType connectionType
,
98 const struct SSLRecordFuncs
*recFuncs
);
100 /* Set the external record layer context */
102 SSLSetRecordContext (SSLContextRef ctx
,
103 SSLRecordContextRef recCtx
);
105 /* The size of of client- and server-generated random numbers in hello messages. */
106 #define SSL_CLIENT_SRVR_RAND_SIZE 32
108 /* The size of the pre-master and master secrets. */
109 #define SSL_RSA_PREMASTER_SECRET_SIZE 48
110 #define SSL_MASTER_SECRET_SIZE 48
113 * For the following three functions, *size is the available
114 * buffer size on entry and the actual size of the data returned
115 * on return. The above consts are for convenience.
117 OSStatus
SSLInternalMasterSecret(
118 SSLContextRef context
,
119 void *secret
, // mallocd by caller, SSL_MASTER_SECRET_SIZE
120 size_t *secretSize
); // in/out
122 OSStatus
SSLInternalServerRandom(
123 SSLContextRef context
,
124 void *randBuf
, // mallocd by caller, SSL_CLIENT_SRVR_RAND_SIZE
125 size_t *randSize
); // in/out
127 OSStatus
SSLInternalClientRandom(
128 SSLContextRef context
,
129 void *randBuf
, // mallocd by caller, SSL_CLIENT_SRVR_RAND_SIZE
130 size_t *randSize
); // in/out
133 * Obtain the sizes of the currently negotiated HMAC digest, session
134 * key, and session key IV.
136 OSStatus
SSLGetCipherSizes(
137 SSLContextRef context
,
139 size_t *symmetricKeySize
,
142 OSStatus
SSLInternal_PRF(
143 SSLContextRef context
,
150 void *out
, // mallocd by caller, length >= outLen
154 * Obtain a SecTrustRef representing peer certificates. Valid anytime,
155 * subsequent to a handshake attempt. The returned SecTrustRef is valid
156 * only as long as the SSLContextRef is.
159 SSLGetPeerSecTrust (SSLContextRef context
,
160 SecTrustRef
*secTrust
); /* RETURNED */
163 * Obtain resumable session info. Can be called anytime subsequent to
166 * if sessionWasResumed is True on return, the session is indeed a
167 * resumed session; the sessionID (an opaque blob generated by the
168 * server) is returned in *sessionID. The length of the sessionID
169 * is returned in *sessionIDLength. Caller must allocate the
170 * sessionID buffer; it max size is MAX_SESSION_ID_LENGTH bytes.
172 #define MAX_SESSION_ID_LENGTH 32
175 SSLGetResumableSessionInfo (
176 SSLContextRef context
,
177 Boolean
*sessionWasResumed
, // RETURNED
178 void *sessionID
, // RETURNED, mallocd by caller
179 size_t *sessionIDLength
); // IN/OUT
182 * Getters for SSLSetCertificate() and SSLSetEncryptionCertificate()
186 SSLContextRef context
,
187 CFArrayRef
*certRefs
); // RETURNED, *not* retained
190 SSLGetEncryptionCertificate (
191 SSLContextRef context
,
192 CFArrayRef
*certRefs
); // RETURNED, *not* retained
195 * Getter for SSLSetClientSideAuthenticate()
198 SSLGetClientSideAuthenticate (
199 SSLContextRef context
,
200 SSLAuthenticate
*auth
); // RETURNED
202 #if !TARGET_OS_IPHONE
204 * Get/set array of trusted leaf certificates.
206 * If none have been set previously with SSLSetTrustedLeafCertificates(),
207 * then SSLCopyTrustedLeafCertificates() will return NULL with errSecSuccess.
210 SSLSetTrustedLeafCertificates (
211 SSLContextRef context
,
212 CFArrayRef certRefs
);
215 SSLCopyTrustedLeafCertificates (
216 SSLContextRef context
,
217 CFArrayRef
*certRefs
); // RETURNED, caller must release
220 * Get/set enable of anonymous ciphers. This is deprecated and now a no-op.
223 SSLSetAllowAnonymousCiphers(
224 SSLContextRef context
,
228 SSLGetAllowAnonymousCiphers(
229 SSLContextRef context
,
233 * Override the default session cache timeout for a cache entry created for
234 * the current session.
237 SSLSetSessionCacheTimeout(
238 SSLContextRef context
,
239 uint32_t timeoutInSeconds
);
242 * Callback function for EAP-style PAC-based session resumption.
243 * This function is called by SecureTransport to obtain the
246 typedef void (*SSLInternalMasterSecretFunction
)(
248 const void *arg
, /* opaque to SecureTransport; app-specific */
249 void *secret
, /* mallocd by caller, SSL_MASTER_SECRET_SIZE */
250 size_t *secretLength
); /* in/out */
253 * Register a callback for obtaining the master_secret when performing
254 * PAC-based session resumption. At the time the callback is called,
255 * the following are guaranteed to be valid:
257 * -- serverRandom (via SSLInternalServerRandom())
258 * -- clientRandom (via SSLInternalClientRandom())
259 * -- negotiated protocol version (via SSLGetNegotiatedProtocolVersion())
260 * -- negotiated CipherSuite (via SSLGetNegotiatedCipher())
262 * Currently, PAC-based session resumption is only implemented on
263 * the client side for Deployment builds.
265 * On the client side, this callback occurs if/when the server sends a
266 * ChangeCipherSpec message immediately following its ServerHello
267 * message (i.e., it's skipped the entire Key Exchange phase of
270 * On the server side (Development builds only) this callback occurs
271 * immediately upon receipt of the Client Hello message, before we send
275 SSLInternalSetMasterSecretFunction(
277 SSLInternalMasterSecretFunction mFunc
,
278 const void *arg
); /* opaque to SecureTransport; app-specific */
281 * Provide an opaque SessionTicket for use in PAC-based session
282 * resumption. Client side only. The provided ticket is sent in
283 * the ClientHello message as a SessionTicket extension.
284 * The maximum ticketLength is 2**16-1.
286 OSStatus
SSLInternalSetSessionTicket(
289 size_t ticketLength
);
292 * Support for specifying and obtaining ECC curves, used with the ECDH-based
297 * These are the named curves from RFC 4492
298 * section 5.1.1, with the exception of SSL_Curve_None which means
299 * "ECDSA not negotiated".
305 SSL_Curve_sect163k1
= 1,
306 SSL_Curve_sect163r1
= 2,
307 SSL_Curve_sect163r2
= 3,
308 SSL_Curve_sect193r1
= 4,
309 SSL_Curve_sect193r2
= 5,
310 SSL_Curve_sect233k1
= 6,
311 SSL_Curve_sect233r1
= 7,
312 SSL_Curve_sect239k1
= 8,
313 SSL_Curve_sect283k1
= 9,
314 SSL_Curve_sect283r1
= 10,
315 SSL_Curve_sect409k1
= 11,
316 SSL_Curve_sect409r1
= 12,
317 SSL_Curve_sect571k1
= 13,
318 SSL_Curve_sect571r1
= 14,
319 SSL_Curve_secp160k1
= 15,
320 SSL_Curve_secp160r1
= 16,
321 SSL_Curve_secp160r2
= 17,
322 SSL_Curve_secp192k1
= 18,
323 SSL_Curve_secp192r1
= 19,
324 SSL_Curve_secp224k1
= 20,
325 SSL_Curve_secp224r1
= 21,
326 SSL_Curve_secp256k1
= 22,
328 /* These are the ones we actually support */
329 SSL_Curve_secp256r1
= 23,
330 SSL_Curve_secp384r1
= 24,
331 SSL_Curve_secp521r1
= 25
332 } SSL_ECDSA_NamedCurve
;
335 * Obtain the SSL_ECDSA_NamedCurve negotiated during a handshake.
336 * Returns errSecParam if no ECDH-related ciphersuite was negotiated.
338 extern OSStatus
SSLGetNegotiatedCurve(
340 SSL_ECDSA_NamedCurve
*namedCurve
); /* RETURNED */
343 * Obtain the number of currently enabled SSL_ECDSA_NamedCurves.
345 extern OSStatus
SSLGetNumberOfECDSACurves(
347 unsigned *numCurves
); /* RETURNED */
350 * Obtain the ordered list of currently enabled SSL_ECDSA_NamedCurves.
351 * Caller allocates returned array and specifies its size (in
352 * SSL_ECDSA_NamedCurves) in *numCurves on entry; *numCurves
353 * is the actual size of the returned array on successful return.
355 extern OSStatus
SSLGetECDSACurves(
357 SSL_ECDSA_NamedCurve
*namedCurves
, /* RETURNED */
358 unsigned *numCurves
); /* IN/OUT */
361 * Specify ordered list of allowable named curves.
363 extern OSStatus
SSLSetECDSACurves(
365 const SSL_ECDSA_NamedCurve
*namedCurves
,
369 * Server-specified client authentication mechanisms.
372 /* doesn't appear on the wire */
373 SSLClientAuthNone
= -1,
375 SSLClientAuth_RSASign
= 1,
376 SSLClientAuth_DSSSign
= 2,
377 SSLClientAuth_RSAFixedDH
= 3,
378 SSLClientAuth_DSS_FixedDH
= 4,
380 SSLClientAuth_ECDSASign
= 64,
381 SSLClientAuth_RSAFixedECDH
= 65,
382 SSLClientAuth_ECDSAFixedECDH
= 66
383 } SSLClientAuthenticationType
;
385 /* TLS 1.2 Signature Algorithms extension values for hash field. */
387 SSL_HashAlgorithmNone
= 0,
388 SSL_HashAlgorithmMD5
= 1,
389 SSL_HashAlgorithmSHA1
= 2,
390 SSL_HashAlgorithmSHA224
= 3,
391 SSL_HashAlgorithmSHA256
= 4,
392 SSL_HashAlgorithmSHA384
= 5,
393 SSL_HashAlgorithmSHA512
= 6
396 /* TLS 1.2 Signature Algorithms extension values for signature field. */
398 SSL_SignatureAlgorithmAnonymous
= 0,
399 SSL_SignatureAlgorithmRSA
= 1,
400 SSL_SignatureAlgorithmDSA
= 2,
401 SSL_SignatureAlgorithmECDSA
= 3
402 } SSL_SignatureAlgorithm
;
405 SSL_HashAlgorithm hash
;
406 SSL_SignatureAlgorithm signature
;
407 } SSLSignatureAndHashAlgorithm
;
410 * Obtain the number of client authentication mechanisms specified by
411 * the server in its Certificate Request message.
412 * Returns errSecParam if server hasn't sent a Certificate Request message
413 * (i.e., client certificate state is kSSLClientCertNone).
415 extern OSStatus
SSLGetNumberOfClientAuthTypes(
420 * Obtain the client authentication mechanisms specified by
421 * the server in its Certificate Request message.
422 * Caller allocates returned array and specifies its size (in
423 * SSLClientAuthenticationTypes) in *numType on entry; *numTypes
424 * is the actual size of the returned array on successful return.
426 extern OSStatus
SSLGetClientAuthTypes(
428 SSLClientAuthenticationType
*authTypes
, /* RETURNED */
429 unsigned *numTypes
); /* IN/OUT */
433 * This is not actually useful. Currently return errSecUnimplemented.
434 * The client auth type is fully determined by the type of private key used by
437 extern OSStatus
SSLGetNegotiatedClientAuthType(
439 SSLClientAuthenticationType
*authType
); /* RETURNED */
443 * Obtain the number of supported_signature_algorithms specified by
444 * the server in its Certificate Request message.
445 * Returns errSecParam if server hasn't sent a Certificate Request message
446 * (i.e., client certificate state is kSSLClientCertNone).
448 extern OSStatus
SSLGetNumberOfSignatureAlgorithms(
450 unsigned *numSigAlgs
);
453 * Obtain the supported_signature_algorithms specified by
454 * the server in its Certificate Request message.
455 * Caller allocates returned array and specifies its size (in
456 * SSLClientAuthenticationTypes) in *numType on entry; *numTypes
457 * is the actual size of the returned array on successful return.
459 extern OSStatus
SSLGetSignatureAlgorithms(
461 SSLSignatureAndHashAlgorithm
*sigAlgs
, /* RETURNED */
462 unsigned *numSigAlgs
); /* IN/OUT */
466 /* Set the Shared Secret for PSK CipherSuite.
467 This need to be set before the handshake starts. */
468 OSStatus
SSLSetPSKSharedSecret(SSLContextRef ctx
,
472 /* Set the Client identity for PSK CipherSuite.
473 This need to be set before the handshake starts.
474 Only useful for client side.*/
475 OSStatus
SSLSetPSKIdentity(SSLContextRef ctx
,
476 const void *pskIdentity
,
477 size_t pskIdentityLen
);
479 /* For client side, get the identity previously set by SSLSetPSKIdentity.
480 For server side, get the identity provided by the client during the handshake.
481 Might be NULL if not set. identity is owned by the SSLContext and is invalid once
482 the SSLContext is released.
484 OSStatus
SSLGetPSKIdentity(SSLContextRef ctx
,
485 const void **pskIdentity
,
486 size_t *pskIdentityLen
);
488 /* For client side, set the minimum allowed DH group size for DHE ciphersuites */
489 OSStatus
SSLSetMinimumDHGroupSize(SSLContextRef ctx
, unsigned nbits
);
491 OSStatus
SSLGetMinimumDHGroupSize(SSLContextRef ctx
, unsigned *nbits
);
493 OSStatus
SSLSetDHEEnabled(SSLContextRef ctx
, bool enabled
);
495 OSStatus
SSLGetDHEEnabled(SSLContextRef ctx
, bool *enabled
);
499 /* Following are SPIs on iOS */
502 * Set allowed SSL protocol versions. Optional.
503 * Specifying kSSLProtocolAll for SSLSetProtocolVersionEnabled results in
504 * specified 'enable' boolean to be applied to all supported protocols.
505 * The default is "all supported protocols are enabled".
506 * This can only be called when no session is active.
508 * Legal values for protocol are :
514 * This is deprecated in favor of SSLSetProtocolVersionMax/SSLSetProtocolVersionMin
517 _SSLSetProtocolVersionEnabled (SSLContextRef context
,
518 SSLProtocol protocol
,
519 Boolean enable
) API_UNAVAILABLE(macCatalyst
);
522 * Obtain a value specified in SSLSetProtocolVersionEnabled.
524 * This is deprecated in favor of SSLGetProtocolVersionMax/SSLGetProtocolVersionMin
527 _SSLGetProtocolVersionEnabled(SSLContextRef context
,
528 SSLProtocol protocol
,
529 Boolean
*enable
) API_UNAVAILABLE(macCatalyst
); /* RETURNED */
532 * Get/set SSL protocol version; optional. Default is kSSLProtocolUnknown,
533 * in which case the highest possible version (currently kTLSProtocol1)
534 * is attempted, but a lower version is accepted if the peer requires it.
536 * SSLSetProtocolVersion can not be called when a session is active.
538 * This is deprecated in favor of SSLSetProtocolVersionEnabled.
540 * This is deprecated in favor of SSLSetProtocolVersionMax/SSLSetProtocolVersionMin
543 _SSLSetProtocolVersion (SSLContextRef context
,
544 SSLProtocol version
) API_UNAVAILABLE(macCatalyst
);
547 * Obtain the protocol version specified in SSLSetProtocolVersion.
548 * This is deprecated in favor of SSLGetProtocolVersionEnabled.
549 * If SSLSetProtocolVersionEnabled() has been called for this session,
550 * SSLGetProtocolVersion() may return errSecParam if the protocol enable
551 * state can not be represented by the SSLProtocol enums (e.g.,
552 * SSL2 and TLS1 enabled, SSL3 disabled).
554 * This is deprecated in favor of SSLGetProtocolVersionMax/SSLGetProtocolVersionMin
557 _SSLGetProtocolVersion (SSLContextRef context
,
558 SSLProtocol
*protocol
) API_UNAVAILABLE(macCatalyst
); /* RETURNED */
561 The following 15 calls were used to change the behaviour of the trust
562 evaluation of the certificate chain.
563 The proper alternative is to break out of the handshake, get the
564 peer's SecTrustRef with SSLCopyPeerTrust and evaluate that.
568 * Enable/disable peer certificate chain validation. Default is enabled.
569 * If caller disables, it is the caller's responsibility to call
570 * SSLCopyPeerTrust() upon successful completion of the handshake
571 * and then to perform external validation of the peer certificate
572 * chain before proceeding with data transfer.
575 _SSLSetEnableCertVerify (SSLContextRef context
,
576 Boolean enableVerify
) API_UNAVAILABLE(macCatalyst
);
579 _SSLGetEnableCertVerify (SSLContextRef context
,
580 Boolean
*enableVerify
) API_UNAVAILABLE(macCatalyst
); /* RETURNED */
583 * Specify the option of ignoring certificates' "expired" times.
584 * This is a common failure in the real SSL world. Default for
585 * this flag is false, meaning expired certs result in a
586 * errSSLCertExpired error.
589 _SSLSetAllowsExpiredCerts (SSLContextRef context
,
590 Boolean allowsExpired
) API_UNAVAILABLE(macCatalyst
);
593 * Obtain the current value of an SSLContext's "allowExpiredCerts" flag.
596 _SSLGetAllowsExpiredCerts (SSLContextRef context
,
597 Boolean
*allowsExpired
) API_UNAVAILABLE(macCatalyst
); /* RETURNED */
600 * Similar to SSLSetAllowsExpiredCerts(), this function allows the
601 * option of ignoring "expired" status for root certificates only.
602 * Default is false, i.e., expired root certs result in an
603 * errSSLCertExpired error.
606 _SSLSetAllowsExpiredRoots (SSLContextRef context
,
607 Boolean allowsExpired
) API_UNAVAILABLE(macCatalyst
);
610 _SSLGetAllowsExpiredRoots (SSLContextRef context
,
611 Boolean
*allowsExpired
) API_UNAVAILABLE(macCatalyst
); /* RETURNED */
614 * Specify option of allowing for an unknown root cert, i.e., one which
615 * this software can not verify as one of a list of known good root certs.
616 * Default for this flag is false, in which case one of the following two
618 * -- The peer returns a cert chain with a root cert, and the chain
619 * verifies to that root, but the root is not one of our trusted
620 * roots. This results in errSSLUnknownRootCert on handshake.
621 * -- The peer returns a cert chain which does not contain a root cert,
622 * and we can't verify the chain to one of our trusted roots. This
623 * results in errSSLNoRootCert on handshake.
625 * Both of these error conditions are ignored when the AllowAnyRoot flag is true,
626 * allowing connection to a totally untrusted peer.
629 _SSLSetAllowsAnyRoot (SSLContextRef context
,
630 Boolean anyRoot
) API_UNAVAILABLE(macCatalyst
);
633 * Obtain the current value of an SSLContext's "allow any root" flag.
636 _SSLGetAllowsAnyRoot (SSLContextRef context
,
637 Boolean
*anyRoot
) API_UNAVAILABLE(macCatalyst
); /* RETURNED */
640 * Augment or replace the system's default trusted root certificate set
641 * for this session. If replaceExisting is true, the specified roots will
642 * be the only roots which are trusted during this session. If replaceExisting
643 * is false, the specified roots will be added to the current set of trusted
644 * root certs. If this function has never been called, the current trusted
645 * root set is the same as the system's default trusted root set.
646 * Successive calls with replaceExisting false result in accumulation
647 * of additional root certs.
649 * The trustedRoots array contains SecCertificateRefs.
652 _SSLSetTrustedRoots (SSLContextRef context
,
653 CFArrayRef trustedRoots
,
654 Boolean replaceExisting
) API_UNAVAILABLE(macCatalyst
);
657 * Obtain an array of SecCertificateRefs representing the current
658 * set of trusted roots. If SSLSetTrustedRoots() has never been called
659 * for this session, this returns the system's default root set.
661 * Caller must CFRelease the returned CFArray.
664 _SSLCopyTrustedRoots (SSLContextRef context
,
665 CFArrayRef
*trustedRoots
) API_UNAVAILABLE(macCatalyst
); /* RETURNED */
668 * Add a SecCertificateRef, or a CFArray of them, to a server's list
669 * of acceptable Certificate Authorities (CAs) to present to the client
670 * when client authentication is performed.
672 * If replaceExisting is true, the specified certificate(s) will replace
673 * a possible existing list of acceptable CAs. If replaceExisting is
674 * false, the specified certificate(s) will be appended to the existing
675 * list of acceptable CAs, if any.
677 * Returns errSecParam is this is called on an SSLContextRef which
678 * is configured as a client, or when a session is active.
681 _SSLSetCertificateAuthorities(SSLContextRef context
,
682 CFTypeRef certificateOrArray
,
683 Boolean replaceExisting
) API_UNAVAILABLE(macCatalyst
);
686 * Obtain the certificates specified in SSLSetCertificateAuthorities(),
687 * if any. Returns a NULL array if SSLSetCertificateAuthorities() has not
689 * Caller must CFRelease the returned array.
693 _SSLCopyCertificateAuthorities(SSLContextRef context
,
694 CFArrayRef
*certificates
) API_UNAVAILABLE(macCatalyst
); /* RETURNED */
697 * Request peer certificates. Valid anytime, subsequent to
698 * a handshake attempt.
700 * The certs argument is a CFArray containing SecCertificateRefs.
701 * Caller must CFRelease the returned array.
703 * The cert at index 0 of the returned array is the subject (end
704 * entity) cert; the root cert (or the closest cert to it) is at
705 * the end of the returned array.
708 This should be removed so that applications are not tempted to
709 use this to evaluate trust, they should use the SecTrustRef returned
710 by SSLCopyPeerTrust instead.
711 But this maybe useful to know which certs where returned by the server
712 vs which where pulled internally.
713 This would be a debug feature, so we deprecate this in iOS. There
714 should be an API in SecTrust to allow getting the original certificates
718 _SSLCopyPeerCertificates (SSLContextRef context
,
719 CFArrayRef
*certs
) API_UNAVAILABLE(macCatalyst
); /* RETURNED */
722 * Specify Diffie-Hellman parameters. Optional; if we are configured to allow
723 * for D-H ciphers and a D-H cipher is negotiated, and this function has not
724 * been called, a set of process-wide parameters will be calculated. However
725 * that can take a long time (30 seconds).
727 OSStatus
_SSLSetDiffieHellmanParams (SSLContextRef context
,
728 const void *dhParams
,
729 size_t dhParamsLen
) API_UNAVAILABLE(macCatalyst
);
732 * Return parameter block specified in SSLSetDiffieHellmanParams.
733 * Returned data is not copied and belongs to the SSLContextRef.
735 OSStatus
_SSLGetDiffieHellmanParams (SSLContextRef context
,
736 const void **dhParams
,
737 size_t *dhParamsLen
) API_UNAVAILABLE(macCatalyst
);
740 * Enable/Disable RSA blinding. This feature thwarts a known timing
741 * attack to which RSA keys are vulnerable; enabling it is a tradeoff
742 * between performance and security. The default for RSA blinding is
745 OSStatus
_SSLSetRsaBlinding (SSLContextRef context
,
746 Boolean blinding
) API_UNAVAILABLE(macCatalyst
);
748 OSStatus
_SSLGetRsaBlinding (SSLContextRef context
,
749 Boolean
*blinding
) API_UNAVAILABLE(macCatalyst
);
752 * Create a new SSL/TLS session context.
753 * Deprecated: please use the allocator based functions, when available.
756 _SSLNewContext (Boolean isServer
,
757 SSLContextRef
*tlsContextPtr
) API_UNAVAILABLE(macCatalyst
); /* RETURNED */
760 * Dispose of an SSLContextRef. This is effectivly a CFRelease.
764 _SSLDisposeContext (SSLContextRef context
) API_UNAVAILABLE(macCatalyst
);
766 /* We redefine the names of all SPIs to avoid collision with unavailable APIs */
767 #define SSLSetProtocolVersionEnabled _SSLSetProtocolVersionEnabled
768 #define SSLGetProtocolVersionEnabled _SSLGetProtocolVersionEnabled
769 #define SSLSetProtocolVersion _SSLSetProtocolVersion
770 #define SSLGetProtocolVersion _SSLGetProtocolVersion
771 #define SSLSetEnableCertVerify _SSLSetEnableCertVerify
772 #define SSLGetEnableCertVerify _SSLGetEnableCertVerify
773 #define SSLSetAllowsExpiredCerts _SSLSetAllowsExpiredCerts
774 #define SSLGetAllowsExpiredCerts _SSLGetAllowsExpiredCerts
775 #define SSLSetAllowsExpiredRoots _SSLSetAllowsExpiredRoots
776 #define SSLGetAllowsExpiredRoots _SSLGetAllowsExpiredRoots
777 #define SSLSetAllowsAnyRoot _SSLSetAllowsAnyRoot
778 #define SSLGetAllowsAnyRoot _SSLGetAllowsAnyRoot
779 #define SSLSetTrustedRoots _SSLSetTrustedRoots
780 #define SSLCopyTrustedRoots _SSLCopyTrustedRoots
781 #define SSLSetCertificateAuthorities _SSLSetCertificateAuthorities
782 #define SSLCopyCertificateAuthorities _SSLCopyCertificateAuthorities
783 #define SSLCopyPeerCertificates _SSLCopyPeerCertificates
784 #define SSLSetDiffieHellmanParams _SSLSetDiffieHellmanParams
785 #define SSLGetDiffieHellmanParams _SSLGetDiffieHellmanParams
786 #define SSLSetRsaBlinding _SSLSetRsaBlinding
787 #define SSLGetRsaBlinding _SSLGetRsaBlinding
788 #define SSLNewContext _SSLNewContext
789 #define SSLNewDatagramContext _SSLNewDatagramContext
790 #define SSLDisposeContext _SSLDisposeContext
792 #endif /* TARGET_OS_IPHONE */
795 * Map the SSLProtocol enum to an enum capturing the wire format (coreTLS) version.
797 #define SECURITY_HAS_TLS_VERSION_TRANSLATOR 1
799 _SSLProtocolVersionToWireFormatValue (SSLProtocol protocol
);
803 * Create a new Datagram TLS session context.
804 * Use in place of SSLNewContext to create a DTLS session.
805 * Deprecated: please use the allocator based functions, when available.
806 * Also note: the symbol is prefixed with underscore in iOS (historical)
809 SSLNewDatagramContext (Boolean isServer
,
810 SSLContextRef
*dtlsContextPtr
) API_UNAVAILABLE(macCatalyst
); /* RETURNED */
817 * If used, must be by client and server before SSLHandshake()
819 * Client: if set the client will announce NPN extension in the
820 * ClientHello, and the a callback will provide the server list, at
821 * that time the client needs to call SSLSetNPNData() in the callback
822 * to provide to the server the support mechanism.
824 * Server: the callback will tell the server that the client supports
825 * NPN and at that time, the server needs to set the supported NPN
826 * types with SSLSetNPNData().
829 (*SSLNPNFunc
) (SSLContextRef ctx
,
830 void *info
, /* info pointer provided by SSLSetNPNFunc */
832 size_t npnDataLength
);
836 SSLSetNPNFunc (SSLContextRef context
,
839 __OSX_AVAILABLE_STARTING(__MAC_10_10
, __IPHONE_8_0
);
842 * For servers, this is the data that is announced.
843 * For clients, this is the picked data in the npnFunc callback.
845 * Return an error on out of memory and if buffer it too large
848 SSLSetNPNData (SSLContextRef context
,
851 __OSX_AVAILABLE_STARTING(__MAC_10_10
, __IPHONE_8_0
);
854 * For servers, return client provided npn data if sent
857 SSLGetNPNData (SSLContextRef context
,
859 __OSX_AVAILABLE_STARTING(__MAC_10_10
, __IPHONE_8_0
);
863 (*SSLALPNFunc
) (SSLContextRef ctx
,
864 void *info
, /* info pointer provided by SSLSetALPNFunc */
865 const void *alpnData
,
866 size_t alpnDataLength
);
869 SSLSetALPNFunc (SSLContextRef context
,
870 SSLALPNFunc alpnFunc
,
872 __OSX_AVAILABLE_STARTING(__MAC_10_11
, __IPHONE_9_0
);
876 SSLSetALPNData (SSLContextRef context
,
879 __OSX_AVAILABLE_STARTING(__MAC_10_11
, __IPHONE_9_0
);
882 SSLGetALPNData (SSLContextRef context
,
884 __OSX_AVAILABLE_STARTING(__MAC_10_11
, __IPHONE_9_0
);
893 #endif /* _SECURE_TRANSPORT_PRIV_H_ */