Signature check with libgpgme-11.dll

Knud Pehrs ph at sevencs.com
Wed Nov 4 16:34:13 CET 2009


Hello!

I have a problem to use the functions of libgpgme-11.dll in my application.
I have downloaded the gnupg-1.4.10, libgpg-error-1.7 and gpg_MadeEasy_1.1.8.
All three packages were installed to c:\usr\local\bin The gnupg-1.4.10 and libgpg-error-1.7 were build with ./configure, make, make install.

I have patched the gnupg-1.4.10 as described by Carlo Luciano Bianco.

The gpg_MadeEasy_1.1.8 was configured with ./configure --prefix=c:/usr/local --enable-static --with-gpg=c:/usr/local --without-gpgsm and build with make and make install.

To build the libraries I used MINGW32.
My operating system is WinXP and Visual Studio 2005 (C++).
In my application I load the libgpgme-11.dll via LoadLibrary(...).

I init GPGME like:
	GPGSETLOCALE pSetLocale = (GPGSETLOCALE) GetProcAddress( hMod, "gpgme_set_locale" );
	if( pSetLocale != NULL )
	{
		GPGVERSIONCHK pVersionChk = (GPGVERSIONCHK) GetProcAddress( hMod, "gpgme_check_version" );
		if( pVersionChk != NULL )
		{
			setlocale (LC_ALL, "");
			pVersionChk( NULL );							// gpgme_check_version
			pSetLocale( NULL, LC_CTYPE, setlocale( LC_CTYPE, NULL ) );	// gpgme_set_locale	
		}
				
	GPGSETENGINEINFO pSetEngineInfo =(GPGSETENGINEINFO)GetProcAddress( hMod, gpgme_set_engine_info" );
		if( pSetEngineInfo != NULL )
		{
		gpgme_error_t error = pSetEngineInfo( GPGME_PROTOCOL_OpenPGP, "gpg.exe", C:/usr/local/bin" );
		if( error != GPG_ERR_NO_ERROR)		// gpgme_set_engine_info	
		{
			freeResult = FreeLibrary( hMod );	// free the DLL module
			return false;
		}
	}

I init CTX like:
	// *** INIT CTX ***
	GPGNEWDATA pNewData = (GPGNEWDATA) GetProcAddress( hMod, "gpgme_new" );
	if( pNewData != NULL )
	{
		gpgme_error_t error = pNewData( &ctx );
		if( error != GPG_ERR_NO_ERROR )
		{
			GPGRELDATA pRelData = (GPGRELDATA) GetProcAddress( hMod, "gpgme_data_release" );
			if( pRelData != NULL )
				pRelData( keydata );
			freeResult = FreeLibrary( hMod );				// free the DLL module
			return false;
		}
	}

I read the public key file like:
	GPGRead pRead = (GPGRead) GetProcAddress( hMod, "gpgme_data_new_from_file" );

	if( pRead != NULL )
	{
		err = pRead( &keydata, cipher_2_asc, 1 );		// Method: gpgme_data_new_from_file
		if( err != GPG_ERR_NO_ERROR )
		{
			// could not create a new data buffer
			GPGRELDATA pRelData = (GPGRELDATA) GetProcAddress( hMod, "gpgme_data_release" );
			if( pRelData != NULL )
				pRelData( keydata );
			freeResult = FreeLibrary( hMod );			// free the DLL module
			return false;
		}
	}


But if I import the public key file into the context CTX like following code I get the error 117440662 (invalid crypto engine).

	GPGIMPORT pImport = (GPGIMPORT) GetProcAddress( hMod, "gpgme_op_import" );

	if( pImport != NULL )
	{
		err = pImport( ctx, keydata );					// Method: gpgme_op_import
		if( err != GPG_ERR_NO_ERROR )
		{
			// could not import public key file
			GPGRELDATA pRelData = (GPGRELDATA) GetProcAddress( hMod, "gpgme_data_release" );
			if( pRelData != NULL )
				pRelData( keydata );

			GPGRELCTX pRelCTX = (GPGRELCTX) GetProcAddress( hMod, "gpgme_release" );
			if( pRelCTX != NULL )
				pRelCTX( ctx );
			freeResult = FreeLibrary( hMod );			// free the DLL module
			return false;
		}
	}


If I test the following I get the ErrorCode GPG_ERR_INV_ENGINE
	GPGENGINECHK pEngineChk = (GPGENGINECHK) GetProcAddress( hMod, "gpgme_engine_check_version" );
	if( pEngineChk != NULL )
	{
		if( pEngineChk( GPGME_PROTOCOL_OpenPGP ) == GPG_ERR_NO_ERROR )
		...
The version no. of the engine cannot found but the file_name can.

Do you have any ideas how I can fix this error (compile gnupg-1.4.10 with valid crypto engine)?

If you need more details please let me know!

A soon answer would be appreciated!

Thank you very much and
best regards


Knud Pehrs
Software-Development
SevenCs GmbH
Ruhrstrasse 90, D-22761 Hamburg
Tel. +49-(0)40 851 72 40
Fax. +49-(0)40 851 72 479
www.sevencs.com

Handelsregister: Amtsgericht Hamburg HRB 102941
Geschäftsführer: John Humphrey




More information about the Gnupg-users mailing list