openssl: OSSL_PROVIDER_load(NULL, "legacy") failes to load + windows 10

Hi, I built openssl on Windows 10: Below are the commands:

perl Configure VC-WIN32 enable-fips --prefix=C:\OpenSSL\3.0.5-source\3.0.5-output\lib\x86\release --openssldir=C:\OpenSSL\3.0.5-source\3.0.5-output\ssl no-shared & nmake & nmake test & nmake install_sw

I shared the library with my colleague and he says that OSSL_PROVIDER_load(NULL, “fips”); & OSSL_PROVIDER_load(NULL, “legacy”); fails. When I tested on my machine I found that OSSL_PROVIDER_load(NULL, "legacy") works. The reason OSSL_PROVIDER_load(NULL, "fips") fails due to not having the fips.lib Below is my code snippet.


#include <iostream>


#include <openssl/provider.h>

#include <openssl/err.h>
#include <openssl/rand.h>
#include <openssl/rc4.h>
#include <openssl/evp.h>
#include <openssl/aes.h>
#include <openssl/provider.h>
#include <openssl/crypto.h>

#include <openssl/param_build.h>
#include <openssl/core_names.h>
#include<tchar.h>
#include <openssl/dh.h>

#pragma comment(lib, "crypt32")
#pragma comment(lib, "ws2_32.lib")

int main()
{
	OSSL_PROVIDER *fipsProvider = NULL;
	OSSL_PROVIDER *legacyProvider = NULL;
	OSSL_PROVIDER *defaultProvider = NULL;

	fipsProvider = OSSL_PROVIDER_load(NULL, "fips");
	if (fipsProvider == NULL)
	{
		std::cout << "FIPS provider load failed\n";
	}
	else
	{
		std::cout << "FIPS provider is loaded\n";
	}
	legacyProvider = OSSL_PROVIDER_load(NULL, "legacy");
	if (legacyProvider == NULL)
	{
		std::cout << "legacy Provider loading failed \n";
	}
	else
	{
		std::cout << "legacy Provider is loaded\n";
	}

	defaultProvider = OSSL_PROVIDER_load(NULL, "default");

	if (defaultProvider == NULL)
	{
		std::cout << "default Provider loading failed \n";
	}
	else
	{
		std::cout << "default Provider is loaded\n";
	}

    std::cout << "Hello World!\n";
}

Q1 : it is expected not to have fips.lib when I build by passing no-shared flag ? If so then release1.zip how can I make it work ? Q2 : why does OSSL_PROVIDER_load(NULL, "legacy"); function fails in my colleauges machine when we use the exactly same code?

I have attached the built library Note: I have removed the .pdb file to reduce the folder size Used VS2017 to build

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 43 (19 by maintainers)

Most upvoted comments

If you want priority responses: take out a support contract.

@levitte Thanks a lot for the help. It works now.

This line was the missing detail:

F83D0000:error:078C0105:common libcrypto routines:provider_init:init fail:crypto\provider_core.c:920:name=legacy

This indicates that the dll was actually loaded, but that the call of its init function failed. That’s a bit of a surprise.

Now, a question: you built OpenSSL with the config target VC-WIN32, did your colleague use the same or did they use something else, like VC-WIN64A?

@levitte Thanks for your response. we used the exactly same library. even I copied the same library on my other laptop and used the exact same test code to verify and got the same error. I understand that you would be quite busy with other stuff. If in case you have some spare time then could you please help me to run it on your machine? I have already attached the library and the sample code. It would be a great help

Hi @levitte Help me on this.

@levitte Thanks for your prompt response. I will do it and share the details with you