From 23d2dbc7ebdf4fbeab09ef863d655ba1682fc47e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?= <grubba@grubba.org> Date: Thu, 4 May 2000 17:47:06 +0200 Subject: [PATCH] More functions added to the API. Rev: src/modules/_Crypto/rsa.c:1.16 --- src/modules/_Crypto/rsa.c | 54 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/src/modules/_Crypto/rsa.c b/src/modules/_Crypto/rsa.c index 91589e1261..90ba9acf9c 100644 --- a/src/modules/_Crypto/rsa.c +++ b/src/modules/_Crypto/rsa.c @@ -1,5 +1,5 @@ /* - * $Id: rsa.c,v 1.15 2000/05/04 12:52:47 grubba Exp $ + * $Id: rsa.c,v 1.16 2000/05/04 15:47:06 grubba Exp $ * * Glue to RSA BSAFE's RSA implementation. * @@ -31,7 +31,7 @@ #include <bsafe.h> -RCSID("$Id: rsa.c,v 1.15 2000/05/04 12:52:47 grubba Exp $"); +RCSID("$Id: rsa.c,v 1.16 2000/05/04 15:47:06 grubba Exp $"); struct pike_rsa_data { @@ -280,6 +280,50 @@ static void f_set_private_key(INT32 args) ref_push_object(fp->current_object); } +/* string cooked_get_n() */ +static void f_cooked_get_n(INT32 args) +{ + A_RSA_KEY rsa_public_key; + int code; + + if (!THIS->n) { + error("Public key has not been set.\n"); + } + + if ((code = B_GetKeyInfo((POINTER *)&rsa_public_key, THIS->public_key, + KI_RSAPublic))) { + error("Crypto rsa.cooked_get_n(): " + "Failed to get public key: %04x\n", code); + } + + pop_n_elems(args); + + push_string(make_shared_binary_string(rsa_public_key.modulus.data, + rsa_public_key.modulus.len)); +} + +/* string cooked_get_e() */ +static void f_cooked_get_e(INT32 args) +{ + A_RSA_KEY rsa_public_key; + int code; + + if (!THIS->n) { + error("Public key has not been set.\n"); + } + + if ((code = B_GetKeyInfo((POINTER *)&rsa_public_key, THIS->public_key, + KI_RSAPublic))) { + error("Crypto rsa.cooked_get_n(): " + "Failed to get public key: %04x\n", code); + } + + pop_n_elems(args); + + push_string(make_shared_binary_string(rsa_public_key.exponent.data, + rsa_public_key.exponent.len)); +} + /* int query_blocksize() */ static void f_query_blocksize(INT32 args) { @@ -811,6 +855,12 @@ void pike_rsa_init(void) ADD_FUNCTION("set_private_key", f_set_private_key, tFunc(tObj tOr(tArr(tObj),tVoid),tObj), 0); + ADD_FUNCTION("cooked_get_n", f_cooked_get_n, + tFunc(tNone, tString), 0); + + ADD_FUNCTION("cooked_get_e", f_cooked_get_e, + tFunc(tNone, tString), 0); + ADD_FUNCTION("query_blocksize", f_query_blocksize, tFunc(tNone, tInt), 0); -- GitLab