aboutsummaryrefslogtreecommitdiffstats
path: root/g10/seskey.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2010-04-20 17:57:50 +0000
committerWerner Koch <[email protected]>2010-04-20 17:57:50 +0000
commit21b0a955be63dc69625194ece8557e79b6ad60c2 (patch)
tree97de4727b46f1f2b5dac30142e5a408c898d48fc /g10/seskey.c
parentAdd missing file. (diff)
downloadgnupg-21b0a955be63dc69625194ece8557e79b6ad60c2.tar.gz
gnupg-21b0a955be63dc69625194ece8557e79b6ad60c2.zip
Generating an OpenPGP key cia gpg-agent basically works.
Diffstat (limited to 'g10/seskey.c')
-rw-r--r--g10/seskey.c30
1 files changed, 14 insertions, 16 deletions
diff --git a/g10/seskey.c b/g10/seskey.c
index ccbfe30af..ee5584c66 100644
--- a/g10/seskey.c
+++ b/g10/seskey.c
@@ -206,19 +206,18 @@ do_encode_md( gcry_md_hd_t md, int algo, size_t len, unsigned nbits,
* bits.
*/
gcry_mpi_t
-encode_md_value (PKT_public_key *pk, PKT_secret_key *sk,
- gcry_md_hd_t md, int hash_algo)
+encode_md_value (PKT_public_key *pk, gcry_md_hd_t md, int hash_algo)
{
gcry_mpi_t frame;
- assert(hash_algo);
- assert(pk || sk);
+ assert (hash_algo);
+ assert (pk);
- if((pk?pk->pubkey_algo:sk->pubkey_algo) == GCRY_PK_DSA)
+ if (pk->pubkey_algo == GCRY_PK_DSA)
{
/* It's a DSA signature, so find out the size of q. */
- size_t qbytes = gcry_mpi_get_nbits (pk?pk->pkey[1]:sk->skey[1]);
+ size_t qbytes = gcry_mpi_get_nbits (pk->pkey[1]);
/* Make sure it is a multiple of 8 bits. */
@@ -237,21 +236,19 @@ encode_md_value (PKT_public_key *pk, PKT_secret_key *sk,
DSA. ;) */
if (qbytes < 160)
{
- log_error (_("DSA key %s uses an unsafe (%u bit) hash\n"),
- pk?keystr_from_pk(pk):keystr_from_sk(sk),
- (unsigned int)qbytes);
+ log_error (_("DSA key %s uses an unsafe (%zu bit) hash\n"),
+ keystr_from_pk (pk), qbytes);
return NULL;
}
- qbytes/=8;
+ qbytes /= 8;
/* Check if we're too short. Too long is safe as we'll
automatically left-truncate. */
if (gcry_md_get_algo_dlen (hash_algo) < qbytes)
{
- log_error (_("DSA key %s requires a %u bit or larger hash\n"),
- pk?keystr_from_pk(pk):keystr_from_sk(sk),
- (unsigned int)(qbytes*8));
+ log_error (_("DSA key %s requires a %zu bit or larger hash\n"),
+ keystr_from_pk(pk), qbytes*8);
return NULL;
}
@@ -269,12 +266,13 @@ encode_md_value (PKT_public_key *pk, PKT_secret_key *sk,
if (rc)
log_fatal ("can't get OID of digest algorithm %d: %s\n",
hash_algo, gpg_strerror (rc));
- asn = xmalloc (asnlen);
+ asn = xtrymalloc (asnlen);
+ if (!asn)
+ return NULL;
if ( gcry_md_algo_info (hash_algo, GCRYCTL_GET_ASNOID, asn, &asnlen) )
BUG();
frame = do_encode_md (md, hash_algo, gcry_md_get_algo_dlen (hash_algo),
- gcry_mpi_get_nbits (pk?pk->pkey[0]:sk->skey[0]),
- asn, asnlen);
+ gcry_mpi_get_nbits (pk->pkey[0]), asn, asnlen);
xfree (asn);
}