This repository was archived by the owner on Dec 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 105
Expand file tree
/
Copy pathWeaveConfig.h
More file actions
2452 lines (2248 loc) · 79 KB
/
Copy pathWeaveConfig.h
File metadata and controls
2452 lines (2248 loc) · 79 KB
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
/*
*
* Copyright (c) 2019 Google LLC.
* Copyright (c) 2013-2018 Nest Labs, Inc.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file
* This file defines default compile-time configuration constants
* for Nest Weave.
*
* Package integrators that wish to override these values should
* either use preprocessor definitions or create a project-
* specific WeaveProjectConfig.h header and then assert
* HAVE_WEAVEPROJECTCONFIG_H via the package configuration tool
* via --with-weave-project-includes=DIR where DIR is the
* directory that contains the header.
*
* NOTE WELL: On some platforms, this header is included by C-language programs.
*
*/
#ifndef WEAVE_CONFIG_H_
#define WEAVE_CONFIG_H_
#include <SystemLayer/SystemConfig.h>
/* COMING SOON: making the INET Layer optional entails making this inclusion optional. */
#include <InetLayer/InetConfig.h>
#if INET_CONFIG_ENABLE_TCP_ENDPOINT && INET_TCP_IDLE_CHECK_INTERVAL <= 0
#error "Weave SDK requires INET_TCP_IDLE_CHECK_INTERVAL > 0"
#endif // INET_CONFIG_ENABLE_TCP_ENDPOINT && INET_TCP_IDLE_CHECK_INTERVAL <= 0
/* Include a project-specific configuration file, if defined.
*
* An application or module that incorporates Weave can define a project configuration
* file to override standard Weave configuration with application-specific values.
* The WeaveProjectConfig.h file is typically located outside the OpenWeave source tree,
* alongside the source code for the application.
*/
#ifdef WEAVE_PROJECT_CONFIG_INCLUDE
#include WEAVE_PROJECT_CONFIG_INCLUDE
#endif
/* Include a platform-specific configuration file, if defined.
*
* A platform configuration file contains overrides to standard Weave configuration
* that are specific to the platform or OS on which Weave is running. It is typically
* provided as apart of an adaptation layer that adapts OpenWeave to the target
* environment. This adaptation layer may be included in the OpenWeave source tree
* itself or implemented externally.
*/
#ifdef WEAVE_PLATFORM_CONFIG_INCLUDE
#include WEAVE_PLATFORM_CONFIG_INCLUDE
#endif
// clang-format off
/**
* @def WEAVE_CONFIG_PROVIDE_OBSOLESCENT_INTERFACES
*
* @brief
* This boolean configuration option is (1) if the obsolescent interfaces
* of the Nest Weave layer are still available for transitional purposes.
*
*/
#ifndef WEAVE_CONFIG_PROVIDE_OBSOLESCENT_INTERFACES
#define WEAVE_CONFIG_PROVIDE_OBSOLESCENT_INTERFACES 0
#endif // WEAVE_CONFIG_PROVIDE_OBSOLESCENT_INTERFACES
// Profile-specific Configuration Headers
#include "WeaveBDXConfig.h"
#include "WeaveDMConfig.h"
#include "WeaveTimeConfig.h"
#include "WeaveTunnelConfig.h"
#include "WeaveEventLoggingConfig.h"
#include "WeaveWRMPConfig.h"
/**
* @def WEAVE_CONFIG_ERROR_TYPE
*
* @brief
* This defines the data type used to represent errors for Weave.
*
*/
#ifndef WEAVE_CONFIG_ERROR_TYPE
#include <stdint.h>
#define WEAVE_CONFIG_ERROR_TYPE int32_t
#endif // WEAVE_CONFIG_ERROR_TYPE
/**
* @def WEAVE_CONFIG_NO_ERROR
*
* @brief
* This defines the Weave error code for no error or success.
*
*/
#ifndef WEAVE_CONFIG_NO_ERROR
#define WEAVE_CONFIG_NO_ERROR 0
#endif // WEAVE_CONFIG_NO_ERROR
/**
* @def WEAVE_CONFIG_ERROR_MIN
*
* @brief
* This defines the base or minimum Weave error number range.
*
*/
#ifndef WEAVE_CONFIG_ERROR_MIN
#define WEAVE_CONFIG_ERROR_MIN 4000
#endif // WEAVE_CONFIG_ERROR_MIN
/**
* @def WEAVE_CONFIG_ERROR_MAX
*
* @brief
* This defines the top or maximum Weave error number range.
*
*/
#ifndef WEAVE_CONFIG_ERROR_MAX
#define WEAVE_CONFIG_ERROR_MAX 4999
#endif // WEAVE_CONFIG_ERROR_MAX
/**
* @def _WEAVE_CONFIG_ERROR
*
* @brief
* This defines a mapping function for Weave errors that allows
* mapping such errors into a platform- or system-specific manner.
*
*/
#ifndef _WEAVE_CONFIG_ERROR
#define _WEAVE_CONFIG_ERROR(e) (WEAVE_ERROR_MIN + (e))
#endif // _WEAVE_CONFIG_ERROR
/**
* @def WEAVE_CONFIG_USE_OPENSSL_ECC
*
* @brief
* Use the OpenSSL implementation of the elliptic curve primitives
* for Weave communication.
*
* Note that this option is mutually exclusive with
* #WEAVE_CONFIG_USE_MICRO_ECC.
*/
#ifndef WEAVE_CONFIG_USE_OPENSSL_ECC
#define WEAVE_CONFIG_USE_OPENSSL_ECC 1
#endif // WEAVE_CONFIG_USE_OPENSSL_ECC
/**
* @def WEAVE_CONFIG_USE_MICRO_ECC
*
* @brief
* Use the Micro ECC implementation of the elliptic curve primitives
* for Weave communication.
*
* Note that this option is mutually exclusive with
* #WEAVE_CONFIG_USE_OPENSSL_ECC.
*
*/
#ifndef WEAVE_CONFIG_USE_MICRO_ECC
#define WEAVE_CONFIG_USE_MICRO_ECC 0
#endif // WEAVE_CONFIG_USE_MICRO_ECC
#if WEAVE_CONFIG_USE_MICRO_ECC && WEAVE_CONFIG_USE_OPENSSL_ECC
#error "Please assert one of either WEAVE_CONFIG_USE_MICRO_ECC or WEAVE_CONFIG_USE_OPENSSL_ECC, but not both."
#endif // WEAVE_CONFIG_USE_MICRO_ECC && WEAVE_CONFIG_USE_OPENSSL_ECC
/**
* @name Weave Elliptic Curve Security Configuration
*
* @brief
* The following definitions enable one or more of four potential
* elliptic curves:
*
* * #WEAVE_CONFIG_SUPPORT_ELLIPTIC_CURVE_SECP160R1
* * #WEAVE_CONFIG_SUPPORT_ELLIPTIC_CURVE_SECP192R1
* * #WEAVE_CONFIG_SUPPORT_ELLIPTIC_CURVE_SECP224R1
* * #WEAVE_CONFIG_SUPPORT_ELLIPTIC_CURVE_SECP256R1
*
* @{
*/
/**
* @def WEAVE_CONFIG_SUPPORT_ELLIPTIC_CURVE_SECP160R1
*
* @brief
* Enable (1) or disable (0) support for the Standards for
* Efficient Cryptography Group (SECG) secp160r1 elliptic curve.
*
*/
#ifndef WEAVE_CONFIG_SUPPORT_ELLIPTIC_CURVE_SECP160R1
#define WEAVE_CONFIG_SUPPORT_ELLIPTIC_CURVE_SECP160R1 0
#endif // WEAVE_CONFIG_SUPPORT_ELLIPTIC_CURVE_SECP160R1
/**
* @def WEAVE_CONFIG_SUPPORT_ELLIPTIC_CURVE_SECP192R1
*
* @brief
* Enable (1) or disable (0) support for the Standards for
* Efficient Cryptography Group (SECG) secp192r1 elliptic curve.
*
*/
#ifndef WEAVE_CONFIG_SUPPORT_ELLIPTIC_CURVE_SECP192R1
#define WEAVE_CONFIG_SUPPORT_ELLIPTIC_CURVE_SECP192R1 1
#endif // WEAVE_CONFIG_SUPPORT_ELLIPTIC_CURVE_SECP192R1
/**
* @def WEAVE_CONFIG_SUPPORT_ELLIPTIC_CURVE_SECP224R1
*
* @brief
* Enable (1) or disable (0) support for the Standards for
* Efficient Cryptography Group (SECG) secp224r1 / National
* Institute of Standards (NIST) P-224 elliptic curve.
*
*/
#ifndef WEAVE_CONFIG_SUPPORT_ELLIPTIC_CURVE_SECP224R1
#define WEAVE_CONFIG_SUPPORT_ELLIPTIC_CURVE_SECP224R1 1
#endif // WEAVE_CONFIG_SUPPORT_ELLIPTIC_CURVE_SECP224R1
/**
* @def WEAVE_CONFIG_SUPPORT_ELLIPTIC_CURVE_SECP256R1
*
* @brief
* Enable (1) or disable (0) support for the Standards for
* Efficient Cryptography Group (SECG) secp256r1 / American
* National Standards Institute (ANSI) prime256v1 / National
* Institute of Standards (NIST) P-256 elliptic curve.
*
*/
#ifndef WEAVE_CONFIG_SUPPORT_ELLIPTIC_CURVE_SECP256R1
#define WEAVE_CONFIG_SUPPORT_ELLIPTIC_CURVE_SECP256R1 1
#endif // WEAVE_CONFIG_SUPPORT_ELLIPTIC_CURVE_SECP256R1
/**
* @}
*/
/**
* @name Weave Password Authenticated Session Establishment (PASE) Configuration
*
* @brief
* The following definitions define the configurations supported
* for Weave's Password Authenticated Session Establishment (PASE)
* protocol.
*
* This protocol is used primarily for establishing a secure
* session for provisioning. Weave supports the following PASE
* configurations:
*
* * #WEAVE_CONFIG_SUPPORT_PASE_CONFIG0_TEST_ONLY
* * #WEAVE_CONFIG_SUPPORT_PASE_CONFIG1
* * #WEAVE_CONFIG_SUPPORT_PASE_CONFIG2
* * #WEAVE_CONFIG_SUPPORT_PASE_CONFIG3
* * #WEAVE_CONFIG_SUPPORT_PASE_CONFIG4
* * #WEAVE_CONFIG_SUPPORT_PASE_CONFIG5
*
* which are summarized in the table below:
*
* | Configuration | J-PAKE Style | Curve | Test Only | Notes |
* | :------------: | :-------------- | :-------: | :---------: | :----------------------------------- |
* | 0 | - | - | Y | Test-only |
* | 1 | Finite Field | - | N | Original Weave default configuration |
* | 2 | Elliptic Curve | secp160r1 | N | |
* | 3 | Elliptic Curve | secp192r1 | N | |
* | 4 | Elliptic Curve | secp224r1 | N | Future Weave default configuration |
* | 5 | Elliptic Curve | secp256r1 | N | |
*
* @{
*
*/
/**
* @def WEAVE_CONFIG_SUPPORT_PASE_CONFIG0_TEST_ONLY
*
* @brief
* This Weave PASE configuration does not use the J-PAKE algorithm
* and sends deterministic messages over the communications
* channel. The size and structure of the messages are similar to
* #WEAVE_CONFIG_SUPPORT_PASE_CONFIG5.
*
* @note The results of this configuration are insecure because the
* computational overhead of the cryptography has largely been
* disabled since the focus of this configuration is testing
* the overall PASE protocol exchange, independently of the
* cryptography.
*
*/
#ifndef WEAVE_CONFIG_SUPPORT_PASE_CONFIG0_TEST_ONLY
#define WEAVE_CONFIG_SUPPORT_PASE_CONFIG0_TEST_ONLY 0
#endif // WEAVE_CONFIG_SUPPORT_PASE_CONFIG0_TEST_ONLY
/**
* @def WEAVE_CONFIG_SUPPORT_PASE_CONFIG1
*
* @brief
* This Weave PASE configuration uses Finite Field J-PAKE and is
* the original, default Weave PASE configuration.
*
*/
#ifndef WEAVE_CONFIG_SUPPORT_PASE_CONFIG1
#define WEAVE_CONFIG_SUPPORT_PASE_CONFIG1 1
#endif // WEAVE_CONFIG_SUPPORT_PASE_CONFIG1
/**
* @def WEAVE_CONFIG_SUPPORT_PASE_CONFIG2
*
* @brief
* This Weave PASE configuration uses Elliptic Curve J-PAKE with a
* SECG secp160r1 curve.
*
* @note When this PASE configuration is enabled, the corresponding
* elliptic curve (i.e. #WEAVE_CONFIG_SUPPORT_ELLIPTIC_CURVE_SECP160R1)
* should also be enabled.
*
*/
#ifndef WEAVE_CONFIG_SUPPORT_PASE_CONFIG2
#define WEAVE_CONFIG_SUPPORT_PASE_CONFIG2 0
#endif // WEAVE_CONFIG_SUPPORT_PASE_CONFIG2
/**
* @def WEAVE_CONFIG_SUPPORT_PASE_CONFIG3
*
* @brief
* This Weave PASE configuration uses Elliptic Curve J-PAKE with a
* SECG secp192r1 curve.
*
* @note When this PASE configuration is enabled, the corresponding
* elliptic curve (i.e. #WEAVE_CONFIG_SUPPORT_ELLIPTIC_CURVE_SECP192R1)
* should also be enabled.
*
*/
#ifndef WEAVE_CONFIG_SUPPORT_PASE_CONFIG3
#define WEAVE_CONFIG_SUPPORT_PASE_CONFIG3 0
#endif // WEAVE_CONFIG_SUPPORT_PASE_CONFIG3
/**
* @def WEAVE_CONFIG_SUPPORT_PASE_CONFIG4
*
* @brief
* This Weave PASE configuration uses Elliptic Curve J-PAKE with a
* SECG secp224r1 curve and will be the new, default Weave PASE
* configuration.
*
* @note When this PASE configuration is enabled, the corresponding
* elliptic curve (i.e. #WEAVE_CONFIG_SUPPORT_ELLIPTIC_CURVE_SECP224R1)
* should also be enabled.
*
*/
#ifndef WEAVE_CONFIG_SUPPORT_PASE_CONFIG4
#define WEAVE_CONFIG_SUPPORT_PASE_CONFIG4 1
#endif // WEAVE_CONFIG_SUPPORT_PASE_CONFIG4
/**
* @def WEAVE_CONFIG_SUPPORT_PASE_CONFIG5
*
* @brief
* This Weave PASE configuration uses Elliptic Curve J-PAKE with a
* SECG secp256r1 curve.
*
* @note When this PASE configuration is enabled, the corresponding
* elliptic curve (i.e. #WEAVE_CONFIG_SUPPORT_ELLIPTIC_CURVE_SECP256R1)
* should also be enabled.
*
*/
#ifndef WEAVE_CONFIG_SUPPORT_PASE_CONFIG5
#define WEAVE_CONFIG_SUPPORT_PASE_CONFIG5 0
#endif // WEAVE_CONFIG_SUPPORT_PASE_CONFIG5
/**
* @}
*/
#if WEAVE_CONFIG_SUPPORT_PASE_CONFIG2 && !WEAVE_CONFIG_SUPPORT_ELLIPTIC_CURVE_SECP160R1
#error "Please assert WEAVE_CONFIG_SUPPORT_ELLIPTIC_CURVE_SECP160R1 when WEAVE_CONFIG_SUPPORT_PASE_CONFIG2 is asserted"
#endif // WEAVE_CONFIG_SUPPORT_PASE_CONFIG2 && !WEAVE_CONFIG_SUPPORT_ELLIPTIC_CURVE_SECP160R1
#if WEAVE_CONFIG_SUPPORT_PASE_CONFIG3 && !WEAVE_CONFIG_SUPPORT_ELLIPTIC_CURVE_SECP192R1
#error "Please assert WEAVE_CONFIG_SUPPORT_ELLIPTIC_CURVE_SECP192R1 when WEAVE_CONFIG_SUPPORT_PASE_CONFIG3 is asserted"
#endif // WEAVE_CONFIG_SUPPORT_PASE_CONFIG3 && !WEAVE_CONFIG_SUPPORT_ELLIPTIC_CURVE_SECP192R1
#if WEAVE_CONFIG_SUPPORT_PASE_CONFIG4 && !WEAVE_CONFIG_SUPPORT_ELLIPTIC_CURVE_SECP224R1
#error "Please assert WEAVE_CONFIG_SUPPORT_ELLIPTIC_CURVE_SECP224R1 when WEAVE_CONFIG_SUPPORT_PASE_CONFIG4 is asserted"
#endif // WEAVE_CONFIG_SUPPORT_PASE_CONFIG4 && !WEAVE_CONFIG_SUPPORT_ELLIPTIC_CURVE_SECP224R1
#if WEAVE_CONFIG_SUPPORT_PASE_CONFIG5 && !WEAVE_CONFIG_SUPPORT_ELLIPTIC_CURVE_SECP256R1
#error "Please assert WEAVE_CONFIG_SUPPORT_ELLIPTIC_CURVE_SECP256R1 when WEAVE_CONFIG_SUPPORT_PASE_CONFIG5 is asserted"
#endif // WEAVE_CONFIG_SUPPORT_PASE_CONFIG5 && !WEAVE_CONFIG_SUPPORT_ELLIPTIC_CURVE_SECP256R1
/**
* @def WEAVE_CONFIG_PASE_MESSAGE_PAYLOAD_ALIGNMENT
*
* @brief
* Align payload on 4-byte boundary for PASE messages.
* Currently, payload alignment is required only when micro-ecc
* library is used and it is compiled with ARM assembly.
* If implementation guarantees that payload is always 4-byte
* aligned this option should stay deasserted to save code size.
*
*/
#ifndef WEAVE_CONFIG_PASE_MESSAGE_PAYLOAD_ALIGNMENT
#if WEAVE_CONFIG_USE_MICRO_ECC
#define WEAVE_CONFIG_PASE_MESSAGE_PAYLOAD_ALIGNMENT 1
#else
#define WEAVE_CONFIG_PASE_MESSAGE_PAYLOAD_ALIGNMENT 0
#endif // WEAVE_CONFIG_USE_MICRO_ECC
#endif // WEAVE_CONFIG_PASE_MESSAGE_PAYLOAD_ALIGNMENT
/**
* @def WEAVE_CONFIG_PASE_RATE_LIMITER_TIMEOUT
*
* @brief
* The amount of time (in milliseconds) in which the Security Manager
* is allowed to have maximum #WEAVE_CONFIG_PASE_RATE_LIMITER_MAX_ATTEMPTS
* counted PASE attempts.
*
*/
#ifndef WEAVE_CONFIG_PASE_RATE_LIMITER_TIMEOUT
#define WEAVE_CONFIG_PASE_RATE_LIMITER_TIMEOUT 15000
#endif // WEAVE_CONFIG_PASE_RATE_LIMITER_TIMEOUT
/**
* @def WEAVE_CONFIG_PASE_RATE_LIMITER_MAX_ATTEMPTS
*
* @brief
* The maximum number of PASE attempts after which the
* next PASE session establishment attempt will be allowed
* only after #WEAVE_CONFIG_PASE_RATE_LIMITER_TIMEOUT expires.
* * For PASE negotiations with key confirmation option enabled:
* only attempts that failed with key confirmation error are counted.
* Successful PASE negotiations do not reset the rate limiter.
* * For PASE negotiations with key confirmation option disabled:
* every PASE negotiation, successful or otherwise, is added
* to the rate limiter.
*
*/
#ifndef WEAVE_CONFIG_PASE_RATE_LIMITER_MAX_ATTEMPTS
#define WEAVE_CONFIG_PASE_RATE_LIMITER_MAX_ATTEMPTS 3
#endif // WEAVE_CONFIG_PASE_RATE_LIMITER_MAX_ATTEMPTS
/**
* @name Weave Security Manager Memory Management Configuration
*
* @brief
* The following definitions enable one of three potential Weave
* Security Manager memory-management options:
*
* * #WEAVE_CONFIG_SECURITY_MGR_MEMORY_MGMT_PLATFORM
* * #WEAVE_CONFIG_SECURITY_MGR_MEMORY_MGMT_SIMPLE
* * #WEAVE_CONFIG_SECURITY_MGR_MEMORY_MGMT_MALLOC
*
* Note that these options are mutually exclusive and only one
* of these options should be set.
*
* @{
*/
/**
* @def WEAVE_CONFIG_SECURITY_MGR_MEMORY_MGMT_PLATFORM
*
* @brief
* Enable (1) or disable (0) support for platform-specific
* implementation of Weave Security Manager memory-management
* functions.
*
* @note This configuration is mutual exclusive with
* #WEAVE_CONFIG_SECURITY_MGR_MEMORY_MGMT_SIMPLE and
* #WEAVE_CONFIG_SECURITY_MGR_MEMORY_MGMT_MALLOC.
*
*/
#ifndef WEAVE_CONFIG_SECURITY_MGR_MEMORY_MGMT_PLATFORM
#define WEAVE_CONFIG_SECURITY_MGR_MEMORY_MGMT_PLATFORM 0
#endif // WEAVE_CONFIG_SECURITY_MGR_MEMORY_MGMT_PLATFORM
/**
* @def WEAVE_CONFIG_SECURITY_MGR_MEMORY_MGMT_SIMPLE
*
* @brief
* Enable (1) or disable (0) support for a Weave-provided
* implementation of Weave Security Manager memory-management
* functions based on temporary network buffer allocation /
* release.
*
* @note This configuration is mutual exclusive with
* #WEAVE_CONFIG_SECURITY_MGR_MEMORY_MGMT_PLATFORM and
* #WEAVE_CONFIG_SECURITY_MGR_MEMORY_MGMT_MALLOC.
*
*/
#ifndef WEAVE_CONFIG_SECURITY_MGR_MEMORY_MGMT_SIMPLE
#define WEAVE_CONFIG_SECURITY_MGR_MEMORY_MGMT_SIMPLE 0
#endif // WEAVE_CONFIG_SECURITY_MGR_MEMORY_MGMT_SIMPLE
/**
* @def WEAVE_CONFIG_SECURITY_MGR_MEMORY_MGMT_MALLOC
*
* @brief
* Enable (1) or disable (0) support for a Weave-provided
* implementation of Weave Security Manager memory-management
* functions based on the C Standard Library malloc / free
* functions.
*
* @note This configuration is mutual exclusive with
* #WEAVE_CONFIG_SECURITY_MGR_MEMORY_MGMT_PLATFORM and
* #WEAVE_CONFIG_SECURITY_MGR_MEMORY_MGMT_SIMPLE.
*
*/
#ifndef WEAVE_CONFIG_SECURITY_MGR_MEMORY_MGMT_MALLOC
#define WEAVE_CONFIG_SECURITY_MGR_MEMORY_MGMT_MALLOC 1
#endif // WEAVE_CONFIG_SECURITY_MGR_MEMORY_MGMT_MALLOC
/**
* @}
*/
#if ((WEAVE_CONFIG_SECURITY_MGR_MEMORY_MGMT_PLATFORM + WEAVE_CONFIG_SECURITY_MGR_MEMORY_MGMT_SIMPLE + WEAVE_CONFIG_SECURITY_MGR_MEMORY_MGMT_MALLOC) != 1)
#error "Please assert exactly one of WEAVE_CONFIG_SECURITY_MGR_MEMORY_MGMT_PLATFORM, WEAVE_CONFIG_SECURITY_MGR_MEMORY_MGMT_SIMPLE, or WEAVE_CONFIG_SECURITY_MGR_MEMORY_MGMT_MALLOC."
#endif // ((WEAVE_CONFIG_SECURITY_MGR_MEMORY_MGMT_PLATFORM + WEAVE_CONFIG_SECURITY_MGR_MEMORY_MGMT_SIMPLE + WEAVE_CONFIG_SECURITY_MGR_MEMORY_MGMT_MALLOC) != 1)
/**
* @def WEAVE_CONFIG_SIMPLE_ALLOCATOR_USE_SMALL_BUFFERS
*
* @brief
* Enable (1) or disable (0) simple memory allocator support
* for small size network buffers. When enabled, this configuration
* requires 4 network buffers with minimum available payload size of
* 600 bytes.
*
* @note This configuration is only relevant when
* #WEAVE_CONFIG_SECURITY_MGR_MEMORY_MGMT_SIMPLE is set and
* ignored otherwise.
*
*/
#ifndef WEAVE_CONFIG_SIMPLE_ALLOCATOR_USE_SMALL_BUFFERS
#define WEAVE_CONFIG_SIMPLE_ALLOCATOR_USE_SMALL_BUFFERS 0
#endif // WEAVE_CONFIG_SIMPLE_ALLOCATOR_USE_SMALL_BUFFERS
/**
* @name Weave Security Manager Time-Consuming Crypto Alerts.
*
* @brief
* The following definitions enable one of two potential Weave
* Security Manager time-consuming crypto alerts implementations:
*
* * #WEAVE_CONFIG_SECURITY_MGR_TIME_ALERTS_DUMMY
* * #WEAVE_CONFIG_SECURITY_MGR_TIME_ALERTS_PLATFORM
*
* Note that these options are mutually exclusive and only one
* of these options should be set.
*
* @{
*/
/**
* @def WEAVE_CONFIG_SECURITY_MGR_TIME_ALERTS_DUMMY
*
* @brief
* Enable (1) or disable (0) support for Weave-provided dummy
* implementation of Weave security manager time-consuming
* crypto alerts functions.
*
* @note This configuration is mutual exclusive with
* #WEAVE_CONFIG_SECURITY_MGR_TIME_ALERTS_PLATFORM.
*
*/
#ifndef WEAVE_CONFIG_SECURITY_MGR_TIME_ALERTS_DUMMY
#define WEAVE_CONFIG_SECURITY_MGR_TIME_ALERTS_DUMMY 1
#endif // WEAVE_CONFIG_SECURITY_MGR_TIME_ALERTS_DUMMY
/**
* @def WEAVE_CONFIG_SECURITY_MGR_TIME_ALERTS_PLATFORM
*
* @brief
* Enable (1) or disable (0) support for a platform-specific
* implementation of Weave security manager time-consuming
* crypto alerts functions.
*
* @note This configuration is mutual exclusive with
* #WEAVE_CONFIG_SECURITY_MGR_TIME_ALERTS_DUMMY.
*
*/
#ifndef WEAVE_CONFIG_SECURITY_MGR_TIME_ALERTS_PLATFORM
#define WEAVE_CONFIG_SECURITY_MGR_TIME_ALERTS_PLATFORM 0
#endif // WEAVE_CONFIG_SECURITY_MGR_TIME_ALERTS_PLATFORM
/**
* @}
*/
#if ((WEAVE_CONFIG_SECURITY_MGR_TIME_ALERTS_DUMMY + WEAVE_CONFIG_SECURITY_MGR_TIME_ALERTS_PLATFORM) != 1)
#error "Please assert exactly one of WEAVE_CONFIG_SECURITY_MGR_TIME_ALERTS_DUMMY or WEAVE_CONFIG_SECURITY_MGR_TIME_ALERTS_PLATFORM."
#endif // ((WEAVE_CONFIG_SECURITY_MGR_TIME_ALERTS_DUMMY + WEAVE_CONFIG_SECURITY_MGR_TIME_ALERTS_PLATFORM) != 1)
/**
* @name Weave Random Number Generator (RNG) Implementation Configuration
*
* @brief
* The following definitions enable one of three potential Weave
* RNG implementation options:
*
* * #WEAVE_CONFIG_RNG_IMPLEMENTATION_PLATFORM
* * #WEAVE_CONFIG_RNG_IMPLEMENTATION_NESTDRBG
* * #WEAVE_CONFIG_RNG_IMPLEMENTATION_OPENSSL
*
* Note that these options are mutually exclusive and only one of
* these options should be set.
*
* @{
*/
/**
* @def WEAVE_CONFIG_RNG_IMPLEMENTATION_PLATFORM
*
* @brief
* Enable (1) or disable (0) support for platform-specific
* implementation of the Weave Random Number Generator.
*
* @note This configuration is mutual exclusive with
* #WEAVE_CONFIG_RNG_IMPLEMENTATION_NESTDRBG and
* #WEAVE_CONFIG_RNG_IMPLEMENTATION_OPENSSL.
*
*/
#ifndef WEAVE_CONFIG_RNG_IMPLEMENTATION_PLATFORM
#define WEAVE_CONFIG_RNG_IMPLEMENTATION_PLATFORM 0
#endif // WEAVE_CONFIG_RNG_IMPLEMENTATION_PLATFORM
/**
* @def WEAVE_CONFIG_RNG_IMPLEMENTATION_NESTDRBG
*
* @brief
* Enable (1) or disable (0) support for a Weave-provided
* implementation of the Weave Random Number Generator.
* This implementation is based on AES-CTR DRBG as
* specified in the NIST SP800-90A document.
*
* @note This configuration is mutual exclusive with
* #WEAVE_CONFIG_RNG_IMPLEMENTATION_PLATFORM and
* #WEAVE_CONFIG_RNG_IMPLEMENTATION_OPENSSL.
*
*/
#ifndef WEAVE_CONFIG_RNG_IMPLEMENTATION_NESTDRBG
#define WEAVE_CONFIG_RNG_IMPLEMENTATION_NESTDRBG 0
#endif // WEAVE_CONFIG_RNG_IMPLEMENTATION_NESTDRBG
/**
* @def WEAVE_CONFIG_RNG_IMPLEMENTATION_OPENSSL
*
* @brief
* Enable (1) or disable (0) support for a standard OpenSSL
* implementation of the Weave Random Number Generator.
*
* @note This configuration is mutual exclusive with
* #WEAVE_CONFIG_RNG_IMPLEMENTATION_PLATFORM and
* #WEAVE_CONFIG_RNG_IMPLEMENTATION_NESTDRBG.
*
*/
#ifndef WEAVE_CONFIG_RNG_IMPLEMENTATION_OPENSSL
#define WEAVE_CONFIG_RNG_IMPLEMENTATION_OPENSSL 1
#endif // WEAVE_CONFIG_RNG_IMPLEMENTATION_OPENSSL
/**
* @}
*/
#if ((WEAVE_CONFIG_RNG_IMPLEMENTATION_PLATFORM + WEAVE_CONFIG_RNG_IMPLEMENTATION_NESTDRBG + WEAVE_CONFIG_RNG_IMPLEMENTATION_OPENSSL) != 1)
#error "Please assert exactly one of WEAVE_CONFIG_RNG_IMPLEMENTATION_PLATFORM, WEAVE_CONFIG_RNG_IMPLEMENTATION_NESTDRBG, or WEAVE_CONFIG_RNG_IMPLEMENTATION_OPENSSL."
#endif // ((WEAVE_CONFIG_RNG_IMPLEMENTATION_PLATFORM + WEAVE_CONFIG_RNG_IMPLEMENTATION_NESTDRBG + WEAVE_CONFIG_RNG_IMPLEMENTATION_OPENSSL) != 1)
/**
* @def WEAVE_CONFIG_DEV_RANDOM_DRBG_SEED
*
* @brief
* Enable (1) or disable (0) a function for seeding the DRBG with
* entropy from the /dev/(u)random device.
*
* @note When enabled along with #WEAVE_CONFIG_RNG_IMPLEMENTATION_NESTDRBG
* this function becomes the default seeding function for the DRBG if
* another isn't specified at initialization time.
*
*/
#ifndef WEAVE_CONFIG_DEV_RANDOM_DRBG_SEED
#define WEAVE_CONFIG_DEV_RANDOM_DRBG_SEED 0
#endif // WEAVE_CONFIG_DEV_RANDOM_DRBG_SEED
/**
* @def WEAVE_CONFIG_DEV_RANDOM_DEVICE_NAME
*
* @brief
* The device name used by the dev random entropy function.
*
* @note Only meaningful when #WEAVE_CONFIG_DEV_RANDOM_DRBG_SEED is enabled.
*
*/
#ifndef WEAVE_CONFIG_DEV_RANDOM_DEVICE_NAME
#define WEAVE_CONFIG_DEV_RANDOM_DEVICE_NAME "/dev/urandom"
#endif // WEAVE_CONFIG_DEV_RANDOM_DEVICE_NAME
/**
* @name Weave AES Block Cipher Algorithm Implementation Configuration.
*
* @brief
* The following definitions enable one of the potential Weave
* AES implementation options:
*
* * #WEAVE_CONFIG_AES_IMPLEMENTATION_PLATFORM
* * #WEAVE_CONFIG_AES_IMPLEMENTATION_OPENSSL
*
* Note that these options are mutually exclusive and only one of
* these options should be set.
*
* @{
*/
/**
* @def WEAVE_CONFIG_AES_IMPLEMENTATION_PLATFORM
*
* @brief
* Enable (1) or disable (0) support for platform-specific
* implementation of the Weave AES functions.
*
* @note This configuration is mutual exclusive with
* #WEAVE_CONFIG_AES_IMPLEMENTATION_OPENSSL and
* #WEAVE_CONFIG_AES_IMPLEMENTATION_AESNI
*
*/
#ifndef WEAVE_CONFIG_AES_IMPLEMENTATION_PLATFORM
#define WEAVE_CONFIG_AES_IMPLEMENTATION_PLATFORM 0
#endif // WEAVE_CONFIG_AES_IMPLEMENTATION_PLATFORM
/**
* @def WEAVE_CONFIG_AES_IMPLEMENTATION_OPENSSL
*
* @brief
* Enable (1) or disable (0) support for the OpenSSL
* implementation of the Weave AES functions.
*
* @note This configuration is mutual exclusive with other
* WEAVE_CONFIG_AES_IMPLEMENTATION options.
*
*/
#ifndef WEAVE_CONFIG_AES_IMPLEMENTATION_OPENSSL
#define WEAVE_CONFIG_AES_IMPLEMENTATION_OPENSSL 1
#endif // WEAVE_CONFIG_AES_IMPLEMENTATION_OPENSSL
/**
* @def WEAVE_CONFIG_AES_IMPLEMENTATION_AESNI
*
* @brief
* Enable (1) or disable (0) support for an implementation
* of the Weave AES functions using Intel AES-NI intrinsics.
*
* @note This configuration is mutual exclusive with other
* WEAVE_CONFIG_AES_IMPLEMENTATION options.
*
*/
#ifndef WEAVE_CONFIG_AES_IMPLEMENTATION_AESNI
#define WEAVE_CONFIG_AES_IMPLEMENTATION_AESNI 0
#endif // WEAVE_CONFIG_AES_IMPLEMENTATION_AESNI
/**
* @def WEAVE_CONFIG_AES_IMPLEMENTATION_MBEDTLS
*
* @brief
* Enable (1) or disable (0) support the mbed TLS
* implementation of the Weave AES functions.
*
* @note This configuration is mutual exclusive with other
* WEAVE_CONFIG_AES_IMPLEMENTATION options.
*
*/
#ifndef WEAVE_CONFIG_AES_IMPLEMENTATION_MBEDTLS
#define WEAVE_CONFIG_AES_IMPLEMENTATION_MBEDTLS 0
#endif // WEAVE_CONFIG_AES_IMPLEMENTATION_MBEDTLS
/**
* @}
*/
#if ((WEAVE_CONFIG_AES_IMPLEMENTATION_PLATFORM + \
WEAVE_CONFIG_AES_IMPLEMENTATION_OPENSSL + \
WEAVE_CONFIG_AES_IMPLEMENTATION_AESNI + \
WEAVE_CONFIG_AES_IMPLEMENTATION_MBEDTLS) != 1)
#error "Please assert exactly one WEAVE_CONFIG_AES_IMPLEMENTATION_... option."
#endif
/**
* @def WEAVE_CONFIG_AES_USE_EXPANDED_KEY
*
* @brief
* Defines whether AES key is used in its expanded (1) or native (0) form.
*
* @note OpenSSL AES implementation uses its own AES key declaration
* and this configuration option is ignored when
* #WEAVE_CONFIG_AES_IMPLEMENTATION_OPENSSL is set.
*
*/
#ifndef WEAVE_CONFIG_AES_USE_EXPANDED_KEY
#define WEAVE_CONFIG_AES_USE_EXPANDED_KEY 0
#endif // WEAVE_CONFIG_AES_USE_EXPANDED_KEY
/**
* @name Weave SHA1 and SHA256 Hash Algorithms Implementation Configuration.
*
* @brief
* The following definitions enable one of three potential Weave
* hash implementation options:
*
* * #WEAVE_CONFIG_HASH_IMPLEMENTATION_PLATFORM
* * #WEAVE_CONFIG_HASH_IMPLEMENTATION_MINCRYPT
* * #WEAVE_CONFIG_HASH_IMPLEMENTATION_OPENSSL
* * #WEAVE_CONFIG_HASH_IMPLEMENTATION_MBEDTLS
*
* Note that these options are mutually exclusive and only one of
* these options should be set.
*
* @{
*/
/**
* @def WEAVE_CONFIG_HASH_IMPLEMENTATION_PLATFORM
*
* @brief
* Enable (1) or disable (0) support for platform-specific
* implementation of the Weave SHA1 and SHA256 hashes.
*
* @note This configuration is mutual exclusive with other
* WEAVE_CONFIG_HASH_IMPLEMENTATION options.
*
*/
#ifndef WEAVE_CONFIG_HASH_IMPLEMENTATION_PLATFORM
#define WEAVE_CONFIG_HASH_IMPLEMENTATION_PLATFORM 0
#endif // WEAVE_CONFIG_HASH_IMPLEMENTATION_PLATFORM
/**
* @def WEAVE_CONFIG_HASH_IMPLEMENTATION_MINCRYPT
*
* @brief
* Enable (1) or disable (0) support for a Weave-provided
* implementation of the Weave SHA1 and SHA256 hash functions.
* This implementation is using sha1 and sha256 engines from
* mincrypt library of Android core.
*
* @note This configuration is mutual exclusive with other
* WEAVE_CONFIG_HASH_IMPLEMENTATION options.
*
*/
#ifndef WEAVE_CONFIG_HASH_IMPLEMENTATION_MINCRYPT
#define WEAVE_CONFIG_HASH_IMPLEMENTATION_MINCRYPT 0
#endif // WEAVE_CONFIG_HASH_IMPLEMENTATION_MINCRYPT
/**
* @def WEAVE_CONFIG_HASH_IMPLEMENTATION_OPENSSL
*
* @brief
* Enable (1) or disable (0) support for the OpenSSL
* implementation of the Weave SHA1 and SHA256 hash functions.
*
* @note This configuration is mutual exclusive with other
* WEAVE_CONFIG_HASH_IMPLEMENTATION options.
*
*/
#ifndef WEAVE_CONFIG_HASH_IMPLEMENTATION_OPENSSL
#define WEAVE_CONFIG_HASH_IMPLEMENTATION_OPENSSL 1
#endif // WEAVE_CONFIG_HASH_IMPLEMENTATION_OPENSSL
/**
* @def WEAVE_CONFIG_HASH_IMPLEMENTATION_MBEDTLS
*
* @brief
* Enable (1) or disable (0) support for the mbedTLS
* implementation of the Weave SHA1 and SHA256 hash functions.
*
* @note This configuration is mutual exclusive with other
* WEAVE_CONFIG_HASH_IMPLEMENTATION options.
*
*/
#ifndef WEAVE_CONFIG_HASH_IMPLEMENTATION_MBEDTLS
#define WEAVE_CONFIG_HASH_IMPLEMENTATION_MBEDTLS 0
#endif // WEAVE_CONFIG_HASH_IMPLEMENTATION_MBEDTLS
/**
* @}
*/
#if ((WEAVE_CONFIG_HASH_IMPLEMENTATION_PLATFORM + \
WEAVE_CONFIG_HASH_IMPLEMENTATION_MINCRYPT + \
WEAVE_CONFIG_HASH_IMPLEMENTATION_OPENSSL + \
WEAVE_CONFIG_HASH_IMPLEMENTATION_MBEDTLS) != 1)
#error "Please assert exactly one WEAVE_CONFIG_HASH_IMPLEMENTATION_... option."
#endif
/**
* @name Weave key export protocol configuration.
*
* @brief
* The following definitions define the configurations supported
* for Weave's key export protocol.
*
* This protocol is used to export secret key material from Weave device.
* Weave supports the following protocol configurations:
*
* * #WEAVE_CONFIG_SUPPORT_KEY_EXPORT_CONFIG1
* * #WEAVE_CONFIG_SUPPORT_KEY_EXPORT_CONFIG2
*
* which are summarized in the table below:
*
* | Configuration | Curve | Notes |
* | :------------: | :-------: | :---------------------- |
* | 1 | secp224r1 | Default configuration |
* | 2 | secp256r1 | |
*
* @{
*
*/
/**
* @def WEAVE_CONFIG_SUPPORT_KEY_EXPORT_CONFIG1
*
* @brief
* This Weave key export protocol configuration uses secp224r1
* Elliptic Curve.
*
*/
#ifndef WEAVE_CONFIG_SUPPORT_KEY_EXPORT_CONFIG1
#define WEAVE_CONFIG_SUPPORT_KEY_EXPORT_CONFIG1 1
#endif // WEAVE_CONFIG_SUPPORT_KEY_EXPORT_CONFIG1
/**
* @def WEAVE_CONFIG_SUPPORT_KEY_EXPORT_CONFIG2
*
* @brief
* This Weave key export protocol configuration uses secp256r1
* Elliptic Curve.
*
*/
#ifndef WEAVE_CONFIG_SUPPORT_KEY_EXPORT_CONFIG2
#define WEAVE_CONFIG_SUPPORT_KEY_EXPORT_CONFIG2 1
#endif // WEAVE_CONFIG_SUPPORT_KEY_EXPORT_CONFIG2
/**
* @}
*/
/**
* @def WEAVE_CONFIG_ALLOW_NON_STANDARD_ELLIPTIC_CURVES
*
* @brief
* Allow the use of elliptic curves beyond the standard ones
* supported by Weave.
*
*/
#ifndef WEAVE_CONFIG_ALLOW_NON_STANDARD_ELLIPTIC_CURVES
#define WEAVE_CONFIG_ALLOW_NON_STANDARD_ELLIPTIC_CURVES 0
#endif // WEAVE_CONFIG_ALLOW_NON_STANDARD_ELLIPTIC_CURVES
/**
* @def WEAVE_CONFIG_MAX_EC_BITS
*
* @brief
* The maximum size elliptic curve supported, in bits.
*
*/
#ifndef WEAVE_CONFIG_MAX_EC_BITS
#define WEAVE_CONFIG_MAX_EC_BITS 256
#endif // WEAVE_CONFIG_MAX_EC_BITS
/**
* @def WEAVE_CONFIG_MAX_RSA_BITS
*
* @brief
* The maximum size RSA modulus supported, in bits.
*
*/
#ifndef WEAVE_CONFIG_MAX_RSA_BITS