home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / dev / gcc / ixemulsrc.lha / ixemul / general / crypt.c < prev    next >
C/C++ Source or Header  |  1996-12-11  |  2KB  |  80 lines

  1. /* Stubs for crypt functions which may be export restricted by stupid USA
  2.  * ITAR (International Trade in Arms Regulations).
  3.  *
  4.  * To compile a version of the library in the free world (IE outside the USA)
  5.  * simply replace this file with the real crypt.c, which should be widely
  6.  * available on ftp servers.
  7.  * 
  8.  */
  9.  
  10. #define _KERNEL
  11. #include "ixemul.h"
  12. #include <unistd.h>
  13. #include <clib/alib_protos.h>
  14.  
  15. /*
  16.  * Return a pointer to static data consisting of the "setting"
  17.  * followed by an encryption produced by the "key" and "setting".
  18.  */
  19.  
  20. char *crypt (const char *key, const char *setting)
  21. {
  22.   size_t setlen;
  23.  
  24.   if (muBase) return 0;
  25.  
  26.   if (u.u_ixnetbase)
  27.     return (char *)netcall(NET_crypt, key, setting);
  28.  
  29.   setlen = strlen(setting);
  30.   if (setlen != 9 && setlen != 2) return 0;
  31.  
  32.   strcpy(u.u_crypt_buf,setting);
  33.   return ACrypt(u.u_crypt_buf + setlen, (char *)key, (char *)setting);
  34. }
  35.  
  36. /*
  37.  * Encrypt (or decrypt if num_iter < 0) the 8 chars at "in" with abs(num_iter)
  38.  * iterations of DES, using the the given 24-bit salt and the pre-computed key
  39.  * schedule, and store the resulting 8 chars at "out" (in == out is permitted).
  40.  *
  41.  * NOTE: the performance of this routine is critically dependent on your
  42.  * compiler and machine architecture.
  43.  */
  44.  
  45. int des_cipher (const char *in, char *out, long salt, int num_iter)
  46. {
  47.   ix_warning("This version of ixemul.library does not support encryption/decryption.");
  48.   return 0;
  49. }
  50.  
  51. /*
  52.  * Set up the key schedule from the key.
  53.  */
  54.  
  55. int des_setkey (const char *key)
  56. {
  57.   ix_warning("This version of ixemul.library does not support encryption/decryption.");
  58.   return 0;
  59. }
  60.  
  61. /*
  62.  * "encrypt" routine (for backwards compatibility)
  63.  */
  64.  
  65. int encrypt (char *block, int flag)
  66. {
  67.   ix_warning("This version of ixemul.library does not support encryption/decryption.");
  68.   return 0;
  69. }
  70.  
  71. /*
  72.  * "setkey" routine (for backwards compatibility)
  73.  */
  74.  
  75. int setkey (const char *key)
  76. {
  77.   ix_warning("This version of ixemul.library does not support encryption/decryption.");
  78.   return 0;
  79. }
  80.