mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-03 12:11:33 +01:00
Adjusted for use with current libgcrypt (1.1.42).
This commit is contained in:
parent
0fe6a1287f
commit
979ed0ca26
@ -27,7 +27,7 @@ AC_INIT(gnupg, 1.9.0-cvs, gnupg-devel@gnupg.org)
|
||||
# feel that the default check for a development version is not
|
||||
# sufficient.
|
||||
development_version=yes
|
||||
NEED_LIBGCRYPT_VERSION=1.1.8
|
||||
NEED_LIBGCRYPT_VERSION=1.1.42
|
||||
NEED_LIBASSUAN_VERSION=0.0.1
|
||||
NEED_KSBA_VERSION=0.4.6
|
||||
NEED_OPENSC_VERSION=0.7.0
|
||||
|
@ -1,3 +1,7 @@
|
||||
2003-07-27 Werner Koch <wk@gnupg.org>
|
||||
|
||||
Adjusted for gcry_mpi_print and gcry_mpi_scan API change.
|
||||
|
||||
2003-07-24 Werner Koch <wk@gnupg.org>
|
||||
|
||||
* g10.c: New command --card-status.
|
||||
|
@ -647,7 +647,7 @@ scd_genkey_cb (void *opaque, const char *line)
|
||||
while (spacep (line))
|
||||
line++;
|
||||
|
||||
rc = gcry_mpi_scan (&a, GCRYMPI_FMT_HEX, line, 0);
|
||||
rc = gcry_mpi_scan (&a, GCRYMPI_FMT_HEX, line, 0, NULL);
|
||||
if (rc)
|
||||
log_error ("error parsing received key data: %s\n", gpg_strerror (rc));
|
||||
else if (*name == 'n' && spacep (name+1))
|
||||
|
@ -86,11 +86,11 @@ make_mpi_comment_node( const char *s, gcry_mpi_t a )
|
||||
size_t n = strlen(s);
|
||||
|
||||
nb1 = mpi_get_nbits( a );
|
||||
if (gcry_mpi_print (GCRYMPI_FMT_PGP, NULL, &n1, a))
|
||||
if (gcry_mpi_print (GCRYMPI_FMT_PGP, NULL, 0, &n1, a))
|
||||
BUG ();
|
||||
/* fixme: allocate it on the stack */
|
||||
buf = xmalloc (n1);
|
||||
if (gcry_mpi_print (GCRYMPI_FMT_PGP, buf, &n1, a))
|
||||
if (gcry_mpi_print (GCRYMPI_FMT_PGP, buf, n1, &n1, a))
|
||||
BUG ();
|
||||
|
||||
pkt = xcalloc (1, sizeof *pkt );
|
||||
|
@ -441,13 +441,13 @@ static int
|
||||
write_sexp_keyparm (iobuf_t out, int *indent, const char *name, gcry_mpi_t a)
|
||||
{
|
||||
int rc;
|
||||
char *buffer;
|
||||
unsigned char *buffer;
|
||||
|
||||
write_sexp_line (out, indent, "(");
|
||||
iobuf_writestr (out, name);
|
||||
iobuf_writestr (out, " #");
|
||||
|
||||
rc = gcry_mpi_aprint (GCRYMPI_FMT_HEX, (void **)&buffer, NULL, a);
|
||||
rc = gcry_mpi_aprint (GCRYMPI_FMT_HEX, &buffer, NULL, a);
|
||||
assert (!rc);
|
||||
iobuf_writestr (out, buffer);
|
||||
iobuf_writestr (out, "#)");
|
||||
|
26
g10/keyid.c
26
g10/keyid.c
@ -67,11 +67,12 @@ do_fingerprint_md( PKT_public_key *pk )
|
||||
for(i=0; i < npkey; i++ ) {
|
||||
size_t nbytes;
|
||||
|
||||
if (gcry_mpi_print( GCRYMPI_FMT_PGP, NULL, &nbytes, pk->pkey[i] ))
|
||||
if (gcry_mpi_print( GCRYMPI_FMT_PGP, NULL, 0, &nbytes, pk->pkey[i] ))
|
||||
BUG ();
|
||||
/* fixme: we should try to allocate a buffer on the stack */
|
||||
pp[i] = xmalloc(nbytes);
|
||||
if (gcry_mpi_print ( GCRYMPI_FMT_PGP, pp[i], &nbytes, pk->pkey[i] ))
|
||||
if (gcry_mpi_print ( GCRYMPI_FMT_PGP, pp[i], nbytes, &nbytes,
|
||||
pk->pkey[i] ))
|
||||
BUG ();
|
||||
nn[i] = nbytes;
|
||||
n += nn[i];
|
||||
@ -135,11 +136,11 @@ v3_keyid (gcry_mpi_t a, u32 *ki)
|
||||
byte *buffer;
|
||||
size_t nbytes;
|
||||
|
||||
if (gcry_mpi_print (GCRYMPI_FMT_USG, NULL, &nbytes, a ))
|
||||
if (gcry_mpi_print (GCRYMPI_FMT_USG, NULL, 0, &nbytes, a ))
|
||||
BUG ();
|
||||
/* fixme: allocate it on the stack */
|
||||
buffer = xmalloc (nbytes);
|
||||
if (gcry_mpi_print( GCRYMPI_FMT_USG, buffer, &nbytes, a ))
|
||||
if (gcry_mpi_print( GCRYMPI_FMT_USG, buffer, nbytes, NULL, a ))
|
||||
BUG ();
|
||||
if (nbytes < 8) /* oops */
|
||||
ki[0] = ki[1] = 0;
|
||||
@ -476,19 +477,20 @@ fingerprint_from_pk( PKT_public_key *pk, byte *array, size_t *ret_len )
|
||||
if( pubkey_get_npkey( pk->pubkey_algo ) > 1 ) {
|
||||
size_t nbytes;
|
||||
|
||||
if (gcry_mpi_print( GCRYMPI_FMT_USG, NULL, &nbytes, pk->pkey[0]))
|
||||
if (gcry_mpi_print( GCRYMPI_FMT_USG, NULL, 0, &nbytes,
|
||||
pk->pkey[0]))
|
||||
BUG ();
|
||||
/* fixme: allocate it on the stack */
|
||||
buf = xmalloc(nbytes);
|
||||
if (gcry_mpi_print (GCRYMPI_FMT_USG, buf, &nbytes, pk->pkey[0]))
|
||||
if (gcry_mpi_print (GCRYMPI_FMT_USG, buf, nbytes, NULL,pk->pkey[0]))
|
||||
BUG ();
|
||||
gcry_md_write (md, buf, nbytes);
|
||||
xfree (buf);
|
||||
if (gcry_mpi_print( GCRYMPI_FMT_USG, NULL, &nbytes, pk->pkey[1]))
|
||||
if (gcry_mpi_print( GCRYMPI_FMT_USG, NULL, 0, &nbytes, pk->pkey[1]))
|
||||
BUG ();
|
||||
/* fixme: allocate it on the stack */
|
||||
buf = xmalloc(nbytes);
|
||||
if (gcry_mpi_print( GCRYMPI_FMT_USG, buf, &nbytes, pk->pkey[1]))
|
||||
if (gcry_mpi_print( GCRYMPI_FMT_USG, buf, nbytes, NULL,pk->pkey[1]))
|
||||
BUG ();
|
||||
gcry_md_write( md, buf, nbytes );
|
||||
xfree(buf);
|
||||
@ -533,19 +535,19 @@ fingerprint_from_sk( PKT_secret_key *sk, byte *array, size_t *ret_len )
|
||||
if( pubkey_get_npkey( sk->pubkey_algo ) > 1 ) {
|
||||
size_t nbytes;
|
||||
|
||||
if (gcry_mpi_print( GCRYMPI_FMT_USG, NULL, &nbytes, sk->skey[0]))
|
||||
if (gcry_mpi_print( GCRYMPI_FMT_USG, NULL, 0, &nbytes, sk->skey[0]))
|
||||
BUG ();
|
||||
/* fixme: allocate it on the stack */
|
||||
buf = xmalloc(nbytes);
|
||||
if (gcry_mpi_print (GCRYMPI_FMT_USG, buf, &nbytes, sk->skey[0]))
|
||||
if (gcry_mpi_print (GCRYMPI_FMT_USG, buf, nbytes, NULL,sk->skey[0]))
|
||||
BUG ();
|
||||
gcry_md_write (md, buf, nbytes);
|
||||
xfree (buf);
|
||||
if (gcry_mpi_print( GCRYMPI_FMT_USG, NULL, &nbytes, sk->skey[1]))
|
||||
if (gcry_mpi_print( GCRYMPI_FMT_USG, NULL, 0, &nbytes, sk->skey[1]))
|
||||
BUG ();
|
||||
/* fixme: allocate it on the stack */
|
||||
buf = xmalloc(nbytes);
|
||||
if (gcry_mpi_print( GCRYMPI_FMT_USG, buf, &nbytes, sk->skey[1]))
|
||||
if (gcry_mpi_print( GCRYMPI_FMT_USG, buf,nbytes, NULL, sk->skey[1]))
|
||||
BUG ();
|
||||
gcry_md_write( md, buf, nbytes );
|
||||
xfree(buf);
|
||||
|
12
g10/misc.c
12
g10/misc.c
@ -122,14 +122,14 @@ checksum_mpi( gcry_mpi_t a )
|
||||
byte *buffer;
|
||||
size_t nbytes;
|
||||
|
||||
rc = gcry_mpi_print( GCRYMPI_FMT_PGP, NULL, &nbytes, a );
|
||||
rc = gcry_mpi_print( GCRYMPI_FMT_PGP, NULL, 0, &nbytes, a );
|
||||
if (rc)
|
||||
BUG ();
|
||||
/* fixme: for numbers not in secure memory we should use a stack
|
||||
* based buffer and only allocate a larger one if mpi_print return
|
||||
* an error */
|
||||
buffer = gcry_is_secure(a)? gcry_xmalloc_secure(nbytes):gcry_xmalloc(nbytes);
|
||||
rc = gcry_mpi_print( GCRYMPI_FMT_PGP, buffer, &nbytes, a );
|
||||
rc = gcry_mpi_print (GCRYMPI_FMT_PGP, buffer, nbytes, NULL, a );
|
||||
if (rc)
|
||||
BUG ();
|
||||
csum = checksum (buffer, nbytes );
|
||||
@ -827,7 +827,7 @@ mpi_write( iobuf_t out, gcry_mpi_t a )
|
||||
int rc;
|
||||
|
||||
nbytes = (MAX_EXTERN_MPI_BITS+7)/8;
|
||||
rc = gcry_mpi_print( GCRYMPI_FMT_PGP, buffer, &nbytes, a );
|
||||
rc = gcry_mpi_print (GCRYMPI_FMT_PGP, buffer, nbytes, &nbytes, a );
|
||||
if( !rc )
|
||||
rc = iobuf_write( out, buffer, nbytes );
|
||||
|
||||
@ -891,7 +891,7 @@ mpi_read(iobuf_t inp, unsigned int *ret_nread, int secure)
|
||||
nread++;
|
||||
}
|
||||
nread += nbytes;
|
||||
if( gcry_mpi_scan( &a, GCRYMPI_FMT_PGP, buf, &nread ) )
|
||||
if( gcry_mpi_scan( &a, GCRYMPI_FMT_PGP, buf, nread, &nread ) )
|
||||
a = NULL;
|
||||
|
||||
leave:
|
||||
@ -961,9 +961,9 @@ mpi_print( FILE *fp, gcry_mpi_t a, int mode )
|
||||
}
|
||||
else {
|
||||
int rc;
|
||||
char *buffer;
|
||||
unsigned char *buffer;
|
||||
|
||||
rc = gcry_mpi_aprint( GCRYMPI_FMT_HEX, (void **)&buffer, NULL, a );
|
||||
rc = gcry_mpi_aprint( GCRYMPI_FMT_HEX, &buffer, NULL, a );
|
||||
assert( !rc );
|
||||
fputs( buffer, fp );
|
||||
n += strlen(buffer);
|
||||
|
@ -149,7 +149,7 @@ get_it( PKT_pubkey_enc *enc, DEK *dek, PKT_secret_key *sk, u32 *keyid )
|
||||
char *rbuf;
|
||||
size_t rbuflen;
|
||||
char *snbuf;
|
||||
void *indata = NULL;
|
||||
unsigned char *indata = NULL;
|
||||
unsigned int indatalen;
|
||||
|
||||
snbuf = serialno_and_fpr_from_sk (sk->protect.iv, sk->protect.ivlen, sk);
|
||||
@ -170,14 +170,11 @@ get_it( PKT_pubkey_enc *enc, DEK *dek, PKT_secret_key *sk, u32 *keyid )
|
||||
}
|
||||
else
|
||||
{
|
||||
void *indata;
|
||||
|
||||
rc = pk_decrypt (sk->pubkey_algo, &plain_dek, enc->data, sk->skey);
|
||||
if( rc )
|
||||
goto leave;
|
||||
if (gcry_mpi_aprint (GCRYMPI_FMT_USG, &indata, &nframe, plain_dek))
|
||||
if (gcry_mpi_aprint (GCRYMPI_FMT_USG, &frame, &nframe, plain_dek))
|
||||
BUG();
|
||||
frame = indata;
|
||||
gcry_mpi_release (plain_dek); plain_dek = NULL;
|
||||
}
|
||||
|
||||
|
@ -161,10 +161,9 @@ do_check( PKT_secret_key *sk, const char *tryagain_text, int mode,
|
||||
because the length may have an arbitrary value */
|
||||
if( sk->csum == csum ) {
|
||||
for( ; i < pubkey_get_nskey(sk->pubkey_algo); i++ ) {
|
||||
nbytes = ndata;
|
||||
assert( gcry_is_secure( p ) );
|
||||
res = gcry_mpi_scan( &sk->skey[i], GCRYMPI_FMT_PGP,
|
||||
p, &nbytes);
|
||||
p, ndata, &nbytes);
|
||||
if( res )
|
||||
log_bug ("gcry_mpi_scan failed in do_check: %s\n",
|
||||
gpg_strerror (res));
|
||||
@ -197,7 +196,7 @@ do_check( PKT_secret_key *sk, const char *tryagain_text, int mode,
|
||||
csum += checksum (buffer, ndata);
|
||||
gcry_mpi_release (sk->skey[i]);
|
||||
res = gcry_mpi_scan( &sk->skey[i], GCRYMPI_FMT_USG,
|
||||
buffer, &ndata );
|
||||
buffer, ndata, &ndata );
|
||||
if( res )
|
||||
log_bug ("gcry_mpi_scan failed in do_check: %s\n",
|
||||
gpg_strerror (res));
|
||||
@ -352,7 +351,7 @@ protect_secret_key( PKT_secret_key *sk, DEK *dek )
|
||||
GCRY_STRONG_RANDOM);
|
||||
gcry_cipher_setiv( cipher_hd, sk->protect.iv, sk->protect.ivlen );
|
||||
if( sk->version >= 4 ) {
|
||||
byte *bufarr[PUBKEY_MAX_NSKEY];
|
||||
unsigned char *bufarr[PUBKEY_MAX_NSKEY];
|
||||
unsigned narr[PUBKEY_MAX_NSKEY];
|
||||
unsigned nbits[PUBKEY_MAX_NSKEY];
|
||||
int ndata=0;
|
||||
@ -363,7 +362,7 @@ protect_secret_key( PKT_secret_key *sk, DEK *dek )
|
||||
assert( !gcry_mpi_get_flag( sk->skey[i],
|
||||
GCRYMPI_FLAG_OPAQUE ));
|
||||
|
||||
if( gcry_mpi_aprint( GCRYMPI_FMT_USG, (void**)bufarr+j,
|
||||
if( gcry_mpi_aprint( GCRYMPI_FMT_USG, bufarr+j,
|
||||
narr+j, sk->skey[i]))
|
||||
BUG();
|
||||
|
||||
|
@ -148,7 +148,7 @@ encode_session_key (DEK *dek, unsigned int nbits)
|
||||
if (DBG_CIPHER)
|
||||
log_printhex ("encoded session key:", frame, nframe );
|
||||
|
||||
if (gcry_mpi_scan( &a, GCRYMPI_FMT_USG, frame, &nframe))
|
||||
if (gcry_mpi_scan( &a, GCRYMPI_FMT_USG, frame, n, &nframe))
|
||||
BUG();
|
||||
xfree (frame);
|
||||
return a;
|
||||
@ -185,7 +185,7 @@ do_encode_md( gcry_md_hd_t md, int algo, size_t len, unsigned nbits,
|
||||
memcpy( frame+n, asn, asnlen ); n += asnlen;
|
||||
memcpy( frame+n, gcry_md_read (md, algo), len ); n += len;
|
||||
assert( n == nframe );
|
||||
if (gcry_mpi_scan( &a, GCRYMPI_FMT_USG, frame, &nframe ))
|
||||
if (gcry_mpi_scan( &a, GCRYMPI_FMT_USG, frame, n, &nframe ))
|
||||
BUG();
|
||||
xfree (frame);
|
||||
return a;
|
||||
@ -214,7 +214,7 @@ encode_md_value (int pubkey_algo, gcry_md_hd_t md, int hash_algo,
|
||||
return NULL;
|
||||
}
|
||||
if (gcry_mpi_scan( &frame, GCRYMPI_FMT_USG,
|
||||
gcry_md_read (md, hash_algo), &n ) )
|
||||
gcry_md_read (md, hash_algo), n, &n ) )
|
||||
BUG();
|
||||
}
|
||||
else
|
||||
|
@ -111,7 +111,7 @@ signature_check2( PKT_signature *sig, MD_HANDLE digest,
|
||||
gcry_md_putc( digest, a & 0xff );
|
||||
for(i=0; i < nsig; i++ ) {
|
||||
size_t n;
|
||||
void *tmp;
|
||||
unsigned char *tmp;
|
||||
|
||||
if (gcry_mpi_aprint (GCRYMPI_FMT_USG, &tmp, &n, sig->data[i]))
|
||||
BUG();
|
||||
|
@ -304,8 +304,8 @@ do_sign( PKT_secret_key *sk, PKT_signature *sig,
|
||||
xfree (snbuf);
|
||||
if (!rc)
|
||||
{
|
||||
unsigned int nbytes = rbuflen;
|
||||
if (gcry_mpi_scan (&sig->data[0], GCRYMPI_FMT_USG, rbuf, &nbytes ))
|
||||
if (gcry_mpi_scan (&sig->data[0], GCRYMPI_FMT_USG,
|
||||
rbuf, rbuflen, NULL ))
|
||||
BUG ();
|
||||
}
|
||||
}
|
||||
@ -325,8 +325,8 @@ do_sign( PKT_secret_key *sk, PKT_signature *sig,
|
||||
xfree (snbuf);
|
||||
if (!rc)
|
||||
{
|
||||
unsigned int nbytes = rbuflen;
|
||||
if (gcry_mpi_scan (&sig->data[0], GCRYMPI_FMT_USG, rbuf, &nbytes ))
|
||||
if (gcry_mpi_scan (&sig->data[0], GCRYMPI_FMT_USG,
|
||||
rbuf, rbuflen, NULL))
|
||||
BUG ();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user