trading keys

salvatore salvatore_uni at tiscali.it
Tue Jul 20 18:08:15 CEST 2004


Here is how i trade publics key... might be this wrong?!7

int trade_publics(void)
{
        char my_pub[KEY_LENTGH], his_pub[KEY_LENTGH];
        gcry_error_t rc,error_code;

	/* KEY_LENTGH is 1024 */
        memset(my_pub,0,KEY_LENTGH);
        memset(his_pub,0,KEY_LENTGH);
        
        /* Convert my public */
        gcry_sexp_sprint(key.my_public_key, GCRYSEXP_FMT_CANON, my_pub, sizeof(my_pub));

        /* Send my public */
        while( (write(sockt, (char *) my_pub, sizeof(my_pub)) ) < 0 )
                ;
        
        
        if( (read(sockt, (char *) his_pub, KEY_LENTGH ) ) < 0 )
                return 0;

        rc = gcry_sexp_sscan(&key.his_public_key, &error_code, his_pub, sizeof(his_pub));

        if( rc )
        {
                fprintf(stderr,"Errore durante la conversione della sua pubblica");
                return 0;
        }   

        return 1;
}

Regards
Emitrax



More information about the Gcrypt-devel mailing list