File tree Expand file tree Collapse file tree 2 files changed +39
-25
lines changed
Expand file tree Collapse file tree 2 files changed +39
-25
lines changed Original file line number Diff line number Diff line change 3131
3232#include <wolfssl/wolfcrypt/asn_public.h>
3333
34- /* Dummy type for EPKI to PKI context. */
35- typedef void wp_Epki2Pki ;
36-
37- /* A fake static global context. */
38- static unsigned char fakeCtx [1 ];
34+ /**
35+ * EPKI to PKI context.
36+ */
37+ typedef struct wp_Epki2Pki {
38+ /** Provider context - useful when duplicating. */
39+ WOLFPROV_CTX * provCtx ;
40+ } wp_Epki2Pki ;
3941
4042/**
4143 * Create a new EPKI to PKI context.
@@ -47,20 +49,26 @@ static unsigned char fakeCtx[1];
4749 */
4850static wp_Epki2Pki * wp_epki2pki_newctx (WOLFPROV_CTX * provCtx )
4951{
50- (void )provCtx ;
51- return fakeCtx ;
52+ wp_Epki2Pki * ctx = NULL ;
53+
54+ if (wolfssl_prov_is_running ()) {
55+ ctx = (wp_Epki2Pki * )OPENSSL_zalloc (sizeof (* ctx ));
56+ }
57+ if (ctx != NULL ) {
58+ ctx -> provCtx = provCtx ;
59+ }
60+
61+ return ctx ;
5262}
5363
5464/**
5565 * Dispose of EPKI to PKI context.
5666 *
57- * Nothing to do as it is a global context.
58- *
59- * @param [in] ctx EPKI to PKI context. Unused.
67+ * @param [in] ctx EPKI to PKI context.
6068 */
6169static void wp_epki2pki_freectx (wp_Epki2Pki * ctx )
6270{
63- ( void ) ctx ;
71+ OPENSSL_free ( ctx ) ;
6472}
6573
6674#if LIBWOLFSSL_VERSION_HEX < 0x05000000
Original file line number Diff line number Diff line change 3131
3232#include <wolfssl/wolfcrypt/asn_public.h>
3333
34- /* Dummy type for PEM to DER context. */
35- typedef void wp_Pem2Der ;
36-
37- /* A fake static global context. */
38- static unsigned char fakeCtx [1 ];
34+ /**
35+ * PEM to DER context.
36+ */
37+ typedef struct wp_Pem2Der {
38+ /** Provider context - useful when duplicating. */
39+ WOLFPROV_CTX * provCtx ;
40+ } wp_Pem2Der ;
3941
4042/**
4143 * Create a new PEM to DER context.
4244 *
43- * No context data required so returning a global context.
44- *
45- * @param [in] provCtx Provider context. Unused.
45+ * @param [in] provCtx Provider context.
4646 * @return Pointer to context.
4747 */
4848static wp_Pem2Der * wp_pem2der_newctx (WOLFPROV_CTX * provCtx )
4949{
50- (void )provCtx ;
51- return fakeCtx ;
50+ wp_Pem2Der * ctx = NULL ;
51+
52+ if (wolfssl_prov_is_running ()) {
53+ ctx = (wp_Pem2Der * )OPENSSL_zalloc (sizeof (* ctx ));
54+ }
55+ if (ctx != NULL ) {
56+ ctx -> provCtx = provCtx ;
57+ }
58+
59+ return ctx ;
5260}
5361
5462/**
5563 * Dispose of PEM to DER context.
5664 *
57- * Nothing to do as it is a global context.
58- *
59- * @param [in] ctx PEM to DER context. Unused.
65+ * @param [in] ctx PEM to DER context.
6066 */
6167static void wp_pem2der_freectx (wp_Pem2Der * ctx )
6268{
63- ( void ) ctx ;
69+ OPENSSL_free ( ctx ) ;
6470}
6571
6672/**
You can’t perform that action at this time.
0 commit comments