10 Commits
Author SHA1 Message Date
neelimapandneelimap 0a1429e9fe FTP build support for m241 (#97)
Co-authored-by: neelimap <neelimaps@neominds.in>
Reviewed-on: http://13.234.246.121:3000/Neominds/ossl35vx69/pulls/97
Co-authored-by: Neelima P S <neelima.ps@neominds.in>
Co-committed-by: Neelima P S <neelima.ps@neominds.in>
2026-07-30 20:48:01 +05:30
neelimapandneelimap 3ded5de19e changes in ssl.h.in (#94)
Co-authored-by: neelimap <neelimaps@neominds.in>
Reviewed-on: http://13.234.246.121:3000/Neominds/ossl35vx69/pulls/94
Co-authored-by: Neelima P S <neelima.ps@neominds.in>
Co-committed-by: Neelima P S <neelima.ps@neominds.in>
2026-07-30 20:48:01 +05:30
neelimapandssingh c7b071e9cf Cherry-pick PR#89 to m241 branch . Adding original ipcom_key_db.c, ipcrypto_key_db_example_keys.c for FTP build. NOTE This commit will NOT compile (#90)
Reviewed-on: http://13.234.246.121:3000/Neominds/ossl35vx69/pulls/89
Co-authored-by: siddhant <siddhant.singh@neominds.in>
Co-committed-by: siddhant <siddhant.singh@neominds.in>
Co-authored-by: siddhant <siddhant.singh@neominds.in>
Reviewed-on: http://13.234.246.121:3000/Neominds/ossl35vx69/pulls/90
Co-authored-by: Neelima P S <neelima.ps@neominds.in>
Co-committed-by: Neelima P S <neelima.ps@neominds.in>
2026-07-30 20:48:01 +05:30
ssingh bc24b5948d created COMPONENT for LIST command. (#79)
Reviewed-on: http://13.234.246.121:3000/Neominds/ossl35vx69/pulls/79
Co-authored-by: siddhant <siddhant.singh@neominds.in>
Co-committed-by: siddhant <siddhant.singh@neominds.in>
2026-07-30 20:48:00 +05:30
ssingh 86208d2959 set bio_out=dup_bio_out(FORMAT_TEXT) in verify_main.c (#78)
Reviewed-on: http://13.234.246.121:3000/Neominds/ossl35vx69/pulls/78
Co-authored-by: siddhant <siddhant.singh@neominds.in>
Co-committed-by: siddhant <siddhant.singh@neominds.in>
2026-07-30 20:48:00 +05:30
ssingh 0b30d404f1 set bio_err=dup_bio_err(FORMAT_TEXT) for all crypto shell cmds. (#77)
[build.log](/attachments/19a9f16f-6abd-4920-b272-1a625ebd1f29)

Reviewed-on: http://13.234.246.121:3000/Neominds/ossl35vx69/pulls/77
Co-authored-by: siddhant <siddhant.singh@neominds.in>
Co-committed-by: siddhant <siddhant.singh@neominds.in>
2026-07-30 20:48:00 +05:30
neelimapandneelimap 52606ba138 Added trace messages for category ENTROPY (#75)
Co-authored-by: neelimap <neelimaps@neominds.in>
Reviewed-on: http://13.234.246.121:3000/Neominds/ossl35vx69/pulls/75
Co-authored-by: Neelima P S <neelima.ps@neominds.in>
Co-committed-by: Neelima P S <neelima.ps@neominds.in>
2026-07-30 20:46:34 +05:30
bjayesh 1f8cf8b317 Merge pull request 'Enabled Trace by default, added trace routines to libapps and added setup_trace to all configurable apps.' (#74) from enable_trace_support into master
Reviewed-on: http://13.234.246.121:3000/Neominds/ossl35vx69/pulls/74
2026-07-30 20:46:02 +05:30
ssingh cc16d0b785 add function to get release date to customer (#73)
Reviewed-on: http://13.234.246.121:3000/Neominds/ossl35vx69/pulls/73
Co-authored-by: siddhant <siddhant.singh@neominds.in>
Co-committed-by: siddhant <siddhant.singh@neominds.in>
2026-07-30 20:45:02 +05:30
ssingh a263b7da47 add debug trace in vxrcu.c (#71)
Reviewed-on: http://13.234.246.121:3000/Neominds/ossl35vx69/pulls/71
Co-authored-by: siddhant <siddhant.singh@neominds.in>
Co-committed-by: siddhant <siddhant.singh@neominds.in>
2026-07-30 20:45:02 +05:30
55 changed files with 2045 additions and 500 deletions
+41 -7
View File
@@ -27,7 +27,6 @@
#include "ipftps_config.h" #include "ipftps_config.h"
#define IPCOM_USE_CLIB_PROTO
#include <ipcom_clib.h> #include <ipcom_clib.h>
#include <ipcom_clib2.h> #include <ipcom_clib2.h>
#include <ipcom_err.h> #include <ipcom_err.h>
@@ -77,19 +76,36 @@ IP_STATIC DH *get_dh512(void)
0x02, 0x02,
}; };
DH *dh; DH *dh;
BIGNUM *p = NULL;
BIGNUM *g = NULL;
if ((dh=DH_new()) == IP_NULL) if ((dh=DH_new()) == IP_NULL)
{ {
return IP_NULL; return IP_NULL;
} }
dh->p=BN_bin2bn(dh512_p,sizeof(dh512_p),IP_NULL); p = BN_bin2bn(dh512_p, sizeof(dh512_p), IP_NULL);
dh->g=BN_bin2bn(dh512_g,sizeof(dh512_g),IP_NULL); g = BN_bin2bn(dh512_g, sizeof(dh512_g), IP_NULL);
if ((dh->p == IP_NULL) || (dh->g == IP_NULL)) if ((p == IP_NULL) || (g == IP_NULL))
{ {
DH_free(dh); DH_free(dh);
if (p)
BN_free(p);
if (g)
BN_free(g);
return IP_NULL; return IP_NULL;
} }
if (DH_set0_pqg(dh, p, NULL, g) != 1)
{
DH_free(dh);
if (p)
BN_free(p);
if (g)
BN_free(g);
return IP_NULL;
}
return dh; return dh;
} }
@@ -112,20 +128,38 @@ IP_STATIC DH *get_dh1024(void)
0x02, 0x02,
}; };
DH *dh; DH *dh;
BIGNUM *p = NULL;
BIGNUM *g = NULL;
if ((dh=DH_new()) == IP_NULL) if ((dh=DH_new()) == IP_NULL)
{ {
return IP_NULL; return IP_NULL;
} }
dh->p=BN_bin2bn(dh1024_p,sizeof(dh1024_p),IP_NULL); p = BN_bin2bn(dh1024_p, sizeof(dh1024_p), IP_NULL);
dh->g=BN_bin2bn(dh1024_g,sizeof(dh1024_g),IP_NULL); g = BN_bin2bn(dh1024_g, sizeof(dh1024_g), IP_NULL);
if ((dh->p == IP_NULL) || (dh->g == IP_NULL)) if ((p == IP_NULL) || (g == IP_NULL))
{ {
DH_free(dh); DH_free(dh);
if (p)
BN_free(p);
if (g)
BN_free(g);
return IP_NULL; return IP_NULL;
} }
if (DH_set0_pqg(dh, p, NULL, g) != 1)
{
DH_free(dh);
if (p)
BN_free(p);
if (g)
BN_free(g);
return IP_NULL;
}
return dh; return dh;
} }
File diff suppressed because it is too large Load Diff
@@ -70,6 +70,14 @@ Component INCLUDE_DGST_CMD
REQUIRES INCLUDE_IPCRYPTO INCLUDE_IPCOM_SHELL_CMD REQUIRES INCLUDE_IPCRYPTO INCLUDE_IPCOM_SHELL_CMD
} }
Component INCLUDE_LIST_CMD
{
NAME OpenSSL list shell command
SYNOPSIS This component includes the OpenSSL list shell command.
_CHILDREN FOLDER_OPENSSL_3_5_0_USE_CMDS
REQUIRES INCLUDE_IPCRYPTO INCLUDE_IPCOM_SHELL_CMD
}
Component INCLUDE_DHPARAM_CMD Component INCLUDE_DHPARAM_CMD
{ {
NAME OpenSSL dhparam shell command NAME OpenSSL dhparam shell command
@@ -62,6 +62,7 @@ extern int verify_main(int argc, char ** argv);
extern int asn1parse_main(int argc, char ** argv); extern int asn1parse_main(int argc, char ** argv);
extern int req_main(int argc,char *argv[]); extern int req_main(int argc,char *argv[]);
extern int dgst_main(int argc,char *argv[]); extern int dgst_main(int argc,char *argv[]);
extern int list_main(int argc, char **argv);
/* /*
* dh command has been obsoleted by dhparam since OpenSSL 1.1.1. * dh command has been obsoleted by dhparam since OpenSSL 1.1.1.
* extern int dh_main(int argc,char *argv[]); * extern int dh_main(int argc,char *argv[]);
@@ -187,6 +188,10 @@ static int ipcrypto_req_main(int argc,char *argv[]);
static int ipcrypto_dgst_main(int argc,char *argv[]); static int ipcrypto_dgst_main(int argc,char *argv[]);
#endif #endif
#ifdef INCLUDE_LIST_CMD
static int ipcrypto_list_main(int argc, char ** argv);
#endif
#ifdef INCLUDE_DH_CMD #ifdef INCLUDE_DH_CMD
static int ipcrypto_dh_main(int argc,char *argv[]); static int ipcrypto_dh_main(int argc,char *argv[]);
#endif #endif
@@ -326,6 +331,7 @@ int ipcrypto_configure(void);
* 7 DATA * 7 DATA
**************************************************************************** ****************************************************************************
*/ */
static const char* WR_REL_VER = "M241/EAR Release -06-24-26";
/* /*
*=========================================================================== *===========================================================================
@@ -383,6 +389,14 @@ ipcrypto_dgst_main(int argc,char *argv[])
} }
#endif #endif
#ifdef INCLUDE_LIST_CMD
static int ipcrypto_list_main(int argc, char ** argv)
{
ipcrypto_cmds_startup();
return list_main(argc, argv);
}
#endif
#ifdef INCLUDE_DH_CMD #ifdef INCLUDE_DH_CMD
static int static int
ipcrypto_dh_main(int argc,char *argv[]) ipcrypto_dh_main(int argc,char *argv[])
@@ -700,6 +714,11 @@ ipcrypto_storeutl_main(int argc,char *argv[])
**************************************************************************** ****************************************************************************
*/ */
void get_ossl350_WR_release_version()
{
fprintf(stderr, "%s\n", WR_REL_VER);
}
/* /*
**************************************************************************** ****************************************************************************
* 11 PUBLIC FUNCTIONS * 11 PUBLIC FUNCTIONS
@@ -735,6 +754,11 @@ ipcrypto_configure(void)
#if defined(INCLUDE_DGST_CMD) #if defined(INCLUDE_DGST_CMD)
(void)ipcrypto_shell_add_cmd("dgst", "dgst [options] [file ...]", "Message Digest Calculation", ipcrypto_dgst_main); (void)ipcrypto_shell_add_cmd("dgst", "dgst [options] [file ...]", "Message Digest Calculation", ipcrypto_dgst_main);
#endif #endif
#if defined(INCLUDE_LIST_CMD)
(void)ipcrypto_shell_add_cmd("list", "list [option]",
"lists which ciphers, providers, or other modules are available in the build",
ipcrypto_list_main);
#endif
#ifndef OPENSSL_NO_DH #ifndef OPENSSL_NO_DH
#if defined(INCLUDE_DH_CMD) #if defined(INCLUDE_DH_CMD)
@@ -17,6 +17,8 @@
#include <openssl/x509.h> #include <openssl/x509.h>
#include <openssl/pem.h> #include <openssl/pem.h>
#include <openssl/asn1t.h> #include <openssl/asn1t.h>
#include <openssl/trace.h>
#include "app_trace.h"
typedef enum OPTION_choice { typedef enum OPTION_choice {
OPT_COMMON, OPT_COMMON,
@@ -77,6 +79,15 @@ int asn1parse_main(int argc, char **argv)
OPTION_CHOICE o; OPTION_CHOICE o;
const ASN1_ITEM *it = NULL; const ASN1_ITEM *it = NULL;
#ifndef OPENSSL_NO_TRACE
setup_trace(getenv("OPENSSL_TRACE"));
#endif
#if defined(OPENSSL_SYS_VXWORKS_SUPPORT)
if (bio_err == NULL)
bio_err = dup_bio_err(FORMAT_TEXT);
#endif
prog = opt_init(argc, argv, asn1parse_options); prog = opt_init(argc, argv, asn1parse_options);
if ((osk = sk_OPENSSL_STRING_new_null()) == NULL) { if ((osk = sk_OPENSSL_STRING_new_null()) == NULL) {
@@ -24,6 +24,8 @@
#include <openssl/objects.h> #include <openssl/objects.h>
#include <openssl/ocsp.h> #include <openssl/ocsp.h>
#include <openssl/pem.h> #include <openssl/pem.h>
#include <openssl/trace.h>
#include "app_trace.h"
#ifndef W_OK #ifndef W_OK
# ifdef OPENSSL_SYS_VMS # ifdef OPENSSL_SYS_VMS
@@ -308,6 +310,15 @@ int ca_main(int argc, char **argv)
X509_REVOKED *r = NULL; X509_REVOKED *r = NULL;
OPTION_CHOICE o; OPTION_CHOICE o;
#ifndef OPENSSL_NO_TRACE
setup_trace(getenv("OPENSSL_TRACE"));
#endif
#if defined(OPENSSL_SYS_VXWORKS_SUPPORT)
if (bio_err == NULL)
bio_err = dup_bio_err(FORMAT_TEXT);
#endif
prog = opt_init(argc, argv, ca_options); prog = opt_init(argc, argv, ca_options);
while ((o = opt_next()) != OPT_EOF) { while ((o = opt_next()) != OPT_EOF) {
switch (o) { switch (o) {
@@ -17,6 +17,8 @@
#include <openssl/x509.h> #include <openssl/x509.h>
#include <openssl/x509v3.h> #include <openssl/x509v3.h>
#include <openssl/pem.h> #include <openssl/pem.h>
#include <openssl/trace.h>
#include "app_trace.h"
typedef enum OPTION_choice { typedef enum OPTION_choice {
OPT_COMMON, OPT_COMMON,
@@ -98,6 +100,15 @@ int crl_main(int argc, char **argv)
int hash_old = 0; int hash_old = 0;
#endif #endif
#ifndef OPENSSL_NO_TRACE
setup_trace(getenv("OPENSSL_TRACE"));
#endif
#if defined(OPENSSL_SYS_VXWORKS_SUPPORT)
if (bio_err == NULL)
bio_err = dup_bio_err(FORMAT_TEXT);
#endif
opt_set_unknown_name("digest"); opt_set_unknown_name("digest");
prog = opt_init(argc, argv, crl_options); prog = opt_init(argc, argv, crl_options);
while ((o = opt_next()) != OPT_EOF) { while ((o = opt_next()) != OPT_EOF) {
@@ -18,6 +18,8 @@
#include <openssl/pkcs7.h> #include <openssl/pkcs7.h>
#include <openssl/pem.h> #include <openssl/pem.h>
#include <openssl/objects.h> #include <openssl/objects.h>
#include <openssl/trace.h>
#include "app_trace.h"
static int add_certs_from_file(STACK_OF(X509) *stack, char *certfile); static int add_certs_from_file(STACK_OF(X509) *stack, char *certfile);
@@ -60,6 +62,15 @@ int crl2pkcs7_main(int argc, char **argv)
0; 0;
OPTION_CHOICE o; OPTION_CHOICE o;
#ifndef OPENSSL_NO_TRACE
setup_trace(getenv("OPENSSL_TRACE"));
#endif
#if defined(OPENSSL_SYS_VXWORKS_SUPPORT)
if (bio_err == NULL)
bio_err = dup_bio_err(FORMAT_TEXT);
#endif
prog = opt_init(argc, argv, crl2pkcs7_options); prog = opt_init(argc, argv, crl2pkcs7_options);
while ((o = opt_next()) != OPT_EOF) { while ((o = opt_next()) != OPT_EOF) {
switch (o) { switch (o) {
@@ -20,6 +20,8 @@
#include <openssl/pem.h> #include <openssl/pem.h>
#include <openssl/hmac.h> #include <openssl/hmac.h>
#include <ctype.h> #include <ctype.h>
#include <openssl/trace.h>
#include "app_trace.h"
#undef OSSL_DGST_BUFSIZE #undef OSSL_DGST_BUFSIZE
#define OSSL_DGST_BUFSIZE 1024*8 #define OSSL_DGST_BUFSIZE 1024*8
@@ -117,6 +119,15 @@ int dgst_main(int argc, char **argv)
EVP_MD_CTX *signctx = NULL; EVP_MD_CTX *signctx = NULL;
int oneshot_sign = 0; int oneshot_sign = 0;
#ifndef OPENSSL_NO_TRACE
setup_trace(getenv("OPENSSL_TRACE"));
#endif
#if defined(OPENSSL_SYS_VXWORKS_SUPPORT)
if (bio_err == NULL)
bio_err = dup_bio_err(FORMAT_TEXT);
#endif
reset_unknown(); reset_unknown();
buf = app_malloc(OSSL_DGST_BUFSIZE, "I/O buffer"); buf = app_malloc(OSSL_DGST_BUFSIZE, "I/O buffer");
@@ -27,6 +27,8 @@
#include <openssl/param_build.h> #include <openssl/param_build.h>
#include <openssl/encoder.h> #include <openssl/encoder.h>
#include <openssl/decoder.h> #include <openssl/decoder.h>
#include <openssl/trace.h>
#include "app_trace.h"
#define DEFBITS 2048 #define DEFBITS 2048
@@ -91,6 +93,15 @@ int dhparam_main(int argc, char **argv)
int informat = FORMAT_PEM, outformat = FORMAT_PEM, check = 0, noout = 0; int informat = FORMAT_PEM, outformat = FORMAT_PEM, check = 0, noout = 0;
OPTION_CHOICE o; OPTION_CHOICE o;
#ifndef OPENSSL_NO_TRACE
setup_trace(getenv("OPENSSL_TRACE"));
#endif
#if defined(OPENSSL_SYS_VXWORKS_SUPPORT)
if (bio_err == NULL)
bio_err = dup_bio_err(FORMAT_TEXT);
#endif
prog = opt_init(argc, argv, dhparam_options); prog = opt_init(argc, argv, dhparam_options);
while ((o = opt_next()) != OPT_EOF) { while ((o = opt_next()) != OPT_EOF) {
switch (o) { switch (o) {
@@ -25,6 +25,8 @@
#include <openssl/encoder.h> #include <openssl/encoder.h>
#include <openssl/core_names.h> #include <openssl/core_names.h>
#include <openssl/core_dispatch.h> #include <openssl/core_dispatch.h>
#include <openssl/trace.h>
#include "app_trace.h"
#ifndef OPENSSL_NO_RC4 #ifndef OPENSSL_NO_RC4
# define DEFAULT_PVK_ENCR_STRENGTH 2 # define DEFAULT_PVK_ENCR_STRENGTH 2
@@ -92,6 +94,15 @@ int dsa_main(int argc, char **argv)
int selection = 0; int selection = 0;
OSSL_ENCODER_CTX *ectx = NULL; OSSL_ENCODER_CTX *ectx = NULL;
#ifndef OPENSSL_NO_TRACE
setup_trace(getenv("OPENSSL_TRACE"));
#endif
#if defined(OPENSSL_SYS_VXWORKS_SUPPORT)
if (bio_err == NULL)
bio_err = dup_bio_err(FORMAT_TEXT);
#endif
opt_set_unknown_name("cipher"); opt_set_unknown_name("cipher");
prog = opt_init(argc, argv, dsa_options); prog = opt_init(argc, argv, dsa_options);
while ((o = opt_next()) != OPT_EOF) { while ((o = opt_next()) != OPT_EOF) {
@@ -21,6 +21,8 @@
#include <openssl/dsa.h> #include <openssl/dsa.h>
#include <openssl/x509.h> #include <openssl/x509.h>
#include <openssl/pem.h> #include <openssl/pem.h>
#include <openssl/trace.h>
#include "app_trace.h"
static int verbose = 0; static int verbose = 0;
@@ -74,6 +76,15 @@ int dsaparam_main(int argc, char **argv)
char *infile = NULL, *outfile = NULL, *prog; char *infile = NULL, *outfile = NULL, *prog;
OPTION_CHOICE o; OPTION_CHOICE o;
#ifndef OPENSSL_NO_TRACE
setup_trace(getenv("OPENSSL_TRACE"));
#endif
#if defined(OPENSSL_SYS_VXWORKS_SUPPORT)
if (bio_err == NULL)
bio_err = dup_bio_err(FORMAT_TEXT);
#endif
prog = opt_init(argc, argv, dsaparam_options); prog = opt_init(argc, argv, dsaparam_options);
while ((o = opt_next()) != OPT_EOF) { while ((o = opt_next()) != OPT_EOF) {
switch (o) { switch (o) {
@@ -16,6 +16,8 @@
#include <openssl/core_dispatch.h> #include <openssl/core_dispatch.h>
#include <openssl/params.h> #include <openssl/params.h>
#include <openssl/err.h> #include <openssl/err.h>
#include <openssl/trace.h>
#include "app_trace.h"
#include "apps.h" #include "apps.h"
#include "progs.h" #include "progs.h"
@@ -80,6 +82,15 @@ int ec_main(int argc, char **argv)
char *point_format = NULL; char *point_format = NULL;
int no_public = 0; int no_public = 0;
#ifndef OPENSSL_NO_TRACE
setup_trace(getenv("OPENSSL_TRACE"));
#endif
#if defined(OPENSSL_SYS_VXWORKS_SUPPORT)
if (bio_err == NULL)
bio_err = dup_bio_err(FORMAT_TEXT);
#endif
opt_set_unknown_name("cipher"); opt_set_unknown_name("cipher");
prog = opt_init(argc, argv, ec_options); prog = opt_init(argc, argv, ec_options);
while ((o = opt_next()) != OPT_EOF) { while ((o = opt_next()) != OPT_EOF) {
@@ -20,6 +20,8 @@
#include "apps.h" #include "apps.h"
#include "progs.h" #include "progs.h"
#include "ec_common.h" #include "ec_common.h"
#include <openssl/trace.h>
#include "app_trace.h"
typedef enum OPTION_choice { typedef enum OPTION_choice {
OPT_COMMON, OPT_COMMON,
@@ -107,6 +109,15 @@ int ecparam_main(int argc, char **argv)
int no_seed = 0, check = 0, check_named = 0, text = 0, genkey = 0; int no_seed = 0, check = 0, check_named = 0, text = 0, genkey = 0;
int list_curves = 0; int list_curves = 0;
#ifndef OPENSSL_NO_TRACE
setup_trace(getenv("OPENSSL_TRACE"));
#endif
#if defined(OPENSSL_SYS_VXWORKS_SUPPORT)
if (bio_err == NULL)
bio_err = dup_bio_err(FORMAT_TEXT);
#endif
prog = opt_init(argc, argv, ecparam_options); prog = opt_init(argc, argv, ecparam_options);
while ((o = opt_next()) != OPT_EOF) { while ((o = opt_next()) != OPT_EOF) {
switch (o) { switch (o) {
@@ -20,6 +20,8 @@
#include <openssl/x509.h> #include <openssl/x509.h>
#include <openssl/rand.h> #include <openssl/rand.h>
#include <openssl/pem.h> #include <openssl/pem.h>
#include <openssl/trace.h>
#include "app_trace.h"
#ifndef OPENSSL_NO_COMP #ifndef OPENSSL_NO_COMP
# include <openssl/comp.h> # include <openssl/comp.h>
#endif #endif
@@ -159,6 +161,15 @@ int enc_main(int argc, char **argv)
EVP_SKEY *skey = NULL; EVP_SKEY *skey = NULL;
EVP_SKEYMGMT *mgmt = NULL; EVP_SKEYMGMT *mgmt = NULL;
#ifndef OPENSSL_NO_TRACE
setup_trace(getenv("OPENSSL_TRACE"));
#endif
#if defined(OPENSSL_SYS_VXWORKS_SUPPORT)
if (bio_err == NULL)
bio_err = dup_bio_err(FORMAT_TEXT);
#endif
reset_unknown(); reset_unknown();
/* first check the command name */ /* first check the command name */
@@ -21,6 +21,8 @@
#include <openssl/engine.h> #include <openssl/engine.h>
#include <openssl/ssl.h> #include <openssl/ssl.h>
#include <openssl/store.h> #include <openssl/store.h>
#include <openssl/trace.h>
#include "app_trace.h"
typedef enum OPTION_choice { typedef enum OPTION_choice {
OPT_COMMON, OPT_COMMON,
@@ -308,6 +310,15 @@ int engine_main(int argc, char **argv)
char *prog; char *prog;
char *argv1; char *argv1;
#ifndef OPENSSL_NO_TRACE
setup_trace(getenv("OPENSSL_TRACE"));
#endif
#if defined(OPENSSL_SYS_VXWORKS_SUPPORT)
if (bio_err == NULL)
bio_err = dup_bio_err(FORMAT_TEXT);
#endif
out = dup_bio_out(FORMAT_TEXT); out = dup_bio_out(FORMAT_TEXT);
if (engines == NULL || pre_cmds == NULL || post_cmds == NULL) if (engines == NULL || pre_cmds == NULL || post_cmds == NULL)
goto end; goto end;
@@ -21,6 +21,8 @@
#include <openssl/dsa.h> #include <openssl/dsa.h>
#include <openssl/x509.h> #include <openssl/x509.h>
#include <openssl/pem.h> #include <openssl/pem.h>
#include <openssl/trace.h>
#include "app_trace.h"
typedef enum OPTION_choice { typedef enum OPTION_choice {
OPT_COMMON, OPT_COMMON,
@@ -63,6 +65,15 @@ int gendsa_main(int argc, char **argv)
OPTION_CHOICE o; OPTION_CHOICE o;
int ret = 1, private = 0, verbose = 0, nbits; int ret = 1, private = 0, verbose = 0, nbits;
#ifndef OPENSSL_NO_TRACE
setup_trace(getenv("OPENSSL_TRACE"));
#endif
#if defined(OPENSSL_SYS_VXWORKS_SUPPORT)
if (bio_err == NULL)
bio_err = dup_bio_err(FORMAT_TEXT);
#endif
opt_set_unknown_name("cipher"); opt_set_unknown_name("cipher");
prog = opt_init(argc, argv, gendsa_options); prog = opt_init(argc, argv, gendsa_options);
while ((o = opt_next()) != OPT_EOF) { while ((o = opt_next()) != OPT_EOF) {
@@ -14,6 +14,8 @@
#include <openssl/pem.h> #include <openssl/pem.h>
#include <openssl/err.h> #include <openssl/err.h>
#include <openssl/evp.h> #include <openssl/evp.h>
#include <openssl/trace.h>
#include "app_trace.h"
static int verbose = 1; static int verbose = 1;
@@ -120,6 +122,15 @@ int genpkey_main(int argc, char **argv)
OSSL_LIB_CTX *libctx = app_get0_libctx(); OSSL_LIB_CTX *libctx = app_get0_libctx();
STACK_OF(OPENSSL_STRING) *keyopt = NULL; STACK_OF(OPENSSL_STRING) *keyopt = NULL;
#ifndef OPENSSL_NO_TRACE
setup_trace(getenv("OPENSSL_TRACE"));
#endif
#if defined(OPENSSL_SYS_VXWORKS_SUPPORT)
if (bio_err == NULL)
bio_err = dup_bio_err(FORMAT_TEXT);
#endif
opt_set_unknown_name("cipher"); opt_set_unknown_name("cipher");
prog = opt_init(argc, argv, genpkey_options); prog = opt_init(argc, argv, genpkey_options);
keyopt = sk_OPENSSL_STRING_new_null(); keyopt = sk_OPENSSL_STRING_new_null();
@@ -23,6 +23,8 @@
#include <openssl/x509.h> #include <openssl/x509.h>
#include <openssl/pem.h> #include <openssl/pem.h>
#include <openssl/rand.h> #include <openssl/rand.h>
#include <openssl/trace.h>
#include "app_trace.h"
#define DEFBITS 2048 #define DEFBITS 2048
#define DEFPRIMES 2 #define DEFPRIMES 2
@@ -89,6 +91,15 @@ int genrsa_main(int argc, char **argv)
OPTION_CHOICE o; OPTION_CHOICE o;
int traditional = 0; int traditional = 0;
#ifndef OPENSSL_NO_TRACE
setup_trace(getenv("OPENSSL_TRACE"));
#endif
#if defined(OPENSSL_SYS_VXWORKS_SUPPORT)
if (bio_err == NULL)
bio_err = dup_bio_err(FORMAT_TEXT);
#endif
if (bn == NULL || cb == NULL) if (bn == NULL || cb == NULL)
goto end; goto end;
@@ -0,0 +1,40 @@
/*
* Copyright 2019-2023 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the Apache License 2.0 (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
* in the file LICENSE in the source distribution or at
* https://www.openssl.org/source/license.html
*/
#ifndef OPENSSL_APPS_TRACE_H
# define OPENSSL_APPS_TRACE_H
# pragma once
# include <stdarg.h>
# include <openssl/bio.h>
# include <openssl/trace.h>
# ifdef __cplusplus
extern "C" {
# endif
#ifndef OPENSSL_NO_TRACE
typedef struct tracedata_st {
BIO *bio;
unsigned int ingroup:1;
} tracedata;
void setup_trace(const char *str);
#endif /* OPENSSL_NO_TRACE */
# ifdef __cplusplus
}
# endif
#endif
@@ -0,0 +1,146 @@
/*
* Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the Apache License 2.0 (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
* in the file LICENSE in the source distribution or at
* https://www.openssl.org/source/license.html
*/
#include "app_trace.h"
#include "apps.h"
#include <openssl/trace.h>
#ifndef OPENSSL_NO_TRACE
BIO *trace_bio_err = NULL;
static size_t internal_trace_cb(const char *buf, size_t cnt,
int category, int cmd, void *vdata)
{
int ret = 0;
tracedata *trace_data = vdata;
char buffer[256], *hex;
CRYPTO_THREAD_ID tid;
switch (cmd) {
case OSSL_TRACE_CTRL_BEGIN:
if (trace_data->ingroup) {
BIO_printf(trace_bio_err, "ERROR: tracing already started\n");
return 0;
}
trace_data->ingroup = 1;
tid = CRYPTO_THREAD_get_current_id();
hex = OPENSSL_buf2hexstr((const unsigned char *)&tid, sizeof(tid));
BIO_snprintf(buffer, sizeof(buffer), "TRACE[%s]:%s: ",
hex == NULL ? "<null>" : hex,
OSSL_trace_get_category_name(category));
OPENSSL_free(hex);
BIO_set_prefix(trace_data->bio, buffer);
break;
case OSSL_TRACE_CTRL_WRITE:
if (!trace_data->ingroup) {
BIO_printf(trace_bio_err, "ERROR: writing when tracing not started\n");
return 0;
}
ret = BIO_write(trace_data->bio, buf, cnt);
break;
case OSSL_TRACE_CTRL_END:
if (!trace_data->ingroup) {
BIO_printf(trace_bio_err, "ERROR: finishing when tracing not started\n");
return 0;
}
trace_data->ingroup = 0;
BIO_set_prefix(trace_data->bio, NULL);
break;
}
return ret < 0 ? 0 : ret;
}
DEFINE_STACK_OF(tracedata)
static STACK_OF(tracedata) *trace_data_stack;
void tracedata_free(tracedata *data)
{
BIO_free_all(data->bio);
OPENSSL_free(data);
}
static void cleanup_trace(void)
{
sk_tracedata_pop_free(trace_data_stack, tracedata_free);
}
static void setup_trace_category(int category)
{
BIO *channel;
tracedata *trace_data;
BIO *bio = NULL;
if (OSSL_trace_enabled(category))
return;
bio = BIO_new(BIO_f_prefix());
channel = BIO_push(bio, dup_bio_err(FORMAT_TEXT));
trace_data = OPENSSL_zalloc(sizeof(*trace_data));
if (trace_data == NULL
|| bio == NULL
|| (trace_data->bio = channel) == NULL
|| OSSL_trace_set_callback(category, internal_trace_cb,
trace_data) == 0
|| sk_tracedata_push(trace_data_stack, trace_data) == 0) {
fprintf(stderr,
"warning: unable to setup trace callback for category '%s'.\n",
OSSL_trace_get_category_name(category));
OSSL_trace_set_callback(category, NULL, NULL);
BIO_free_all(channel);
}
}
void setup_trace(const char *str)
{
char *val;
OSSL_trace_unset_all_callbacks();
/*
* We add this handler as early as possible to ensure it's executed
* as late as possible, i.e. after the TRACE code has done its cleanup
* (which happens last in OPENSSL_cleanup).
*/
atexit(cleanup_trace);
trace_data_stack = sk_tracedata_new_null();
val = OPENSSL_strdup(str);
if (val != NULL) {
char *valp = val;
char *item;
for (valp = val; (item = strtok(valp, ",")) != NULL; valp = NULL) {
int category = OSSL_trace_get_category_num(item);
if (category == OSSL_TRACE_CATEGORY_ALL) {
while (++category < OSSL_TRACE_CATEGORY_NUM)
setup_trace_category(category);
break;
} else if (category > 0) {
setup_trace_category(category);
} else {
fprintf(stderr,
"warning: unknown trace category: '%s'.\n", item);
}
}
}
OPENSSL_free(val);
}
#endif /* OPENSSL_NO_TRACE */
@@ -8,7 +8,7 @@ IF[{- $config{target} =~ /^vms-/ -}]
ENDIF ENDIF
# Source for libapps # Source for libapps
$LIBAPPSSRC=apps.c apps_ui.c log.c opt.c fmt.c s_cb.c s_socket.c app_rand.c \ $LIBAPPSSRC=apps.c app_trace.c apps_ui.c log.c opt.c fmt.c s_cb.c s_socket.c app_rand.c \
columns.c app_params.c names.c app_provider.c app_x509.c http_server.c \ columns.c app_params.c names.c app_provider.c app_x509.c http_server.c \
engine_lib.c engine_loader.c app_libctx.c apps_opt_printf.c engine_lib.c engine_loader.c app_libctx.c apps_opt_printf.c
@@ -26,11 +26,13 @@
#include <openssl/safestack.h> #include <openssl/safestack.h>
#include <openssl/ssl.h> #include <openssl/ssl.h>
#include <openssl/tls1.h> #include <openssl/tls1.h>
#include <openssl/trace.h>
#include "apps.h" #include "apps.h"
#include "app_params.h" #include "app_params.h"
#include "progs.h" #include "progs.h"
#include "opt.h" #include "opt.h"
#include "names.h" #include "names.h"
#include "app_trace.h"
static int verbose = 0; static int verbose = 0;
static const char *select_name = NULL; static const char *select_name = NULL;
@@ -1768,6 +1770,18 @@ int list_main(int argc, char **argv)
verbose = 0; /* Clear a possible previous call */ verbose = 0; /* Clear a possible previous call */
#ifndef OPENSSL_NO_TRACE
setup_trace(getenv("OPENSSL_TRACE"));
#endif
#if defined(OPENSSL_SYS_VXWORKS_SUPPORT)
if (bio_err == NULL)
bio_err = dup_bio_err(FORMAT_TEXT);
if (bio_out == NULL)
bio_out = dup_bio_out(FORMAT_TEXT);
#endif
prog = opt_init(argc, argv, list_options); prog = opt_init(argc, argv, list_options);
while ((o = opt_next()) != OPT_EOF) { while ((o = opt_next()) != OPT_EOF) {
switch (o) { switch (o) {
@@ -13,6 +13,8 @@
#include "progs.h" #include "progs.h"
#include <openssl/pem.h> #include <openssl/pem.h>
#include <openssl/err.h> #include <openssl/err.h>
#include <openssl/trace.h>
#include "app_trace.h"
typedef enum OPTION_choice { typedef enum OPTION_choice {
OPT_COMMON, OPT_COMMON,
@@ -44,6 +46,15 @@ int nseq_main(int argc, char **argv)
int toseq = 0, ret = 1, i; int toseq = 0, ret = 1, i;
char *infile = NULL, *outfile = NULL, *prog; char *infile = NULL, *outfile = NULL, *prog;
#ifndef OPENSSL_NO_TRACE
setup_trace(getenv("OPENSSL_TRACE"));
#endif
#if defined(OPENSSL_SYS_VXWORKS_SUPPORT)
if (bio_err == NULL)
bio_err = dup_bio_err(FORMAT_TEXT);
#endif
prog = opt_init(argc, argv, nseq_options); prog = opt_init(argc, argv, nseq_options);
while ((o = opt_next()) != OPT_EOF) { while ((o = opt_next()) != OPT_EOF) {
switch (o) { switch (o) {
@@ -32,6 +32,8 @@
#include <openssl/evp.h> #include <openssl/evp.h>
#include <openssl/bn.h> #include <openssl/bn.h>
#include <openssl/x509v3.h> #include <openssl/x509v3.h>
#include <openssl/trace.h>
#include "app_trace.h"
#if defined(OPENSSL_SYS_VXWORKS) #if defined(OPENSSL_SYS_VXWORKS)
/* not supported */ /* not supported */
@@ -252,6 +254,15 @@ int ocsp_main(int argc, char **argv)
unsigned long sign_flags = 0, verify_flags = 0, rflags = 0; unsigned long sign_flags = 0, verify_flags = 0, rflags = 0;
OPTION_CHOICE o; OPTION_CHOICE o;
#ifndef OPENSSL_NO_TRACE
setup_trace(getenv("OPENSSL_TRACE"));
#endif
#if defined(OPENSSL_SYS_VXWORKS_SUPPORT)
if (bio_err == NULL)
bio_err = dup_bio_err(FORMAT_TEXT);
#endif
if ((reqnames = sk_OPENSSL_STRING_new_null()) == NULL if ((reqnames = sk_OPENSSL_STRING_new_null()) == NULL
|| (ids = sk_OCSP_CERTID_new_null()) == NULL || (ids = sk_OCSP_CERTID_new_null()) == NULL
|| (vpm = X509_VERIFY_PARAM_new()) == NULL) || (vpm = X509_VERIFY_PARAM_new()) == NULL)
@@ -21,6 +21,8 @@
#endif #endif
#include <openssl/md5.h> #include <openssl/md5.h>
#include <openssl/sha.h> #include <openssl/sha.h>
#include <openssl/trace.h>
#include "app_trace.h"
static const unsigned char cov_2char[64] = { static const unsigned char cov_2char[64] = {
/* from crypto/des/fcrypt.c */ /* from crypto/des/fcrypt.c */
@@ -107,6 +109,15 @@ int passwd_main(int argc, char **argv)
size_t pw_maxlen = 256; /* arbitrary limit, should be enough for most size_t pw_maxlen = 256; /* arbitrary limit, should be enough for most
* passwords */ * passwords */
#ifndef OPENSSL_NO_TRACE
setup_trace(getenv("OPENSSL_TRACE"));
#endif
#if defined(OPENSSL_SYS_VXWORKS_SUPPORT)
if (bio_err == NULL)
bio_err = dup_bio_err(FORMAT_TEXT);
#endif
prog = opt_init(argc, argv, passwd_options); prog = opt_init(argc, argv, passwd_options);
while ((o = opt_next()) != OPT_EOF) { while ((o = opt_next()) != OPT_EOF) {
switch (o) { switch (o) {
@@ -22,6 +22,8 @@
#include <openssl/provider.h> #include <openssl/provider.h>
#include <openssl/kdf.h> #include <openssl/kdf.h>
#include <openssl/rand.h> #include <openssl/rand.h>
#include <openssl/trace.h>
#include "app_trace.h"
#define NOKEYS 0x1 #define NOKEYS 0x1
#define NOCERTS 0x2 #define NOCERTS 0x2
@@ -191,6 +193,15 @@ int pkcs12_main(int argc, char **argv)
EVP_CIPHER *enc = (EVP_CIPHER *)default_enc; EVP_CIPHER *enc = (EVP_CIPHER *)default_enc;
OPTION_CHOICE o; OPTION_CHOICE o;
#ifndef OPENSSL_NO_TRACE
setup_trace(getenv("OPENSSL_TRACE"));
#endif
#if defined(OPENSSL_SYS_VXWORKS_SUPPORT)
if (bio_err == NULL)
bio_err = dup_bio_err(FORMAT_TEXT);
#endif
opt_set_unknown_name("cipher"); opt_set_unknown_name("cipher");
prog = opt_init(argc, argv, pkcs12_options); prog = opt_init(argc, argv, pkcs12_options);
while ((o = opt_next()) != OPT_EOF) { while ((o = opt_next()) != OPT_EOF) {
@@ -19,6 +19,8 @@
#include <openssl/x509.h> #include <openssl/x509.h>
#include <openssl/pkcs7.h> #include <openssl/pkcs7.h>
#include <openssl/pem.h> #include <openssl/pem.h>
#include <openssl/trace.h>
#include "app_trace.h"
typedef enum OPTION_choice { typedef enum OPTION_choice {
OPT_COMMON, OPT_COMMON,
@@ -64,6 +66,15 @@ int pkcs7_main(int argc, char **argv)
OPTION_CHOICE o; OPTION_CHOICE o;
OSSL_LIB_CTX *libctx = app_get0_libctx(); OSSL_LIB_CTX *libctx = app_get0_libctx();
#ifndef OPENSSL_NO_TRACE
setup_trace(getenv("OPENSSL_TRACE"));
#endif
#if defined(OPENSSL_SYS_VXWORKS_SUPPORT)
if (bio_err == NULL)
bio_err = dup_bio_err(FORMAT_TEXT);
#endif
prog = opt_init(argc, argv, pkcs7_options); prog = opt_init(argc, argv, pkcs7_options);
while ((o = opt_next()) != OPT_EOF) { while ((o = opt_next()) != OPT_EOF) {
switch (o) { switch (o) {
@@ -16,6 +16,8 @@
#include <openssl/err.h> #include <openssl/err.h>
#include <openssl/evp.h> #include <openssl/evp.h>
#include <openssl/pkcs12.h> #include <openssl/pkcs12.h>
#include <openssl/trace.h>
#include "app_trace.h"
#define STR(a) XSTR(a) #define STR(a) XSTR(a)
#define XSTR(a) #a #define XSTR(a) #a
@@ -95,6 +97,15 @@ int pkcs8_main(int argc, char **argv)
#endif #endif
int saltlen = 0; /* A value of zero chooses the default */ int saltlen = 0; /* A value of zero chooses the default */
#ifndef OPENSSL_NO_TRACE
setup_trace(getenv("OPENSSL_TRACE"));
#endif
#if defined(OPENSSL_SYS_VXWORKS_SUPPORT)
if (bio_err == NULL)
bio_err = dup_bio_err(FORMAT_TEXT);
#endif
prog = opt_init(argc, argv, pkcs8_options); prog = opt_init(argc, argv, pkcs8_options);
while ((o = opt_next()) != OPT_EOF) { while ((o = opt_next()) != OPT_EOF) {
switch (o) { switch (o) {
@@ -16,6 +16,8 @@
#include <openssl/err.h> #include <openssl/err.h>
#include <openssl/evp.h> #include <openssl/evp.h>
#include <openssl/core_names.h> #include <openssl/core_names.h>
#include <openssl/trace.h>
#include "app_trace.h"
typedef enum OPTION_choice { typedef enum OPTION_choice {
OPT_COMMON, OPT_COMMON,
@@ -83,6 +85,15 @@ int pkey_main(int argc, char **argv)
char *point_format = NULL; char *point_format = NULL;
#endif #endif
#ifndef OPENSSL_NO_TRACE
setup_trace(getenv("OPENSSL_TRACE"));
#endif
#if defined(OPENSSL_SYS_VXWORKS_SUPPORT)
if (bio_err == NULL)
bio_err = dup_bio_err(FORMAT_TEXT);
#endif
opt_set_unknown_name("cipher"); opt_set_unknown_name("cipher");
prog = opt_init(argc, argv, pkey_options); prog = opt_init(argc, argv, pkey_options);
while ((o = opt_next()) != OPT_EOF) { while ((o = opt_next()) != OPT_EOF) {
@@ -15,6 +15,8 @@
#include <openssl/pem.h> #include <openssl/pem.h>
#include <openssl/err.h> #include <openssl/err.h>
#include <openssl/evp.h> #include <openssl/evp.h>
#include <openssl/trace.h>
#include "app_trace.h"
typedef enum OPTION_choice { typedef enum OPTION_choice {
OPT_COMMON, OPT_COMMON,
@@ -53,6 +55,15 @@ int pkeyparam_main(int argc, char **argv)
OPTION_CHOICE o; OPTION_CHOICE o;
char *infile = NULL, *outfile = NULL, *prog; char *infile = NULL, *outfile = NULL, *prog;
#ifndef OPENSSL_NO_TRACE
setup_trace(getenv("OPENSSL_TRACE"));
#endif
#if defined(OPENSSL_SYS_VXWORKS_SUPPORT)
if (bio_err == NULL)
bio_err = dup_bio_err(FORMAT_TEXT);
#endif
prog = opt_init(argc, argv, pkeyparam_options); prog = opt_init(argc, argv, pkeyparam_options);
while ((o = opt_next()) != OPT_EOF) { while ((o = opt_next()) != OPT_EOF) {
switch (o) { switch (o) {
@@ -14,6 +14,8 @@
#include <openssl/pem.h> #include <openssl/pem.h>
#include <openssl/evp.h> #include <openssl/evp.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <openssl/trace.h>
#include "app_trace.h"
#define KEY_NONE 0 #define KEY_NONE 0
#define KEY_PRIVKEY 1 #define KEY_PRIVKEY 1
@@ -149,6 +151,17 @@ int pkeyutl_main(int argc, char **argv)
EVP_MD_CTX *mctx = NULL; EVP_MD_CTX *mctx = NULL;
EVP_MD *md = NULL; EVP_MD *md = NULL;
int filesize = -1; int filesize = -1;
#ifndef OPENSSL_NO_TRACE
setup_trace(getenv("OPENSSL_TRACE"));
#endif
#if defined(OPENSSL_SYS_VXWORKS_SUPPORT)
if (bio_err == NULL)
bio_err = dup_bio_err(FORMAT_TEXT);
#endif
OSSL_LIB_CTX *libctx = app_get0_libctx(); OSSL_LIB_CTX *libctx = app_get0_libctx();
prog = opt_init(argc, argv, pkeyutl_options); prog = opt_init(argc, argv, pkeyutl_options);
@@ -17,6 +17,8 @@
#include <openssl/bio.h> #include <openssl/bio.h>
#include <openssl/err.h> #include <openssl/err.h>
#include <openssl/rand.h> #include <openssl/rand.h>
#include <openssl/trace.h>
#include "app_trace.h"
typedef enum OPTION_choice { typedef enum OPTION_choice {
OPT_COMMON, OPT_COMMON,
@@ -58,6 +60,16 @@ int rand_main(int argc, char **argv)
uint64_t scaled_num = 0; uint64_t scaled_num = 0;
uint8_t *buf = NULL; uint8_t *buf = NULL;
#ifndef OPENSSL_NO_TRACE
setup_trace(getenv("OPENSSL_TRACE"));
#endif
#if defined(OPENSSL_SYS_VXWORKS_SUPPORT)
if (bio_err == NULL)
bio_err = dup_bio_err(FORMAT_TEXT);
#endif
prog = opt_init(argc, argv, rand_options); prog = opt_init(argc, argv, rand_options);
while ((o = opt_next()) != OPT_EOF) { while ((o = opt_next()) != OPT_EOF) {
switch (o) { switch (o) {
@@ -27,6 +27,8 @@
#include <openssl/bn.h> #include <openssl/bn.h>
#include <openssl/lhash.h> #include <openssl/lhash.h>
#include <openssl/rsa.h> #include <openssl/rsa.h>
#include <openssl/trace.h>
#include "app_trace.h"
#ifndef OPENSSL_NO_DSA #ifndef OPENSSL_NO_DSA
# include <openssl/dsa.h> # include <openssl/dsa.h>
#endif #endif
@@ -275,6 +277,16 @@ int req_main(int argc, char **argv)
long newkey_len = -1; long newkey_len = -1;
unsigned long chtype = MBSTRING_ASC, reqflag = 0; unsigned long chtype = MBSTRING_ASC, reqflag = 0;
#ifndef OPENSSL_NO_TRACE
setup_trace(getenv("OPENSSL_TRACE"));
#endif
#if defined(OPENSSL_SYS_VXWORKS_SUPPORT)
if (bio_err == NULL)
bio_err = dup_bio_err(FORMAT_TEXT);
#endif
cipher = (EVP_CIPHER *)EVP_aes_256_cbc(); cipher = (EVP_CIPHER *)EVP_aes_256_cbc();
opt_set_unknown_name("digest"); opt_set_unknown_name("digest");
@@ -26,6 +26,8 @@
#include <openssl/pem.h> #include <openssl/pem.h>
#include <openssl/bn.h> #include <openssl/bn.h>
#include <openssl/encoder.h> #include <openssl/encoder.h>
#include <openssl/trace.h>
#include "app_trace.h"
/* /*
* This include is to get OSSL_KEYMGMT_SELECT_*, which feels a bit * This include is to get OSSL_KEYMGMT_SELECT_*, which feels a bit
@@ -139,6 +141,16 @@ int rsa_main(int argc, char **argv)
int selection = 0; int selection = 0;
OSSL_ENCODER_CTX *ectx = NULL; OSSL_ENCODER_CTX *ectx = NULL;
#ifndef OPENSSL_NO_TRACE
setup_trace(getenv("OPENSSL_TRACE"));
#endif
#if defined(OPENSSL_SYS_VXWORKS_SUPPORT)
if (bio_err == NULL)
bio_err = dup_bio_err(FORMAT_TEXT);
#endif
opt_set_unknown_name("cipher"); opt_set_unknown_name("cipher");
prog = opt_init(argc, argv, rsa_options); prog = opt_init(argc, argv, rsa_options);
while ((o = opt_next()) != OPT_EOF) { while ((o = opt_next()) != OPT_EOF) {
@@ -15,6 +15,8 @@
#include <openssl/err.h> #include <openssl/err.h>
#include <openssl/pem.h> #include <openssl/pem.h>
#include <openssl/rsa.h> #include <openssl/rsa.h>
#include <openssl/trace.h>
#include "app_trace.h"
#define RSA_SIGN 1 #define RSA_SIGN 1
#define RSA_VERIFY 2 #define RSA_VERIFY 2
@@ -85,6 +87,16 @@ int rsautl_main(int argc, char **argv)
int hexdump = 0, asn1parse = 0, need_priv = 0, rev = 0; int hexdump = 0, asn1parse = 0, need_priv = 0, rev = 0;
OPTION_CHOICE o; OPTION_CHOICE o;
#ifndef OPENSSL_NO_TRACE
setup_trace(getenv("OPENSSL_TRACE"));
#endif
#if defined(OPENSSL_SYS_VXWORKS_SUPPORT)
if (bio_err == NULL)
bio_err = dup_bio_err(FORMAT_TEXT);
#endif
prog = opt_init(argc, argv, rsautl_options); prog = opt_init(argc, argv, rsautl_options);
while ((o = opt_next()) != OPT_EOF) { while ((o = opt_next()) != OPT_EOF) {
switch (o) { switch (o) {
@@ -48,6 +48,8 @@ typedef unsigned int u_int;
#include "s_apps.h" #include "s_apps.h"
#include "timeouts.h" #include "timeouts.h"
#include "internal/sockets.h" #include "internal/sockets.h"
#include <openssl/trace.h>
#include "app_trace.h"
#if defined(__has_feature) #if defined(__has_feature)
# if __has_feature(memory_sanitizer) # if __has_feature(memory_sanitizer)
@@ -961,6 +963,10 @@ int s_client_main(int argc, char **argv)
BIO_ADDR *peer_addr = NULL; BIO_ADDR *peer_addr = NULL;
struct user_data_st user_data; struct user_data_st user_data;
#ifndef OPENSSL_NO_TRACE
setup_trace(getenv("OPENSSL_TRACE"));
#endif
FD_ZERO(&readfds); FD_ZERO(&readfds);
FD_ZERO(&writefds); FD_ZERO(&writefds);
/* Known false-positive of MemorySanitizer. */ /* Known false-positive of MemorySanitizer. */
@@ -57,6 +57,8 @@ typedef unsigned int u_int;
#include <openssl/ebcdic.h> #include <openssl/ebcdic.h>
#endif #endif
#include "internal/sockets.h" #include "internal/sockets.h"
#include <openssl/trace.h>
#include "app_trace.h"
static int not_resumable_sess_cb(SSL *s, int is_forward_secure); static int not_resumable_sess_cb(SSL *s, int is_forward_secure);
static int sv_body(int s, int stype, int prot, unsigned char *context); static int sv_body(int s, int stype, int prot, unsigned char *context);
@@ -1114,6 +1116,10 @@ int s_server_main(int argc, char *argv[])
use_sendfile = 0; use_sendfile = 0;
use_zc_sendfile = 0; use_zc_sendfile = 0;
#ifndef OPENSSL_NO_TRACE
setup_trace(getenv("OPENSSL_TRACE"));
#endif
#if defined(OPENSSL_SYS_VXWORKS_SUPPORT) #if defined(OPENSSL_SYS_VXWORKS_SUPPORT)
if (bio_err == NULL) if (bio_err == NULL)
bio_err = dup_bio_err(FORMAT_TEXT); bio_err = dup_bio_err(FORMAT_TEXT);
@@ -18,6 +18,8 @@
#include <openssl/err.h> #include <openssl/err.h>
#include <openssl/x509_vfy.h> #include <openssl/x509_vfy.h>
#include <openssl/x509v3.h> #include <openssl/x509v3.h>
#include <openssl/trace.h>
#include "app_trace.h"
static int save_certs(char *signerfile, STACK_OF(X509) *signers); static int save_certs(char *signerfile, STACK_OF(X509) *signers);
static int smime_cb(int ok, X509_STORE_CTX *ctx); static int smime_cb(int ok, X509_STORE_CTX *ctx);
@@ -184,6 +186,17 @@ int smime_main(int argc, char **argv)
int vpmtouched = 0, rv = 0; int vpmtouched = 0, rv = 0;
ENGINE *e = NULL; ENGINE *e = NULL;
const char *mime_eol = "\n"; const char *mime_eol = "\n";
#ifndef OPENSSL_NO_TRACE
setup_trace(getenv("OPENSSL_TRACE"));
#endif
#if defined(OPENSSL_SYS_VXWORKS_SUPPORT)
if (bio_err == NULL)
bio_err = dup_bio_err(FORMAT_TEXT);
#endif
OSSL_LIB_CTX *libctx = app_get0_libctx(); OSSL_LIB_CTX *libctx = app_get0_libctx();
if ((vpm = X509_VERIFY_PARAM_new()) == NULL) if ((vpm = X509_VERIFY_PARAM_new()) == NULL)
@@ -44,6 +44,8 @@
#include <openssl/core_names.h> #include <openssl/core_names.h>
#include <openssl/async.h> #include <openssl/async.h>
#include <openssl/provider.h> #include <openssl/provider.h>
#include <openssl/trace.h>
#include "app_trace.h"
#if !defined(OPENSSL_SYS_MSDOS) #if !defined(OPENSSL_SYS_MSDOS)
# include <unistd.h> # include <unistd.h>
#endif #endif
@@ -1907,6 +1909,17 @@ int speed_main(int argc, char **argv)
#ifndef NO_FORK #ifndef NO_FORK
int multi = 0; int multi = 0;
#endif #endif
#ifndef OPENSSL_NO_TRACE
setup_trace(getenv("OPENSSL_TRACE"));
#endif
#if defined(OPENSSL_SYS_VXWORKS_SUPPORT)
if (bio_err == NULL)
bio_err = dup_bio_err(FORMAT_TEXT);
#endif
long op_count = 1; long op_count = 1;
openssl_speed_sec_t seconds = { SECONDS, RSA_SECONDS, DSA_SECONDS, openssl_speed_sec_t seconds = { SECONDS, RSA_SECONDS, DSA_SECONDS,
ECDSA_SECONDS, ECDH_SECONDS, ECDSA_SECONDS, ECDH_SECONDS,
@@ -19,6 +19,8 @@
#include <openssl/evp.h> #include <openssl/evp.h>
#include <openssl/x509.h> #include <openssl/x509.h>
#include <openssl/pem.h> #include <openssl/pem.h>
#include <openssl/trace.h>
#include "app_trace.h"
typedef enum OPTION_choice { typedef enum OPTION_choice {
OPT_COMMON, OPT_COMMON,
@@ -73,6 +75,16 @@ int spkac_main(int argc, char **argv)
int keyformat = FORMAT_UNDEF; int keyformat = FORMAT_UNDEF;
OPTION_CHOICE o; OPTION_CHOICE o;
#ifndef OPENSSL_NO_TRACE
setup_trace(getenv("OPENSSL_TRACE"));
#endif
#if defined(OPENSSL_SYS_VXWORKS_SUPPORT)
if (bio_err == NULL)
bio_err = dup_bio_err(FORMAT_TEXT);
#endif
prog = opt_init(argc, argv, spkac_options); prog = opt_init(argc, argv, spkac_options);
while ((o = opt_next()) != OPT_EOF) { while ((o = opt_next()) != OPT_EOF) {
switch (o) { switch (o) {
@@ -15,6 +15,8 @@
#include <openssl/pem.h> #include <openssl/pem.h>
#include <openssl/store.h> #include <openssl/store.h>
#include <openssl/x509v3.h> /* s2i_ASN1_INTEGER */ #include <openssl/x509v3.h> /* s2i_ASN1_INTEGER */
#include <openssl/trace.h>
#include "app_trace.h"
static int process(const char *uri, const UI_METHOD *uimeth, PW_CB_DATA *uidata, static int process(const char *uri, const UI_METHOD *uimeth, PW_CB_DATA *uidata,
int expected, int criterion, OSSL_STORE_SEARCH *search, int expected, int criterion, OSSL_STORE_SEARCH *search,
@@ -88,6 +90,15 @@ int storeutl_main(int argc, char *argv[])
EVP_MD *digest = NULL; EVP_MD *digest = NULL;
OSSL_LIB_CTX *libctx = app_get0_libctx(); OSSL_LIB_CTX *libctx = app_get0_libctx();
#ifndef OPENSSL_NO_TRACE
setup_trace(getenv("OPENSSL_TRACE"));
#endif
#if defined(OPENSSL_SYS_VXWORKS_SUPPORT)
if (bio_err == NULL)
bio_err = dup_bio_err(FORMAT_TEXT);
#endif
opt_set_unknown_name("digest"); opt_set_unknown_name("digest");
prog = opt_init(argc, argv, storeutl_options); prog = opt_init(argc, argv, storeutl_options);
while ((o = opt_next()) != OPT_EOF) { while ((o = opt_next()) != OPT_EOF) {
@@ -17,6 +17,8 @@
#include <openssl/x509.h> #include <openssl/x509.h>
#include <openssl/x509v3.h> #include <openssl/x509v3.h>
#include <openssl/pem.h> #include <openssl/pem.h>
#include <openssl/trace.h>
#include "app_trace.h"
static int cb(int ok, X509_STORE_CTX *ctx); static int cb(int ok, X509_STORE_CTX *ctx);
static int check(X509_STORE *ctx, const char *file, static int check(X509_STORE *ctx, const char *file,
@@ -89,6 +91,18 @@ int verify_main(int argc, char **argv)
int vpmtouched = 0, crl_download = 0, show_chain = 0, i = 0, ret = 1; int vpmtouched = 0, crl_download = 0, show_chain = 0, i = 0, ret = 1;
OPTION_CHOICE o; OPTION_CHOICE o;
#ifndef OPENSSL_NO_TRACE
setup_trace(getenv("OPENSSL_TRACE"));
#endif
#if defined(OPENSSL_SYS_VXWORKS_SUPPORT)
if (bio_err == NULL)
bio_err = dup_bio_err(FORMAT_TEXT);
if (bio_out == NULL)
bio_out = dup_bio_out(FORMAT_TEXT);
#endif
if ((vpm = X509_VERIFY_PARAM_new()) == NULL) if ((vpm = X509_VERIFY_PARAM_new()) == NULL)
goto end; goto end;
@@ -15,6 +15,8 @@
#include <openssl/evp.h> #include <openssl/evp.h>
#include <openssl/crypto.h> #include <openssl/crypto.h>
#include <openssl/bn.h> #include <openssl/bn.h>
#include <openssl/trace.h>
#include "app_trace.h"
typedef enum OPTION_choice { typedef enum OPTION_choice {
OPT_COMMON, OPT_COMMON,
@@ -57,6 +59,15 @@ int version_main(int argc, char **argv)
char *prog; char *prog;
OPTION_CHOICE o; OPTION_CHOICE o;
#ifndef OPENSSL_NO_TRACE
setup_trace(getenv("OPENSSL_TRACE"));
#endif
#if defined(OPENSSL_SYS_VXWORKS_SUPPORT)
if (bio_err == NULL)
bio_err = dup_bio_err(FORMAT_TEXT);
#endif
prog = opt_init(argc, argv, version_options); prog = opt_init(argc, argv, version_options);
while ((o = opt_next()) != OPT_EOF) { while ((o = opt_next()) != OPT_EOF) {
switch (o) { switch (o) {
@@ -22,6 +22,8 @@
#include <openssl/objects.h> #include <openssl/objects.h>
#include <openssl/pem.h> #include <openssl/pem.h>
#include <openssl/rsa.h> #include <openssl/rsa.h>
#include <openssl/trace.h>
#include "app_trace.h"
#ifndef OPENSSL_NO_DSA #ifndef OPENSSL_NO_DSA
# include <openssl/dsa.h> # include <openssl/dsa.h>
#endif #endif
@@ -306,6 +308,15 @@ int x509_main(int argc, char **argv)
int subject_hash_old = 0, issuer_hash_old = 0; int subject_hash_old = 0, issuer_hash_old = 0;
#endif #endif
#ifndef OPENSSL_NO_TRACE
setup_trace(getenv("OPENSSL_TRACE"));
#endif
#if defined(OPENSSL_SYS_VXWORKS_SUPPORT)
if (bio_err == NULL)
bio_err = dup_bio_err(FORMAT_TEXT);
#endif
reset_unknown(); reset_unknown();
ctx = X509_STORE_new(); ctx = X509_STORE_new();
@@ -395,6 +395,14 @@ static int trace_attach_w_callback_cb(int category, int type, const void *data)
} }
#endif #endif
void OSSL_trace_unset_all_callbacks(void)
{
int i;
for (i = 0; i < OSSL_TRACE_CATEGORY_NUM; i++) {
OSSL_trace_set_callback(i, NULL, NULL);
}
}
int OSSL_trace_set_callback(int category, OSSL_trace_cb callback, void *data) int OSSL_trace_set_callback(int category, OSSL_trace_cb callback, void *data)
{ {
#ifndef OPENSSL_NO_TRACE #ifndef OPENSSL_NO_TRACE
@@ -1,6 +1,10 @@
#include <string.h>
#include <taskLibCommon.h>
#include <openssl/crypto.h> #include <openssl/crypto.h>
#include <openssl/vxrcu.h> #include <openssl/vxrcu.h>
#include <openssl/err.h> #include <openssl/err.h>
#include <openssl/trace.h>
static CRYPTO_RWLOCK_VX *local_rcu_rwlock = NULL; static CRYPTO_RWLOCK_VX *local_rcu_rwlock = NULL;
static int is_rwlock_init = 0; static int is_rwlock_init = 0;
@@ -57,6 +61,7 @@ CRYPTO_RCU_LOCK *ossl_rcu_lock_new(int num_writers, OSSL_LIB_CTX *ctx)
ERR_print_errors_fp(stderr); ERR_print_errors_fp(stderr);
return NULL; return NULL;
} }
OSSL_TRACE1 (RCU, "[%08x] ossl_rcu_lock_new:: allocated memory for lock.\n", taskIdSelf());
lock->writer_lock = semMCreate (SEM_Q_PRIORITY | SEM_DELETE_SAFE | SEM_INVERSION_SAFE); lock->writer_lock = semMCreate (SEM_Q_PRIORITY | SEM_DELETE_SAFE | SEM_INVERSION_SAFE);
if (!(lock->writer_lock)) if (!(lock->writer_lock))
@@ -65,6 +70,7 @@ CRYPTO_RCU_LOCK *ossl_rcu_lock_new(int num_writers, OSSL_LIB_CTX *ctx)
ERR_add_error_data(1, "ossl_rcu_lock_new:: semMCreate failed for writer_lock\n"); ERR_add_error_data(1, "ossl_rcu_lock_new:: semMCreate failed for writer_lock\n");
ERR_print_errors_fp(stderr); ERR_print_errors_fp(stderr);
} }
OSSL_TRACE1 (RCU, "[%08x] ossl_rcu_lock_new:: created semaphore for writer_lock.\n", taskIdSelf());
lock->active_readers = 0; lock->active_readers = 0;
@@ -78,6 +84,7 @@ CRYPTO_RCU_LOCK *ossl_rcu_lock_new(int num_writers, OSSL_LIB_CTX *ctx)
ERR_print_errors_fp(stderr); ERR_print_errors_fp(stderr);
return NULL; return NULL;
} }
OSSL_TRACE1 (RCU, "[%08x] ossl_rcu_lock_new:: allocated memory for local_rcu_rwlock.\n", taskIdSelf());
memset (local_rcu_rwlock, sizeof (CRYPTO_RWLOCK_VX), 0); memset (local_rcu_rwlock, sizeof (CRYPTO_RWLOCK_VX), 0);
@@ -90,8 +97,11 @@ CRYPTO_RCU_LOCK *ossl_rcu_lock_new(int num_writers, OSSL_LIB_CTX *ctx)
} }
is_rwlock_init = 1; is_rwlock_init = 1;
OSSL_TRACE1 (RCU, "[%08x] ossl_rcu_lock_new:: created semaphore for local_rcu_rwlock and set is_rwlock_init=1.\n",
taskIdSelf());
} }
OSSL_TRACE1 (RCU, "[%08x] ossl_rcu_lock_new:: done.\n", taskIdSelf());
return lock; return lock;
} }
@@ -104,6 +114,7 @@ void ossl_rcu_lock_free(CRYPTO_RCU_LOCK *lock)
local_rcu_rwlock = NULL; local_rcu_rwlock = NULL;
is_rwlock_init = 0; is_rwlock_init = 0;
} }
OSSL_TRACE1 (RCU, "[%08x] ossl_rcu_lock_free:: freed local_rcu_rwlock.\n", taskIdSelf());
if (!lock) if (!lock)
{ {
@@ -113,33 +124,41 @@ void ossl_rcu_lock_free(CRYPTO_RCU_LOCK *lock)
return; return;
} }
OSSL_TRACE1 (RCU, "[%08x] ossl_rcu_lock_free:: deleting writer_lock and freeing lock.\n", taskIdSelf());
semDelete (lock->writer_lock); semDelete (lock->writer_lock);
free(lock); free(lock);
OSSL_TRACE1 (RCU, "[%08x] ossl_rcu_lock_free:: done.\n", taskIdSelf());
} }
void ossl_rcu_read_lock(CRYPTO_RCU_LOCK *lock) void ossl_rcu_read_lock(CRYPTO_RCU_LOCK *lock)
{ {
vxAtomicInc (&(lock->active_readers)); vxAtomicInc (&(lock->active_readers));
OSSL_TRACE1 (RCU, "[%08x] ossl_rcu_read_lock:: done.\n", taskIdSelf());
} }
void ossl_rcu_read_unlock(CRYPTO_RCU_LOCK *lock) void ossl_rcu_read_unlock(CRYPTO_RCU_LOCK *lock)
{ {
vxAtomicDec (&(lock->active_readers)); vxAtomicDec (&(lock->active_readers));
OSSL_TRACE1 (RCU, "[%08x] ossl_rcu_read_unlock:: done.\n", taskIdSelf());
} }
void ossl_rcu_write_lock(CRYPTO_RCU_LOCK *lock) void ossl_rcu_write_lock(CRYPTO_RCU_LOCK *lock)
{ {
semMTake (lock->writer_lock, WAIT_FOREVER); semMTake (lock->writer_lock, WAIT_FOREVER);
OSSL_TRACE1 (RCU, "[%08x] ossl_rcu_write_lock:: done.\n", taskIdSelf());
} }
void ossl_rcu_write_unlock(CRYPTO_RCU_LOCK *lock) void ossl_rcu_write_unlock(CRYPTO_RCU_LOCK *lock)
{ {
semMGive (lock->writer_lock); semMGive (lock->writer_lock);
OSSL_TRACE1 (RCU, "[%08x] ossl_rcu_write_unlock:: done.\n", taskIdSelf());
} }
void *ossl_rcu_uptr_deref(void **p) void *ossl_rcu_uptr_deref(void **p)
{ {
/* readers just dereference safely */ /* readers just dereference safely */
OSSL_TRACE1 (RCU, "[%08x] ossl_rcu_uptr_deref:: returning dereferenced pointer.\n",
taskIdSelf());
return *p; return *p;
} }
@@ -152,6 +171,7 @@ void ossl_rcu_assign_uptr(void **p, void **v)
/* publish new pointer immediately */ /* publish new pointer immediately */
CRYPTO_atomic_load_int(val, ret, local_rcu_rwlock); CRYPTO_atomic_load_int(val, ret, local_rcu_rwlock);
OSSL_TRACE1 (RCU, "[%08x] ossl_rcu_assign_uptr:: done.\n", taskIdSelf());
} }
void ossl_synchronize_rcu(CRYPTO_RCU_LOCK *lock) void ossl_synchronize_rcu(CRYPTO_RCU_LOCK *lock)
@@ -179,6 +199,8 @@ void ossl_synchronize_rcu(CRYPTO_RCU_LOCK *lock)
tmpcb->fn(tmpcb->data); tmpcb->fn(tmpcb->data);
OPENSSL_free(tmpcb); OPENSSL_free(tmpcb);
} }
OSSL_TRACE1 (RCU, "[%08x] ossl_synchronize_rcu:: done.\n", taskIdSelf());
} }
int ossl_rcu_call(CRYPTO_RCU_LOCK *lock, rcu_cb_fn cb, void *data) int ossl_rcu_call(CRYPTO_RCU_LOCK *lock, rcu_cb_fn cb, void *data)
@@ -206,6 +228,7 @@ int ossl_rcu_call(CRYPTO_RCU_LOCK *lock, rcu_cb_fn cb, void *data)
new->next = lock->cb_items; new->next = lock->cb_items;
lock->cb_items = new; lock->cb_items = new;
OSSL_TRACE1 (RCU, "[%08x] ossl_rcu_call:: done.\n", taskIdSelf());
return 1; return 1;
} }
@@ -44,9 +44,13 @@ use OpenSSL::stackhash qw(generate_stack_macros generate_const_stack_macros);
# include <openssl/ct.h> # include <openssl/ct.h>
# include <openssl/sslerr.h> # include <openssl/sslerr.h>
# include <openssl/prov_ssl.h> # include <openssl/prov_ssl.h>
# if defined(IPCRYPTO_USE_TYPE_MAPPING)
# include <ipcrypto_iptype_map.h>
# else
# ifndef OPENSSL_NO_STDIO # ifndef OPENSSL_NO_STDIO
# include <stdio.h> # include <stdio.h>
# endif # endif
# endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@@ -64,6 +64,10 @@ extern "C" {
# define OSSL_TRACE_CATEGORY_NUM 24 # define OSSL_TRACE_CATEGORY_NUM 24
/* KEEP THIS LIST IN SYNC with trace_categories[] in crypto/trace.c */ /* KEEP THIS LIST IN SYNC with trace_categories[] in crypto/trace.c */
/* Unsets (clears) all previously registered trace callbacks for every trace category */
void OSSL_trace_unset_all_callbacks(void);
/* Returns the trace category number for the given |name| */ /* Returns the trace category number for the given |name| */
int OSSL_trace_get_category_num(const char *name); int OSSL_trace_get_category_num(const char *name);
@@ -23,6 +23,8 @@
#include "crypto/evp.h" #include "crypto/evp.h"
#include "crypto/evp/evp_local.h" #include "crypto/evp/evp_local.h"
#include "internal/provider.h" #include "internal/provider.h"
#include <openssl/trace.h>
static OSSL_FUNC_rand_newctx_fn drbg_ctr_new_wrapper; static OSSL_FUNC_rand_newctx_fn drbg_ctr_new_wrapper;
static OSSL_FUNC_rand_freectx_fn drbg_ctr_free; static OSSL_FUNC_rand_freectx_fn drbg_ctr_free;
@@ -345,6 +347,15 @@ static int drbg_ctr_instantiate_wrapper(void *vdrbg, unsigned int strength,
goto err; goto err;
ret = ossl_prov_drbg_instantiate(drbg, strength, prediction_resistance, ret = ossl_prov_drbg_instantiate(drbg, strength, prediction_resistance,
pstr, pstr_len); pstr, pstr_len);
OSSL_TRACE_BEGIN(ENTROPY) {
BIO_printf(trc_out, "ossl_prov_drbg_instantiate returned: %d\n", ret);
if (ret == 1) {
BIO_printf(trc_out, "DRBG instantiated successfully: ret = %d\n", ret);
} else {
BIO_printf(trc_out, "DRBG instantiation failed: ret = %d\n", ret);
}
} OSSL_TRACE_END(ENTROPY);
err: err:
if (drbg->lock != NULL) if (drbg->lock != NULL)
CRYPTO_THREAD_unlock(drbg->lock); CRYPTO_THREAD_unlock(drbg->lock);
@@ -21,6 +21,8 @@
#include "prov/provider_ctx.h" #include "prov/provider_ctx.h"
#include "crypto/rand.h" #include "crypto/rand.h"
#include "crypto/rand_pool.h" #include "crypto/rand_pool.h"
#include <openssl/trace.h>
static OSSL_FUNC_rand_newctx_fn seed_src_new; static OSSL_FUNC_rand_newctx_fn seed_src_new;
static OSSL_FUNC_rand_freectx_fn seed_src_free; static OSSL_FUNC_rand_freectx_fn seed_src_free;
@@ -195,6 +197,8 @@ static size_t seed_get_seed(void *vseed, unsigned char **pout,
/* Get entropy by polling system entropy sources. */ /* Get entropy by polling system entropy sources. */
entropy_available = ossl_pool_acquire_entropy(pool); entropy_available = ossl_pool_acquire_entropy(pool);
OSSL_TRACE1(ENTROPY, "entropy_available = %d\n", entropy_available);
if (entropy_available > 0 if (entropy_available > 0
&& ossl_rand_pool_adin_mix_in(pool, adin, adin_len)) { && ossl_rand_pool_adin_mix_in(pool, adin, adin_len)) {
ret = ossl_rand_pool_length(pool); ret = ossl_rand_pool_length(pool);
@@ -17,6 +17,8 @@
#include <version.h> #include <version.h>
#include <taskLib.h> #include <taskLib.h>
#include "sysLib.h" #include "sysLib.h"
#include <openssl/trace.h>
extern unsigned char *collectEntropyFromInterruptJitter(void); extern unsigned char *collectEntropyFromInterruptJitter(void);
@@ -133,6 +135,8 @@ size_t ossl_pool_acquire_entropy(RAND_POOL *pool)
bytes_needed = ossl_rand_pool_bytes_needed(pool, 1 /*entropy_factor*/); bytes_needed = ossl_rand_pool_bytes_needed(pool, 1 /*entropy_factor*/);
OSSL_TRACE1(ENTROPY, "ossl_rand_pool_bytes_needed(),bytes_needed = %d\n", bytes_needed);
if (bytes_needed > 0) { if (bytes_needed > 0) {
int retryCount = 0; int retryCount = 0;
STATUS result = ERROR; STATUS result = ERROR;
@@ -32,7 +32,7 @@ endif
OPENSSL_CPPFLAGS = -DOPENSSL_SYS_VXWORKS_SUPPORT -DOPENSSL_NO_THREAD_POOL -DVX69_TIMESTAMP_ENTROPY_SUPPORT OPENSSL_CPPFLAGS = -DOPENSSL_SYS_VXWORKS_SUPPORT -DOPENSSL_NO_THREAD_POOL -DVX69_TIMESTAMP_ENTROPY_SUPPORT
OPENSSL_CONFIGURE_OPTIONS = no-shared OPENSSL_CONFIGURE_OPTIONS = no-shared enable-trace
ifneq (, $(findstring enable-fips, $(CONFIGURE_CMD))) ifneq (, $(findstring enable-fips, $(CONFIGURE_CMD)))
OPENSSL_FIPS_ENABLE = OPENSSL_FIPS_ENABLE =
@@ -1,479 +0,0 @@
/*
* Copyright (c) 2014, 2017-2018, 2020-2021 Wind River Systems, Inc.
*
* The right to copy, distribute, modify or otherwise make use
* of this software may be licensed only pursuant to the terms
* of an applicable Wind River license agreement.
*/
/*
****************************************************************************
* 1 DESCRIPTION
****************************************************************************
*/
/*
****************************************************************************
* 2 CONFIGURATION
****************************************************************************
*/
#include <ipcom_key_db.h>
#ifdef IPCOM_USE_KEY_DB
/*
****************************************************************************
* 3 INCLUDE FILES
****************************************************************************
*/
#include <ipcom_type.h>
#include <ipcom_cstyle.h>
#include <ipcom_clib.h>
#include <ipcom_sysvar.h>
#include <ipcom_syslog.h>
#include <ipcom_err.h>
#include <ipcom_file.h>
#include <vxWorks.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <taskLib.h>
#include <sysLib.h>
#include <secSecret.h>
#include <secKeyStore.h>
#include <private/secSecretP.h>
#include <private/secKeyStoreP.h>
/*
****************************************************************************
* 4 DEFINES
****************************************************************************
*/
#ifndef IPCOM_KEY_DB_MAX_PATH
#define IPCOM_KEY_DB_MAX_PATH 128
#endif
#ifndef IPCOM_KEY_DB_MAX_SECRET
#define IPCOM_KEY_DB_MAX_SECRET 32
#endif
#define IPCOM_KEY_DB_TYPE_PKEY 1
#define IPCOM_KEY_DB_TYPE_BUF 2
#define IPCOM_KEY_DB_MODE_READ 1
#define IPCOM_KEY_DB_MODE_WRITE 2
#define IPCOM_SYSLOG_PRIORITY IPCOM_SYSLOG_IPCOM_PRIORITY
#define IPCOM_SYSLOG_FACILITY IPCOM_LOG_IPCOM_KEY_DB
#define MAX_BLOCK_SIZE 16
#ifdef EVP_MAX_KEY_LENGTH
#define IPCOM_KEY_DB_MAX_KEY_LENGTH EVP_MAX_KEY_LENGTH
#else
#define IPCOM_KEY_DB_MAX_KEY_LENGTH 32
#endif
#ifdef EVP_MAX_IV_LENGTH
#define IPCOM_KEY_DB_MAX_IV_LENGTH EVP_MAX_IV_LENGTH
#else
#define IPCOM_KEY_DB_MAX_IV_LENGTH 16
#endif
/*
****************************************************************************
* 5 TYPES
****************************************************************************
*/
struct evp_pkey_st;
typedef struct evp_pkey_st EVP_PKEY;
/*
****************************************************************************
* 6 EXTERN PROTOTYPES
****************************************************************************
*/
extern void keydb_configure(void);
/*
****************************************************************************
* 7 LOCAL PROTOTYPES
****************************************************************************
*/
/*
****************************************************************************
* 8 DATA
****************************************************************************
*/
/*
****************************************************************************
* 9 STATIC FUNCTIONS
****************************************************************************
*/
/*
****************************************************************************
* 11 PUBLIC FUNCTIONS
****************************************************************************
*/
/*
*===========================================================================
* ipcom_key_db_pkey_get
*===========================================================================
* Description:
* Parameters:
* Returns:
*
*/
IP_PUBLIC EVP_PKEY*
ipcom_key_db_pkey_get(const char* key_id)
{
if (!key_id || ipcom_strlen(key_id) > IPCOM_KEY_DB_MAX_ID)
return NULL;
return secKeyStoreGet(key_id);
}
/*
*===========================================================================
* ipcom_key_db_pkey_import
*===========================================================================
* Description:
* Parameters:
* Returns:
*
*/
IP_PUBLIC Ip_err
ipcom_key_db_pkey_import(const char* key_id, EVP_PKEY* key)
{
STATUS rc;
if (!key || !key_id || ipcom_strlen(key_id) > IPCOM_KEY_DB_MAX_ID)
return IPCOM_ERR_INVALID_ARG;
rc = secKeyStoreImport(key_id, key);
if (rc != OK)
switch (errno)
{
case EEXIST:
return IPCOM_ERR_ALREADY_INSTALLED;
default:
return IPCOM_ERR_FAILED;
}
return IPCOM_SUCCESS;
}
/*
*===========================================================================
* ipcom_key_db_pkey_get2
*===========================================================================
* Description:
* Parameters:
* Returns:
*
*/
IP_PUBLIC EVP_PKEY*
ipcom_key_db_pkey_get2(struct x509_st* x509, char* key_id, int* key_id_len)
{
return secKeyStoreX509Get(x509, key_id, key_id_len);
}
/*
*===========================================================================
* ipcom_key_db_pkey_opendb
*===========================================================================
* Description:
* Parameters:
* Returns:
*
*/
IP_PUBLIC void*
ipcom_key_db_pkey_opendb(void)
{
return secKeyStoreOpen();
}
/*
*===========================================================================
* ipcom_key_db_pkey_readdb
*===========================================================================
* Description:
* Parameters:
* Returns:
*
*/
IP_PUBLIC Ip_err
ipcom_key_db_pkey_readdb(void* handle, char* name, int name_len)
{
STATUS rc;
if (!handle || !name)
return IPCOM_ERR_INVALID_ARG;
rc = secKeyStoreRead(handle, name, name_len);
if (rc != OK)
switch (errno)
{
case EINVAL:
return IPCOM_ERR_INVALID_ARG;
default:
return IPCOM_ERR_END;
}
return IPCOM_SUCCESS;
}
/*
*===========================================================================
* ipcom_key_db_pkey_closedb
*===========================================================================
* Description:
* Parameters:
* Returns:
*
*/
IP_PUBLIC Ip_err
ipcom_key_db_pkey_closedb(void* handle)
{
if (secKeyStoreClose(handle) != OK)
return IPCOM_ERR_FAILED;
return IPCOM_SUCCESS;
}
/*
*===========================================================================
* ipcom_key_db_pkey_del
*===========================================================================
* Description:
* Parameters:
* Returns:
*
*/
IP_PUBLIC Ip_err
ipcom_key_db_pkey_del(const char* key_id)
{
STATUS rc;
rc = secKeyStoreDel(key_id);
if (rc != OK)
switch (errno)
{
case EINVAL:
return IPCOM_ERR_INVALID_ARG;
case ENOENT:
return IPCOM_ERR_NOT_FOUND;
default:
return IPCOM_ERR_FAILED;
}
return IPCOM_SUCCESS;
}
/*
*===========================================================================
* ipcom_key_db_buf_import
*===========================================================================
* Description:
* Parameters:
* Returns:
*
*/
IP_PUBLIC Ip_err
ipcom_key_db_buf_import(const char* key_id, const UINT8* key, int key_len)
{
STATUS status;
if (!key_id || ipcom_strlen(key_id) > IPCOM_KEY_DB_MAX_ID ||
!key ||
key_len > IPCOM_KEY_DB_MAX_BUF)
return IPCOM_ERR_INVALID_ARG;
status = secSecretImport(key_id, (const char*) key, key_len);
if (status != OK)
switch (errno)
{
case EEXIST:
return IPCOM_ERR_ALREADY_INSTALLED;
default:
return IPCOM_ERR_FAILED;
}
return IPCOM_SUCCESS;
}
/*
*===========================================================================
* ipcom_key_db_buf_get
*===========================================================================
* Description:
* Parameters:
* Returns:
*
*/
IP_PUBLIC Ip_err
ipcom_key_db_buf_get(const char* key_id, UINT8* buf, int* buf_len)
{
STATUS rc;
if (!key_id || ipcom_strlen(key_id) > IPCOM_KEY_DB_MAX_ID ||
!buf_len)
{
return IPCOM_ERR_INVALID_ARG;
}
rc = secSecretGet(key_id, (char*) buf, buf_len);
if (rc != OK)
switch (errno)
{
case ENOENT:
return IPCOM_ERR_NOT_FOUND;
default:
return IPCOM_ERR_FAILED;
}
return IPCOM_SUCCESS;
}
/*
*===========================================================================
* ipcom_key_db_buf_del
*===========================================================================
* Description:
* Parameters:
* Returns:
*
*/
IP_PUBLIC Ip_err
ipcom_key_db_buf_del(const char* key_id)
{
STATUS status;
if (!key_id || ipcom_strlen(key_id) > IPCOM_KEY_DB_MAX_ID)
{
return IPCOM_ERR_INVALID_ARG;
}
status = secSecretDel(key_id);
if (status != OK)
return IPCOM_ERR_FAILED;
return IPCOM_SUCCESS;
}
/*
*===========================================================================
* ipcom_key_db_buf_opendb
*===========================================================================
* Description:
* Parameters:
* Returns:
*
*/
IP_PUBLIC void*
ipcom_key_db_buf_opendb(void)
{
return secSecretOpen();
}
/*
*===========================================================================
* ipcom_key_db_buf_readdb
*===========================================================================
* Description:
* Parameters:
* Returns:
*
*/
IP_PUBLIC Ip_err
ipcom_key_db_buf_readdb(void* handle, char* name, int name_len)
{
STATUS rc;
rc = secSecretRead(handle, name, name_len);
if (rc != OK)
switch (errno)
{
case EINVAL:
return IPCOM_ERR_INVALID_ARG;
default:
return IPCOM_ERR_END;
}
return IPCOM_SUCCESS;
}
/*
*===========================================================================
* ipcom_key_db_buf_closedb
*===========================================================================
* Description:
* Parameters:
* Returns:
*
*/
IP_PUBLIC Ip_err
ipcom_key_db_buf_closedb(void* handle)
{
if (secSecretClose(handle) != OK)
return IPCOM_ERR_FAILED;
return IPCOM_SUCCESS;
}
/*
*===========================================================================
* ipcom_key_db_file_ready
*===========================================================================
* Description:
* Parameters:
* Returns:
*
*/
IP_GLOBAL void
ipcom_key_db_file_ready(void)
{
int i = 0;
while (secKeyStoreReadyCheck() != OK)
{
i++;
if (i >= 10)
{
break;
}
(void) taskDelay (sysClkRateGet()/10);
}
return;
}
#else
int ipcom_key_db_empty_file;
#endif
/*
****************************************************************************
* END OF FILE
****************************************************************************
*/
@@ -25,7 +25,6 @@
**************************************************************************** ****************************************************************************
*/ */
#define IPCOM_USE_CLIB_PROTO
#include <ipcom_config.h> #include <ipcom_config.h>
#include "ipcrypto_config.h" #include "ipcrypto_config.h"
@@ -50,7 +49,7 @@
* 3 DEFINES * 3 DEFINES
**************************************************************************** ****************************************************************************
*/ */
#define IPCOM_SYSLOG_PRIORITY IPCRYPTO_SYSLOG_PRIORITY #define IPCOM_SYSLOG_PRIORITY IPCOM_LOG_DEBUG
#define IPCOM_SYSLOG_FACILITY IPCOM_LOG_IPCRYPTO #define IPCOM_SYSLOG_FACILITY IPCOM_LOG_IPCRYPTO
#define IPCRYPTO_KEY_DB_EXAMPLE_DSA_KEY \ #define IPCRYPTO_KEY_DB_EXAMPLE_DSA_KEY \