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
@@ -418,8 +427,8 @@ int GetEchConfig(WOLFSSL_EchConfig* config, byte* output, word32* outputLen)
418427 output += 2 ;
419428 }
420429
421- /* set maximum name length to 0 */
422- * output = 0 ;
430+ /* maximum name len */
431+ * output = config -> maxNameLen ;
423432 output ++ ;
424433
425434 /* publicName len */
@@ -430,7 +439,7 @@ int GetEchConfig(WOLFSSL_EchConfig* config, byte* output, word32* outputLen)
430439 XMEMCPY (output , config -> publicName , publicNameLen );
431440 output += publicNameLen ;
432441
433- /* terminating zeros */
442+ /* no extensions, print zeros */
434443 c16toa (0 , output );
435444 /* output += 2; */
436445
@@ -656,11 +665,12 @@ int SetEchConfigsEx(WOLFSSL_EchConfig** outputConfigs, void* heap,
656665 idx += 4 ;
657666 }
658667
659- /* ignore maximum name length */
668+ /* maxNameLen */
660669 if (idx + 1 > length ) {
661670 ret = BUFFER_E ;
662671 break ;
663672 }
673+ workingConfig -> maxNameLen = echConfig [idx ];
664674 idx += 1 ;
665675
666676 /* publicName */
@@ -701,7 +711,7 @@ int SetEchConfigsEx(WOLFSSL_EchConfig** outputConfigs, void* heap,
701711 }
702712
703713 ret = EchConfigCheckExtensions (echConfig + idx , extensionsLen );
704- if (ret < 0 )
714+ if (ret < 0 && ret != WC_NO_ERR_TRACE ( UNSUPPORTED_EXTENSION ) )
705715 break ;
706716
707717 /* KEM, ciphersuite, or mandatory extension not supported, free this
0 commit comments