@@ -203,7 +203,6 @@ static int c_debug=0;
203
203
#ifndef OPENSSL_NO_TLSEXT
204
204
static int c_tlsextdebug = 0 ;
205
205
static int c_status_req = 0 ;
206
- static int c_proof_debug = 0 ;
207
206
#endif
208
207
static int c_msg = 0 ;
209
208
static int c_showcerts = 0 ;
@@ -215,14 +214,44 @@ static void sc_usage(void);
215
214
static void print_stuff (BIO * berr ,SSL * con ,int full );
216
215
#ifndef OPENSSL_NO_TLSEXT
217
216
static int ocsp_resp_cb (SSL * s , void * arg );
218
- static int audit_proof_cb (SSL * s , void * arg );
217
+ static int c_auth = 0 ;
218
+ static int c_auth_require_reneg = 0 ;
219
219
#endif
220
220
static BIO * bio_c_out = NULL ;
221
221
static BIO * bio_c_msg = NULL ;
222
222
static int c_quiet = 0 ;
223
223
static int c_ign_eof = 0 ;
224
224
static int c_brief = 0 ;
225
225
226
+ #ifndef OPENSSL_NO_TLSEXT
227
+
228
+ static const unsigned char * most_recent_supplemental_data ;
229
+ static size_t most_recent_supplemental_data_length ;
230
+
231
+ static int server_provided_server_authz = 0 ;
232
+ static int server_provided_client_authz = 0 ;
233
+
234
+ static const unsigned char auth_ext_data []= {TLSEXT_AUTHZDATAFORMAT_dtcp };
235
+
236
+ static int suppdata_cb (SSL * s , unsigned short supp_data_type ,
237
+ const unsigned char * in ,
238
+ unsigned short inlen , int * al ,
239
+ void * arg );
240
+
241
+ static int auth_suppdata_generate_cb (SSL * s , unsigned short supp_data_type ,
242
+ const unsigned char * * out ,
243
+ unsigned short * outlen , void * arg );
244
+
245
+ static int authz_tlsext_generate_cb (SSL * s , unsigned short ext_type ,
246
+ const unsigned char * * out , unsigned short * outlen ,
247
+ void * arg );
248
+
249
+ static int authz_tlsext_cb (SSL * s , unsigned short ext_type ,
250
+ const unsigned char * in ,
251
+ unsigned short inlen , int * al ,
252
+ void * arg );
253
+ #endif
254
+
226
255
#ifndef OPENSSL_NO_PSK
227
256
/* Default PSK identity and key */
228
257
static char * psk_identity = "Client_identity" ;
@@ -362,14 +391,13 @@ static void sc_usage(void)
362
391
BIO_printf (bio_err ," -tlsextdebug - hex dump of all TLS extensions received\n" );
363
392
BIO_printf (bio_err ," -status - request certificate status from server\n" );
364
393
BIO_printf (bio_err ," -no_ticket - disable use of RFC4507bis session tickets\n" );
365
- BIO_printf (bio_err ," -proof_debug - request an audit proof and print its hex dump\n" );
394
+ BIO_printf (bio_err ," -serverinfo types - send empty ClientHello extensions (comma-separated numbers)\n" );
395
+ BIO_printf (bio_err ," -auth - send and receive RFC 5878 TLS auth extensions and supplemental data\n" );
396
+ BIO_printf (bio_err ," -auth_require_reneg - Do not send TLS auth extensions until renegotiation\n" );
366
397
# ifndef OPENSSL_NO_NEXTPROTONEG
367
398
BIO_printf (bio_err ," -nextprotoneg arg - enable NPN extension, considering named protocols supported (comma-separated list)\n" );
368
399
BIO_printf (bio_err ," -alpn arg - enable ALPN extension, considering named protocols supported (comma-separated list)\n" );
369
400
# endif
370
- #ifndef OPENSSL_NO_TLSEXT
371
- BIO_printf (bio_err ," -serverinfo types - send empty ClientHello extensions (comma-separated numbers)\n" );
372
- #endif
373
401
#endif
374
402
BIO_printf (bio_err ," -legacy_renegotiation - enable use of legacy renegotiation (dangerous)\n" );
375
403
BIO_printf (bio_err ," -use_srtp profiles - Offer SRTP key management with a colon-separated profile list\n" );
@@ -823,8 +851,10 @@ static char *jpake_secret = NULL;
823
851
c_tlsextdebug = 1 ;
824
852
else if (strcmp (* argv ,"- status ") == 0 )
825
853
c_status_req = 1 ;
826
- else if (strcmp (* argv ,"- proof_debug ") == 0 )
827
- c_proof_debug = 1 ;
854
+ else if (strcmp (* argv ,"- auth ") == 0 )
855
+ c_auth = 1 ;
856
+ else if (strcmp (* argv ,"- auth_require_reneg ") == 0 )
857
+ c_auth_require_reneg = 1 ;
828
858
#endif
829
859
#ifdef WATT32
830
860
else if (strcmp (* argv ,"- wdebug ") == 0 )
@@ -1399,9 +1429,12 @@ static char *jpake_secret = NULL;
1399
1429
}
1400
1430
1401
1431
#endif
1402
- if (c_proof_debug )
1403
- SSL_CTX_set_tlsext_authz_server_audit_proof_cb (ctx ,
1404
- audit_proof_cb );
1432
+ if (c_auth )
1433
+ {
1434
+ SSL_CTX_set_custom_cli_ext (ctx , TLSEXT_TYPE_client_authz , authz_tlsext_generate_cb , authz_tlsext_cb , bio_err );
1435
+ SSL_CTX_set_custom_cli_ext (ctx , TLSEXT_TYPE_server_authz , authz_tlsext_generate_cb , authz_tlsext_cb , bio_err );
1436
+ SSL_CTX_set_cli_supp_data (ctx , TLSEXT_SUPPLEMENTALDATATYPE_authz_data , suppdata_cb , auth_suppdata_generate_cb , bio_err );
1437
+ }
1405
1438
#endif
1406
1439
1407
1440
con = SSL_new (ctx );
@@ -2395,26 +2428,76 @@ static int ocsp_resp_cb(SSL *s, void *arg)
2395
2428
return 1 ;
2396
2429
}
2397
2430
2398
- static int audit_proof_cb (SSL * s , void * arg )
2431
+ static int authz_tlsext_cb (SSL * s , unsigned short ext_type ,
2432
+ const unsigned char * in ,
2433
+ unsigned short inlen , int * al ,
2434
+ void * arg )
2399
2435
{
2400
- const unsigned char * proof ;
2401
- size_t proof_len ;
2402
- size_t i ;
2403
- SSL_SESSION * sess = SSL_get_session (s );
2404
-
2405
- proof = SSL_SESSION_get_tlsext_authz_server_audit_proof (sess ,
2406
- & proof_len );
2407
- if (proof != NULL )
2436
+ if (TLSEXT_TYPE_server_authz == ext_type )
2408
2437
{
2409
- BIO_printf (bio_c_out , "Audit proof: " );
2410
- for (i = 0 ; i < proof_len ; ++ i )
2411
- BIO_printf (bio_c_out , "%02X" , proof [i ]);
2412
- BIO_printf (bio_c_out , "\n" );
2438
+ server_provided_server_authz = (memchr (in ,
2439
+ TLSEXT_AUTHZDATAFORMAT_dtcp ,
2440
+ inlen ) != NULL );
2413
2441
}
2414
- else
2442
+
2443
+ if (TLSEXT_TYPE_client_authz == ext_type )
2444
+ {
2445
+ server_provided_client_authz = (memchr (in ,
2446
+ TLSEXT_AUTHZDATAFORMAT_dtcp ,
2447
+ inlen ) != NULL );
2448
+ }
2449
+
2450
+ return 1 ;
2451
+ }
2452
+
2453
+ static int authz_tlsext_generate_cb (SSL * s , unsigned short ext_type ,
2454
+ const unsigned char * * out , unsigned short * outlen ,
2455
+ void * arg )
2456
+ {
2457
+ if (c_auth )
2415
2458
{
2416
- BIO_printf (bio_c_out , "No audit proof found.\n" );
2459
+ if (!c_auth_require_reneg || (c_auth_require_reneg && SSL_num_renegotiations (s )))
2460
+ {
2461
+ * out = auth_ext_data ;
2462
+ * outlen = 1 ;
2463
+ return 1 ;
2464
+ }
2465
+ }
2466
+ //no auth extension to send
2467
+ return -1 ;
2468
+ }
2469
+
2470
+ static int suppdata_cb (SSL * s , unsigned short supp_data_type ,
2471
+ const unsigned char * in ,
2472
+ unsigned short inlen , int * al ,
2473
+ void * arg )
2474
+ {
2475
+ if (supp_data_type == TLSEXT_SUPPLEMENTALDATATYPE_authz_data )
2476
+ {
2477
+ most_recent_supplemental_data = in ;
2478
+ most_recent_supplemental_data_length = inlen ;
2417
2479
}
2418
2480
return 1 ;
2419
2481
}
2482
+
2483
+ static int auth_suppdata_generate_cb (SSL * s , unsigned short supp_data_type ,
2484
+ const unsigned char * * out ,
2485
+ unsigned short * outlen , void * arg )
2486
+ {
2487
+ unsigned char * result ;
2488
+ if (c_auth && server_provided_client_authz && server_provided_server_authz )
2489
+ {
2490
+ if (!c_auth_require_reneg || (c_auth_require_reneg && SSL_num_renegotiations (s )))
2491
+ {
2492
+ result = OPENSSL_malloc (10 );
2493
+ memcpy (result , "5432154321" , 10 );
2494
+ * out = result ;
2495
+ * outlen = 10 ;
2496
+ return 1 ;
2497
+ }
2498
+ }
2499
+ //no supplemental data to send
2500
+ return -1 ;
2501
+ }
2502
+
2420
2503
#endif
0 commit comments