apply patches to original opensource openssl-3.5.0. NOTE: This commit will NOT COMPILE. (#17)

Reviewed-on: http://13.234.246.121:3000/Neominds/ossl35vx69/pulls/17
Co-authored-by: siddhant <siddhant.singh@neominds.in>
Co-committed-by: siddhant <siddhant.singh@neominds.in>
This commit is contained in:
2026-07-30 19:33:32 +05:30
committed by neelimap
parent 1fa225b5aa
commit 23ab638c92
91 changed files with 1792 additions and 108 deletions
@@ -35,6 +35,12 @@
#include <openssl/ssl.h> /* for OPENSSL_INIT_(NO_)?LOAD_SSL_STRINGS */
#include "crypto/ctype.h"
#include "sslerr.h"
#if defined(OPENSSL_SYS_VXWORKS)
#include <stdio.h>
#include <semLib.h>
#include <openssl/provider.h>
#include "ipcrypto_config.h"
#endif
static int stopped = 0;
static uint64_t optsdone = 0;
@@ -109,8 +115,10 @@ DEFINE_RUN_ONCE_STATIC(ossl_init_register_atexit)
if (_onexit(win32atexit) == NULL)
return 0;
# else
# if !defined(_WRS_KERNEL)
if (atexit(OPENSSL_cleanup) != 0)
return 0;
# endif
# endif
# endif
#endif
@@ -762,3 +770,117 @@ int OPENSSL_atexit(void (*handler)(void))
return 1;
}
#if defined(OPENSSL_SYS_VXWORKS)
BIO *bio_out = NULL;
BIO *bio_err = NULL;
char *default_config_file = IPCRYPTO_DEFAULT_CONFIG_FILE;
#define SEM_ID_NULL NULL
RAND_METHOD* vxRandLibMeth(void);
extern int OPENSSL_thread_started();
static STATUS openSSLTaskDeleteHook (TASK_ID taskId)
{
/*
* Ensure OPENSSL_thread_stop is called for tasking using OpenSSL which
* relies on TSS API.
* OPENSSL_thread_stop might access TSS API for the first time and register
* thrdDeleteHook if current task is not using OpenSSL. It is not a designed
* behavior to register one task delete hook while running another one.
*/
if (OPENSSL_thread_started ())
{
OPENSSL_thread_stop ();
}
return OK;
}
/*******************************************************************************
*
* crypto_init_internal - initialize openssl algorithms and setup callback function
*/
int ipcrypto_init_internal(SEM_ID semId)
{
static int init = 0;
OSSL_PROVIDER *legacy;
OSSL_PROVIDER *deflt;
if(init == 0)
{
init = 1;
#ifndef _WRS_CONFIG_OPENSSL_FIPSMODULE
RAND_set_rand_method(vxRandLibMeth());
#endif
OpenSSL_add_all_algorithms();
/* Init things so we will get meaningful error messages rather than numbers. */
ERR_load_crypto_strings();
#ifndef OPENSSL_NO_ENGINE
ENGINE_load_builtin_engines();
#endif
legacy = OSSL_PROVIDER_load(NULL, "legacy");
if (legacy == NULL) {
printf("Failed to load Legacy provider\n");
}
deflt = OSSL_PROVIDER_load(NULL, "default");
if (deflt == NULL) {
printf("Failed to load Default provider\n");
OSSL_PROVIDER_unload(legacy);
}
#if defined (_WRS_KERNEL)
/* use shareable FILEs rather than task-specific stdout/stderr */
FILE * fpout = _Files[1];
FILE * fperr = _Files[2];
bio_out = BIO_new_fp(fpout, BIO_NOCLOSE | BIO_FP_TEXT);
bio_err = BIO_new_fp(fperr, BIO_NOCLOSE | BIO_FP_TEXT);
#else
bio_out = BIO_new_fp(stdout, BIO_NOCLOSE | BIO_FP_TEXT);
bio_err = BIO_new_fp(stderr, BIO_NOCLOSE | BIO_FP_TEXT);
#endif /* _WRS_KERNEL */
/*
* Explicitly deallocates resources associated with one task when task
* exits. VxWorks uses C11 thread-specific API tssXXX to implement
* CRYPTO_THREAD_XXX API. But as the cleanup passed to tss_create is
* invoked only for C11 thread not for normal task or pthread, that
* would cause memory leak without OPENSSL_thread_stop being called.
* This step has to be placed at the end to make sure this hook is
* added after TSS hook thrdDeleteHookInit and hence called earlier.
*/
if (taskDeleteHookAdd ((FUNCPTR) openSSLTaskDeleteHook) != OK) {
printf ("ipcrypto_init_internal() failed to add delete hook");
return -1;
}
}
if (semId)
(void)semGive(semId);
return OK;
}
#ifndef _WRS_KERNEL
/*******************************************************************************
*
* crypto_init - it must run after pthreadLibInit and pthreadRwLocksInit
*/
_WRS_CONSTRUCTOR(ipcrypto_init, 70)
{
(void)ipcrypto_init_internal(SEM_ID_NULL);
}
#endif /*_WRS_KERNEL*/
#endif /*OPENSSL_SYS_VXWORKS*/