@@ -9,10 +9,13 @@ #include "tlsInt.h" #include #include #include +#if OPENSSL_VERSION_NUMBER >= 0x30000000L +#include +#endif /* * Valid SSL and TLS Protocol Versions */ static const char *protocols[] = { @@ -920,10 +923,51 @@ /*******************************************************************/ /* *------------------------------------------------------------------- * + * ProviderObjCmd -- + * + * Load a provider. + * + * Results: + * A standard Tcl result. + * + * Side effects: + * None. + * + *------------------------------------------------------------------- + */ +#if OPENSSL_VERSION_NUMBER >= 0x30000000L +static int +ProviderObjCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { + char *name; + (void) clientData; + + dprintf("Called"); + + /* Validate arg count */ + if (objc != 2) { + Tcl_WrongNumArgs(interp, 1, objv, "provider"); + return TCL_ERROR; + } + + name = Tcl_GetStringFromObj(objv[1], NULL); + if (!OSSL_PROVIDER_try_load(NULL, (const char *) name, 1)) { + Tcl_AppendResult(interp, GET_ERR_REASON(), (char *) NULL); + return TCL_ERROR; + } + + return TCL_OK; +} +#endif + +/*******************************************************************/ + +/* + *------------------------------------------------------------------- + * * VersionObjCmd -- * * Return a string with the OpenSSL version info. * * Results: @@ -982,9 +1026,12 @@ Tcl_CreateObjCommand(interp, "tls::digests", DigestsObjCmd, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); Tcl_CreateObjCommand(interp, "tls::kdfs", KdfsObjCmd, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); Tcl_CreateObjCommand(interp, "tls::macs", MacsObjCmd, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); Tcl_CreateObjCommand(interp, "tls::pkeys", PkeysObjCmd, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); Tcl_CreateObjCommand(interp, "tls::protocols", ProtocolsObjCmd, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); +#if OPENSSL_VERSION_NUMBER >= 0x30000000L + Tcl_CreateObjCommand(interp, "tls::provider", ProviderObjCmd, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); +#endif Tcl_CreateObjCommand(interp, "tls::version", VersionObjCmd, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); return TCL_OK; }