home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 8 Other / 08-Other.zip / rc5clnt.zip / client.h < prev    next >
C/C++ Source or Header  |  1997-02-23  |  2KB  |  83 lines

  1. #ifndef CLIENT_H
  2. #define CLIENT_H
  3.  
  4. #define SHL(x, s) ((RC5_WORD) ((x) << ((s) & RC5_ROTMASK)))
  5. #define SHR(x, s) ((RC5_WORD) ((x) >> ((RC5_WORDSIZE) - ((s) & RC5_ROTMASK))))
  6.  
  7. #if defined(ASM_I486) && defined(__GNUC__)
  8.  
  9. static __inline__ RC5_WORD ROTL(RC5_WORD x, RC5_WORD y)
  10. {
  11.     register RC5_WORD res;
  12.  
  13.     __asm__ __volatile(
  14.         "roll %%cl,%0\n\t"
  15.         :"=g" (res)
  16.         :"0" (x), "cx" (y)
  17.         :"cx");
  18.  
  19.     return res;
  20. }
  21.  
  22. static __inline__ RC5_WORD ROTL3(RC5_WORD x)
  23. {
  24.     register RC5_WORD res;
  25.  
  26.     __asm__ __volatile(
  27.         "roll $3,%0\n\t"
  28.         :"=g" (res)
  29.         :"0" (x));
  30.  
  31.     return res;
  32. }
  33.  
  34. #elif defined(ASM_SPARC) && defined(__GNUC__)
  35.  
  36. # define ROTL(x, s) ((RC5_WORD) (SHL((x), (s)) | SHR((x), (s))))
  37. # define ROTL3(x) ROTL(x, 3)
  38.  
  39. #elif defined(ASM_MIPS) && defined(__GNUC__)
  40.  
  41. # define ROTL(x, s) ((RC5_WORD) (SHL((x), (s)) | SHR((x), (s))))
  42. # define ROTL3(x) ROTL(x, 3)
  43.  
  44. #else
  45.  
  46. # define ROTL(x, s) ((RC5_WORD) (SHL((x), (s)) | SHR((x), (s))))
  47. # define ROTL3(x) ROTL(x, 3)
  48.  
  49. #endif
  50.  
  51. #define P        P32
  52. #define Q        Q32
  53.  
  54. /* These precomputed values are in case our compiler doesn't
  55.  * precompute them for us
  56.  */
  57. #if 0
  58. #define LL        ((RC5_KEYBYTES + RC5_WORDBYTES - 1) / RC5_WORDBYTES)
  59. #else
  60. /* two words is ok for up to a 64-bit key */
  61. #define    LL        (2)
  62. #endif
  63.  
  64. #if 0
  65. #define    T         (2 * (RC5_ROUNDS + 1))
  66. #else
  67. #define    T        (26)
  68. #endif
  69.  
  70. /* client.c */
  71. extern char *client_id;
  72.  
  73. /* cliops.c */
  74. extern int open_sock();
  75. extern int get_keyspace(RC5_WORD *, RC5_WORD *, RC5_WORD *, RC5_WORD *,
  76.                         unsigned int *);
  77. extern int end_keyspace(RC5_WORD *, RC5_WORD *, RC5_WORD *, RC5_WORD *,
  78.                         unsigned int);
  79. extern int notify_server(RC5_WORD *, int, int);
  80.  
  81. #endif
  82.  
  83.