@@ -262,83 +262,61 @@ static int wp_ecx_digest_verify_init(wp_EcxSigCtx *ctx, const char *mdName,
262262 return ok ;
263263}
264264
265+ /** Parameters that we support getting from the ECX signature context. */
266+ static const OSSL_PARAM wp_supported_gettable_ctx_params [] = {
267+ OSSL_PARAM_octet_string (OSSL_SIGNATURE_PARAM_ALGORITHM_ID , NULL , 0 ),
268+ OSSL_PARAM_END
269+ };
265270/**
266- * Put DER encoding of the Ed25519 signature algorithm in the parameter object .
271+ * Returns an array of ECX signature context parameters that can be retrieved .
267272 *
268- * @param [in] ctx ECX signature context object.
269- * @param [in] p Parameter object.
270- * @return 1 on success.
271- * @return 0 on failure.
273+ * @param [in] ctx ECX signature context object. Unused.
274+ * @param [in] provCtx wolfProvider context object. Unused.
275+ * @return Array of parameters.
272276 */
273- static int wp_ed25519_get_alg_id (wp_EcxSigCtx * ctx , OSSL_PARAM * p )
277+ static const OSSL_PARAM * wp_ecx_gettable_ctx_params (wp_EcxSigCtx * ctx ,
278+ WOLFPROV_CTX * provCtx )
274279{
275- /* Ed25519 Algorithm Id: SEQ OBJ 2b 65 70 */
276- static const byte ed25519AlgId [] = {
277- 0x30 , 0x05 , 0x06 , 0x03 , 0x2b , 0x65 , 0x70 ,
278- };
279-
280280 (void )ctx ;
281-
282- return OSSL_PARAM_set_octet_string ( p , ed25519AlgId , sizeof ( ed25519AlgId )) ;
281+ ( void ) provCtx ;
282+ return wp_supported_gettable_ctx_params ;
283283}
284284
285- /**
286- * Put data from Ed25519 signture context object into parameter objects.
287- *
288- * @param [in] ctx ECX signature context object.
289- * @param [in] params Array of parameter objects.
290- * @return 1 on success.
291- * @return 0 on failure.
292- */
293- static int wp_ed25519_get_ctx_params (wp_EcxSigCtx * ctx , OSSL_PARAM * params )
294- {
295- int ok = 1 ;
296- OSSL_PARAM * p ;
297-
298- if (ctx == NULL ) {
299- ok = 0 ;
300- }
301-
302- if (ok ) {
303- p = OSSL_PARAM_locate (params , OSSL_SIGNATURE_PARAM_ALGORITHM_ID );
304- if (p != NULL ) {
305- ok = wp_ed25519_get_alg_id (ctx , p );
306- }
307- }
285+ #ifdef WP_HAVE_ED25519
308286
309- WOLFPROV_LEAVE ( WP_LOG_KE , __FILE__ ":" WOLFPROV_STRINGIZE ( __LINE__ ), ok );
310- return ok ;
311- }
287+ /*
288+ * Ed25519
289+ */
312290
313291/**
314- * Put DER encoding of the Ed448 signature algorithm in the parameter object.
292+ * Put DER encoding of the Ed25519 signature algorithm in the parameter object.
315293 *
316294 * @param [in] ctx ECX signature context object.
317295 * @param [in] p Parameter object.
318296 * @return 1 on success.
319297 * @return 0 on failure.
320298 */
321- static int wp_ed448_get_alg_id (wp_EcxSigCtx * ctx , OSSL_PARAM * p )
299+ static int wp_ed25519_get_alg_id (wp_EcxSigCtx * ctx , OSSL_PARAM * p )
322300{
323- /* Ed448 Algorithm Id: SEQ OBJ 2b 65 71 */
324- static const byte ed448AlgId [] = {
325- 0x30 , 0x05 , 0x06 , 0x03 , 0x2b , 0x65 , 0x71 ,
301+ /* Ed25519 Algorithm Id: SEQ OBJ 2b 65 70 */
302+ static const byte ed25519AlgId [] = {
303+ 0x30 , 0x05 , 0x06 , 0x03 , 0x2b , 0x65 , 0x70 ,
326304 };
327305
328306 (void )ctx ;
329307
330- return OSSL_PARAM_set_octet_string (p , ed448AlgId , sizeof (ed448AlgId ));
308+ return OSSL_PARAM_set_octet_string (p , ed25519AlgId , sizeof (ed25519AlgId ));
331309}
332310
333311/**
334- * Put data from Ed448 signture context object into parameter objects.
312+ * Put data from Ed25519 signture context object into parameter objects.
335313 *
336314 * @param [in] ctx ECX signature context object.
337315 * @param [in] params Array of parameter objects.
338316 * @return 1 on success.
339317 * @return 0 on failure.
340318 */
341- static int wp_ed448_get_ctx_params (wp_EcxSigCtx * ctx , OSSL_PARAM * params )
319+ static int wp_ed25519_get_ctx_params (wp_EcxSigCtx * ctx , OSSL_PARAM * params )
342320{
343321 int ok = 1 ;
344322 OSSL_PARAM * p ;
@@ -350,40 +328,14 @@ static int wp_ed448_get_ctx_params(wp_EcxSigCtx *ctx, OSSL_PARAM *params)
350328 if (ok ) {
351329 p = OSSL_PARAM_locate (params , OSSL_SIGNATURE_PARAM_ALGORITHM_ID );
352330 if (p != NULL ) {
353- ok = wp_ed448_get_alg_id (ctx , p );
331+ ok = wp_ed25519_get_alg_id (ctx , p );
354332 }
355333 }
356334
357335 WOLFPROV_LEAVE (WP_LOG_KE , __FILE__ ":" WOLFPROV_STRINGIZE (__LINE__ ), ok );
358336 return ok ;
359337}
360338
361- /** Parameters that we support getting from the ECX signature context. */
362- static const OSSL_PARAM wp_supported_gettable_ctx_params [] = {
363- OSSL_PARAM_octet_string (OSSL_SIGNATURE_PARAM_ALGORITHM_ID , NULL , 0 ),
364- OSSL_PARAM_END
365- };
366- /**
367- * Returns an array of ECX signature context parameters that can be retrieved.
368- *
369- * @param [in] ctx ECX signature context object. Unused.
370- * @param [in] provCtx wolfProvider context object. Unused.
371- * @return Array of parameters.
372- */
373- static const OSSL_PARAM * wp_ecx_gettable_ctx_params (wp_EcxSigCtx * ctx ,
374- WOLFPROV_CTX * provCtx )
375- {
376- (void )ctx ;
377- (void )provCtx ;
378- return wp_supported_gettable_ctx_params ;
379- }
380-
381- #ifdef WP_HAVE_ED25519
382-
383- /*
384- * Ed25519
385- */
386-
387339/**
388340 * Sign the data using an Ed25519 key.
389341 *
@@ -529,6 +481,54 @@ const OSSL_DISPATCH wp_ed25519_signature_functions[] = {
529481 * Ed448
530482 */
531483
484+ /**
485+ * Put DER encoding of the Ed448 signature algorithm in the parameter object.
486+ *
487+ * @param [in] ctx ECX signature context object.
488+ * @param [in] p Parameter object.
489+ * @return 1 on success.
490+ * @return 0 on failure.
491+ */
492+ static int wp_ed448_get_alg_id (wp_EcxSigCtx * ctx , OSSL_PARAM * p )
493+ {
494+ /* Ed448 Algorithm Id: SEQ OBJ 2b 65 71 */
495+ static const byte ed448AlgId [] = {
496+ 0x30 , 0x05 , 0x06 , 0x03 , 0x2b , 0x65 , 0x71 ,
497+ };
498+
499+ (void )ctx ;
500+
501+ return OSSL_PARAM_set_octet_string (p , ed448AlgId , sizeof (ed448AlgId ));
502+ }
503+
504+ /**
505+ * Put data from Ed448 signture context object into parameter objects.
506+ *
507+ * @param [in] ctx ECX signature context object.
508+ * @param [in] params Array of parameter objects.
509+ * @return 1 on success.
510+ * @return 0 on failure.
511+ */
512+ static int wp_ed448_get_ctx_params (wp_EcxSigCtx * ctx , OSSL_PARAM * params )
513+ {
514+ int ok = 1 ;
515+ OSSL_PARAM * p ;
516+
517+ if (ctx == NULL ) {
518+ ok = 0 ;
519+ }
520+
521+ if (ok ) {
522+ p = OSSL_PARAM_locate (params , OSSL_SIGNATURE_PARAM_ALGORITHM_ID );
523+ if (p != NULL ) {
524+ ok = wp_ed448_get_alg_id (ctx , p );
525+ }
526+ }
527+
528+ WOLFPROV_LEAVE (WP_LOG_KE , __FILE__ ":" WOLFPROV_STRINGIZE (__LINE__ ), ok );
529+ return ok ;
530+ }
531+
532532/**
533533 * Sign the data using an Ed448 key.
534534 *
0 commit comments