summaryrefslogtreecommitdiffstats
path: root/3rd_party/libsrp6a-sha512/srp_aux.h
diff options
context:
space:
mode:
Diffstat (limited to '3rd_party/libsrp6a-sha512/srp_aux.h')
-rw-r--r--3rd_party/libsrp6a-sha512/srp_aux.h146
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
36extern "C" {
37#endif
38
39/* BigInteger abstraction API */
40
41#ifndef MATH_PRIV
42typedef void * BigInteger;
43typedef void * BigIntegerCtx;
44typedef 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)
54typedef 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 */