@@ -495,6 +495,7 @@ def build_ffi(local_wolfssl, features):
495495 int ML_KEM_ENABLED = """ + str (features ["ML_KEM" ]) + """;
496496 int ML_DSA_ENABLED = """ + str (features ["ML_DSA" ]) + """;
497497 int HKDF_ENABLED = """ + str (features ["HKDF" ]) + """;
498+ int ERROR_STRINGS_ENABLED = """ + str (features ["ERROR_STRINGS" ]) + """;
498499 """
499500
500501 ffibuilder .set_source ( "wolfcrypt._ffi" , init_source_string ,
@@ -534,6 +535,7 @@ def build_ffi(local_wolfssl, features):
534535 extern int ML_KEM_ENABLED;
535536 extern int ML_DSA_ENABLED;
536537 extern int HKDF_ENABLED;
538+ extern int ERROR_STRINGS_ENABLED;
537539
538540 typedef unsigned char byte;
539541 typedef unsigned int word32;
@@ -559,6 +561,7 @@ def build_ffi(local_wolfssl, features):
559561 typedef struct { ...; } mp_int;
560562
561563 int mp_init (mp_int * a);
564+ void mp_clear (mp_int * a);
562565 int mp_to_unsigned_bin (mp_int * a, unsigned char *b);
563566 int mp_to_unsigned_bin_len (mp_int * a, unsigned char *b, int c);
564567 int mp_read_unsigned_bin (mp_int * a, const unsigned char *b, int c);
@@ -570,6 +573,7 @@ def build_ffi(local_wolfssl, features):
570573 int wc_InitSha(wc_Sha*);
571574 int wc_ShaUpdate(wc_Sha*, const byte*, word32);
572575 int wc_ShaFinal(wc_Sha*, byte*);
576+ void wc_ShaFree(wc_Sha*);
573577 """
574578
575579 if features ["SHA256" ]:
@@ -578,6 +582,7 @@ def build_ffi(local_wolfssl, features):
578582 int wc_InitSha256(wc_Sha256*);
579583 int wc_Sha256Update(wc_Sha256*, const byte*, word32);
580584 int wc_Sha256Final(wc_Sha256*, byte*);
585+ void wc_Sha256Free(wc_Sha256*);
581586 """
582587
583588 if features ["SHA384" ]:
@@ -586,6 +591,7 @@ def build_ffi(local_wolfssl, features):
586591 int wc_InitSha384(wc_Sha384*);
587592 int wc_Sha384Update(wc_Sha384*, const byte*, word32);
588593 int wc_Sha384Final(wc_Sha384*, byte*);
594+ void wc_Sha384Free(wc_Sha384*);
589595 """
590596
591597 if features ["SHA512" ]:
@@ -595,6 +601,7 @@ def build_ffi(local_wolfssl, features):
595601 int wc_InitSha512(wc_Sha512*);
596602 int wc_Sha512Update(wc_Sha512*, const byte*, word32);
597603 int wc_Sha512Final(wc_Sha512*, byte*);
604+ void wc_Sha512Free(wc_Sha512*);
598605 """
599606 if features ["SHA3" ]:
600607 cdef += """
@@ -611,6 +618,10 @@ def build_ffi(local_wolfssl, features):
611618 int wc_Sha3_256_Final(wc_Sha3*, byte*);
612619 int wc_Sha3_384_Final(wc_Sha3*, byte*);
613620 int wc_Sha3_512_Final(wc_Sha3*, byte*);
621+ int wc_Sha3_224_Free(wc_Sha3*);
622+ int wc_Sha3_256_Free(wc_Sha3*);
623+ int wc_Sha3_384_Free(wc_Sha3*);
624+ int wc_Sha3_512_Free(wc_Sha3*);
614625 """
615626
616627 if features ["DES3" ]:
@@ -707,6 +718,7 @@ def build_ffi(local_wolfssl, features):
707718 int wc_HmacSetKey(Hmac*, int, const byte*, word32);
708719 int wc_HmacUpdate(Hmac*, const byte*, word32);
709720 int wc_HmacFinal(Hmac*, byte*);
721+ void wc_HmacFree(Hmac*);
710722 """
711723
712724 if features ["RSA" ]:
@@ -991,6 +1003,11 @@ def build_ffi(local_wolfssl, features):
9911003 int wolfCrypt_GetPrivateKeyReadEnable_fips(enum wc_KeyType);
9921004 """
9931005
1006+ if features ["ERROR_STRINGS" ]:
1007+ cdef += """
1008+ const char* wc_GetErrorString(int error);
1009+ """
1010+
9941011 if features ["ML_KEM" ] or features ["ML_DSA" ]:
9951012 cdef += """
9961013 static const int INVALID_DEVID;
0 commit comments