updates.
[silc.git] / lib / silccrypt / rsa.c
index 4fd1dc1b38de527cff288ad6eeff0afbbf0272a8..a4479334ddf35701a36af6a51fe8a5302bdeaae4 100644 (file)
@@ -73,7 +73,7 @@
 
 SILC_PKCS_API_INIT(rsa)
 {
-  unsigned int prime_bits = keylen / 2;
+  uint32 prime_bits = keylen / 2;
   SilcInt p, q;
 
   printf("Generating RSA Public and Private keys, might take a while...\n");
@@ -128,7 +128,7 @@ SILC_PKCS_API_GET_PUBLIC_KEY(rsa)
 {
   RsaKey *key = (RsaKey *)context;
   unsigned char *e, *n, *ret;
-  unsigned int e_len, n_len;
+  uint32 e_len, n_len;
   unsigned char tmp[4];
 
   e = silc_mp_mp2bin(&key->e, 0, &e_len);
@@ -167,7 +167,7 @@ SILC_PKCS_API_GET_PRIVATE_KEY(rsa)
 {
   RsaKey *key = (RsaKey *)context;
   unsigned char *e, *n, *d, *ret;
-  unsigned int e_len, n_len, d_len;
+  uint32 e_len, n_len, d_len;
   unsigned char tmp[4];
 
   e = silc_mp_mp2bin(&key->e, 0, &e_len);
@@ -214,7 +214,7 @@ SILC_PKCS_API_SET_PUBLIC_KEY(rsa)
 {
   RsaKey *key = (RsaKey *)context;
   unsigned char tmp[4];
-  unsigned int e_len, n_len;
+  uint32 e_len, n_len;
 
   silc_mp_init(&key->e);
   silc_mp_init(&key->n);
@@ -224,7 +224,7 @@ SILC_PKCS_API_SET_PUBLIC_KEY(rsa)
   if (e_len > key_len) {
     silc_mp_clear(&key->e);
     silc_mp_clear(&key->n);
-    return FALSE;
+    return 0;
   }
 
   silc_mp_bin2mp(key_data + 4, e_len, &key->e);
@@ -234,14 +234,14 @@ SILC_PKCS_API_SET_PUBLIC_KEY(rsa)
   if (e_len + n_len > key_len) {
     silc_mp_clear(&key->e);
     silc_mp_clear(&key->n);
-    return FALSE;
+    return 0;
   }
 
   silc_mp_bin2mp(key_data + 4 + e_len + 4, n_len, &key->n);
 
   key->bits = n_len * 8;
 
-  return TRUE;
+  return key->bits;
 }
 
 /* Set private key. This derives the public key from the private
@@ -252,7 +252,7 @@ SILC_PKCS_API_SET_PRIVATE_KEY(rsa)
 {
   RsaKey *key = (RsaKey *)context;
   unsigned char tmp[4];
-  unsigned int e_len, n_len, d_len;
+  uint32 e_len, n_len, d_len;
 
   silc_mp_init(&key->e);
   silc_mp_init(&key->n);
@@ -298,40 +298,6 @@ SILC_PKCS_API_CONTEXT_LEN(rsa)
   return sizeof(RsaKey);
 }
 
-SILC_PKCS_API_DATA_CONTEXT_LEN(rsa)
-{
-  return sizeof(RsaDataContext);
-}
-
-SILC_PKCS_API_SET_ARG(rsa)
-{
-  RsaDataContext *data_ctx = (RsaDataContext *)data_context;
-
-  switch(argnum) {
-  case 1:
-    data_ctx->src = val;
-    return TRUE;
-    break;
-  case 2:
-    data_ctx->dst = val;
-    return TRUE;
-    break;
-  case 3:
-    data_ctx->exp = val;
-    return TRUE;
-    break;
-  case 4:
-    data_ctx->mod = val;
-    return TRUE;
-    break;
-  default:
-    return FALSE;
-    break;
-  }
-
-  return FALSE;
-}
-
 SILC_PKCS_API_ENCRYPT(rsa)
 {
   RsaKey *key = (RsaKey *)context;
@@ -477,7 +443,7 @@ SILC_PKCS_API_VERIFY(rsa)
    to compute the modulus n has to be generated before calling this. They
    are then sent as argument for the function. */
 
-void rsa_generate_keys(RsaKey *key, unsigned int bits, 
+void rsa_generate_keys(RsaKey *key, uint32 bits, 
                       SilcInt *p, SilcInt *q)
 {
   SilcInt phi, hlp;