libgcrypt again: error "conflicting use" in gcry_pk_encrypt
Claudia Reuter
reuter at do.isst.fraunhofer.de
Thu Aug 4 17:06:10 CEST 2005
hi everybody.
so now I try to create a session key to encrypt my text files. this
seems to work. the session key must of course be encrypted with some
public key. Now an error "conflicting use" occurs in the gcry_pk_encrypt
function.
Maybe anyone could tell me what's wrong.
gcry_md_open( &Hash , SelectedHash , 0 );
// Retrive digest size
HashDigestSize = gcry_md_get_algo_dlen( SelectedHash );
Salt = (unsigned int*)gcry_random_bytes( SelectedSaltLength ,
GCRY_STRONG_RANDOM );
// Add salt to hash
gcry_md_write( Hash , Salt , SelectedSaltLength );
// Fetch digest
HashResult = gcry_md_read( Hash , SelectedHash );
//HashResult = (unsigned char*)
malloc(SelectedSaltLength*sizeof(char));
//gcry_randomize(HashResult, SelectedSaltLength, GCRY_STRONG_RANDOM);
rc = gcry_sexp_build(&sexp, NULL, "(data (flags pkcs1) (hash sha256
%b))", HashDigestSize, HashResult);
if(rc) {
throw GeneralError( "Unable to build S-Expression. %s\n" ,
gpg_strerror( rc ) );
}
rc = gcry_pk_encrypt(&sexpSessionKey, sexp, pKey);
if(rc) {
throw GeneralError( "Unable to encrypt session key. %s\n",
gpg_strerror( rc ) );
}
Thanks in advance.
More information about the Gnupg-users
mailing list