@@ -39,29 +39,36 @@ LinuxDeviceOptions gDeviceOptions;
39
39
// Follow the code style of command line arguments in case we need to add more options in the future.
40
40
enum
41
41
{
42
- kDeviceOption_BleDevice = 0x1000 ,
43
- kDeviceOption_WiFi = 0x1001 ,
44
- kDeviceOption_Thread = 0x1002 ,
45
- kDeviceOption_Version = 0x1003 ,
46
- kDeviceOption_VendorID = 0x1004 ,
47
- kDeviceOption_ProductID = 0x1005 ,
48
- kDeviceOption_CustomFlow = 0x1006 ,
49
- kDeviceOption_Capabilities = 0x1007 ,
50
- kDeviceOption_Discriminator = 0x1008 ,
51
- kDeviceOption_Passcode = 0x1009 ,
52
- kDeviceOption_SecuredDevicePort = 0x100a ,
53
- kDeviceOption_SecuredCommissionerPort = 0x100b ,
54
- kDeviceOption_UnsecuredCommissionerPort = 0x100c ,
55
- kDeviceOption_Command = 0x100d ,
56
- kDeviceOption_PICS = 0x100e ,
57
- kDeviceOption_KVS = 0x100f ,
58
- kDeviceOption_InterfaceId = 0x1010 ,
59
- kDeviceOption_Spake2pVerifierBase64 = 0x1011 ,
60
- kDeviceOption_Spake2pSaltBase64 = 0x1012 ,
61
- kDeviceOption_Spake2pIterations = 0x1013 ,
62
- kDeviceOption_TraceFile = 0x1014 ,
63
- kDeviceOption_TraceLog = 0x1015 ,
64
- kDeviceOption_TraceDecode = 0x1016 ,
42
+ kDeviceOption_BleDevice = 0x1000 ,
43
+ kDeviceOption_WiFi = 0x1001 ,
44
+ kDeviceOption_Thread = 0x1002 ,
45
+ kDeviceOption_Version = 0x1003 ,
46
+ kDeviceOption_VendorID = 0x1004 ,
47
+ kDeviceOption_ProductID = 0x1005 ,
48
+ kDeviceOption_CustomFlow = 0x1006 ,
49
+ kDeviceOption_Capabilities = 0x1007 ,
50
+ kDeviceOption_Discriminator = 0x1008 ,
51
+ kDeviceOption_Passcode = 0x1009 ,
52
+ kDeviceOption_SecuredDevicePort = 0x100a ,
53
+ kDeviceOption_SecuredCommissionerPort = 0x100b ,
54
+ kDeviceOption_UnsecuredCommissionerPort = 0x100c ,
55
+ kDeviceOption_Command = 0x100d ,
56
+ kDeviceOption_PICS = 0x100e ,
57
+ kDeviceOption_KVS = 0x100f ,
58
+ kDeviceOption_InterfaceId = 0x1010 ,
59
+ kDeviceOption_Spake2pVerifierBase64 = 0x1011 ,
60
+ kDeviceOption_Spake2pSaltBase64 = 0x1012 ,
61
+ kDeviceOption_Spake2pIterations = 0x1013 ,
62
+ kDeviceOption_TraceFile = 0x1014 ,
63
+ kDeviceOption_TraceLog = 0x1015 ,
64
+ kDeviceOption_TraceDecode = 0x1016 ,
65
+ kOptionCSRResponseCSRIncorrectType = 0x1017 ,
66
+ kOptionCSRResponseCSRNonceIncorrectType = 0x1018 ,
67
+ kOptionCSRResponseCSRNonceTooLong = 0x1019 ,
68
+ kOptionCSRResponseCSRNonceInvalid = 0x101a ,
69
+ kOptionCSRResponseNOCSRElementsTooLong = 0x101b ,
70
+ kOptionCSRResponseAttestationSignatureIncorrectType = 0x101c ,
71
+ kOptionCSRResponseAttestationSignatureInvalid = 0x101d ,
65
72
};
66
73
67
74
constexpr unsigned kAppUsageLength = 64 ;
@@ -98,6 +105,13 @@ OptionDef sDeviceOptionDefs[] = {
98
105
{ " trace_log" , kArgumentRequired , kDeviceOption_TraceLog },
99
106
{ " trace_decode" , kArgumentRequired , kDeviceOption_TraceDecode },
100
107
#endif // CHIP_CONFIG_TRANSPORT_TRACE_ENABLED
108
+ { " cert_error_csr_incorrect_type" , kNoArgument , kOptionCSRResponseCSRIncorrectType },
109
+ { " cert_error_csr_nonce_incorrect_type" , kNoArgument , kOptionCSRResponseCSRNonceIncorrectType },
110
+ { " cert_error_csr_nonce_too_long" , kNoArgument , kOptionCSRResponseCSRNonceTooLong },
111
+ { " cert_error_csr_nonce_invalid" , kNoArgument , kOptionCSRResponseCSRNonceInvalid },
112
+ { " cert_error_nocsrelements_too_long" , kNoArgument , kOptionCSRResponseNOCSRElementsTooLong },
113
+ { " cert_error_attestation_signature_incorrect_type" , kNoArgument , kOptionCSRResponseAttestationSignatureIncorrectType },
114
+ { " cert_error_attestation_signature_invalid" , kNoArgument , kOptionCSRResponseAttestationSignatureInvalid },
101
115
{}
102
116
};
103
117
@@ -183,6 +197,20 @@ const char * sDeviceOptionHelp =
183
197
" --trace_decode <1/0>\n "
184
198
" A value of 1 enables traces decoding, 0 disables this (default 0).\n "
185
199
#endif // CHIP_CONFIG_TRANSPORT_TRACE_ENABLED
200
+ " --cert_error_csr_incorrect_type\n "
201
+ " Configure the CSRResponse to be built with an invalid CSR type.\n "
202
+ " --cert_error_csr_nonce_incorrect_type\n "
203
+ " Configure the CSRResponse to be built with an invalid CSRNonce type.\n "
204
+ " --cert_error_csr_nonce_too_long\n "
205
+ " Configure the CSRResponse to be built with a CSRNonce that is longer than expected.\n "
206
+ " --cert_error_csr_nonce_invalid\n "
207
+ " Configure the CSRResponse to be built with a CSRNonce that does not match the CSRNonce from the CSRRequest.\n "
208
+ " --cert_error_nocsrelements_too_long\n "
209
+ " Configure the CSRResponse to contains an NOCSRElements larger than the allowed RESP_MAX.\n "
210
+ " --cert_error_attestation_signature_incorrect_type\n "
211
+ " Configure the CSRResponse to be build with an invalid AttestationSignature type.\n "
212
+ " --cert_error_attestation_signature_invalid\n "
213
+ " Configure the CSRResponse to be build with an AttestationSignature that does not match what is expected.\n "
186
214
" \n " ;
187
215
188
216
bool Base64ArgToVector (const char * arg, size_t maxSize, std::vector<uint8_t > & outVector)
@@ -386,6 +414,28 @@ bool HandleOption(const char * aProgram, OptionSet * aOptions, int aIdentifier,
386
414
break ;
387
415
#endif // CHIP_CONFIG_TRANSPORT_TRACE_ENABLED
388
416
417
+ case kOptionCSRResponseCSRIncorrectType :
418
+ LinuxDeviceOptions::GetInstance ().mCSRResponseOptions .csrIncorrectType = true ;
419
+ break ;
420
+ case kOptionCSRResponseCSRNonceIncorrectType :
421
+ LinuxDeviceOptions::GetInstance ().mCSRResponseOptions .csrNonceIncorrectType = true ;
422
+ break ;
423
+ case kOptionCSRResponseCSRNonceTooLong :
424
+ LinuxDeviceOptions::GetInstance ().mCSRResponseOptions .csrNonceTooLong = true ;
425
+ break ;
426
+ case kOptionCSRResponseCSRNonceInvalid :
427
+ LinuxDeviceOptions::GetInstance ().mCSRResponseOptions .csrNonceInvalid = true ;
428
+ break ;
429
+ case kOptionCSRResponseNOCSRElementsTooLong :
430
+ LinuxDeviceOptions::GetInstance ().mCSRResponseOptions .nocsrElementsTooLong = true ;
431
+ break ;
432
+ case kOptionCSRResponseAttestationSignatureIncorrectType :
433
+ LinuxDeviceOptions::GetInstance ().mCSRResponseOptions .attestationSignatureIncorrectType = true ;
434
+ break ;
435
+ case kOptionCSRResponseAttestationSignatureInvalid :
436
+ LinuxDeviceOptions::GetInstance ().mCSRResponseOptions .attestationSignatureInvalid = true ;
437
+ break ;
438
+
389
439
default :
390
440
PrintArgError (" %s: INTERNAL ERROR: Unhandled option: %s\n " , aProgram, aName);
391
441
retval = false ;
0 commit comments