Vanilla Netrek Server Development Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[VANILLA-L:618] GMP 2 RSA files fixes.




For all of you maintaining RSA code. Here I include the required changes
to get it working with the GMP 2 patch.

The diffs are based on the European PGP version, and I don't know how
the code differs from the US RSA version.

So maybe one of the US hackers may check the diffs which are pretty
straight forward and patch the RSA files.

In any case the unmodified RSA code should still work as long you
don't use GMP 2.

Kurt (007)



*** ../orig/Server/res-rsa/rsa_utilmp.c	Sat May 31 13:45:37 1997
--- res-rsa/rsa_utilmp.c	Sat May 31 11:54:25 1997
***************
*** 1,4 ****
! #include <mp.h>
  
  /****************************************************************************
   * Note: libraries are searched in order. This file uses the some functions
--- 1,6 ----
! #include "../config.h"
! #include INC_MP
! MPTYPEDEF
  
  /****************************************************************************
   * Note: libraries are searched in order. This file uses the some functions
***************
*** 13,31 ****
   Loads it into the publicly availablt MINT format. (GNU or berkeley will do.)
   */
  raw_to_num(out, in, digits)
! MINT *out;
  unsigned char *in;
  int digits;
  {
      int i;
!     MINT *temp, *twofiftysix, *thisval;
   
!     temp = itom(0);
!     twofiftysix = itom(256);
   
      for (i = 0; i < digits; i++)
      {
!         thisval = itom(in[digits - i - 1]);
          mult(temp, twofiftysix, temp);
          madd(temp, thisval, temp);
          mfree(thisval);
--- 15,33 ----
   Loads it into the publicly availablt MINT format. (GNU or berkeley will do.)
   */
  raw_to_num(out, in, digits)
! MPTYPE out;
  unsigned char *in;
  int digits;
  {
      int i;
!     MPTYPE temp, twofiftysix, thisval;
   
!     assignItom(temp,0);
!     assignItom(twofiftysix,256);
   
      for (i = 0; i < digits; i++)
      {
!         assignItom(thisval,in[digits - i - 1]);
          mult(temp, twofiftysix, temp);
          madd(temp, thisval, temp);
          mfree(thisval);
***************
*** 42,55 ****
  */
  num_to_raw(out, in, digits)  /* Destroys in */
  unsigned char *out;
! MINT *in;
  int digits;
  {
      int i;
      short temp;
!     MINT *zero;
  
!     zero = itom(0);
   
      for (i = 0; i < digits; i++)
      {
--- 44,57 ----
  */
  num_to_raw(out, in, digits)  /* Destroys in */
  unsigned char *out;
! MPTYPE in;
  int digits;
  {
      int i;
      short temp;
!     MPTYPE zero;
  
!     assignItom(zero,0);
   
      for (i = 0; i < digits; i++)
      {
***************
*** 72,83 ****
  int digits;
  {
      int i;
!     MINT *result, *n_message, *n_key, *n_global;
  
!     result = itom(0);
!     n_message = itom(0);
!     n_key = itom(0);
!     n_global = itom(0);
   
   
      raw_to_num(n_global, global, digits);
--- 74,85 ----
  int digits;
  {
      int i;
!     MPTYPE result, n_message, n_key, n_global;
  
!     assignItom(result,0);
!     assignItom(n_message,0);
!     assignItom(n_key,0);
!     assignItom(n_global,0);
   
   
      raw_to_num(n_global, global, digits);
***************
*** 85,91 ****
      raw_to_num(n_key, key, digits);
  
  /* this was written by James Outside the USA */
!     pow(n_message,n_key,n_global,result);
      
      num_to_raw(out, result, digits);
  }
--- 87,93 ----
      raw_to_num(n_key, key, digits);
  
  /* this was written by James Outside the USA */
!     mp_pow(n_message,n_key,n_global,result);
      
      num_to_raw(out, result, digits);
  }