mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-03 22:56:33 +02:00
Move OpenPGP OID helpers to common/.
This is needed so that the agent will be able to export and import OpenPGP secret keys. Add test case. Removed unused function.
This commit is contained in:
parent
328a642aa5
commit
e0d4139e19
10 changed files with 393 additions and 242 deletions
|
@ -245,37 +245,3 @@ hex2str_alloc (const char *hexstring, size_t *r_count)
|
|||
BUG ();
|
||||
return result;
|
||||
}
|
||||
|
||||
/* returns hex representation of the MPI;
|
||||
* caller must free with xfree
|
||||
* Returns NULL on error, never throws
|
||||
*/
|
||||
char *
|
||||
mpi2hex( gcry_mpi_t m )
|
||||
{
|
||||
#warning we have code for this in libcrypt
|
||||
size_t nbytes;
|
||||
size_t nbytes2;
|
||||
int rc;
|
||||
byte *p;
|
||||
|
||||
nbytes = (mpi_get_nbits ( m )+7)/8;
|
||||
if( nbytes == 0 )
|
||||
return NULL;
|
||||
p = xtrymalloc( nbytes*3+1 );
|
||||
if( p==NULL )
|
||||
return NULL;
|
||||
rc = gcry_mpi_print (GCRYMPI_FMT_USG, p+2*nbytes+1, nbytes, &nbytes2, m);
|
||||
if( rc ) {
|
||||
xfree( p );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bin2hex( p+2*nbytes+1, nbytes2, p );
|
||||
p[nbytes2*2] = '\0';
|
||||
/*printf("%s:%d>>>> Created the string %s from %d bytes %02x %02x
|
||||
..., MPI was %d bytes\n", __FILE__, __LINE__, p, nbytes2,
|
||||
p[2*nbytes+1], p[2*nbytes+2], nbytes); */
|
||||
return p;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue