@@ -126,6 +126,60 @@ volatile sword16 mlkem_opt_blocker = 0;
126126
127127/******************************************************************************/
128128
129+ #ifndef WC_NO_CONSTRUCTORS
130+ /**
131+ * Create a new ML-KEM key object.
132+ *
133+ * Allocates and initializes a ML-KEM key object.
134+ *
135+ * @param [in] type Type of key:
136+ * WC_ML_KEM_512, WC_ML_KEM_768, WC_ML_KEM_1024,
137+ * KYBER512, KYBER768, KYBER1024.
138+ * @param [in] heap Dynamic memory hint.
139+ * @param [in] devId Device Id.
140+ * @return Pointer to new MlKemKey object, or NULL on failure.
141+ */
142+
143+ MlKemKey * wc_MlKemKey_New (int type , void * heap , int devId )
144+ {
145+ int ret ;
146+ MlKemKey * key = (MlKemKey * )XMALLOC (sizeof (MlKemKey ), heap ,
147+ DYNAMIC_TYPE_TMP_BUFFER );
148+ if (key != NULL ) {
149+ ret = wc_MlKemKey_Init (key , type , heap , devId );
150+ if (ret != 0 ) {
151+ XFREE (key , heap , DYNAMIC_TYPE_TMP_BUFFER );
152+ key = NULL ;
153+ }
154+ }
155+
156+ return key ;
157+ }
158+
159+ /**
160+ * Delete and free a ML-KEM key object.
161+ *
162+ * Frees resources associated with a ML-KEM key object and sets pointer to NULL.
163+ *
164+ * @param [in] key ML-KEM key object to delete.
165+ * @param [in, out] key_p Pointer to key pointer to set to NULL.
166+ * @return 0 on success.
167+ * @return BAD_FUNC_ARG when key is NULL.
168+ */
169+
170+ int wc_MlKemKey_Delete (MlKemKey * key , MlKemKey * * key_p )
171+ {
172+ if (key == NULL )
173+ return BAD_FUNC_ARG ;
174+ wc_MlKemKey_Free (key );
175+ XFREE (key , key -> heap , DYNAMIC_TYPE_TMP_BUFFER );
176+ if (key_p != NULL )
177+ * key_p = NULL ;
178+
179+ return 0 ;
180+ }
181+ #endif /* !WC_NO_CONSTRUCTORS */
182+
129183/**
130184 * Initialize the Kyber key.
131185 *
0 commit comments