1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
|
/*
* Copyright (c) 1997 Stanford University
*
* The use of this software for revenue-generating purposes may require a
* license from the owners of the underlying intellectual property.
* Specifically, the SRP protocol may not be used for revenue-generating
* purposes without license.
*
* Within that constraint, permission to use, copy, modify, and distribute
* this software and its documentation for any purpose is hereby granted
* without fee, provided that the above copyright notices and this permission
* notice appear in all copies of the software and related documentation.
*
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
*
* IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
* INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF
* THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef T_CLIENT_H
#define T_CLIENT_H
#include "t_sha.h"
#if !defined(P)
#ifdef __STDC__
#define P(x) x
#else
#define P(x) ()
#endif
#endif
#define ALEN 32
struct t_client {
struct t_num n;
struct t_num g;
struct t_num s;
struct t_num a;
struct t_num A;
struct t_num p;
struct t_num v;
SHA1_CTX hash, ckhash;
char username[MAXUSERLEN];
unsigned char session_key[SESSION_KEY_LEN];
unsigned char session_response[RESPONSE_LEN];
unsigned char nbuf[MAXPARAMLEN], gbuf[MAXPARAMLEN], sbuf[MAXSALTLEN];
unsigned char pbuf[MAXPARAMLEN], vbuf[MAXPARAMLEN];
unsigned char abuf[ALEN], Abuf[MAXPARAMLEN];
};
/*
* SRP client-side negotiation
*
* This code negotiates the client side of an SRP exchange.
* "t_clientopen" accepts a username, and N, g, and s parameters,
* which are usually sent by the server in the first round.
* The client should then call...
* "t_clientgenexp" will generate a random 256-bit exponent and
* raise g to that power, returning the result. This result
* should be sent to the server as w(p).
* "t_clientpasswd" accepts the user's password, which should be
* entered locally and updates the client's state.
* "t_clientgetkey" accepts the exponential y(p), which should
* be sent by the server in the next round and computes the
* 256-bit session key. This data should be saved before the
* session is closed.
* "t_clientresponse" computes the session key proof as SHA(y(p), K).
* "t_clientclose" closes the session and frees its memory.
*
* Note that authentication is not performed per se; it is up
* to either/both sides of the protocol to now verify securely
* that their session keys agree in order to establish authenticity.
* One possible way is through "oracle hashing"; one side sends
* r, the other replies with H(r,K), where H() is a hash function.
*/
extern struct t_client *
t_clientopen P((const char *, struct t_num *, struct t_num *,
struct t_num *));
extern struct t_num * t_clientgenexp P((struct t_client *));
extern void t_clientpasswd P((struct t_client *, char *));
extern unsigned char *
t_clientgetkey P((struct t_client *, struct t_num *));
extern int t_clientverify P((struct t_client *, unsigned char *));
extern unsigned char * t_clientresponse P((struct t_client *));
extern void t_clientclose P((struct t_client *));
#endif
|