mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-10 13:04:23 +01:00
(pk_sign): Fix last change.
(pk_verify): Check for valid DATA array so that we don't segv in Libgcrypt. (pk_verify): Ditto.
This commit is contained in:
parent
4140c3d447
commit
dbb7f4c89c
@ -1,3 +1,14 @@
|
|||||||
|
2003-08-07 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* pkglue.c (pk_sign): Fix last change.
|
||||||
|
(pk_verify): Check for valid DATA array so that we don't segv in
|
||||||
|
Libgcrypt.
|
||||||
|
(pk_verify): Ditto.
|
||||||
|
|
||||||
|
2003-08-06 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* pkglue.c (pk_sign): Allow signing using RSA.
|
||||||
|
|
||||||
2003-08-05 Werner Koch <wk@gnupg.org>
|
2003-08-05 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
* Makefile.am (install-data-local): Dropped check for the ancient
|
* Makefile.am (install-data-local): Dropped check for the ancient
|
||||||
|
30
g10/pkglue.c
30
g10/pkglue.c
@ -48,6 +48,13 @@ pk_sign (int algo, gcry_mpi_t * data, gcry_mpi_t hash, gcry_mpi_t * skey)
|
|||||||
"(private-key(dsa(p%m)(q%m)(g%m)(y%m)(x%m)))",
|
"(private-key(dsa(p%m)(q%m)(g%m)(y%m)(x%m)))",
|
||||||
skey[0], skey[1], skey[2], skey[3], skey[4]);
|
skey[0], skey[1], skey[2], skey[3], skey[4]);
|
||||||
}
|
}
|
||||||
|
else if (algo == GCRY_PK_RSA)
|
||||||
|
{
|
||||||
|
rc = gcry_sexp_build (&s_skey, NULL,
|
||||||
|
"(private-key(rsa(n%m)(e%m)(d%m)(p%m)(q%m)(u%m)))",
|
||||||
|
skey[0], skey[1], skey[2], skey[3], skey[4],
|
||||||
|
skey[5]);
|
||||||
|
}
|
||||||
else if (algo == GCRY_PK_ELG || algo == GCRY_PK_ELG_E)
|
else if (algo == GCRY_PK_ELG || algo == GCRY_PK_ELG_E)
|
||||||
{
|
{
|
||||||
rc = gcry_sexp_build (&s_skey, NULL,
|
rc = gcry_sexp_build (&s_skey, NULL,
|
||||||
@ -70,6 +77,14 @@ pk_sign (int algo, gcry_mpi_t * data, gcry_mpi_t hash, gcry_mpi_t * skey)
|
|||||||
|
|
||||||
if (rc)
|
if (rc)
|
||||||
;
|
;
|
||||||
|
else if (algo == GCRY_PK_RSA)
|
||||||
|
{
|
||||||
|
list = gcry_sexp_find_token (s_sig, "s", 0);
|
||||||
|
assert (list);
|
||||||
|
data[0] = gcry_sexp_nth_mpi (list, 1, 0);
|
||||||
|
assert (data[0]);
|
||||||
|
gcry_sexp_release (list);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
list = gcry_sexp_find_token (s_sig, "r", 0);
|
list = gcry_sexp_find_token (s_sig, "r", 0);
|
||||||
@ -131,16 +146,25 @@ pk_verify (int algo, gcry_mpi_t hash, gcry_mpi_t * data, gcry_mpi_t * pkey)
|
|||||||
/* put data into a S-Exp s_sig */
|
/* put data into a S-Exp s_sig */
|
||||||
if (algo == GCRY_PK_DSA)
|
if (algo == GCRY_PK_DSA)
|
||||||
{
|
{
|
||||||
|
if (!data[0] || !data[1])
|
||||||
|
rc = gpg_error (GPG_ERR_BAD_MPI);
|
||||||
|
else
|
||||||
rc = gcry_sexp_build (&s_sig, NULL,
|
rc = gcry_sexp_build (&s_sig, NULL,
|
||||||
"(sig-val(dsa(r%m)(s%m)))", data[0], data[1]);
|
"(sig-val(dsa(r%m)(s%m)))", data[0], data[1]);
|
||||||
}
|
}
|
||||||
else if (algo == GCRY_PK_ELG || algo == GCRY_PK_ELG_E)
|
else if (algo == GCRY_PK_ELG || algo == GCRY_PK_ELG_E)
|
||||||
{
|
{
|
||||||
|
if (!data[0] || !data[1])
|
||||||
|
rc = gpg_error (GPG_ERR_BAD_MPI);
|
||||||
|
else
|
||||||
rc = gcry_sexp_build (&s_sig, NULL,
|
rc = gcry_sexp_build (&s_sig, NULL,
|
||||||
"(sig-val(elg(r%m)(s%m)))", data[0], data[1]);
|
"(sig-val(elg(r%m)(s%m)))", data[0], data[1]);
|
||||||
}
|
}
|
||||||
else if (algo == GCRY_PK_RSA)
|
else if (algo == GCRY_PK_RSA)
|
||||||
{
|
{
|
||||||
|
if (!data[0])
|
||||||
|
rc = gpg_error (GPG_ERR_BAD_MPI);
|
||||||
|
else
|
||||||
rc = gcry_sexp_build (&s_sig, NULL, "(sig-val(rsa(s%m)))", data[0]);
|
rc = gcry_sexp_build (&s_sig, NULL, "(sig-val(rsa(s%m)))", data[0]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -259,11 +283,17 @@ pk_decrypt (int algo, gcry_mpi_t * result, gcry_mpi_t * data,
|
|||||||
/* put data into a S-Exp s_data */
|
/* put data into a S-Exp s_data */
|
||||||
if (algo == GCRY_PK_ELG || algo == GCRY_PK_ELG_E)
|
if (algo == GCRY_PK_ELG || algo == GCRY_PK_ELG_E)
|
||||||
{
|
{
|
||||||
|
if (!data[0] || !data[1])
|
||||||
|
rc = gpg_error (GPG_ERR_BAD_MPI);
|
||||||
|
else
|
||||||
rc = gcry_sexp_build (&s_data, NULL,
|
rc = gcry_sexp_build (&s_data, NULL,
|
||||||
"(enc-val(elg(a%m)(b%m)))", data[0], data[1]);
|
"(enc-val(elg(a%m)(b%m)))", data[0], data[1]);
|
||||||
}
|
}
|
||||||
else if (algo == GCRY_PK_RSA)
|
else if (algo == GCRY_PK_RSA)
|
||||||
{
|
{
|
||||||
|
if (!data[0])
|
||||||
|
rc = gpg_error (GPG_ERR_BAD_MPI);
|
||||||
|
else
|
||||||
rc = gcry_sexp_build (&s_data, NULL, "(enc-val(rsa(a%m)))", data[0]);
|
rc = gcry_sexp_build (&s_data, NULL, "(enc-val(rsa(a%m)))", data[0]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user