mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-22 10:19:57 +01:00
2003-08-25 Timo Schulz <twoaday@freakmail.de>
* pkglue.c (mpi_from_sexp): New. Used to factor out some common code.
This commit is contained in:
parent
ab0f32351d
commit
93ddaf9acc
@ -1,3 +1,8 @@
|
|||||||
|
2003-08-25 Timo Schulz <twoaday@freakmail.de>
|
||||||
|
|
||||||
|
* pkglue.c (mpi_from_sexp): New. Used to factor out
|
||||||
|
some common code.
|
||||||
|
|
||||||
2003-08-18 Timo Schulz <twoaday@freakmail.de>
|
2003-08-18 Timo Schulz <twoaday@freakmail.de>
|
||||||
|
|
||||||
* encode.c (encode_sesskey): Checked the code and removed
|
* encode.c (encode_sesskey): Checked the code and removed
|
||||||
|
53
g10/pkglue.c
53
g10/pkglue.c
@ -30,6 +30,20 @@
|
|||||||
#include "pkglue.h"
|
#include "pkglue.h"
|
||||||
|
|
||||||
|
|
||||||
|
static gcry_mpi_t
|
||||||
|
mpi_from_sexp (gcry_sexp_t sexp, const char * item)
|
||||||
|
{
|
||||||
|
gcry_sexp_t list;
|
||||||
|
gcry_mpi_t data;
|
||||||
|
|
||||||
|
list = gcry_sexp_find_token (sexp, item, 0);
|
||||||
|
assert (list);
|
||||||
|
data = gcry_sexp_nth_mpi (list, 1, 0);
|
||||||
|
assert (data);
|
||||||
|
gcry_sexp_release (list);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/****************
|
/****************
|
||||||
* Emulate our old PK interface here - sometime in the future we might
|
* Emulate our old PK interface here - sometime in the future we might
|
||||||
@ -38,7 +52,7 @@
|
|||||||
int
|
int
|
||||||
pk_sign (int algo, gcry_mpi_t * data, gcry_mpi_t hash, gcry_mpi_t * skey)
|
pk_sign (int algo, gcry_mpi_t * data, gcry_mpi_t hash, gcry_mpi_t * skey)
|
||||||
{
|
{
|
||||||
gcry_sexp_t s_sig, s_hash, s_skey, list;
|
gcry_sexp_t s_sig, s_hash, s_skey;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
/* make a sexp from skey */
|
/* make a sexp from skey */
|
||||||
@ -78,29 +92,13 @@ 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)
|
else if (algo == GCRY_PK_RSA)
|
||||||
{
|
data[0] = mpi_from_sexp (s_sig, "s");
|
||||||
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);
|
data[0] = mpi_from_sexp (s_sig, "r");
|
||||||
assert (list);
|
data[1] = mpi_from_sexp (s_sig, "s");
|
||||||
data[0] = gcry_sexp_nth_mpi (list, 1, 0);
|
|
||||||
assert (data[0]);
|
|
||||||
gcry_sexp_release (list);
|
|
||||||
|
|
||||||
list = gcry_sexp_find_token (s_sig, "s", 0);
|
|
||||||
assert (list);
|
|
||||||
data[1] = gcry_sexp_nth_mpi (list, 1, 0);
|
|
||||||
assert (data[1]);
|
|
||||||
gcry_sexp_release (list);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
gcry_sexp_release (s_sig);
|
gcry_sexp_release (s_sig);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
@ -226,20 +224,9 @@ pk_encrypt (int algo, gcry_mpi_t * resarr, gcry_mpi_t data, gcry_mpi_t * pkey)
|
|||||||
;
|
;
|
||||||
else
|
else
|
||||||
{ /* add better error handling or make gnupg use S-Exp directly */
|
{ /* add better error handling or make gnupg use S-Exp directly */
|
||||||
gcry_sexp_t list = gcry_sexp_find_token (s_ciph, "a", 0);
|
resarr[0] = mpi_from_sexp (s_ciph, "a");
|
||||||
assert (list);
|
|
||||||
resarr[0] = gcry_sexp_nth_mpi (list, 1, 0);
|
|
||||||
assert (resarr[0]);
|
|
||||||
gcry_sexp_release (list);
|
|
||||||
|
|
||||||
if (algo != GCRY_PK_RSA)
|
if (algo != GCRY_PK_RSA)
|
||||||
{
|
resarr[1] = mpi_from_sexp (s_ciph, "b");
|
||||||
list = gcry_sexp_find_token (s_ciph, "b", 0);
|
|
||||||
assert (list);
|
|
||||||
resarr[1] = gcry_sexp_nth_mpi (list, 1, 0);
|
|
||||||
assert (resarr[1]);
|
|
||||||
gcry_sexp_release (list);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gcry_sexp_release (s_ciph);
|
gcry_sexp_release (s_ciph);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user