summaryrefslogtreecommitdiffstats
path: root/g10/pubkey-enc.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2000-07-25 17:38:12 +0200
committerWerner Koch <wk@gnupg.org>2000-07-25 17:38:12 +0200
commitb872ea2577bb68fc29d126cf79900d88d55ba268 (patch)
tree8464add6c2571724cf174d25b45a7cd05778eed0 /g10/pubkey-enc.c
parentSee ChangeLog: Mon Jul 17 16:35:47 CEST 2000 Werner Koch (diff)
downloadgnupg2-b872ea2577bb68fc29d126cf79900d88d55ba268.tar.xz
gnupg2-b872ea2577bb68fc29d126cf79900d88d55ba268.zip
See ChangeLog: Tue Jul 25 17:44:15 CEST 2000 Werner Koch
Diffstat (limited to 'g10/pubkey-enc.c')
-rw-r--r--g10/pubkey-enc.c42
1 files changed, 17 insertions, 25 deletions
diff --git a/g10/pubkey-enc.c b/g10/pubkey-enc.c
index 2019d0301..aa848a2cb 100644
--- a/g10/pubkey-enc.c
+++ b/g10/pubkey-enc.c
@@ -51,45 +51,36 @@ pk_decrypt( int algo, MPI *result, MPI *data, MPI *skey )
*result = NULL;
/* make a sexp from skey */
if( algo == GCRY_PK_ELG || algo == GCRY_PK_ELG_E ) {
- s_skey = SEXP_CONS( SEXP_NEW( "private-key", 0 ),
- gcry_sexp_vlist( SEXP_NEW( "elg", 0 ),
- gcry_sexp_new_name_mpi( "p", skey[0] ),
- gcry_sexp_new_name_mpi( "g", skey[1] ),
- gcry_sexp_new_name_mpi( "y", skey[2] ),
- gcry_sexp_new_name_mpi( "x", skey[3] ),
- NULL ));
+ rc = gcry_sexp_build ( &s_skey, NULL,
+ "(private-key(elg(p%m)(g%m)(y%m)(x%m)))",
+ skey[0], skey[1], skey[2], skey[3] );
}
else if( algo == GCRY_PK_RSA ) {
- s_skey = SEXP_CONS( SEXP_NEW( "private-key", 0 ),
- gcry_sexp_vlist( SEXP_NEW( "rsa", 0 ),
- gcry_sexp_new_name_mpi( "n", skey[0] ),
- gcry_sexp_new_name_mpi( "e", skey[1] ),
- gcry_sexp_new_name_mpi( "d", skey[2] ),
- gcry_sexp_new_name_mpi( "p", skey[3] ),
- gcry_sexp_new_name_mpi( "q", skey[4] ),
- gcry_sexp_new_name_mpi( "u", skey[5] ),
- NULL ));
+ 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
return GPGERR_PUBKEY_ALGO;
+ if ( rc )
+ BUG ();
+
/* put data into a S-Exp s_data */
if( algo == GCRY_PK_ELG || algo == GCRY_PK_ELG_E ) {
- s_data = SEXP_CONS( SEXP_NEW( "enc-val", 0 ),
- gcry_sexp_vlist( SEXP_NEW( "elg", 0 ),
- gcry_sexp_new_name_mpi( "a", data[0] ),
- gcry_sexp_new_name_mpi( "b", data[1] ),
- NULL ));
+ rc = gcry_sexp_build ( &s_data, NULL,
+ "(enc-val(elg(a%m)(b%m)))", data[0], data[1] );
}
else if( algo == GCRY_PK_RSA ) {
- s_data = SEXP_CONS( SEXP_NEW( "enc-val", 0 ),
- gcry_sexp_vlist( SEXP_NEW( "rsa", 0 ),
- gcry_sexp_new_name_mpi( "a", data[0] ),
- NULL ));
+ rc = gcry_sexp_build ( &s_data, NULL,
+ "(enc-val(rsa(a%m)))", data[0] );
}
else
BUG();
+ if ( rc )
+ BUG ();
+
rc = gcry_pk_decrypt( &s_plain, s_data, s_skey );
gcry_sexp_release( s_skey );
gcry_sexp_release( s_data);
@@ -97,6 +88,7 @@ pk_decrypt( int algo, MPI *result, MPI *data, MPI *skey )
return rc;
*result = gcry_sexp_car_mpi( s_plain, 0 );
+ gcry_sexp_release( s_plain );
if( !*result )
return -1; /* oops */