2 * Copyright (c) 1997-1999 The Stanford SRP Authentication Project
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:
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
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.
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.
26 * In addition, the following conditions apply:
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)."
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/)."
38 * 3. Redistributions in source or binary form must retain an intact copy
39 * of this copyright notice and list of conditions.
55 /* For building dynamic link libraries under windows, windows NT
56 * using MSVC1.5 or MSVC2.0
62 #ifdef MSVC15 /* MSVC1.5 support for 16 bit apps */
63 #define _MSVC15EXPORT _export
65 #define _DLLAPI _export _pascal
66 #define _TYPE(a) a _MSVC15EXPORT
71 #define _MSVC20EXPORT _declspec(dllexport)
73 #define _TYPE(a) _MSVC20EXPORT a
76 #else /* Default, non-dll. Use this for Unix or DOS */
77 #define _MSVC15DEXPORT
85 #define MIN_MOD_BYTES 64 /* 512 bits */
98 SHA1_CTX hash
, ckhash
;
100 char username
[MAXUSERLEN
];
101 unsigned char session_key
[SESSION_KEY_LEN
];
102 unsigned char session_response
[RESPONSE_LEN
];
104 unsigned char nbuf
[MAXPARAMLEN
], gbuf
[MAXPARAMLEN
], sbuf
[MAXSALTLEN
];
105 unsigned char pbuf
[MAXPARAMLEN
], vbuf
[MAXPARAMLEN
];
106 unsigned char abuf
[ALEN
], Abuf
[MAXPARAMLEN
];
110 * SRP client-side negotiation
112 * This code negotiates the client side of an SRP exchange.
113 * "t_clientopen" accepts a username, and N, g, and s parameters,
114 * which are usually sent by the server in the first round.
115 * The client should then call...
116 * "t_clientgenexp" will generate a random 256-bit exponent and
117 * raise g to that power, returning the result. This result
118 * should be sent to the server as w(p).
119 * "t_clientpasswd" accepts the user's password, which should be
120 * entered locally and updates the client's state.
121 * "t_clientgetkey" accepts the exponential y(p), which should
122 * be sent by the server in the next round and computes the
123 * 256-bit session key. This data should be saved before the
125 * "t_clientresponse" computes the session key proof as SHA(y(p), K).
126 * "t_clientclose" closes the session and frees its memory.
128 * Note that authentication is not performed per se; it is up
129 * to either/both sides of the protocol to now verify securely
130 * that their session keys agree in order to establish authenticity.
131 * One possible way is through "oracle hashing"; one side sends
132 * r, the other replies with H(r,K), where H() is a hash function.
134 * t_clientresponse and t_clientverify now implement a version of
135 * the session-key verification described above.
137 _TYPE( struct t_client
* )
138 t_clientopen
P((const char *, struct t_num
*, struct t_num
*,
140 _TYPE( struct t_num
* ) t_clientgenexp
P((struct t_client
*));
141 _TYPE( void ) t_clientpasswd
P((struct t_client
*, char *));
142 _TYPE( unsigned char * )
143 t_clientgetkey
P((struct t_client
*, struct t_num
*));
144 _TYPE( int ) t_clientverify
P((struct t_client
*, unsigned char *));
145 _TYPE( unsigned char * ) t_clientresponse
P((struct t_client
*));
146 _TYPE( void ) t_clientclose
P((struct t_client
*));
This page took 0.063358 seconds and 5 git commands to generate.