gpgme_op_verify behaves weird

Francois Gaudin alf at bordel-ambiant.org
Tue Sep 5 11:42:57 CEST 2006


Hello, I'm new to this list, nice to meet you =)

so, my problem is that I can sign text, but the verification failed with a 
segfault and I can't find why.

here is my code :
	
	gpgme_signers_clear(context) ;

	// retrieving key
	gpgme_key_t gpgkey ;
	gpgme_error_t result = gpgme_get_key(context, 
key.toLocal8Bit(),&gpgkey,true) ;
	Q_ASSERT(result == GPG_ERR_NO_ERROR) ;
	Q_ASSERT(gpgkey != NULL) ;

	// signing
	result = gpgme_signers_add(context,gpgkey) ;
	Q_ASSERT(result == GPG_ERR_NO_ERROR) ;
	gpgme_data_t signature ;
	result = gpgme_data_new(&signature);
	Q_ASSERT(result == GPG_ERR_NO_ERROR) ;

	gpgme_data_t msg ;
	result = 
gpgme_data_new_from_mem(&msg,message.toLocal8Bit(),message.size(),0) ;
	
	
	result = gpgme_op_sign(context, msg,signature, GPGME_SIG_MODE_DETACH) ;
	Q_ASSERT(result == GPG_ERR_NO_ERROR || result == GPG_ERR_BAD_PASSPHRASE || 
result == GPG_ERR_CANCELED) ;

	QString signatureStr ;
	char  * buffer = (char *) calloc(1024,sizeof(char)) ;
	gpgme_data_rewind(signature) ;
// should be the following, but for a fucking mysterious reason, it doesn't 
want to work
// 	gpgme_data_seek(signature,0,SEEK_SET) ;
	gpgme_data_read(signature,buffer,1024) ;

	signatureStr += buffer ;

	qDebug() << "signature" << signatureStr ;

	// test part
	result = gpgme_op_verify (context, signature, msg , NULL) ;
	qDebug() << "verify result" << result ;
	Q_ASSERT(result != GPG_ERR_INV_VALUE) ;
	Q_ASSERT(result != GPG_ERR_NO_DATA) ;
// 	Q_ASSERT(result == GPG_ERR_NO_ERROR) ;
	qDebug() << "verify" ;
	
	gpgme_verify_result_t verification = gpgme_op_verify_result(context) ;
	Q_ASSERT(verification != NULL) ;
	qDebug() << "result" ;
	
	gpgme_signature_t signatures = verification->signatures ;
	qDebug() << signatures->summary ;
	qDebug() << "GPGME_SIGSUM_VALID" << GPGME_SIGSUM_VALID ;
	qDebug() << "GPGME_SIGSUM_GREEN" << GPGME_SIGSUM_GREEN ;
	qDebug() << "GPGME_SIGSUM_RED" << GPGME_SIGSUM_RED ;
	gpgme_error_t status = signatures->status ;
	qDebug() << "status" << status ;
	gpgme_error_t validity_reason = signatures->validity_reason ;
	qDebug() << "validity reason" << validity_reason ;
	if(signatures->summary == GPGME_SIGSUM_VALID || signatures->summary == 
GPGME_SIGSUM_GREEN) {
		qDebug() << "verified" ;
	} else {
		qDebug() << "not verified" ;
	}

And here is the output :
signature "-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)

iD8DBQFE/UXk3r3TxDvLjIQRAst5AJ44V0/f8w9gTtlWw79rkmzq5RDdfwCeK5fR
1QBGb0cEEUBkWQg0rc3HG7g=
=OKaA
-----END PGP SIGNATURE-----
"
verify result 117440570
verify
result
Erreur de segmentation

so it seems to well sign but the value returned by gpgme_op_verify is 
weird ...

Is there a known bug or I do something wrong ?
gnupg version is : 1.4.2.2-1ubuntu2.2
gpgme version is : 1.1.0-1

thx

--
Francois Gaudin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 829 bytes
Desc: not available
Url : /pipermail/attachments/20060905/856a5eea/attachment.pgp


More information about the Gnupg-devel mailing list