mirror of https://github.com/openssl/openssl.git
decode_pem2der: convert to use generated parameter parsing
Reviewed-by: Paul Yang <paulyang.inf@gmail.com> Reviewed-by: Shane Lontis <shane.lontis@oracle.com> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/28152)
This commit is contained in:
parent
324fc17017
commit
70e33aef6e
|
@ -6,6 +6,9 @@
|
||||||
* in the file LICENSE in the source distribution or at
|
* in the file LICENSE in the source distribution or at
|
||||||
* https://www.openssl.org/source/license.html
|
* https://www.openssl.org/source/license.html
|
||||||
*/
|
*/
|
||||||
|
{-
|
||||||
|
use OpenSSL::paramnames qw(produce_param_decoder);
|
||||||
|
-}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* RSA low level APIs are deprecated for public use, but still ok for
|
* RSA low level APIs are deprecated for public use, but still ok for
|
||||||
|
@ -23,6 +26,7 @@
|
||||||
#include <openssl/params.h>
|
#include <openssl/params.h>
|
||||||
#include <openssl/pem.h>
|
#include <openssl/pem.h>
|
||||||
#include <openssl/proverr.h>
|
#include <openssl/proverr.h>
|
||||||
|
#include "internal/cryptlib.h"
|
||||||
#include "internal/nelem.h"
|
#include "internal/nelem.h"
|
||||||
#include "internal/sizes.h"
|
#include "internal/sizes.h"
|
||||||
#include "prov/bio.h"
|
#include "prov/bio.h"
|
||||||
|
@ -74,32 +78,33 @@ static void pem2der_freectx(void *vctx)
|
||||||
OPENSSL_free(ctx);
|
OPENSSL_free(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{- produce_param_decoder('pem2der_set_ctx_params',
|
||||||
|
(['DECODER_PARAM_PROPERTIES', 'propq', 'utf8_string'],
|
||||||
|
['OBJECT_PARAM_DATA_STRUCTURE', 'ds', 'utf8_string'],
|
||||||
|
)); -}
|
||||||
|
|
||||||
static const OSSL_PARAM *pem2der_settable_ctx_params(ossl_unused void *provctx)
|
static const OSSL_PARAM *pem2der_settable_ctx_params(ossl_unused void *provctx)
|
||||||
{
|
{
|
||||||
static const OSSL_PARAM settables[] = {
|
return pem2der_set_ctx_params_list;
|
||||||
OSSL_PARAM_utf8_string(OSSL_DECODER_PARAM_PROPERTIES, NULL, 0),
|
|
||||||
OSSL_PARAM_utf8_string(OSSL_OBJECT_PARAM_DATA_STRUCTURE, NULL, 0),
|
|
||||||
OSSL_PARAM_END
|
|
||||||
};
|
|
||||||
return settables;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int pem2der_set_ctx_params(void *vctx, const OSSL_PARAM params[])
|
static int pem2der_set_ctx_params(void *vctx, const OSSL_PARAM params[])
|
||||||
{
|
{
|
||||||
struct pem2der_ctx_st *ctx = vctx;
|
struct pem2der_ctx_st *ctx = vctx;
|
||||||
const OSSL_PARAM *p;
|
struct pem2der_set_ctx_params_st p;
|
||||||
char *str;
|
char *str;
|
||||||
|
|
||||||
p = OSSL_PARAM_locate_const(params, OSSL_DECODER_PARAM_PROPERTIES);
|
if (ctx == NULL || !pem2der_set_ctx_params_decoder(params, &p))
|
||||||
str = ctx->propq;
|
return 0;
|
||||||
if (p != NULL
|
|
||||||
&& !OSSL_PARAM_get_utf8_string(p, &str, sizeof(ctx->propq)))
|
str = ctx->propq;
|
||||||
|
if (p.propq != NULL
|
||||||
|
&& !OSSL_PARAM_get_utf8_string(p.propq, &str, sizeof(ctx->propq)))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
p = OSSL_PARAM_locate_const(params, OSSL_OBJECT_PARAM_DATA_STRUCTURE);
|
|
||||||
str = ctx->data_structure;
|
str = ctx->data_structure;
|
||||||
if (p != NULL
|
if (p.ds != NULL
|
||||||
&& !OSSL_PARAM_get_utf8_string(p, &str, sizeof(ctx->data_structure)))
|
&& !OSSL_PARAM_get_utf8_string(p.ds, &str, sizeof(ctx->data_structure)))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
Loading…
Reference in New Issue