@@ -13270,13 +13270,9 @@ static int TLSX_ECH_Write(WOLFSSL_ECH* ech, byte msgType, byte* writeBuf,
1327013270 word32 configsLen = 0;
1327113271 void* ephemeralKey = NULL;
1327213272 byte* writeBuf_p = writeBuf;
13273- #ifdef WOLFSSL_SMALL_STACK
13274- Hpke* hpke = NULL;
13275- WC_RNG* rng = NULL;
13276- #else
13277- Hpke hpke[1];
13278- WC_RNG rng[1];
13279- #endif
13273+ WC_DECLARE_VAR(hpke, Hpke, 1, DYNAMIC_TYPE_TMP_BUFFER);
13274+ WC_DECLARE_VAR(rng, WC_RNG, 1, DYNAMIC_TYPE_RNG);
13275+
1328013276 WOLFSSL_MSG("TLSX_ECH_Write");
1328113277 if (msgType == hello_retry_request) {
1328213278 /* reserve space to write the confirmation to */
@@ -13322,19 +13318,13 @@ static int TLSX_ECH_Write(WOLFSSL_ECH* ech, byte msgType, byte* writeBuf,
1332213318 }
1332313319 writeBuf_p += 2;
1332413320 if (ech->state == ECH_WRITE_GREASE) {
13325- #ifdef WOLFSSL_SMALL_STACK
13326- hpke = (Hpke*)XMALLOC(sizeof(Hpke), NULL, DYNAMIC_TYPE_TMP_BUFFER);
13327- if (hpke == NULL)
13328- return MEMORY_E;
13329- rng = (WC_RNG*)XMALLOC(sizeof(WC_RNG), NULL, DYNAMIC_TYPE_RNG);
13330- if (rng == NULL) {
13331- XFREE(hpke, NULL, DYNAMIC_TYPE_RNG);
13332- return MEMORY_E;
13333- }
13334- #endif
13321+ WC_ALLOC_VAR_EX(hpke, Hpke, 1, NULL, DYNAMIC_TYPE_TMP_BUFFER, ret = MEMORY_E);
13322+ WC_ALLOC_VAR_EX(rng, WC_RNG, 1, NULL, DYNAMIC_TYPE_RNG, ret = MEMORY_E);
1333513323 /* hpke init */
13336- ret = wc_HpkeInit(hpke, ech->kemId, ech->cipherSuite.kdfId,
13337- ech->cipherSuite.aeadId, NULL);
13324+ if (ret == 0) {
13325+ ret = wc_HpkeInit(hpke, ech->kemId, ech->cipherSuite.kdfId,
13326+ ech->cipherSuite.aeadId, NULL);
13327+ }
1333813328 if (ret == 0)
1333913329 rngRet = ret = wc_InitRng(rng);
1334013330 /* create the ephemeralKey */
0 commit comments