summaryrefslogtreecommitdiff
path: root/lib/opencdk
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2009-07-15 22:01:47 +0300
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2009-07-15 22:01:47 +0300
commitc832d7f4546cd0217d0a9be2fd13ebaca886f704 (patch)
treea8c1c2dee99dd3f6f0cf8133939f99d135100de2 /lib/opencdk
parent39b8135436431c12ab76024bf3dfba338e25e0ec (diff)
downloadgnutls-c832d7f4546cd0217d0a9be2fd13ebaca886f704.tar.gz
Several bug fixes by Fabian Keil (some were modified by me).
Diffstat (limited to 'lib/opencdk')
-rw-r--r--lib/opencdk/stream.c4
-rw-r--r--lib/opencdk/write-packet.c54
2 files changed, 30 insertions, 28 deletions
diff --git a/lib/opencdk/stream.c b/lib/opencdk/stream.c
index 60823cbf5c..7171371a7d 100644
--- a/lib/opencdk/stream.c
+++ b/lib/opencdk/stream.c
@@ -932,7 +932,6 @@ cdk_stream_read (cdk_stream_t s, void *buf, size_t buflen)
if (!s)
{
- s->error = CDK_Inv_Value;
gnutls_assert ();
return EOF;
}
@@ -989,7 +988,6 @@ cdk_stream_getc (cdk_stream_t s)
if (!s)
{
- s->error = CDK_Inv_Value;
gnutls_assert ();
return EOF;
}
@@ -1022,7 +1020,6 @@ cdk_stream_write (cdk_stream_t s, const void *buf, size_t count)
if (!s)
{
- s->error = CDK_Inv_Value;
gnutls_assert ();
return EOF;
}
@@ -1081,7 +1078,6 @@ cdk_stream_putc (cdk_stream_t s, int c)
if (!s)
{
- s->error = CDK_Inv_Value;
gnutls_assert ();
return EOF;
}
diff --git a/lib/opencdk/write-packet.c b/lib/opencdk/write-packet.c
index 24e47b0574..285f413359 100644
--- a/lib/opencdk/write-packet.c
+++ b/lib/opencdk/write-packet.c
@@ -562,34 +562,40 @@ write_secret_key (cdk_stream_t out, cdk_pkt_seckey_t sk,
}
if (!rc)
rc = stream_putc (out, _cdk_pub_algo_to_pgp (pk->pubkey_algo));
+
if (!rc)
rc = write_mpibuf (out, pk->mpi, npkey);
- if (sk->is_protected == 0)
- rc = stream_putc (out, 0x00);
- else
+
+ if (!rc)
{
- if (is_RSA (pk->pubkey_algo) && pk->version < 4)
- stream_putc (out, _gnutls_cipher_to_pgp (sk->protect.algo));
- else if (sk->protect.s2k)
- {
- s2k_mode = sk->protect.s2k->mode;
- rc = stream_putc (out, sk->protect.sha1chk ? 0xFE : 0xFF);
- if (!rc)
- rc = stream_putc (out, _gnutls_cipher_to_pgp (sk->protect.algo));
- if (!rc)
- rc = stream_putc (out, sk->protect.s2k->mode);
- if (!rc)
- rc = stream_putc (out, sk->protect.s2k->hash_algo);
- if (!rc && (s2k_mode == 1 || s2k_mode == 3))
- {
- rc = stream_write (out, sk->protect.s2k->salt, 8);
- if (!rc && s2k_mode == 3)
- rc = stream_putc (out, sk->protect.s2k->count);
- }
- }
+ if (sk->is_protected == 0)
+ rc = stream_putc (out, 0x00);
else
- return CDK_Inv_Value;
- rc = stream_write (out, sk->protect.iv, sk->protect.ivlen);
+ {
+ if (is_RSA (pk->pubkey_algo) && pk->version < 4)
+ rc = stream_putc (out, _gnutls_cipher_to_pgp (sk->protect.algo));
+ else if (sk->protect.s2k)
+ {
+ s2k_mode = sk->protect.s2k->mode;
+ rc = stream_putc (out, sk->protect.sha1chk ? 0xFE : 0xFF);
+ if (!rc)
+ rc = stream_putc (out, _gnutls_cipher_to_pgp (sk->protect.algo));
+ if (!rc)
+ rc = stream_putc (out, sk->protect.s2k->mode);
+ if (!rc)
+ rc = stream_putc (out, sk->protect.s2k->hash_algo);
+ if (!rc && (s2k_mode == 1 || s2k_mode == 3))
+ {
+ rc = stream_write (out, sk->protect.s2k->salt, 8);
+ if (!rc && s2k_mode == 3)
+ rc = stream_putc (out, sk->protect.s2k->count);
+ }
+ }
+ else
+ return CDK_Inv_Value;
+ if (!rc)
+ rc = stream_write (out, sk->protect.iv, sk->protect.ivlen);
+ }
}
if (!rc && sk->is_protected && pk->version == 4)
{