3232/* create the hpke key and ech config to send to clients */
3333int wolfSSL_CTX_GenerateEchConfig (WOLFSSL_CTX * ctx , const char * publicName ,
3434 word16 kemId , word16 kdfId , word16 aeadId )
35+ {
36+ return wolfSSL_CTX_GenerateEchConfigEx (ctx , publicName , kemId , kdfId ,
37+ aeadId , 0 );
38+ }
39+
40+ /* create the hpke key and ech config to send to clients
41+ * maximum_name_length may also be set for a more stable padding length */
42+ int wolfSSL_CTX_GenerateEchConfigEx (WOLFSSL_CTX * ctx , const char * publicName ,
43+ word16 kemId , word16 kdfId , word16 aeadId , byte maxNameLen )
3544{
3645 int ret = 0 ;
3746 WOLFSSL_EchConfig * newConfig ;
@@ -129,8 +138,8 @@ int wolfSSL_CTX_GenerateEchConfig(WOLFSSL_CTX* ctx, const char* publicName,
129138 ret = MEMORY_E ;
130139 }
131140 else {
132- XMEMCPY (newConfig -> publicName , publicName ,
133- XSTRLEN ( publicName ) + 1 ) ;
141+ XMEMCPY (newConfig -> publicName , publicName , XSTRLEN ( publicName ) + 1 );
142+ newConfig -> maxNameLen = maxNameLen ;
134143 }
135144 }
136145
@@ -399,8 +408,8 @@ int GetEchConfig(WOLFSSL_EchConfig* config, byte* output, word32* outputLen)
399408 output += 2 ;
400409 }
401410
402- /* set maximum name length to 0 */
403- * output = 0 ;
411+ /* maximum name len */
412+ * output = config -> maxNameLen ;
404413 output ++ ;
405414
406415 /* publicName len */
@@ -411,7 +420,7 @@ int GetEchConfig(WOLFSSL_EchConfig* config, byte* output, word32* outputLen)
411420 XMEMCPY (output , config -> publicName , publicNameLen );
412421 output += publicNameLen ;
413422
414- /* terminating zeros */
423+ /* no extensions, print zeros */
415424 c16toa (0 , output );
416425 /* output += 2; */
417426
@@ -599,12 +608,13 @@ int SetEchConfigsEx(WOLFSSL_EchConfig** outputConfigs, void* heap,
599608 echConfig += 4 ;
600609 }
601610
602- /* ignore the maximum name length */
611+ /* maxNameLen */
603612 idx ++ ;
604613 if (idx >= length ) {
605614 ret = BUFFER_E ;
606615 break ;
607616 }
617+ workingConfig -> maxNameLen = * echConfig ;
608618 echConfig ++ ;
609619
610620 /* publicNameLen */
0 commit comments