| 1 | /* |
| 2 | * Copyright (c) 1997-1999 The Stanford SRP Authentication Project |
| 3 | * All Rights Reserved. |
| 4 | * |
| 5 | * Permission is hereby granted, free of charge, to any person obtaining |
| 6 | * a copy of this software and associated documentation files (the |
| 7 | * "Software"), to deal in the Software without restriction, including |
| 8 | * without limitation the rights to use, copy, modify, merge, publish, |
| 9 | * distribute, sublicense, and/or sell copies of the Software, and to |
| 10 | * permit persons to whom the Software is furnished to do so, subject to |
| 11 | * the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be |
| 14 | * included in all copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, |
| 17 | * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY |
| 18 | * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. |
| 19 | * |
| 20 | * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INCIDENTAL, |
| 21 | * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER |
| 22 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF |
| 23 | * THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT |
| 24 | * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 25 | * |
| 26 | * In addition, the following conditions apply: |
| 27 | * |
| 28 | * 1. Any software that incorporates the SRP authentication technology |
| 29 | * must display the following acknowlegment: |
| 30 | * "This product uses the 'Secure Remote Password' cryptographic |
| 31 | * authentication system developed by Tom Wu (tjw@CS.Stanford.EDU)." |
| 32 | * |
| 33 | * 2. Any software that incorporates all or part of the SRP distribution |
| 34 | * itself must also display the following acknowledgment: |
| 35 | * "This product includes software developed by Tom Wu and Eugene |
| 36 | * Jhong for the SRP Distribution (http://srp.stanford.edu/srp/)." |
| 37 | * |
| 38 | * 3. Redistributions in source or binary form must retain an intact copy |
| 39 | * of this copyright notice and list of conditions. |
| 40 | */ |
| 41 | |
| 42 | #ifndef T_DEFINES_H |
| 43 | #define T_DEFINES_H |
| 44 | |
| 45 | #ifndef P |
| 46 | #if defined(__STDC__) || defined(__cplusplus) |
| 47 | #define P(x) x |
| 48 | #else |
| 49 | #define P(x) () |
| 50 | #endif |
| 51 | #endif |
| 52 | |
| 53 | #ifdef HAVE_CONFIG_H |
| 54 | #include "config.h" |
| 55 | #endif /* HAVE_CONFIG_H */ |
| 56 | |
| 57 | #ifndef _DLLDECL |
| 58 | #define _DLLDECL |
| 59 | |
| 60 | #ifdef MSVC15 /* MSVC1.5 support for 16 bit apps */ |
| 61 | #define _MSVC15EXPORT _export |
| 62 | #define _MSVC20EXPORT |
| 63 | #define _DLLAPI _export _pascal |
| 64 | #define _TYPE(a) a _MSVC15EXPORT |
| 65 | #define DLLEXPORT 1 |
| 66 | |
| 67 | #elif MSVC20 |
| 68 | #define _MSVC15EXPORT |
| 69 | #define _MSVC20EXPORT _declspec(dllexport) |
| 70 | #define _DLLAPI |
| 71 | #define _TYPE(a) _MSVC20EXPORT a |
| 72 | #define DLLEXPORT 1 |
| 73 | |
| 74 | #else /* Default, non-dll. Use this for Unix or DOS */ |
| 75 | #define _MSVC15DEXPORT |
| 76 | #define _MSVC20EXPORT |
| 77 | #define _DLLAPI |
| 78 | #define _TYPE(a) a |
| 79 | #endif |
| 80 | #endif |
| 81 | |
| 82 | #if STDC_HEADERS |
| 83 | #include <stdlib.h> |
| 84 | #include <string.h> |
| 85 | #else /* not STDC_HEADERS */ |
| 86 | #ifndef HAVE_STRCHR |
| 87 | #define strchr index |
| 88 | #define strrchr rindex |
| 89 | #endif |
| 90 | char *strchr(), *strrchr(), *strtok(); |
| 91 | #ifndef HAVE_MEMCPY |
| 92 | #define memcpy(d, s, n) bcopy((s), (d), (n)) |
| 93 | #endif |
| 94 | #endif /* not STDC_HEADERS */ |
| 95 | |
| 96 | #include <sys/types.h> |
| 97 | |
| 98 | #if TIME_WITH_SYS_TIME |
| 99 | #include <sys/time.h> |
| 100 | #include <time.h> |
| 101 | #else /* not TIME_WITH_SYS_TIME */ |
| 102 | #if HAVE_SYS_TIME_H |
| 103 | #include <sys/time.h> |
| 104 | #else |
| 105 | #include <time.h> |
| 106 | #endif |
| 107 | #endif /* not TIME_WITH_SYS_TIME */ |
| 108 | |
| 109 | #if HAVE_TERMIOS_H |
| 110 | #include <termios.h> |
| 111 | #define STTY(fd, termio) tcsetattr(fd, TCSANOW, termio) |
| 112 | #define GTTY(fd, termio) tcgetattr(fd, termio) |
| 113 | #define TERMIO struct termios |
| 114 | #define USE_TERMIOS |
| 115 | #elif HAVE_TERMIO_H |
| 116 | #include <sys/ioctl.h> |
| 117 | #include <termio.h> |
| 118 | #define STTY(fd, termio) ioctl(fd, TCSETA, termio) |
| 119 | #define GTTY(fd, termio) ioctl(fd, TCGETA, termio) |
| 120 | #define TEMRIO struct termio |
| 121 | #define USE_TERMIO |
| 122 | #elif HAVE_SGTTY_H |
| 123 | #include <sgtty.h> |
| 124 | #define STTY(fd, termio) stty(fd, termio) |
| 125 | #define GTTY(fd, termio) gtty(fd, termio) |
| 126 | #define TERMIO struct sgttyb |
| 127 | #define USE_SGTTY |
| 128 | #endif |
| 129 | |
| 130 | #ifdef USE_FTIME |
| 131 | #include <sys/timeb.h> |
| 132 | #endif |
| 133 | |
| 134 | #ifndef MATH_PRIV |
| 135 | typedef void * BigInteger; |
| 136 | #endif |
| 137 | |
| 138 | _TYPE( BigInteger ) BigIntegerFromInt P((unsigned int number)); |
| 139 | _TYPE( BigInteger ) BigIntegerFromBytes P((unsigned char * bytes, int length)); |
| 140 | _TYPE( int ) BigIntegerToBytes P((BigInteger src, unsigned char * dest)); |
| 141 | _TYPE( int ) BigIntegerBitLen P((BigInteger b)); |
| 142 | _TYPE( int ) BigIntegerCmp P((BigInteger c1, BigInteger c2)); |
| 143 | _TYPE( int ) BigIntegerCmpInt P((BigInteger c1, unsigned int c2)); |
| 144 | _TYPE( void ) BigIntegerLShift P((BigInteger result, BigInteger x, |
| 145 | unsigned int bits)); |
| 146 | _TYPE( void ) BigIntegerAdd P((BigInteger result, BigInteger a1, BigInteger a2)); |
| 147 | _TYPE( void ) BigIntegerAddInt P((BigInteger result, |
| 148 | BigInteger a1, unsigned int a2)); |
| 149 | _TYPE( void ) BigIntegerSub P((BigInteger result, BigInteger s1, BigInteger s2)); |
| 150 | _TYPE( void ) BigIntegerSubInt P((BigInteger result, |
| 151 | BigInteger s1, unsigned int s2)); |
| 152 | /* For BigIntegerMul{,Int}: result != m1, m2 */ |
| 153 | _TYPE( void ) BigIntegerMul P((BigInteger result, BigInteger m1, BigInteger m2)); |
| 154 | _TYPE( void ) BigIntegerMulInt P((BigInteger result, |
| 155 | BigInteger m1, unsigned int m2)); |
| 156 | _TYPE( void ) BigIntegerDivInt P((BigInteger result, |
| 157 | BigInteger d, unsigned int m)); |
| 158 | _TYPE( void ) BigIntegerMod P((BigInteger result, BigInteger d, BigInteger m)); |
| 159 | _TYPE( unsigned int ) BigIntegerModInt P((BigInteger d, unsigned int m)); |
| 160 | _TYPE( void ) BigIntegerModMul P((BigInteger result, |
| 161 | BigInteger m1, BigInteger m2, BigInteger m)); |
| 162 | _TYPE( void ) BigIntegerModExp P((BigInteger result, BigInteger base, |
| 163 | BigInteger expt, BigInteger modulus)); |
| 164 | _TYPE( void ) BigIntegerModExpInt P((BigInteger result, BigInteger base, |
| 165 | unsigned int expt, BigInteger modulus)); |
| 166 | _TYPE( int ) BigIntegerCheckPrime P((BigInteger n)); |
| 167 | _TYPE( void ) BigIntegerFree P((BigInteger b)); |
| 168 | |
| 169 | #endif |
| 170 | |