-
Notifications
You must be signed in to change notification settings - Fork 16
/
tls.h
2635 lines (2150 loc) · 85 KB
/
tls.h
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
/**
* @file tls.h
* @brief TLS (Transport Layer Security)
*
* @section License
*
* SPDX-License-Identifier: GPL-2.0-or-later
*
* Copyright (C) 2010-2024 Oryx Embedded SARL. All rights reserved.
*
* This file is part of CycloneSSL Open.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* @author Oryx Embedded SARL (www.oryx-embedded.com)
* @version 2.4.4
**/
#ifndef _TLS_H
#define _TLS_H
//Forward declaration of TlsContext structure
struct _TlsContext;
#define TlsContext struct _TlsContext
//Forward declaration of TlsEncryptionEngine structure
struct _TlsEncryptionEngine;
#define TlsEncryptionEngine struct _TlsEncryptionEngine
//Dependencies
#include "core/crypto.h"
#include "mac/hmac.h"
#include "aead/aead_algorithms.h"
#include "pkc/key_exch_algorithms.h"
#include "pkc/rsa.h"
#include "pkc/dsa.h"
#include "ecc/ecdsa.h"
#include "pkix/x509_common.h"
#include "tls_config.h"
#include "tls_legacy.h"
#include "tls13_misc.h"
#include "dtls_misc.h"
/*
* CycloneSSL Open is licensed under GPL version 2. In particular:
*
* - If you link your program to CycloneSSL Open, the result is a derivative
* work that can only be distributed under the same GPL license terms.
*
* - If additions or changes to CycloneSSL Open are made, the result is a
* derivative work that can only be distributed under the same license terms.
*
* - The GPL license requires that you make the source code available to
* whoever you make the binary available to.
*
* - If you sell or distribute a hardware product that runs CycloneSSL Open,
* the GPL license requires you to provide public and full access to all
* source code on a nondiscriminatory basis.
*
* If you fully understand and accept the terms of the GPL license, then edit
* the os_port_config.h header and add the following directive:
*
* #define GPL_LICENSE_TERMS_ACCEPTED
*/
#ifndef GPL_LICENSE_TERMS_ACCEPTED
#error Before compiling CycloneSSL Open, you must accept the terms of the GPL license
#endif
//Version string
#define CYCLONE_SSL_VERSION_STRING "2.4.4"
//Major version
#define CYCLONE_SSL_MAJOR_VERSION 2
//Minor version
#define CYCLONE_SSL_MINOR_VERSION 4
//Revision number
#define CYCLONE_SSL_REV_NUMBER 4
//TLS version numbers
#define SSL_VERSION_3_0 0x0300
#define TLS_VERSION_1_0 0x0301
#define TLS_VERSION_1_1 0x0302
#define TLS_VERSION_1_2 0x0303
#define TLS_VERSION_1_3 0x0304
//TLS support
#ifndef TLS_SUPPORT
#define TLS_SUPPORT ENABLED
#elif (TLS_SUPPORT != ENABLED && TLS_SUPPORT != DISABLED)
#error TLS_SUPPORT parameter is not valid
#endif
//Client mode of operation
#ifndef TLS_CLIENT_SUPPORT
#define TLS_CLIENT_SUPPORT ENABLED
#elif (TLS_CLIENT_SUPPORT != ENABLED && TLS_CLIENT_SUPPORT != DISABLED)
#error TLS_CLIENT_SUPPORT parameter is not valid
#endif
//Server mode of operation
#ifndef TLS_SERVER_SUPPORT
#define TLS_SERVER_SUPPORT ENABLED
#elif (TLS_SERVER_SUPPORT != ENABLED && TLS_SERVER_SUPPORT != DISABLED)
#error TLS_SERVER_SUPPORT parameter is not valid
#endif
//Minimum TLS version that can be negotiated
#ifndef TLS_MIN_VERSION
#define TLS_MIN_VERSION TLS_VERSION_1_2
#elif (TLS_MIN_VERSION < TLS_VERSION_1_0)
#error TLS_MIN_VERSION parameter is not valid
#endif
//Maximum TLS version that can be negotiated
#ifndef TLS_MAX_VERSION
#define TLS_MAX_VERSION TLS_VERSION_1_3
#elif (TLS_MAX_VERSION > TLS_VERSION_1_3 || TLS_MAX_VERSION < TLS_MIN_VERSION)
#error TLS_MAX_VERSION parameter is not valid
#endif
//Session resumption mechanism
#ifndef TLS_SESSION_RESUME_SUPPORT
#define TLS_SESSION_RESUME_SUPPORT ENABLED
#elif (TLS_SESSION_RESUME_SUPPORT != ENABLED && TLS_SESSION_RESUME_SUPPORT != DISABLED)
#error TLS_SESSION_RESUME_SUPPORT parameter is not valid
#endif
//Lifetime of session cache entries
#ifndef TLS_SESSION_CACHE_LIFETIME
#define TLS_SESSION_CACHE_LIFETIME 3600000
#elif (TLS_SESSION_CACHE_LIFETIME < 1000)
#error TLS_SESSION_CACHE_LIFETIME parameter is not valid
#endif
//Session ticket mechanism
#ifndef TLS_TICKET_SUPPORT
#define TLS_TICKET_SUPPORT DISABLED
#elif (TLS_TICKET_SUPPORT != ENABLED && TLS_TICKET_SUPPORT != DISABLED)
#error TLS_TICKET_SUPPORT parameter is not valid
#endif
//Maximum size for session tickets
#ifndef TLS_MAX_TICKET_SIZE
#define TLS_MAX_TICKET_SIZE 1024
#elif (TLS_MAX_TICKET_SIZE < 32)
#error TLS_MAX_TICKET_SIZE parameter is not valid
#endif
//Lifetime of session tickets
#ifndef TLS_TICKET_LIFETIME
#define TLS_TICKET_LIFETIME 3600000
#elif (TLS_TICKET_LIFETIME < 0)
#error TLS_TICKET_LIFETIME parameter is not valid
#endif
//SNI (Server Name Indication) extension
#ifndef TLS_SNI_SUPPORT
#define TLS_SNI_SUPPORT ENABLED
#elif (TLS_SNI_SUPPORT != ENABLED && TLS_SNI_SUPPORT != DISABLED)
#error TLS_SNI_SUPPORT parameter is not valid
#endif
//Maximum Fragment Length extension
#ifndef TLS_MAX_FRAG_LEN_SUPPORT
#define TLS_MAX_FRAG_LEN_SUPPORT DISABLED
#elif (TLS_MAX_FRAG_LEN_SUPPORT != ENABLED && TLS_MAX_FRAG_LEN_SUPPORT != DISABLED)
#error TLS_MAX_FRAG_LEN_SUPPORT parameter is not valid
#endif
//Record Size Limit extension
#ifndef TLS_RECORD_SIZE_LIMIT_SUPPORT
#define TLS_RECORD_SIZE_LIMIT_SUPPORT ENABLED
#elif (TLS_RECORD_SIZE_LIMIT_SUPPORT != ENABLED && TLS_RECORD_SIZE_LIMIT_SUPPORT != DISABLED)
#error TLS_RECORD_SIZE_LIMIT_SUPPORT parameter is not valid
#endif
//ALPN (Application-Layer Protocol Negotiation) extension
#ifndef TLS_ALPN_SUPPORT
#define TLS_ALPN_SUPPORT DISABLED
#elif (TLS_ALPN_SUPPORT != ENABLED && TLS_ALPN_SUPPORT != DISABLED)
#error TLS_ALPN_SUPPORT parameter is not valid
#endif
//Encrypt-then-MAC extension
#ifndef TLS_ENCRYPT_THEN_MAC_SUPPORT
#define TLS_ENCRYPT_THEN_MAC_SUPPORT DISABLED
#elif (TLS_ENCRYPT_THEN_MAC_SUPPORT != ENABLED && TLS_ENCRYPT_THEN_MAC_SUPPORT != DISABLED)
#error TLS_ENCRYPT_THEN_MAC_SUPPORT parameter is not valid
#endif
//Extended Master Secret extension
#ifndef TLS_EXT_MASTER_SECRET_SUPPORT
#define TLS_EXT_MASTER_SECRET_SUPPORT ENABLED
#elif (TLS_EXT_MASTER_SECRET_SUPPORT != ENABLED && TLS_EXT_MASTER_SECRET_SUPPORT != DISABLED)
#error TLS_EXT_MASTER_SECRET_SUPPORT parameter is not valid
#endif
//ClientHello Padding extension
#ifndef TLS_CLIENT_HELLO_PADDING_SUPPORT
#define TLS_CLIENT_HELLO_PADDING_SUPPORT ENABLED
#elif (TLS_CLIENT_HELLO_PADDING_SUPPORT != ENABLED && TLS_CLIENT_HELLO_PADDING_SUPPORT != DISABLED)
#error TLS_CLIENT_HELLO_PADDING_SUPPORT parameter is not valid
#endif
//Certificate Authorities extension
#ifndef TLS_CERT_AUTHORITIES_SUPPORT
#define TLS_CERT_AUTHORITIES_SUPPORT DISABLED
#elif (TLS_CERT_AUTHORITIES_SUPPORT != ENABLED && TLS_CERT_AUTHORITIES_SUPPORT != DISABLED)
#error TLS_CERT_AUTHORITIES_SUPPORT parameter is not valid
#endif
//Signature Algorithms Certificate extension
#ifndef TLS_SIGN_ALGOS_CERT_SUPPORT
#define TLS_SIGN_ALGOS_CERT_SUPPORT DISABLED
#elif (TLS_SIGN_ALGOS_CERT_SUPPORT != ENABLED && TLS_SIGN_ALGOS_CERT_SUPPORT != DISABLED)
#error TLS_SIGN_ALGOS_CERT_SUPPORT parameter is not valid
#endif
//RPK (Raw Public Key) support
#ifndef TLS_RAW_PUBLIC_KEY_SUPPORT
#define TLS_RAW_PUBLIC_KEY_SUPPORT DISABLED
#elif (TLS_RAW_PUBLIC_KEY_SUPPORT != ENABLED && TLS_RAW_PUBLIC_KEY_SUPPORT != DISABLED)
#error TLS_RAW_PUBLIC_KEY_SUPPORT parameter is not valid
#endif
//Secure renegotiation support
#ifndef TLS_SECURE_RENEGOTIATION_SUPPORT
#define TLS_SECURE_RENEGOTIATION_SUPPORT ENABLED
#elif (TLS_SECURE_RENEGOTIATION_SUPPORT != ENABLED && TLS_SECURE_RENEGOTIATION_SUPPORT != DISABLED)
#error TLS_SECURE_RENEGOTIATION_SUPPORT parameter is not valid
#endif
//Fallback SCSV support
#ifndef TLS_FALLBACK_SCSV_SUPPORT
#define TLS_FALLBACK_SCSV_SUPPORT DISABLED
#elif (TLS_FALLBACK_SCSV_SUPPORT != ENABLED && TLS_FALLBACK_SCSV_SUPPORT != DISABLED)
#error TLS_FALLBACK_SCSV_SUPPORT parameter is not valid
#endif
//ECC callback functions
#ifndef TLS_ECC_CALLBACK_SUPPORT
#define TLS_ECC_CALLBACK_SUPPORT DISABLED
#elif (TLS_ECC_CALLBACK_SUPPORT != ENABLED && TLS_ECC_CALLBACK_SUPPORT != DISABLED)
#error TLS_ECC_CALLBACK_SUPPORT parameter is not valid
#endif
//Maximum number of certificates the end entity can load
#ifndef TLS_MAX_CERTIFICATES
#define TLS_MAX_CERTIFICATES 3
#elif (TLS_MAX_CERTIFICATES < 1)
#error TLS_MAX_CERTIFICATES parameter is not valid
#endif
//RSA key exchange support
#ifndef TLS_RSA_KE_SUPPORT
#define TLS_RSA_KE_SUPPORT ENABLED
#elif (TLS_RSA_KE_SUPPORT != ENABLED && TLS_RSA_KE_SUPPORT != DISABLED)
#error TLS_RSA_KE_SUPPORT parameter is not valid
#endif
//DHE_RSA key exchange support
#ifndef TLS_DHE_RSA_KE_SUPPORT
#define TLS_DHE_RSA_KE_SUPPORT ENABLED
#elif (TLS_DHE_RSA_KE_SUPPORT != ENABLED && TLS_DHE_RSA_KE_SUPPORT != DISABLED)
#error TLS_DHE_RSA_KE_SUPPORT parameter is not valid
#endif
//DHE_DSS key exchange support
#ifndef TLS_DHE_DSS_KE_SUPPORT
#define TLS_DHE_DSS_KE_SUPPORT DISABLED
#elif (TLS_DHE_DSS_KE_SUPPORT != ENABLED && TLS_DHE_DSS_KE_SUPPORT != DISABLED)
#error TLS_DHE_DSS_KE_SUPPORT parameter is not valid
#endif
//DH_anon key exchange support (insecure)
#ifndef TLS_DH_ANON_KE_SUPPORT
#define TLS_DH_ANON_KE_SUPPORT DISABLED
#elif (TLS_DH_ANON_KE_SUPPORT != ENABLED && TLS_DH_ANON_KE_SUPPORT != DISABLED)
#error TLS_DH_ANON_KE_SUPPORT parameter is not valid
#endif
//ECDHE_RSA key exchange support
#ifndef TLS_ECDHE_RSA_KE_SUPPORT
#define TLS_ECDHE_RSA_KE_SUPPORT ENABLED
#elif (TLS_ECDHE_RSA_KE_SUPPORT != ENABLED && TLS_ECDHE_RSA_KE_SUPPORT != DISABLED)
#error TLS_ECDHE_RSA_KE_SUPPORT parameter is not valid
#endif
//ECDHE_ECDSA key exchange support
#ifndef TLS_ECDHE_ECDSA_KE_SUPPORT
#define TLS_ECDHE_ECDSA_KE_SUPPORT ENABLED
#elif (TLS_ECDHE_ECDSA_KE_SUPPORT != ENABLED && TLS_ECDHE_ECDSA_KE_SUPPORT != DISABLED)
#error TLS_ECDHE_ECDSA_KE_SUPPORT parameter is not valid
#endif
//ECDH_anon key exchange support (insecure)
#ifndef TLS_ECDH_ANON_KE_SUPPORT
#define TLS_ECDH_ANON_KE_SUPPORT DISABLED
#elif (TLS_ECDH_ANON_KE_SUPPORT != ENABLED && TLS_ECDH_ANON_KE_SUPPORT != DISABLED)
#error TLS_ECDH_ANON_KE_SUPPORT parameter is not valid
#endif
//PSK key exchange support
#ifndef TLS_PSK_KE_SUPPORT
#define TLS_PSK_KE_SUPPORT DISABLED
#elif (TLS_PSK_KE_SUPPORT != ENABLED && TLS_PSK_KE_SUPPORT != DISABLED)
#error TLS_PSK_KE_SUPPORT parameter is not valid
#endif
//RSA_PSK key exchange support
#ifndef TLS_RSA_PSK_KE_SUPPORT
#define TLS_RSA_PSK_KE_SUPPORT DISABLED
#elif (TLS_RSA_PSK_KE_SUPPORT != ENABLED && TLS_RSA_PSK_KE_SUPPORT != DISABLED)
#error TLS_RSA_PSK_KE_SUPPORT parameter is not valid
#endif
//DHE_PSK key exchange support
#ifndef TLS_DHE_PSK_KE_SUPPORT
#define TLS_DHE_PSK_KE_SUPPORT DISABLED
#elif (TLS_DHE_PSK_KE_SUPPORT != ENABLED && TLS_DHE_PSK_KE_SUPPORT != DISABLED)
#error TLS_DHE_PSK_KE_SUPPORT parameter is not valid
#endif
//ECDHE_PSK key exchange support
#ifndef TLS_ECDHE_PSK_KE_SUPPORT
#define TLS_ECDHE_PSK_KE_SUPPORT DISABLED
#elif (TLS_ECDHE_PSK_KE_SUPPORT != ENABLED && TLS_ECDHE_PSK_KE_SUPPORT != DISABLED)
#error TLS_ECDHE_PSK_KE_SUPPORT parameter is not valid
#endif
//RSA signature capability
#ifndef TLS_RSA_SIGN_SUPPORT
#define TLS_RSA_SIGN_SUPPORT ENABLED
#elif (TLS_RSA_SIGN_SUPPORT != ENABLED && TLS_RSA_SIGN_SUPPORT != DISABLED)
#error TLS_RSA_SIGN_SUPPORT parameter is not valid
#endif
//RSA-PSS signature capability
#ifndef TLS_RSA_PSS_SIGN_SUPPORT
#define TLS_RSA_PSS_SIGN_SUPPORT ENABLED
#elif (TLS_RSA_PSS_SIGN_SUPPORT != ENABLED && TLS_RSA_PSS_SIGN_SUPPORT != DISABLED)
#error TLS_RSA_PSS_SIGN_SUPPORT parameter is not valid
#endif
//DSA signature capability
#ifndef TLS_DSA_SIGN_SUPPORT
#define TLS_DSA_SIGN_SUPPORT DISABLED
#elif (TLS_DSA_SIGN_SUPPORT != ENABLED && TLS_DSA_SIGN_SUPPORT != DISABLED)
#error TLS_DSA_SIGN_SUPPORT parameter is not valid
#endif
//ECDSA signature capability
#ifndef TLS_ECDSA_SIGN_SUPPORT
#define TLS_ECDSA_SIGN_SUPPORT ENABLED
#elif (TLS_ECDSA_SIGN_SUPPORT != ENABLED && TLS_ECDSA_SIGN_SUPPORT != DISABLED)
#error TLS_ECDSA_SIGN_SUPPORT parameter is not valid
#endif
//SM2 signature capability (not recommended by the IETF)
#ifndef TLS_SM2_SIGN_SUPPORT
#define TLS_SM2_SIGN_SUPPORT DISABLED
#elif (TLS_SM2_SIGN_SUPPORT != ENABLED && TLS_SM2_SIGN_SUPPORT != DISABLED)
#error TLS_SM2_SIGN_SUPPORT parameter is not valid
#endif
//Ed25519 signature capability
#ifndef TLS_ED25519_SIGN_SUPPORT
#define TLS_ED25519_SIGN_SUPPORT DISABLED
#elif (TLS_ED25519_SIGN_SUPPORT != ENABLED && TLS_ED25519_SIGN_SUPPORT != DISABLED)
#error TLS_ED25519_SIGN_SUPPORT parameter is not valid
#endif
//Ed448 signature capability
#ifndef TLS_ED448_SIGN_SUPPORT
#define TLS_ED448_SIGN_SUPPORT DISABLED
#elif (TLS_ED448_SIGN_SUPPORT != ENABLED && TLS_ED448_SIGN_SUPPORT != DISABLED)
#error TLS_ED448_SIGN_SUPPORT parameter is not valid
#endif
//NULL cipher support (insecure)
#ifndef TLS_NULL_CIPHER_SUPPORT
#define TLS_NULL_CIPHER_SUPPORT DISABLED
#elif (TLS_NULL_CIPHER_SUPPORT != ENABLED && TLS_NULL_CIPHER_SUPPORT != DISABLED)
#error TLS_NULL_CIPHER_SUPPORT parameter is not valid
#endif
//Stream cipher support
#ifndef TLS_STREAM_CIPHER_SUPPORT
#define TLS_STREAM_CIPHER_SUPPORT DISABLED
#elif (TLS_STREAM_CIPHER_SUPPORT != ENABLED && TLS_STREAM_CIPHER_SUPPORT != DISABLED)
#error TLS_STREAM_CIPHER_SUPPORT parameter is not valid
#endif
//CBC block cipher support
#ifndef TLS_CBC_CIPHER_SUPPORT
#define TLS_CBC_CIPHER_SUPPORT ENABLED
#elif (TLS_CBC_CIPHER_SUPPORT != ENABLED && TLS_CBC_CIPHER_SUPPORT != DISABLED)
#error TLS_CBC_CIPHER_SUPPORT parameter is not valid
#endif
//CCM AEAD support
#ifndef TLS_CCM_CIPHER_SUPPORT
#define TLS_CCM_CIPHER_SUPPORT DISABLED
#elif (TLS_CCM_CIPHER_SUPPORT != ENABLED && TLS_CCM_CIPHER_SUPPORT != DISABLED)
#error TLS_CCM_CIPHER_SUPPORT parameter is not valid
#endif
//CCM_8 AEAD support
#ifndef TLS_CCM_8_CIPHER_SUPPORT
#define TLS_CCM_8_CIPHER_SUPPORT DISABLED
#elif (TLS_CCM_8_CIPHER_SUPPORT != ENABLED && TLS_CCM_8_CIPHER_SUPPORT != DISABLED)
#error TLS_CCM_8_CIPHER_SUPPORT parameter is not valid
#endif
//GCM AEAD support
#ifndef TLS_GCM_CIPHER_SUPPORT
#define TLS_GCM_CIPHER_SUPPORT ENABLED
#elif (TLS_GCM_CIPHER_SUPPORT != ENABLED && TLS_GCM_CIPHER_SUPPORT != DISABLED)
#error TLS_GCM_CIPHER_SUPPORT parameter is not valid
#endif
//ChaCha20Poly1305 AEAD support
#ifndef TLS_CHACHA20_POLY1305_SUPPORT
#define TLS_CHACHA20_POLY1305_SUPPORT DISABLED
#elif (TLS_CHACHA20_POLY1305_SUPPORT != ENABLED && TLS_CHACHA20_POLY1305_SUPPORT != DISABLED)
#error TLS_CHACHA20_POLY1305_SUPPORT parameter is not valid
#endif
//RC4 cipher support (insecure)
#ifndef TLS_RC4_SUPPORT
#define TLS_RC4_SUPPORT DISABLED
#elif (TLS_RC4_SUPPORT != ENABLED && TLS_RC4_SUPPORT != DISABLED)
#error TLS_RC4_SUPPORT parameter is not valid
#endif
//IDEA cipher support (insecure)
#ifndef TLS_IDEA_SUPPORT
#define TLS_IDEA_SUPPORT DISABLED
#elif (TLS_IDEA_SUPPORT != ENABLED && TLS_IDEA_SUPPORT != DISABLED)
#error TLS_IDEA_SUPPORT parameter is not valid
#endif
//DES cipher support (insecure)
#ifndef TLS_DES_SUPPORT
#define TLS_DES_SUPPORT DISABLED
#elif (TLS_DES_SUPPORT != ENABLED && TLS_DES_SUPPORT != DISABLED)
#error TLS_DES_SUPPORT parameter is not valid
#endif
//Triple DES cipher support (weak)
#ifndef TLS_3DES_SUPPORT
#define TLS_3DES_SUPPORT DISABLED
#elif (TLS_3DES_SUPPORT != ENABLED && TLS_3DES_SUPPORT != DISABLED)
#error TLS_3DES_SUPPORT parameter is not valid
#endif
//AES 128-bit cipher support
#ifndef TLS_AES_128_SUPPORT
#define TLS_AES_128_SUPPORT ENABLED
#elif (TLS_AES_128_SUPPORT != ENABLED && TLS_AES_128_SUPPORT != DISABLED)
#error TLS_AES_128_SUPPORT parameter is not valid
#endif
//AES 256-bit cipher support
#ifndef TLS_AES_256_SUPPORT
#define TLS_AES_256_SUPPORT ENABLED
#elif (TLS_AES_256_SUPPORT != ENABLED && TLS_AES_256_SUPPORT != DISABLED)
#error TLS_AES_256_SUPPORT parameter is not valid
#endif
//Camellia 128-bit cipher support
#ifndef TLS_CAMELLIA_128_SUPPORT
#define TLS_CAMELLIA_128_SUPPORT DISABLED
#elif (TLS_CAMELLIA_128_SUPPORT != ENABLED && TLS_CAMELLIA_128_SUPPORT != DISABLED)
#error TLS_CAMELLIA_128_SUPPORT parameter is not valid
#endif
//Camellia 256-bit cipher support
#ifndef TLS_CAMELLIA_256_SUPPORT
#define TLS_CAMELLIA_256_SUPPORT DISABLED
#elif (TLS_CAMELLIA_256_SUPPORT != ENABLED && TLS_CAMELLIA_256_SUPPORT != DISABLED)
#error TLS_CAMELLIA_256_SUPPORT parameter is not valid
#endif
//ARIA 128-bit cipher support
#ifndef TLS_ARIA_128_SUPPORT
#define TLS_ARIA_128_SUPPORT DISABLED
#elif (TLS_ARIA_128_SUPPORT != ENABLED && TLS_ARIA_128_SUPPORT != DISABLED)
#error TLS_ARIA_128_SUPPORT parameter is not valid
#endif
//ARIA 256-bit cipher support
#ifndef TLS_ARIA_256_SUPPORT
#define TLS_ARIA_256_SUPPORT DISABLED
#elif (TLS_ARIA_256_SUPPORT != ENABLED && TLS_ARIA_256_SUPPORT != DISABLED)
#error TLS_ARIA_256_SUPPORT parameter is not valid
#endif
//SEED cipher support
#ifndef TLS_SEED_SUPPORT
#define TLS_SEED_SUPPORT DISABLED
#elif (TLS_SEED_SUPPORT != ENABLED && TLS_SEED_SUPPORT != DISABLED)
#error TLS_SEED_SUPPORT parameter is not valid
#endif
//SM4 cipher support (not recommended by the IETF)
#ifndef TLS_SM4_SUPPORT
#define TLS_SM4_SUPPORT DISABLED
#elif (TLS_SM4_SUPPORT != ENABLED && TLS_SM4_SUPPORT != DISABLED)
#error TLS_SM4_SUPPORT parameter is not valid
#endif
//MD5 hash support (insecure)
#ifndef TLS_MD5_SUPPORT
#define TLS_MD5_SUPPORT DISABLED
#elif (TLS_MD5_SUPPORT != ENABLED && TLS_MD5_SUPPORT != DISABLED)
#error TLS_MD5_SUPPORT parameter is not valid
#endif
//SHA-1 hash support (weak)
#ifndef TLS_SHA1_SUPPORT
#define TLS_SHA1_SUPPORT ENABLED
#elif (TLS_SHA1_SUPPORT != ENABLED && TLS_SHA1_SUPPORT != DISABLED)
#error TLS_SHA1_SUPPORT parameter is not valid
#endif
//SHA-224 hash support (weak)
#ifndef TLS_SHA224_SUPPORT
#define TLS_SHA224_SUPPORT DISABLED
#elif (TLS_SHA224_SUPPORT != ENABLED && TLS_SHA224_SUPPORT != DISABLED)
#error TLS_SHA224_SUPPORT parameter is not valid
#endif
//SHA-256 hash support
#ifndef TLS_SHA256_SUPPORT
#define TLS_SHA256_SUPPORT ENABLED
#elif (TLS_SHA256_SUPPORT != ENABLED && TLS_SHA256_SUPPORT != DISABLED)
#error TLS_SHA256_SUPPORT parameter is not valid
#endif
//SHA-384 hash support
#ifndef TLS_SHA384_SUPPORT
#define TLS_SHA384_SUPPORT ENABLED
#elif (TLS_SHA384_SUPPORT != ENABLED && TLS_SHA384_SUPPORT != DISABLED)
#error TLS_SHA384_SUPPORT parameter is not valid
#endif
//SHA-512 hash support
#ifndef TLS_SHA512_SUPPORT
#define TLS_SHA512_SUPPORT DISABLED
#elif (TLS_SHA512_SUPPORT != ENABLED && TLS_SHA512_SUPPORT != DISABLED)
#error TLS_SHA512_SUPPORT parameter is not valid
#endif
//SM3 hash support (not recommended by the IETF)
#ifndef TLS_SM3_SUPPORT
#define TLS_SM3_SUPPORT DISABLED
#elif (TLS_SM3_SUPPORT != ENABLED && TLS_SM3_SUPPORT != DISABLED)
#error TLS_SM3_SUPPORT parameter is not valid
#endif
//FFDHE key exchange mechanism
#ifndef TLS_FFDHE_SUPPORT
#define TLS_FFDHE_SUPPORT DISABLED
#elif (TLS_FFDHE_SUPPORT != ENABLED && TLS_FFDHE_SUPPORT != DISABLED)
#error TLS_FFDHE_SUPPORT parameter is not valid
#endif
//ffdhe2048 group support
#ifndef TLS_FFDHE2048_SUPPORT
#define TLS_FFDHE2048_SUPPORT ENABLED
#elif (TLS_FFDHE2048_SUPPORT != ENABLED && TLS_FFDHE2048_SUPPORT != DISABLED)
#error TLS_FFDHE2048_SUPPORT parameter is not valid
#endif
//ffdhe3072 group support
#ifndef TLS_FFDHE3072_SUPPORT
#define TLS_FFDHE3072_SUPPORT DISABLED
#elif (TLS_FFDHE3072_SUPPORT != ENABLED && TLS_FFDHE3072_SUPPORT != DISABLED)
#error TLS_FFDHE3072_SUPPORT parameter is not valid
#endif
//ffdhe4096 group support
#ifndef TLS_FFDHE4096_SUPPORT
#define TLS_FFDHE4096_SUPPORT DISABLED
#elif (TLS_FFDHE4096_SUPPORT != ENABLED && TLS_FFDHE4096_SUPPORT != DISABLED)
#error TLS_FFDHE4096_SUPPORT parameter is not valid
#endif
//secp160k1 elliptic curve support (weak)
#ifndef TLS_SECP160K1_SUPPORT
#define TLS_SECP160K1_SUPPORT DISABLED
#elif (TLS_SECP160K1_SUPPORT != ENABLED && TLS_SECP160K1_SUPPORT != DISABLED)
#error TLS_SECP160K1_SUPPORT parameter is not valid
#endif
//secp160r1 elliptic curve support (weak)
#ifndef TLS_SECP160R1_SUPPORT
#define TLS_SECP160R1_SUPPORT DISABLED
#elif (TLS_SECP160R1_SUPPORT != ENABLED && TLS_SECP160R1_SUPPORT != DISABLED)
#error TLS_SECP160R1_SUPPORT parameter is not valid
#endif
//secp160r2 elliptic curve support (weak)
#ifndef TLS_SECP160R2_SUPPORT
#define TLS_SECP160R2_SUPPORT DISABLED
#elif (TLS_SECP160R2_SUPPORT != ENABLED && TLS_SECP160R2_SUPPORT != DISABLED)
#error TLS_SECP160R2_SUPPORT parameter is not valid
#endif
//secp192k1 elliptic curve support
#ifndef TLS_SECP192K1_SUPPORT
#define TLS_SECP192K1_SUPPORT DISABLED
#elif (TLS_SECP192K1_SUPPORT != ENABLED && TLS_SECP192K1_SUPPORT != DISABLED)
#error TLS_SECP192K1_SUPPORT parameter is not valid
#endif
//secp192r1 elliptic curve support (NIST P-192)
#ifndef TLS_SECP192R1_SUPPORT
#define TLS_SECP192R1_SUPPORT DISABLED
#elif (TLS_SECP192R1_SUPPORT != ENABLED && TLS_SECP192R1_SUPPORT != DISABLED)
#error TLS_SECP192R1_SUPPORT parameter is not valid
#endif
//secp224k1 elliptic curve support
#ifndef TLS_SECP224K1_SUPPORT
#define TLS_SECP224K1_SUPPORT DISABLED
#elif (TLS_SECP224K1_SUPPORT != ENABLED && TLS_SECP224K1_SUPPORT != DISABLED)
#error TLS_SECP224K1_SUPPORT parameter is not valid
#endif
//secp224r1 elliptic curve support (NIST P-224)
#ifndef TLS_SECP224R1_SUPPORT
#define TLS_SECP224R1_SUPPORT DISABLED
#elif (TLS_SECP224R1_SUPPORT != ENABLED && TLS_SECP224R1_SUPPORT != DISABLED)
#error TLS_SECP224R1_SUPPORT parameter is not valid
#endif
//secp256k1 elliptic curve support
#ifndef TLS_SECP256K1_SUPPORT
#define TLS_SECP256K1_SUPPORT DISABLED
#elif (TLS_SECP256K1_SUPPORT != ENABLED && TLS_SECP256K1_SUPPORT != DISABLED)
#error TLS_SECP256K1_SUPPORT parameter is not valid
#endif
//secp256r1 elliptic curve support (NIST P-256)
#ifndef TLS_SECP256R1_SUPPORT
#define TLS_SECP256R1_SUPPORT ENABLED
#elif (TLS_SECP256R1_SUPPORT != ENABLED && TLS_SECP256R1_SUPPORT != DISABLED)
#error TLS_SECP256R1_SUPPORT parameter is not valid
#endif
//secp384r1 elliptic curve support (NIST P-384)
#ifndef TLS_SECP384R1_SUPPORT
#define TLS_SECP384R1_SUPPORT ENABLED
#elif (TLS_SECP384R1_SUPPORT != ENABLED && TLS_SECP384R1_SUPPORT != DISABLED)
#error TLS_SECP384R1_SUPPORT parameter is not valid
#endif
//secp521r1 elliptic curve support (NIST P-521)
#ifndef TLS_SECP521R1_SUPPORT
#define TLS_SECP521R1_SUPPORT DISABLED
#elif (TLS_SECP521R1_SUPPORT != ENABLED && TLS_SECP521R1_SUPPORT != DISABLED)
#error TLS_SECP521R1_SUPPORT parameter is not valid
#endif
//brainpoolP256r1 elliptic curve support
#ifndef TLS_BRAINPOOLP256R1_SUPPORT
#define TLS_BRAINPOOLP256R1_SUPPORT DISABLED
#elif (TLS_BRAINPOOLP256R1_SUPPORT != ENABLED && TLS_BRAINPOOLP256R1_SUPPORT != DISABLED)
#error TLS_BRAINPOOLP256R1_SUPPORT parameter is not valid
#endif
//brainpoolP384r1 elliptic curve support
#ifndef TLS_BRAINPOOLP384R1_SUPPORT
#define TLS_BRAINPOOLP384R1_SUPPORT DISABLED
#elif (TLS_BRAINPOOLP384R1_SUPPORT != ENABLED && TLS_BRAINPOOLP384R1_SUPPORT != DISABLED)
#error TLS_BRAINPOOLP384R1_SUPPORT parameter is not valid
#endif
//brainpoolP512r1 elliptic curve support
#ifndef TLS_BRAINPOOLP512R1_SUPPORT
#define TLS_BRAINPOOLP512R1_SUPPORT DISABLED
#elif (TLS_BRAINPOOLP512R1_SUPPORT != ENABLED && TLS_BRAINPOOLP512R1_SUPPORT != DISABLED)
#error TLS_BRAINPOOLP512R1_SUPPORT parameter is not valid
#endif
//SM2 elliptic curve support (not recommended by the IETF)
#ifndef TLS_SM2_SUPPORT
#define TLS_SM2_SUPPORT DISABLED
#elif (TLS_SM2_SUPPORT != ENABLED && TLS_SM2_SUPPORT != DISABLED)
#error TLS_SM2_SUPPORT parameter is not valid
#endif
//Curve25519 elliptic curve support
#ifndef TLS_X25519_SUPPORT
#define TLS_X25519_SUPPORT DISABLED
#elif (TLS_X25519_SUPPORT != ENABLED && TLS_X25519_SUPPORT != DISABLED)
#error TLS_X25519_SUPPORT parameter is not valid
#endif
//Curve448 elliptic curve support
#ifndef TLS_X448_SUPPORT
#define TLS_X448_SUPPORT DISABLED
#elif (TLS_X448_SUPPORT != ENABLED && TLS_X448_SUPPORT != DISABLED)
#error TLS_X448_SUPPORT parameter is not valid
#endif
//ML-KEM-768 key encapsulation method
#ifndef TLS_MLKEM768_SUPPORT
#define TLS_MLKEM768_SUPPORT DISABLED
#elif (TLS_MLKEM768_SUPPORT != ENABLED && TLS_MLKEM768_SUPPORT != DISABLED)
#error TLS_MLKEM768_SUPPORT parameter is not valid
#endif
//Certificate key usage verification
#ifndef TLS_CERT_KEY_USAGE_SUPPORT
#define TLS_CERT_KEY_USAGE_SUPPORT ENABLED
#elif (TLS_CERT_KEY_USAGE_SUPPORT != ENABLED && TLS_CERT_KEY_USAGE_SUPPORT != DISABLED)
#error TLS_CERT_KEY_USAGE_SUPPORT parameter is not valid
#endif
//Key logging (for debugging purpose only)
#ifndef TLS_KEY_LOG_SUPPORT
#define TLS_KEY_LOG_SUPPORT DISABLED
#elif (TLS_KEY_LOG_SUPPORT != ENABLED && TLS_KEY_LOG_SUPPORT != DISABLED)
#error TLS_KEY_LOG_SUPPORT parameter is not valid
#endif
//Maximum length of server name
#ifndef TLS_MAX_SERVER_NAME_LEN
#define TLS_MAX_SERVER_NAME_LEN 255
#elif (TLS_MAX_SERVER_NAME_LEN < 1)
#error TLS_MAX_SERVER_NAME_LEN parameter is not valid
#endif
//Maximum length of password
#ifndef TLS_MAX_PASSWORD_LEN
#define TLS_MAX_PASSWORD_LEN 32
#elif (TLS_MAX_PASSWORD_LEN < 0)
#error TLS_MAX_PASSWORD_LEN parameter is not valid
#endif
//Minimum acceptable size for Diffie-Hellman prime modulus
#ifndef TLS_MIN_DH_MODULUS_SIZE
#define TLS_MIN_DH_MODULUS_SIZE 1024
#elif (TLS_MIN_DH_MODULUS_SIZE < 512)
#error TLS_MIN_DH_MODULUS_SIZE parameter is not valid
#endif
//Maximum acceptable size for Diffie-Hellman prime modulus
#ifndef TLS_MAX_DH_MODULUS_SIZE
#define TLS_MAX_DH_MODULUS_SIZE 2048
#elif (TLS_MAX_DH_MODULUS_SIZE < TLS_MIN_DH_MODULUS_SIZE)
#error TLS_MAX_DH_MODULUS_SIZE parameter is not valid
#endif
//Minimum acceptable size for RSA modulus
#ifndef TLS_MIN_RSA_MODULUS_SIZE
#define TLS_MIN_RSA_MODULUS_SIZE 1024
#elif (TLS_MIN_RSA_MODULUS_SIZE < 512)
#error TLS_MIN_RSA_MODULUS_SIZE parameter is not valid
#endif
//Maximum acceptable size for RSA modulus
#ifndef TLS_MAX_RSA_MODULUS_SIZE
#define TLS_MAX_RSA_MODULUS_SIZE 4096
#elif (TLS_MAX_RSA_MODULUS_SIZE < TLS_MIN_RSA_MODULUS_SIZE)
#error TLS_MAX_RSA_MODULUS_SIZE parameter is not valid
#endif
//Minimum acceptable size for DSA prime modulus
#ifndef TLS_MIN_DSA_MODULUS_SIZE
#define TLS_MIN_DSA_MODULUS_SIZE 1024
#elif (TLS_MIN_DSA_MODULUS_SIZE < 512)
#error TLS_MIN_DSA_MODULUS_SIZE parameter is not valid
#endif
//Maximum acceptable size for DSA prime modulus
#ifndef TLS_MAX_DSA_MODULUS_SIZE
#define TLS_MAX_DSA_MODULUS_SIZE 4096
#elif (TLS_MAX_DSA_MODULUS_SIZE < TLS_MIN_DSA_MODULUS_SIZE)
#error TLS_MAX_DSA_MODULUS_SIZE parameter is not valid
#endif
//Master secret size
#ifndef TLS_MASTER_SECRET_SIZE
#define TLS_MASTER_SECRET_SIZE 48
#elif (TLS_MASTER_SECRET_SIZE < 48)
#error TLS_MASTER_SECRET_SIZE parameter is not valid
#endif
//Maximum size for premaster secret
#ifndef TLS_PREMASTER_SECRET_SIZE
#define TLS_PREMASTER_SECRET_SIZE (TLS_MAX_DH_MODULUS_SIZE / 8)
#elif (TLS_PREMASTER_SECRET_SIZE < 48)
#error TLS_PREMASTER_SECRET_SIZE parameter is not valid
#endif
//Maximum number of consecutive warning alerts
#ifndef TLS_MAX_WARNING_ALERTS
#define TLS_MAX_WARNING_ALERTS 5
#elif (TLS_MAX_WARNING_ALERTS < 0)
#error TLS_MAX_WARNING_ALERTS parameter is not valid
#endif
//Maximum number of consecutive empty records
#ifndef TLS_MAX_EMPTY_RECORDS
#define TLS_MAX_EMPTY_RECORDS 10
#elif (TLS_MAX_EMPTY_RECORDS < 0)
#error TLS_MAX_EMPTY_RECORDS parameter is not valid
#endif
//Maximum number of consecutive ChangeCipherSpec messages
#ifndef TLS_MAX_CHANGE_CIPHER_SPEC_MESSAGES
#define TLS_MAX_CHANGE_CIPHER_SPEC_MESSAGES 5
#elif (TLS_MAX_CHANGE_CIPHER_SPEC_MESSAGES < 0)
#error TLS_MAX_CHANGE_CIPHER_SPEC_MESSAGES parameter is not valid
#endif
//Maximum number of consecutive KeyUpdate messages
#ifndef TLS_MAX_KEY_UPDATE_MESSAGES
#define TLS_MAX_KEY_UPDATE_MESSAGES 5
#elif (TLS_MAX_KEY_UPDATE_MESSAGES < 0)
#error TLS_MAX_KEY_UPDATE_MESSAGES parameter is not valid
#endif
//Application specific context (TLS context)
#ifndef TLS_PRIVATE_CONTEXT
#define TLS_PRIVATE_CONTEXT
#endif
//Application specific context (encryption engine)
#ifndef TLS_PRIVATE_ENCRYPTION_ENGINE
#define TLS_PRIVATE_ENCRYPTION_ENGINE
#endif
//Allocate memory block
#ifndef tlsAllocMem
#define tlsAllocMem(size) osAllocMem(size)
#endif
//Deallocate memory block
#ifndef tlsFreeMem
#define tlsFreeMem(p) osFreeMem(p)
#endif
//Support for Diffie-Hellman key exchange?
#if ((TLS_MAX_VERSION >= TLS_VERSION_1_0 && TLS_MIN_VERSION <= TLS_VERSION_1_2) && \
(TLS_DH_ANON_KE_SUPPORT == ENABLED || TLS_DHE_RSA_KE_SUPPORT == ENABLED || \
TLS_DHE_DSS_KE_SUPPORT == ENABLED || TLS_DHE_PSK_KE_SUPPORT == ENABLED))
#define TLS_DH_SUPPORT ENABLED
#elif ((TLS_MAX_VERSION >= TLS_VERSION_1_3 && TLS_MIN_VERSION <= TLS_VERSION_1_3) && \
(TLS13_DHE_KE_SUPPORT == ENABLED || TLS13_PSK_DHE_KE_SUPPORT == ENABLED))
#define TLS_DH_SUPPORT ENABLED
#else
#define TLS_DH_SUPPORT DISABLED
#endif
//Support for ECDH key exchange?
#if ((TLS_MAX_VERSION >= TLS_VERSION_1_0 && TLS_MIN_VERSION <= TLS_VERSION_1_2) && \
(TLS_ECDH_ANON_KE_SUPPORT == ENABLED || TLS_ECDHE_RSA_KE_SUPPORT == ENABLED || \
TLS_ECDHE_ECDSA_KE_SUPPORT == ENABLED || TLS_ECDHE_PSK_KE_SUPPORT == ENABLED))
#define TLS_ECDH_SUPPORT ENABLED
#elif ((TLS_MAX_VERSION >= TLS_VERSION_1_3 && TLS_MIN_VERSION <= TLS_VERSION_1_3) && \
(TLS13_ECDHE_KE_SUPPORT == ENABLED || TLS13_PSK_ECDHE_KE_SUPPORT == ENABLED))
#define TLS_ECDH_SUPPORT ENABLED
#else
#define TLS_ECDH_SUPPORT DISABLED
#endif
//Support for hybrid key exchange?
#if ((TLS_MAX_VERSION >= TLS_VERSION_1_3 && TLS_MIN_VERSION <= TLS_VERSION_1_3) && \
(TLS13_HYBRID_KE_SUPPORT == ENABLED || TLS13_PSK_HYBRID_KE_SUPPORT == ENABLED))
#define TLS_HYBRID_SUPPORT ENABLED
#else
#define TLS_HYBRID_SUPPORT DISABLED
#endif
//Support for RSA?
#if ((TLS_MAX_VERSION >= TLS_VERSION_1_0 && TLS_MIN_VERSION <= TLS_VERSION_1_2) && \
(TLS_RSA_SIGN_SUPPORT == ENABLED || TLS_RSA_PSS_SIGN_SUPPORT == ENABLED || \
TLS_RSA_KE_SUPPORT == ENABLED || TLS_DHE_RSA_KE_SUPPORT == ENABLED || \
TLS_ECDHE_RSA_KE_SUPPORT == ENABLED || TLS_RSA_PSK_KE_SUPPORT == ENABLED))
#define TLS_RSA_SUPPORT ENABLED
#elif ((TLS_MAX_VERSION >= TLS_VERSION_1_3 && TLS_MIN_VERSION <= TLS_VERSION_1_3) && \
(TLS_RSA_SIGN_SUPPORT == ENABLED || TLS_RSA_PSS_SIGN_SUPPORT == ENABLED))
#define TLS_RSA_SUPPORT ENABLED
#else
#define TLS_RSA_SUPPORT DISABLED
#endif
//Support for PSK?
#if ((TLS_MAX_VERSION >= TLS_VERSION_1_0 && TLS_MIN_VERSION <= TLS_VERSION_1_2) && \
(TLS_PSK_KE_SUPPORT == ENABLED || TLS_RSA_PSK_KE_SUPPORT == ENABLED || \
TLS_DHE_PSK_KE_SUPPORT == ENABLED || TLS_ECDHE_PSK_KE_SUPPORT == ENABLED))
#define TLS_PSK_SUPPORT ENABLED
#elif ((TLS_MAX_VERSION >= TLS_VERSION_1_3 && TLS_MIN_VERSION <= TLS_VERSION_1_3) && \
(TLS13_PSK_KE_SUPPORT == ENABLED || TLS13_PSK_DHE_KE_SUPPORT == ENABLED || \
TLS13_PSK_ECDHE_KE_SUPPORT == ENABLED || TLS13_PSK_HYBRID_KE_SUPPORT == ENABLED))
#define TLS_PSK_SUPPORT ENABLED
#else
#define TLS_PSK_SUPPORT DISABLED
#endif
//Maximum size for HKDF digests
#if (TLS_SHA384_SUPPORT == ENABLED)
#define TLS_MAX_HKDF_DIGEST_SIZE 48
#else
#define TLS_MAX_HKDF_DIGEST_SIZE 32
#endif
//Bind TLS to a particular socket
#define tlsSetSocket(context, socket) tlsSetSocketCallbacks(context, \
(TlsSocketSendCallback) socketSend, (TlsSocketReceiveCallback) socketReceive, \
(TlsSocketHandle) socket)
//Minimum plaintext record length
#define TLS_MIN_RECORD_LENGTH 512
//Maximum plaintext record length
#define TLS_MAX_RECORD_LENGTH 16384
//Data overhead caused by record encryption
#define TLS_MAX_RECORD_OVERHEAD 512
//Size of client and server random values
#define TLS_RANDOM_SIZE 32
//TLS signature scheme definition
#define TLS_SIGN_SCHEME(signAlgo, hashAlgo) \
((TlsSignatureScheme) (((hashAlgo) << 8) | (signAlgo)))
//C++ guard
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief TLS transport protocols
**/
typedef enum
{
TLS_TRANSPORT_PROTOCOL_STREAM = 0,
TLS_TRANSPORT_PROTOCOL_DATAGRAM = 1,
TLS_TRANSPORT_PROTOCOL_EAP = 2
} TlsTransportProtocol;
/**
* @brief TLS connection end
**/
typedef enum
{
TLS_CONNECTION_END_CLIENT = 0,
TLS_CONNECTION_END_SERVER = 1
} TlsConnectionEnd;
/**
* @brief Client authentication mode
**/
typedef enum
{
TLS_CLIENT_AUTH_NONE = 0,
TLS_CLIENT_AUTH_OPTIONAL = 1,
TLS_CLIENT_AUTH_REQUIRED = 2
} TlsClientAuthMode;
/**
* @brief Early data status
**/
typedef enum
{
TLS_EARLY_DATA_REJECTED = 0,
TLS_EARLY_DATA_ACCEPTED = 1
} TlsEarlyDataStatus;
/**
* @brief Flags used by read and write functions
**/
typedef enum