diff options
Diffstat (limited to '3rd_party/libsrp6a-sha512/srp_aux.h')
| -rw-r--r-- | 3rd_party/libsrp6a-sha512/srp_aux.h | 146 |
1 files changed, 146 insertions, 0 deletions
diff --git a/3rd_party/libsrp6a-sha512/srp_aux.h b/3rd_party/libsrp6a-sha512/srp_aux.h new file mode 100644 index 0000000..5088f08 --- /dev/null +++ b/3rd_party/libsrp6a-sha512/srp_aux.h | |||
| @@ -0,0 +1,146 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 1997-2007 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 | * Redistributions in source or binary form must retain an intact copy | ||
| 27 | * of this copyright notice. | ||
| 28 | */ | ||
| 29 | |||
| 30 | #ifndef SRP_AUX_H | ||
| 31 | #define SRP_AUX_H | ||
| 32 | |||
| 33 | #include "cstr.h" | ||
| 34 | |||
| 35 | #ifdef __cplusplus | ||
| 36 | extern "C" { | ||
| 37 | #endif | ||
| 38 | |||
| 39 | /* BigInteger abstraction API */ | ||
| 40 | |||
| 41 | #ifndef MATH_PRIV | ||
| 42 | typedef void * BigInteger; | ||
| 43 | typedef void * BigIntegerCtx; | ||
| 44 | typedef void * BigIntegerModAccel; | ||
| 45 | #endif | ||
| 46 | |||
| 47 | /* | ||
| 48 | * Some functions return a BigIntegerResult. | ||
| 49 | * Use BigIntegerOK to test for success. | ||
| 50 | */ | ||
| 51 | #define BIG_INTEGER_SUCCESS 0 | ||
| 52 | #define BIG_INTEGER_ERROR -1 | ||
| 53 | #define BigIntegerOK(v) ((v) == BIG_INTEGER_SUCCESS) | ||
| 54 | typedef int BigIntegerResult; | ||
| 55 | |||
| 56 | _TYPE( BigInteger ) BigIntegerFromInt P((unsigned int number)); | ||
| 57 | _TYPE( BigInteger ) BigIntegerFromBytes P((const unsigned char * bytes, | ||
| 58 | int length)); | ||
| 59 | #define BigIntegerByteLen(X) ((BigIntegerBitLen(X)+7)/8) | ||
| 60 | _TYPE( int ) BigIntegerToBytes P((BigInteger src, | ||
| 61 | unsigned char * dest, int destlen)); | ||
| 62 | _TYPE( BigIntegerResult ) BigIntegerToCstr P((BigInteger src, cstr * dest)); | ||
| 63 | _TYPE( BigIntegerResult ) BigIntegerToCstrEx P((BigInteger src, cstr * dest, int len)); | ||
| 64 | _TYPE( BigIntegerResult ) BigIntegerToHex P((BigInteger src, | ||
| 65 | char * dest, int destlen)); | ||
| 66 | _TYPE( BigIntegerResult ) BigIntegerToString P((BigInteger src, | ||
| 67 | char * dest, int destlen, | ||
| 68 | unsigned int radix)); | ||
| 69 | _TYPE( int ) BigIntegerBitLen P((BigInteger b)); | ||
| 70 | _TYPE( int ) BigIntegerCmp P((BigInteger c1, BigInteger c2)); | ||
| 71 | _TYPE( int ) BigIntegerCmpInt P((BigInteger c1, unsigned int c2)); | ||
| 72 | _TYPE( BigIntegerResult ) BigIntegerLShift P((BigInteger result, BigInteger x, | ||
| 73 | unsigned int bits)); | ||
| 74 | _TYPE( BigIntegerResult ) BigIntegerAdd P((BigInteger result, | ||
| 75 | BigInteger a1, BigInteger a2)); | ||
| 76 | _TYPE( BigIntegerResult ) BigIntegerAddInt P((BigInteger result, | ||
| 77 | BigInteger a1, unsigned int a2)); | ||
| 78 | _TYPE( BigIntegerResult ) BigIntegerSub P((BigInteger result, | ||
| 79 | BigInteger s1, BigInteger s2)); | ||
| 80 | _TYPE( BigIntegerResult ) BigIntegerSubInt P((BigInteger result, | ||
| 81 | BigInteger s1, unsigned int s2)); | ||
| 82 | /* For BigIntegerMul{,Int}: result != m1, m2 */ | ||
| 83 | _TYPE( BigIntegerResult ) BigIntegerMul P((BigInteger result, BigInteger m1, | ||
| 84 | BigInteger m2, BigIntegerCtx ctx)); | ||
| 85 | _TYPE( BigIntegerResult ) BigIntegerMulInt P((BigInteger result, | ||
| 86 | BigInteger m1, unsigned int m2, | ||
| 87 | BigIntegerCtx ctx)); | ||
| 88 | _TYPE( BigIntegerResult ) BigIntegerDivInt P((BigInteger result, | ||
| 89 | BigInteger d, unsigned int m, | ||
| 90 | BigIntegerCtx ctx)); | ||
| 91 | _TYPE( BigIntegerResult ) BigIntegerMod P((BigInteger result, BigInteger d, | ||
| 92 | BigInteger m, BigIntegerCtx ctx)); | ||
| 93 | _TYPE( unsigned int ) BigIntegerModInt P((BigInteger d, unsigned int m, | ||
| 94 | BigIntegerCtx ctx)); | ||
| 95 | _TYPE( BigIntegerResult ) BigIntegerModMul P((BigInteger result, | ||
| 96 | BigInteger m1, BigInteger m2, | ||
| 97 | BigInteger m, BigIntegerCtx ctx)); | ||
| 98 | _TYPE( BigIntegerResult ) BigIntegerModExp P((BigInteger result, | ||
| 99 | BigInteger base, BigInteger expt, | ||
| 100 | BigInteger modulus, | ||
| 101 | BigIntegerCtx ctx, | ||
| 102 | BigIntegerModAccel accel)); | ||
| 103 | _TYPE( int ) BigIntegerCheckPrime P((BigInteger n, BigIntegerCtx ctx)); | ||
| 104 | |||
| 105 | _TYPE( BigIntegerResult ) BigIntegerFree P((BigInteger b)); | ||
| 106 | _TYPE( BigIntegerResult ) BigIntegerClearFree P((BigInteger b)); | ||
| 107 | |||
| 108 | _TYPE( BigIntegerCtx ) BigIntegerCtxNew(); | ||
| 109 | _TYPE( BigIntegerResult ) BigIntegerCtxFree P((BigIntegerCtx ctx)); | ||
| 110 | |||
| 111 | _TYPE( BigIntegerModAccel ) BigIntegerModAccelNew P((BigInteger m, | ||
| 112 | BigIntegerCtx ctx)); | ||
| 113 | _TYPE( BigIntegerResult ) BigIntegerModAccelFree P((BigIntegerModAccel accel)); | ||
| 114 | |||
| 115 | _TYPE( BigIntegerResult ) BigIntegerInitialize(); | ||
| 116 | _TYPE( BigIntegerResult ) BigIntegerFinalize(); | ||
| 117 | |||
| 118 | _TYPE( BigIntegerResult ) BigIntegerUseEngine P((const char * engine)); | ||
| 119 | _TYPE( BigIntegerResult ) BigIntegerReleaseEngine(); | ||
| 120 | |||
| 121 | /* Miscellaneous functions - formerly in t_pwd.h */ | ||
| 122 | |||
| 123 | /* | ||
| 124 | * "t_random" is a cryptographic random number generator, which is seeded | ||
| 125 | * from various high-entropy sources and uses a one-way hash function | ||
| 126 | * in a feedback configuration. | ||
| 127 | * "t_sessionkey" is the interleaved hash used to generate session keys | ||
| 128 | * from a large integer. | ||
| 129 | * "t_mgf1" is an implementation of MGF1 using SHA1 to generate session | ||
| 130 | * keys from large integers, and is preferred over the older | ||
| 131 | * interleaved hash, and is used with SRP6. | ||
| 132 | * "t_getpass" reads a password from the terminal without echoing. | ||
| 133 | */ | ||
| 134 | _TYPE( void ) t_random P((unsigned char *, unsigned)); | ||
| 135 | _TYPE( void ) t_stronginitrand(); | ||
| 136 | _TYPE( unsigned char * ) | ||
| 137 | t_sessionkey P((unsigned char *, unsigned char *, unsigned)); | ||
| 138 | _TYPE( void ) t_mgf1 P((unsigned char *, unsigned, | ||
| 139 | const unsigned char *, unsigned)); | ||
| 140 | _TYPE( int ) t_getpass P((char *, unsigned, const char *)); | ||
| 141 | |||
| 142 | #ifdef __cplusplus | ||
| 143 | } | ||
| 144 | #endif | ||
| 145 | |||
| 146 | #endif /* SRP_AUX_H */ | ||
