-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsectransp.c
3505 lines (3195 loc) · 125 KB
/
sectransp.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) Daniel Stenberg, <[email protected]>, et al.
* Copyright (C) Nick Zitzmann, <[email protected]>.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
/*
* Source file for all iOS and macOS SecureTransport-specific code for the
* TLS/SSL layer. No code but vtls.c should ever call or use these functions.
*/
#include "curl_setup.h"
#include "urldata.h" /* for the Curl_easy definition */
#include "curl_base64.h"
#include "strtok.h"
#include "multiif.h"
#include "strcase.h"
#include "x509asn1.h"
#include "strerror.h"
#ifdef USE_SECTRANSP
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wtautological-pointer-compare"
#endif /* __clang__ */
#ifdef __GNUC__
#pragma GCC diagnostic ignored "-Waddress"
#pragma GCC diagnostic ignored "-Wundef"
#endif
#include <limits.h>
#include <Security/Security.h>
/* For some reason, when building for iOS, the omnibus header above does
* not include SecureTransport.h as of iOS SDK 5.1. */
#include <Security/SecureTransport.h>
#include <CoreFoundation/CoreFoundation.h>
#include <CommonCrypto/CommonDigest.h>
/* The Security framework has changed greatly between iOS and different macOS
versions, and we will try to support as many of them as we can (back to
Leopard and iOS 5) by using macros and weak-linking.
In general, you want to build this using the most recent OS SDK, since some
features require curl to be built against the latest SDK. TLS 1.1 and 1.2
support, for instance, require the macOS 10.8 SDK or later. TLS 1.3
requires the macOS 10.13 or iOS 11 SDK or later. */
#if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE))
#if MAC_OS_X_VERSION_MAX_ALLOWED < 1050
#error "The Secure Transport back-end requires Leopard or later."
#endif /* MAC_OS_X_VERSION_MAX_ALLOWED < 1050 */
#define CURL_BUILD_IOS 0
#define CURL_BUILD_IOS_7 0
#define CURL_BUILD_IOS_9 0
#define CURL_BUILD_IOS_11 0
#define CURL_BUILD_IOS_13 0
#define CURL_BUILD_MAC 1
/* This is the maximum API level we are allowed to use when building: */
#define CURL_BUILD_MAC_10_5 MAC_OS_X_VERSION_MAX_ALLOWED >= 1050
#define CURL_BUILD_MAC_10_6 MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
#define CURL_BUILD_MAC_10_7 MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
#define CURL_BUILD_MAC_10_8 MAC_OS_X_VERSION_MAX_ALLOWED >= 1080
#define CURL_BUILD_MAC_10_9 MAC_OS_X_VERSION_MAX_ALLOWED >= 1090
#define CURL_BUILD_MAC_10_11 MAC_OS_X_VERSION_MAX_ALLOWED >= 101100
#define CURL_BUILD_MAC_10_13 MAC_OS_X_VERSION_MAX_ALLOWED >= 101300
#define CURL_BUILD_MAC_10_15 MAC_OS_X_VERSION_MAX_ALLOWED >= 101500
/* These macros mean "the following code is present to allow runtime backward
compatibility with at least this cat or earlier":
(You set this at build-time using the compiler command line option
"-mmacosx-version-min.") */
#define CURL_SUPPORT_MAC_10_5 MAC_OS_X_VERSION_MIN_REQUIRED <= 1050
#define CURL_SUPPORT_MAC_10_6 MAC_OS_X_VERSION_MIN_REQUIRED <= 1060
#define CURL_SUPPORT_MAC_10_7 MAC_OS_X_VERSION_MIN_REQUIRED <= 1070
#define CURL_SUPPORT_MAC_10_8 MAC_OS_X_VERSION_MIN_REQUIRED <= 1080
#define CURL_SUPPORT_MAC_10_9 MAC_OS_X_VERSION_MIN_REQUIRED <= 1090
#elif TARGET_OS_EMBEDDED || TARGET_OS_IPHONE
#define CURL_BUILD_IOS 1
#define CURL_BUILD_IOS_7 __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000
#define CURL_BUILD_IOS_9 __IPHONE_OS_VERSION_MAX_ALLOWED >= 90000
#define CURL_BUILD_IOS_11 __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000
#define CURL_BUILD_IOS_13 __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
#define CURL_BUILD_MAC 0
#define CURL_BUILD_MAC_10_5 0
#define CURL_BUILD_MAC_10_6 0
#define CURL_BUILD_MAC_10_7 0
#define CURL_BUILD_MAC_10_8 0
#define CURL_BUILD_MAC_10_9 0
#define CURL_BUILD_MAC_10_11 0
#define CURL_BUILD_MAC_10_13 0
#define CURL_BUILD_MAC_10_15 0
#define CURL_SUPPORT_MAC_10_5 0
#define CURL_SUPPORT_MAC_10_6 0
#define CURL_SUPPORT_MAC_10_7 0
#define CURL_SUPPORT_MAC_10_8 0
#define CURL_SUPPORT_MAC_10_9 0
#else
#error "The Secure Transport back-end requires iOS or macOS."
#endif /* (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)) */
#if CURL_BUILD_MAC
#include <sys/sysctl.h>
#endif /* CURL_BUILD_MAC */
#include "sendf.h"
#include "inet_pton.h"
#include "connect.h"
#include "select.h"
#include "vtls.h"
#include "vtls_int.h"
#include "sectransp.h"
#include "curl_printf.h"
#include "strdup.h"
#include "curl_memory.h"
/* The last #include file should be: */
#include "memdebug.h"
/* From MacTypes.h (which we can't include because it isn't present in iOS: */
#define ioErr -36
#define paramErr -50
struct st_ssl_backend_data {
SSLContextRef ssl_ctx;
bool ssl_direction; /* true if writing, false if reading */
size_t ssl_write_buffered_length;
};
struct st_cipher {
const char *name; /* Cipher suite IANA name. It starts with "TLS_" prefix */
const char *alias_name; /* Alias name is the same as OpenSSL cipher name */
SSLCipherSuite num; /* Cipher suite code/number defined in IANA registry */
bool weak; /* Flag to mark cipher as weak based on previous implementation
of Secure Transport back-end by CURL */
};
/* Macro to initialize st_cipher data structure: stringify id to name, cipher
number/id, 'weak' suite flag
*/
#define CIPHER_DEF(num, alias, weak) \
{ #num, alias, num, weak }
/*
Macro to initialize st_cipher data structure with name, code (IANA cipher
number/id value), and 'weak' suite flag. The first 28 cipher suite numbers
have the same IANA code for both SSL and TLS standards: numbers 0x0000 to
0x001B. They have different names though. The first 4 letters of the cipher
suite name are the protocol name: "SSL_" or "TLS_", rest of the IANA name is
the same for both SSL and TLS cipher suite name.
The second part of the problem is that macOS/iOS SDKs don't define all TLS
codes but only 12 of them. The SDK defines all SSL codes though, i.e. SSL_NUM
constant is always defined for those 28 ciphers while TLS_NUM is defined only
for 12 of the first 28 ciphers. Those 12 TLS cipher codes match to
corresponding SSL enum value and represent the same cipher suite. Therefore
we'll use the SSL enum value for those cipher suites because it is defined
for all 28 of them.
We make internal data consistent and based on TLS names, i.e. all st_cipher
item names start with the "TLS_" prefix.
Summarizing all the above, those 28 first ciphers are presented in our table
with both TLS and SSL names. Their cipher numbers are assigned based on the
SDK enum value for the SSL cipher, which matches to IANA TLS number.
*/
#define CIPHER_DEF_SSLTLS(num_wo_prefix, alias, weak) \
{ "TLS_" #num_wo_prefix, alias, SSL_##num_wo_prefix, weak }
/*
Cipher suites were marked as weak based on the following:
RC4 encryption - rfc7465, the document contains a list of deprecated ciphers.
Marked in the code below as weak.
RC2 encryption - many mentions, was found vulnerable to a relatively easy
attack https://link.springer.com/chapter/10.1007%2F3-540-69710-1_14
Marked in the code below as weak.
DES and IDEA encryption - rfc5469, has a list of deprecated ciphers.
Marked in the code below as weak.
Anonymous Diffie-Hellman authentication and anonymous elliptic curve
Diffie-Hellman - vulnerable to a man-in-the-middle attack. Deprecated by
RFC 4346 aka TLS 1.1 (section A.5, page 60)
Null bulk encryption suites - not encrypted communication
Export ciphers, i.e. ciphers with restrictions to be used outside the US for
software exported to some countries, they were excluded from TLS 1.1
version. More precisely, they were noted as ciphers which MUST NOT be
negotiated in RFC 4346 aka TLS 1.1 (section A.5, pages 60 and 61).
All of those filters were considered weak because they contain a weak
algorithm like DES, RC2 or RC4, and already considered weak by other
criteria.
3DES - NIST deprecated it and is going to retire it by 2023
https://csrc.nist.gov/News/2017/Update-to-Current-Use-and-Deprecation-of-TDEA
OpenSSL https://www.openssl.org/blog/blog/2016/08/24/sweet32/ also
deprecated those ciphers. Some other libraries also consider it
vulnerable or at least not strong enough.
CBC ciphers are vulnerable with SSL3.0 and TLS1.0:
https://www.cisco.com/c/en/us/support/docs/security/email-security-appliance
/118518-technote-esa-00.html
We don't take care of this issue because it is resolved by later TLS
versions and for us, it requires more complicated checks, we need to
check a protocol version also. Vulnerability doesn't look very critical
and we do not filter out those cipher suites.
*/
#define CIPHER_WEAK_NOT_ENCRYPTED TRUE
#define CIPHER_WEAK_RC_ENCRYPTION TRUE
#define CIPHER_WEAK_DES_ENCRYPTION TRUE
#define CIPHER_WEAK_IDEA_ENCRYPTION TRUE
#define CIPHER_WEAK_ANON_AUTH TRUE
#define CIPHER_WEAK_3DES_ENCRYPTION TRUE
#define CIPHER_STRONG_ENOUGH FALSE
/* Please do not change the order of the first ciphers available for SSL.
Do not insert and do not delete any of them. Code below
depends on their order and continuity.
If you add a new cipher, please maintain order by number, i.e.
insert in between existing items to appropriate place based on
cipher suite IANA number
*/
static const struct st_cipher ciphertable[] = {
/* SSL version 3.0 and initial TLS 1.0 cipher suites.
Defined since SDK 10.2.8 */
CIPHER_DEF_SSLTLS(NULL_WITH_NULL_NULL, /* 0x0000 */
NULL,
CIPHER_WEAK_NOT_ENCRYPTED),
CIPHER_DEF_SSLTLS(RSA_WITH_NULL_MD5, /* 0x0001 */
"NULL-MD5",
CIPHER_WEAK_NOT_ENCRYPTED),
CIPHER_DEF_SSLTLS(RSA_WITH_NULL_SHA, /* 0x0002 */
"NULL-SHA",
CIPHER_WEAK_NOT_ENCRYPTED),
CIPHER_DEF_SSLTLS(RSA_EXPORT_WITH_RC4_40_MD5, /* 0x0003 */
"EXP-RC4-MD5",
CIPHER_WEAK_RC_ENCRYPTION),
CIPHER_DEF_SSLTLS(RSA_WITH_RC4_128_MD5, /* 0x0004 */
"RC4-MD5",
CIPHER_WEAK_RC_ENCRYPTION),
CIPHER_DEF_SSLTLS(RSA_WITH_RC4_128_SHA, /* 0x0005 */
"RC4-SHA",
CIPHER_WEAK_RC_ENCRYPTION),
CIPHER_DEF_SSLTLS(RSA_EXPORT_WITH_RC2_CBC_40_MD5, /* 0x0006 */
"EXP-RC2-CBC-MD5",
CIPHER_WEAK_RC_ENCRYPTION),
CIPHER_DEF_SSLTLS(RSA_WITH_IDEA_CBC_SHA, /* 0x0007 */
"IDEA-CBC-SHA",
CIPHER_WEAK_IDEA_ENCRYPTION),
CIPHER_DEF_SSLTLS(RSA_EXPORT_WITH_DES40_CBC_SHA, /* 0x0008 */
"EXP-DES-CBC-SHA",
CIPHER_WEAK_DES_ENCRYPTION),
CIPHER_DEF_SSLTLS(RSA_WITH_DES_CBC_SHA, /* 0x0009 */
"DES-CBC-SHA",
CIPHER_WEAK_DES_ENCRYPTION),
CIPHER_DEF_SSLTLS(RSA_WITH_3DES_EDE_CBC_SHA, /* 0x000A */
"DES-CBC3-SHA",
CIPHER_WEAK_3DES_ENCRYPTION),
CIPHER_DEF_SSLTLS(DH_DSS_EXPORT_WITH_DES40_CBC_SHA, /* 0x000B */
"EXP-DH-DSS-DES-CBC-SHA",
CIPHER_WEAK_DES_ENCRYPTION),
CIPHER_DEF_SSLTLS(DH_DSS_WITH_DES_CBC_SHA, /* 0x000C */
"DH-DSS-DES-CBC-SHA",
CIPHER_WEAK_DES_ENCRYPTION),
CIPHER_DEF_SSLTLS(DH_DSS_WITH_3DES_EDE_CBC_SHA, /* 0x000D */
"DH-DSS-DES-CBC3-SHA",
CIPHER_WEAK_3DES_ENCRYPTION),
CIPHER_DEF_SSLTLS(DH_RSA_EXPORT_WITH_DES40_CBC_SHA, /* 0x000E */
"EXP-DH-RSA-DES-CBC-SHA",
CIPHER_WEAK_DES_ENCRYPTION),
CIPHER_DEF_SSLTLS(DH_RSA_WITH_DES_CBC_SHA, /* 0x000F */
"DH-RSA-DES-CBC-SHA",
CIPHER_WEAK_DES_ENCRYPTION),
CIPHER_DEF_SSLTLS(DH_RSA_WITH_3DES_EDE_CBC_SHA, /* 0x0010 */
"DH-RSA-DES-CBC3-SHA",
CIPHER_WEAK_3DES_ENCRYPTION),
CIPHER_DEF_SSLTLS(DHE_DSS_EXPORT_WITH_DES40_CBC_SHA, /* 0x0011 */
"EXP-EDH-DSS-DES-CBC-SHA",
CIPHER_WEAK_DES_ENCRYPTION),
CIPHER_DEF_SSLTLS(DHE_DSS_WITH_DES_CBC_SHA, /* 0x0012 */
"EDH-DSS-CBC-SHA",
CIPHER_WEAK_DES_ENCRYPTION),
CIPHER_DEF_SSLTLS(DHE_DSS_WITH_3DES_EDE_CBC_SHA, /* 0x0013 */
"DHE-DSS-DES-CBC3-SHA",
CIPHER_WEAK_3DES_ENCRYPTION),
CIPHER_DEF_SSLTLS(DHE_RSA_EXPORT_WITH_DES40_CBC_SHA, /* 0x0014 */
"EXP-EDH-RSA-DES-CBC-SHA",
CIPHER_WEAK_DES_ENCRYPTION),
CIPHER_DEF_SSLTLS(DHE_RSA_WITH_DES_CBC_SHA, /* 0x0015 */
"EDH-RSA-DES-CBC-SHA",
CIPHER_WEAK_DES_ENCRYPTION),
CIPHER_DEF_SSLTLS(DHE_RSA_WITH_3DES_EDE_CBC_SHA, /* 0x0016 */
"DHE-RSA-DES-CBC3-SHA",
CIPHER_WEAK_3DES_ENCRYPTION),
CIPHER_DEF_SSLTLS(DH_anon_EXPORT_WITH_RC4_40_MD5, /* 0x0017 */
"EXP-ADH-RC4-MD5",
CIPHER_WEAK_ANON_AUTH),
CIPHER_DEF_SSLTLS(DH_anon_WITH_RC4_128_MD5, /* 0x0018 */
"ADH-RC4-MD5",
CIPHER_WEAK_ANON_AUTH),
CIPHER_DEF_SSLTLS(DH_anon_EXPORT_WITH_DES40_CBC_SHA, /* 0x0019 */
"EXP-ADH-DES-CBC-SHA",
CIPHER_WEAK_ANON_AUTH),
CIPHER_DEF_SSLTLS(DH_anon_WITH_DES_CBC_SHA, /* 0x001A */
"ADH-DES-CBC-SHA",
CIPHER_WEAK_ANON_AUTH),
CIPHER_DEF_SSLTLS(DH_anon_WITH_3DES_EDE_CBC_SHA, /* 0x001B */
"ADH-DES-CBC3-SHA",
CIPHER_WEAK_3DES_ENCRYPTION),
CIPHER_DEF(SSL_FORTEZZA_DMS_WITH_NULL_SHA, /* 0x001C */
NULL,
CIPHER_WEAK_NOT_ENCRYPTED),
CIPHER_DEF(SSL_FORTEZZA_DMS_WITH_FORTEZZA_CBC_SHA, /* 0x001D */
NULL,
CIPHER_STRONG_ENOUGH),
#if CURL_BUILD_MAC_10_9 || CURL_BUILD_IOS_7
/* RFC 4785 - Pre-Shared Key (PSK) Ciphersuites with NULL Encryption */
CIPHER_DEF(TLS_PSK_WITH_NULL_SHA, /* 0x002C */
"PSK-NULL-SHA",
CIPHER_WEAK_NOT_ENCRYPTED),
CIPHER_DEF(TLS_DHE_PSK_WITH_NULL_SHA, /* 0x002D */
"DHE-PSK-NULL-SHA",
CIPHER_WEAK_NOT_ENCRYPTED),
CIPHER_DEF(TLS_RSA_PSK_WITH_NULL_SHA, /* 0x002E */
"RSA-PSK-NULL-SHA",
CIPHER_WEAK_NOT_ENCRYPTED),
#endif /* CURL_BUILD_MAC_10_9 || CURL_BUILD_IOS_7 */
/* TLS addenda using AES, per RFC 3268. Defined since SDK 10.4u */
CIPHER_DEF(TLS_RSA_WITH_AES_128_CBC_SHA, /* 0x002F */
"AES128-SHA",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_DH_DSS_WITH_AES_128_CBC_SHA, /* 0x0030 */
"DH-DSS-AES128-SHA",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_DH_RSA_WITH_AES_128_CBC_SHA, /* 0x0031 */
"DH-RSA-AES128-SHA",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_DHE_DSS_WITH_AES_128_CBC_SHA, /* 0x0032 */
"DHE-DSS-AES128-SHA",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_DHE_RSA_WITH_AES_128_CBC_SHA, /* 0x0033 */
"DHE-RSA-AES128-SHA",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_DH_anon_WITH_AES_128_CBC_SHA, /* 0x0034 */
"ADH-AES128-SHA",
CIPHER_WEAK_ANON_AUTH),
CIPHER_DEF(TLS_RSA_WITH_AES_256_CBC_SHA, /* 0x0035 */
"AES256-SHA",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_DH_DSS_WITH_AES_256_CBC_SHA, /* 0x0036 */
"DH-DSS-AES256-SHA",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_DH_RSA_WITH_AES_256_CBC_SHA, /* 0x0037 */
"DH-RSA-AES256-SHA",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_DHE_DSS_WITH_AES_256_CBC_SHA, /* 0x0038 */
"DHE-DSS-AES256-SHA",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_DHE_RSA_WITH_AES_256_CBC_SHA, /* 0x0039 */
"DHE-RSA-AES256-SHA",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_DH_anon_WITH_AES_256_CBC_SHA, /* 0x003A */
"ADH-AES256-SHA",
CIPHER_WEAK_ANON_AUTH),
#if CURL_BUILD_MAC_10_8 || CURL_BUILD_IOS
/* TLS 1.2 addenda, RFC 5246 */
/* Server provided RSA certificate for key exchange. */
CIPHER_DEF(TLS_RSA_WITH_NULL_SHA256, /* 0x003B */
"NULL-SHA256",
CIPHER_WEAK_NOT_ENCRYPTED),
CIPHER_DEF(TLS_RSA_WITH_AES_128_CBC_SHA256, /* 0x003C */
"AES128-SHA256",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_RSA_WITH_AES_256_CBC_SHA256, /* 0x003D */
"AES256-SHA256",
CIPHER_STRONG_ENOUGH),
/* Server-authenticated (and optionally client-authenticated)
Diffie-Hellman. */
CIPHER_DEF(TLS_DH_DSS_WITH_AES_128_CBC_SHA256, /* 0x003E */
"DH-DSS-AES128-SHA256",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_DH_RSA_WITH_AES_128_CBC_SHA256, /* 0x003F */
"DH-RSA-AES128-SHA256",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_DHE_DSS_WITH_AES_128_CBC_SHA256, /* 0x0040 */
"DHE-DSS-AES128-SHA256",
CIPHER_STRONG_ENOUGH),
/* TLS 1.2 addenda, RFC 5246 */
CIPHER_DEF(TLS_DHE_RSA_WITH_AES_128_CBC_SHA256, /* 0x0067 */
"DHE-RSA-AES128-SHA256",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_DH_DSS_WITH_AES_256_CBC_SHA256, /* 0x0068 */
"DH-DSS-AES256-SHA256",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_DH_RSA_WITH_AES_256_CBC_SHA256, /* 0x0069 */
"DH-RSA-AES256-SHA256",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_DHE_DSS_WITH_AES_256_CBC_SHA256, /* 0x006A */
"DHE-DSS-AES256-SHA256",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_DHE_RSA_WITH_AES_256_CBC_SHA256, /* 0x006B */
"DHE-RSA-AES256-SHA256",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_DH_anon_WITH_AES_128_CBC_SHA256, /* 0x006C */
"ADH-AES128-SHA256",
CIPHER_WEAK_ANON_AUTH),
CIPHER_DEF(TLS_DH_anon_WITH_AES_256_CBC_SHA256, /* 0x006D */
"ADH-AES256-SHA256",
CIPHER_WEAK_ANON_AUTH),
#endif /* CURL_BUILD_MAC_10_8 || CURL_BUILD_IOS */
#if CURL_BUILD_MAC_10_9 || CURL_BUILD_IOS_7
/* Addendum from RFC 4279, TLS PSK */
CIPHER_DEF(TLS_PSK_WITH_RC4_128_SHA, /* 0x008A */
"PSK-RC4-SHA",
CIPHER_WEAK_RC_ENCRYPTION),
CIPHER_DEF(TLS_PSK_WITH_3DES_EDE_CBC_SHA, /* 0x008B */
"PSK-3DES-EDE-CBC-SHA",
CIPHER_WEAK_3DES_ENCRYPTION),
CIPHER_DEF(TLS_PSK_WITH_AES_128_CBC_SHA, /* 0x008C */
"PSK-AES128-CBC-SHA",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_PSK_WITH_AES_256_CBC_SHA, /* 0x008D */
"PSK-AES256-CBC-SHA",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_DHE_PSK_WITH_RC4_128_SHA, /* 0x008E */
"DHE-PSK-RC4-SHA",
CIPHER_WEAK_RC_ENCRYPTION),
CIPHER_DEF(TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA, /* 0x008F */
"DHE-PSK-3DES-EDE-CBC-SHA",
CIPHER_WEAK_3DES_ENCRYPTION),
CIPHER_DEF(TLS_DHE_PSK_WITH_AES_128_CBC_SHA, /* 0x0090 */
"DHE-PSK-AES128-CBC-SHA",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_DHE_PSK_WITH_AES_256_CBC_SHA, /* 0x0091 */
"DHE-PSK-AES256-CBC-SHA",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_RSA_PSK_WITH_RC4_128_SHA, /* 0x0092 */
"RSA-PSK-RC4-SHA",
CIPHER_WEAK_RC_ENCRYPTION),
CIPHER_DEF(TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA, /* 0x0093 */
"RSA-PSK-3DES-EDE-CBC-SHA",
CIPHER_WEAK_3DES_ENCRYPTION),
CIPHER_DEF(TLS_RSA_PSK_WITH_AES_128_CBC_SHA, /* 0x0094 */
"RSA-PSK-AES128-CBC-SHA",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_RSA_PSK_WITH_AES_256_CBC_SHA, /* 0x0095 */
"RSA-PSK-AES256-CBC-SHA",
CIPHER_STRONG_ENOUGH),
#endif /* CURL_BUILD_MAC_10_9 || CURL_BUILD_IOS_7 */
#if CURL_BUILD_MAC_10_8 || CURL_BUILD_IOS
/* Addenda from rfc 5288 AES Galois Counter Mode (GCM) Cipher Suites
for TLS. */
CIPHER_DEF(TLS_RSA_WITH_AES_128_GCM_SHA256, /* 0x009C */
"AES128-GCM-SHA256",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_RSA_WITH_AES_256_GCM_SHA384, /* 0x009D */
"AES256-GCM-SHA384",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, /* 0x009E */
"DHE-RSA-AES128-GCM-SHA256",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_DHE_RSA_WITH_AES_256_GCM_SHA384, /* 0x009F */
"DHE-RSA-AES256-GCM-SHA384",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_DH_RSA_WITH_AES_128_GCM_SHA256, /* 0x00A0 */
"DH-RSA-AES128-GCM-SHA256",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_DH_RSA_WITH_AES_256_GCM_SHA384, /* 0x00A1 */
"DH-RSA-AES256-GCM-SHA384",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_DHE_DSS_WITH_AES_128_GCM_SHA256, /* 0x00A2 */
"DHE-DSS-AES128-GCM-SHA256",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_DHE_DSS_WITH_AES_256_GCM_SHA384, /* 0x00A3 */
"DHE-DSS-AES256-GCM-SHA384",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_DH_DSS_WITH_AES_128_GCM_SHA256, /* 0x00A4 */
"DH-DSS-AES128-GCM-SHA256",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_DH_DSS_WITH_AES_256_GCM_SHA384, /* 0x00A5 */
"DH-DSS-AES256-GCM-SHA384",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_DH_anon_WITH_AES_128_GCM_SHA256, /* 0x00A6 */
"ADH-AES128-GCM-SHA256",
CIPHER_WEAK_ANON_AUTH),
CIPHER_DEF(TLS_DH_anon_WITH_AES_256_GCM_SHA384, /* 0x00A7 */
"ADH-AES256-GCM-SHA384",
CIPHER_WEAK_ANON_AUTH),
#endif /* CURL_BUILD_MAC_10_8 || CURL_BUILD_IOS */
#if CURL_BUILD_MAC_10_9 || CURL_BUILD_IOS_7
/* RFC 5487 - PSK with SHA-256/384 and AES GCM */
CIPHER_DEF(TLS_PSK_WITH_AES_128_GCM_SHA256, /* 0x00A8 */
"PSK-AES128-GCM-SHA256",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_PSK_WITH_AES_256_GCM_SHA384, /* 0x00A9 */
"PSK-AES256-GCM-SHA384",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_DHE_PSK_WITH_AES_128_GCM_SHA256, /* 0x00AA */
"DHE-PSK-AES128-GCM-SHA256",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_DHE_PSK_WITH_AES_256_GCM_SHA384, /* 0x00AB */
"DHE-PSK-AES256-GCM-SHA384",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_RSA_PSK_WITH_AES_128_GCM_SHA256, /* 0x00AC */
"RSA-PSK-AES128-GCM-SHA256",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_RSA_PSK_WITH_AES_256_GCM_SHA384, /* 0x00AD */
"RSA-PSK-AES256-GCM-SHA384",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_PSK_WITH_AES_128_CBC_SHA256, /* 0x00AE */
"PSK-AES128-CBC-SHA256",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_PSK_WITH_AES_256_CBC_SHA384, /* 0x00AF */
"PSK-AES256-CBC-SHA384",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_PSK_WITH_NULL_SHA256, /* 0x00B0 */
"PSK-NULL-SHA256",
CIPHER_WEAK_NOT_ENCRYPTED),
CIPHER_DEF(TLS_PSK_WITH_NULL_SHA384, /* 0x00B1 */
"PSK-NULL-SHA384",
CIPHER_WEAK_NOT_ENCRYPTED),
CIPHER_DEF(TLS_DHE_PSK_WITH_AES_128_CBC_SHA256, /* 0x00B2 */
"DHE-PSK-AES128-CBC-SHA256",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_DHE_PSK_WITH_AES_256_CBC_SHA384, /* 0x00B3 */
"DHE-PSK-AES256-CBC-SHA384",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_DHE_PSK_WITH_NULL_SHA256, /* 0x00B4 */
"DHE-PSK-NULL-SHA256",
CIPHER_WEAK_NOT_ENCRYPTED),
CIPHER_DEF(TLS_DHE_PSK_WITH_NULL_SHA384, /* 0x00B5 */
"DHE-PSK-NULL-SHA384",
CIPHER_WEAK_NOT_ENCRYPTED),
CIPHER_DEF(TLS_RSA_PSK_WITH_AES_128_CBC_SHA256, /* 0x00B6 */
"RSA-PSK-AES128-CBC-SHA256",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_RSA_PSK_WITH_AES_256_CBC_SHA384, /* 0x00B7 */
"RSA-PSK-AES256-CBC-SHA384",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_RSA_PSK_WITH_NULL_SHA256, /* 0x00B8 */
"RSA-PSK-NULL-SHA256",
CIPHER_WEAK_NOT_ENCRYPTED),
CIPHER_DEF(TLS_RSA_PSK_WITH_NULL_SHA384, /* 0x00B9 */
"RSA-PSK-NULL-SHA384",
CIPHER_WEAK_NOT_ENCRYPTED),
#endif /* CURL_BUILD_MAC_10_9 || CURL_BUILD_IOS_7 */
/* RFC 5746 - Secure Renegotiation. This is not a real suite,
it is a response to initiate negotiation again */
CIPHER_DEF(TLS_EMPTY_RENEGOTIATION_INFO_SCSV, /* 0x00FF */
NULL,
CIPHER_STRONG_ENOUGH),
#if CURL_BUILD_MAC_10_13 || CURL_BUILD_IOS_11
/* TLS 1.3 standard cipher suites for ChaCha20+Poly1305.
Note: TLS 1.3 ciphersuites do not specify the key exchange
algorithm -- they only specify the symmetric ciphers.
Cipher alias name matches to OpenSSL cipher name, and for
TLS 1.3 ciphers */
CIPHER_DEF(TLS_AES_128_GCM_SHA256, /* 0x1301 */
NULL, /* The OpenSSL cipher name matches to the IANA name */
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_AES_256_GCM_SHA384, /* 0x1302 */
NULL, /* The OpenSSL cipher name matches to the IANA name */
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_CHACHA20_POLY1305_SHA256, /* 0x1303 */
NULL, /* The OpenSSL cipher name matches to the IANA name */
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_AES_128_CCM_SHA256, /* 0x1304 */
NULL, /* The OpenSSL cipher name matches to the IANA name */
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_AES_128_CCM_8_SHA256, /* 0x1305 */
NULL, /* The OpenSSL cipher name matches to the IANA name */
CIPHER_STRONG_ENOUGH),
#endif /* CURL_BUILD_MAC_10_13 || CURL_BUILD_IOS_11 */
#if CURL_BUILD_MAC_10_6 || CURL_BUILD_IOS
/* ECDSA addenda, RFC 4492 */
CIPHER_DEF(TLS_ECDH_ECDSA_WITH_NULL_SHA, /* 0xC001 */
"ECDH-ECDSA-NULL-SHA",
CIPHER_WEAK_NOT_ENCRYPTED),
CIPHER_DEF(TLS_ECDH_ECDSA_WITH_RC4_128_SHA, /* 0xC002 */
"ECDH-ECDSA-RC4-SHA",
CIPHER_WEAK_RC_ENCRYPTION),
CIPHER_DEF(TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA, /* 0xC003 */
"ECDH-ECDSA-DES-CBC3-SHA",
CIPHER_WEAK_3DES_ENCRYPTION),
CIPHER_DEF(TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA, /* 0xC004 */
"ECDH-ECDSA-AES128-SHA",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA, /* 0xC005 */
"ECDH-ECDSA-AES256-SHA",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_ECDHE_ECDSA_WITH_NULL_SHA, /* 0xC006 */
"ECDHE-ECDSA-NULL-SHA",
CIPHER_WEAK_NOT_ENCRYPTED),
CIPHER_DEF(TLS_ECDHE_ECDSA_WITH_RC4_128_SHA, /* 0xC007 */
"ECDHE-ECDSA-RC4-SHA",
CIPHER_WEAK_RC_ENCRYPTION),
CIPHER_DEF(TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA, /* 0xC008 */
"ECDHE-ECDSA-DES-CBC3-SHA",
CIPHER_WEAK_3DES_ENCRYPTION),
CIPHER_DEF(TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, /* 0xC009 */
"ECDHE-ECDSA-AES128-SHA",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, /* 0xC00A */
"ECDHE-ECDSA-AES256-SHA",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_ECDH_RSA_WITH_NULL_SHA, /* 0xC00B */
"ECDH-RSA-NULL-SHA",
CIPHER_WEAK_NOT_ENCRYPTED),
CIPHER_DEF(TLS_ECDH_RSA_WITH_RC4_128_SHA, /* 0xC00C */
"ECDH-RSA-RC4-SHA",
CIPHER_WEAK_RC_ENCRYPTION),
CIPHER_DEF(TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA, /* 0xC00D */
"ECDH-RSA-DES-CBC3-SHA",
CIPHER_WEAK_3DES_ENCRYPTION),
CIPHER_DEF(TLS_ECDH_RSA_WITH_AES_128_CBC_SHA, /* 0xC00E */
"ECDH-RSA-AES128-SHA",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_ECDH_RSA_WITH_AES_256_CBC_SHA, /* 0xC00F */
"ECDH-RSA-AES256-SHA",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_ECDHE_RSA_WITH_NULL_SHA, /* 0xC010 */
"ECDHE-RSA-NULL-SHA",
CIPHER_WEAK_NOT_ENCRYPTED),
CIPHER_DEF(TLS_ECDHE_RSA_WITH_RC4_128_SHA, /* 0xC011 */
"ECDHE-RSA-RC4-SHA",
CIPHER_WEAK_RC_ENCRYPTION),
CIPHER_DEF(TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA, /* 0xC012 */
"ECDHE-RSA-DES-CBC3-SHA",
CIPHER_WEAK_3DES_ENCRYPTION),
CIPHER_DEF(TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, /* 0xC013 */
"ECDHE-RSA-AES128-SHA",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, /* 0xC014 */
"ECDHE-RSA-AES256-SHA",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_ECDH_anon_WITH_NULL_SHA, /* 0xC015 */
"AECDH-NULL-SHA",
CIPHER_WEAK_ANON_AUTH),
CIPHER_DEF(TLS_ECDH_anon_WITH_RC4_128_SHA, /* 0xC016 */
"AECDH-RC4-SHA",
CIPHER_WEAK_ANON_AUTH),
CIPHER_DEF(TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA, /* 0xC017 */
"AECDH-DES-CBC3-SHA",
CIPHER_WEAK_3DES_ENCRYPTION),
CIPHER_DEF(TLS_ECDH_anon_WITH_AES_128_CBC_SHA, /* 0xC018 */
"AECDH-AES128-SHA",
CIPHER_WEAK_ANON_AUTH),
CIPHER_DEF(TLS_ECDH_anon_WITH_AES_256_CBC_SHA, /* 0xC019 */
"AECDH-AES256-SHA",
CIPHER_WEAK_ANON_AUTH),
#endif /* CURL_BUILD_MAC_10_6 || CURL_BUILD_IOS */
#if CURL_BUILD_MAC_10_8 || CURL_BUILD_IOS
/* Addenda from rfc 5289 Elliptic Curve Cipher Suites with
HMAC SHA-256/384. */
CIPHER_DEF(TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, /* 0xC023 */
"ECDHE-ECDSA-AES128-SHA256",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384, /* 0xC024 */
"ECDHE-ECDSA-AES256-SHA384",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256, /* 0xC025 */
"ECDH-ECDSA-AES128-SHA256",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384, /* 0xC026 */
"ECDH-ECDSA-AES256-SHA384",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, /* 0xC027 */
"ECDHE-RSA-AES128-SHA256",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384, /* 0xC028 */
"ECDHE-RSA-AES256-SHA384",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256, /* 0xC029 */
"ECDH-RSA-AES128-SHA256",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384, /* 0xC02A */
"ECDH-RSA-AES256-SHA384",
CIPHER_STRONG_ENOUGH),
/* Addenda from rfc 5289 Elliptic Curve Cipher Suites with
SHA-256/384 and AES Galois Counter Mode (GCM) */
CIPHER_DEF(TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, /* 0xC02B */
"ECDHE-ECDSA-AES128-GCM-SHA256",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, /* 0xC02C */
"ECDHE-ECDSA-AES256-GCM-SHA384",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256, /* 0xC02D */
"ECDH-ECDSA-AES128-GCM-SHA256",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384, /* 0xC02E */
"ECDH-ECDSA-AES256-GCM-SHA384",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, /* 0xC02F */
"ECDHE-RSA-AES128-GCM-SHA256",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, /* 0xC030 */
"ECDHE-RSA-AES256-GCM-SHA384",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256, /* 0xC031 */
"ECDH-RSA-AES128-GCM-SHA256",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384, /* 0xC032 */
"ECDH-RSA-AES256-GCM-SHA384",
CIPHER_STRONG_ENOUGH),
#endif /* CURL_BUILD_MAC_10_8 || CURL_BUILD_IOS */
#if CURL_BUILD_MAC_10_15 || CURL_BUILD_IOS_13
/* ECDHE_PSK Cipher Suites for Transport Layer Security (TLS), RFC 5489 */
CIPHER_DEF(TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA, /* 0xC035 */
"ECDHE-PSK-AES128-CBC-SHA",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA, /* 0xC036 */
"ECDHE-PSK-AES256-CBC-SHA",
CIPHER_STRONG_ENOUGH),
#endif /* CURL_BUILD_MAC_10_15 || CURL_BUILD_IOS_13 */
#if CURL_BUILD_MAC_10_13 || CURL_BUILD_IOS_11
/* Addenda from rfc 7905 ChaCha20-Poly1305 Cipher Suites for
Transport Layer Security (TLS). */
CIPHER_DEF(TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256, /* 0xCCA8 */
"ECDHE-RSA-CHACHA20-POLY1305",
CIPHER_STRONG_ENOUGH),
CIPHER_DEF(TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256, /* 0xCCA9 */
"ECDHE-ECDSA-CHACHA20-POLY1305",
CIPHER_STRONG_ENOUGH),
#endif /* CURL_BUILD_MAC_10_13 || CURL_BUILD_IOS_11 */
#if CURL_BUILD_MAC_10_15 || CURL_BUILD_IOS_13
/* ChaCha20-Poly1305 Cipher Suites for Transport Layer Security (TLS),
RFC 7905 */
CIPHER_DEF(TLS_PSK_WITH_CHACHA20_POLY1305_SHA256, /* 0xCCAB */
"PSK-CHACHA20-POLY1305",
CIPHER_STRONG_ENOUGH),
#endif /* CURL_BUILD_MAC_10_15 || CURL_BUILD_IOS_13 */
/* Tags for SSL 2 cipher kinds which are not specified for SSL 3.
Defined since SDK 10.2.8 */
CIPHER_DEF(SSL_RSA_WITH_RC2_CBC_MD5, /* 0xFF80 */
NULL,
CIPHER_WEAK_RC_ENCRYPTION),
CIPHER_DEF(SSL_RSA_WITH_IDEA_CBC_MD5, /* 0xFF81 */
NULL,
CIPHER_WEAK_IDEA_ENCRYPTION),
CIPHER_DEF(SSL_RSA_WITH_DES_CBC_MD5, /* 0xFF82 */
NULL,
CIPHER_WEAK_DES_ENCRYPTION),
CIPHER_DEF(SSL_RSA_WITH_3DES_EDE_CBC_MD5, /* 0xFF83 */
NULL,
CIPHER_WEAK_3DES_ENCRYPTION),
};
#define NUM_OF_CIPHERS sizeof(ciphertable)/sizeof(ciphertable[0])
/* pinned public key support tests */
/* version 1 supports macOS 10.12+ and iOS 10+ */
#if ((TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MIN_REQUIRED >= 100000) || \
(!TARGET_OS_IPHONE && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200))
#define SECTRANSP_PINNEDPUBKEY_V1 1
#endif
/* version 2 supports MacOSX 10.7+ */
#if (!TARGET_OS_IPHONE && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070)
#define SECTRANSP_PINNEDPUBKEY_V2 1
#endif
#if defined(SECTRANSP_PINNEDPUBKEY_V1) || defined(SECTRANSP_PINNEDPUBKEY_V2)
/* this backend supports CURLOPT_PINNEDPUBLICKEY */
#define SECTRANSP_PINNEDPUBKEY 1
#endif /* SECTRANSP_PINNEDPUBKEY */
#ifdef SECTRANSP_PINNEDPUBKEY
/* both new and old APIs return rsa keys missing the spki header (not DER) */
static const unsigned char rsa4096SpkiHeader[] = {
0x30, 0x82, 0x02, 0x22, 0x30, 0x0d,
0x06, 0x09, 0x2a, 0x86, 0x48, 0x86,
0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05,
0x00, 0x03, 0x82, 0x02, 0x0f, 0x00};
static const unsigned char rsa2048SpkiHeader[] = {
0x30, 0x82, 0x01, 0x22, 0x30, 0x0d,
0x06, 0x09, 0x2a, 0x86, 0x48, 0x86,
0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05,
0x00, 0x03, 0x82, 0x01, 0x0f, 0x00};
#ifdef SECTRANSP_PINNEDPUBKEY_V1
/* the *new* version doesn't return DER encoded ecdsa certs like the old... */
static const unsigned char ecDsaSecp256r1SpkiHeader[] = {
0x30, 0x59, 0x30, 0x13, 0x06, 0x07,
0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02,
0x01, 0x06, 0x08, 0x2a, 0x86, 0x48,
0xce, 0x3d, 0x03, 0x01, 0x07, 0x03,
0x42, 0x00};
static const unsigned char ecDsaSecp384r1SpkiHeader[] = {
0x30, 0x76, 0x30, 0x10, 0x06, 0x07,
0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02,
0x01, 0x06, 0x05, 0x2b, 0x81, 0x04,
0x00, 0x22, 0x03, 0x62, 0x00};
#endif /* SECTRANSP_PINNEDPUBKEY_V1 */
#endif /* SECTRANSP_PINNEDPUBKEY */
static OSStatus bio_cf_in_read(SSLConnectionRef connection,
void *buf,
size_t *dataLength) /* IN/OUT */
{
struct Curl_cfilter *cf = (struct Curl_cfilter *)connection;
struct ssl_connect_data *connssl = cf->ctx;
struct st_ssl_backend_data *backend =
(struct st_ssl_backend_data *)connssl->backend;
struct Curl_easy *data = CF_DATA_CURRENT(cf);
ssize_t nread;
CURLcode result;
OSStatus rtn = noErr;
DEBUGASSERT(data);
nread = Curl_conn_cf_recv(cf->next, data, buf, *dataLength, &result);
CURL_TRC_CF(data, cf, "bio_read(len=%zu) -> %zd, result=%d",
*dataLength, nread, result);
if(nread < 0) {
switch(result) {
case CURLE_OK:
case CURLE_AGAIN:
rtn = errSSLWouldBlock;
backend->ssl_direction = false;
break;
default:
rtn = ioErr;
break;
}
nread = 0;
}
else if(nread == 0) {
rtn = errSSLClosedGraceful;
}
else if((size_t)nread < *dataLength) {
rtn = errSSLWouldBlock;
}
*dataLength = nread;
return rtn;
}
static OSStatus bio_cf_out_write(SSLConnectionRef connection,
const void *buf,
size_t *dataLength) /* IN/OUT */
{
struct Curl_cfilter *cf = (struct Curl_cfilter *)connection;
struct ssl_connect_data *connssl = cf->ctx;
struct st_ssl_backend_data *backend =
(struct st_ssl_backend_data *)connssl->backend;
struct Curl_easy *data = CF_DATA_CURRENT(cf);
ssize_t nwritten;
CURLcode result;
OSStatus rtn = noErr;
DEBUGASSERT(data);
nwritten = Curl_conn_cf_send(cf->next, data, buf, *dataLength, &result);
CURL_TRC_CF(data, cf, "bio_send(len=%zu) -> %zd, result=%d",
*dataLength, nwritten, result);
if(nwritten <= 0) {
if(result == CURLE_AGAIN) {
rtn = errSSLWouldBlock;
backend->ssl_direction = true;
}
else {
rtn = ioErr;
}
nwritten = 0;
}
else if((size_t)nwritten < *dataLength) {
rtn = errSSLWouldBlock;
}
*dataLength = nwritten;
return rtn;
}
#ifndef CURL_DISABLE_VERBOSE_STRINGS
CF_INLINE const char *TLSCipherNameForNumber(SSLCipherSuite cipher)
{
/* The first ciphers in the ciphertable are continuous. Here we do small
optimization and instead of loop directly get SSL name by cipher number.
*/
size_t i;
if(cipher <= SSL_FORTEZZA_DMS_WITH_FORTEZZA_CBC_SHA) {
return ciphertable[cipher].name;
}
/* Iterate through the rest of the ciphers */
for(i = SSL_FORTEZZA_DMS_WITH_FORTEZZA_CBC_SHA + 1; i < NUM_OF_CIPHERS;
++i) {
if(ciphertable[i].num == cipher) {
return ciphertable[i].name;
}
}
return ciphertable[SSL_NULL_WITH_NULL_NULL].name;
}
#endif /* !CURL_DISABLE_VERBOSE_STRINGS */
#if CURL_BUILD_MAC
CF_INLINE void GetDarwinVersionNumber(int *major, int *minor)
{
int mib[2];
char *os_version;
size_t os_version_len;
char *os_version_major, *os_version_minor;
char *tok_buf;
/* Get the Darwin kernel version from the kernel using sysctl(): */
mib[0] = CTL_KERN;
mib[1] = KERN_OSRELEASE;
if(sysctl(mib, 2, NULL, &os_version_len, NULL, 0) == -1)
return;
os_version = malloc(os_version_len*sizeof(char));
if(!os_version)
return;
if(sysctl(mib, 2, os_version, &os_version_len, NULL, 0) == -1) {
free(os_version);
return;
}
/* Parse the version: */
os_version_major = strtok_r(os_version, ".", &tok_buf);
os_version_minor = strtok_r(NULL, ".", &tok_buf);
*major = atoi(os_version_major);
*minor = atoi(os_version_minor);
free(os_version);
}
#endif /* CURL_BUILD_MAC */
/* Apple provides a myriad of ways of getting information about a certificate
into a string. Some aren't available under iOS or newer cats. So here's
a unified function for getting a string describing the certificate that
ought to work in all cats starting with Leopard. */
CF_INLINE CFStringRef getsubject(SecCertificateRef cert)
{
CFStringRef server_cert_summary = CFSTR("(null)");
#if CURL_BUILD_IOS
/* iOS: There's only one way to do this. */
server_cert_summary = SecCertificateCopySubjectSummary(cert);
#else
#if CURL_BUILD_MAC_10_7
/* Lion & later: Get the long description if we can. */
if(SecCertificateCopyLongDescription)
server_cert_summary =
SecCertificateCopyLongDescription(NULL, cert, NULL);
else
#endif /* CURL_BUILD_MAC_10_7 */
#if CURL_BUILD_MAC_10_6
/* Snow Leopard: Get the certificate summary. */
if(SecCertificateCopySubjectSummary)
server_cert_summary = SecCertificateCopySubjectSummary(cert);
else
#endif /* CURL_BUILD_MAC_10_6 */
/* Leopard is as far back as we go... */
(void)SecCertificateCopyCommonName(cert, &server_cert_summary);
#endif /* CURL_BUILD_IOS */
return server_cert_summary;
}
static CURLcode CopyCertSubject(struct Curl_easy *data,
SecCertificateRef cert, char **certp)
{
CFStringRef c = getsubject(cert);
CURLcode result = CURLE_OK;
const char *direct;
char *cbuf = NULL;
*certp = NULL;
if(!c) {
failf(data, "SSL: invalid CA certificate subject");