No empty .Rs/.Re
[netbsd-mini2440.git] / crypto / external / bsd / openssh / dist / jpake.h
blob3ef42d477f60c489c0b386edd63043386b03cedb
1 /* $NetBSD: jpake.h,v 1.1.1.2 2009/12/27 01:06:55 christos Exp $ */
2 /* $OpenBSD: jpake.h,v 1.2 2009/03/05 07:18:19 djm Exp $ */
3 /*
4 * Copyright (c) 2008 Damien Miller. All rights reserved.
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 #ifndef JPAKE_H
20 #define JPAKE_H
22 #include <sys/types.h>
24 #include <openssl/bn.h>
26 /* Set JPAKE_DEBUG in CFLAGS for privacy-violating debugging */
27 #ifndef JPAKE_DEBUG
28 # define JPAKE_DEBUG_BN(a)
29 # define JPAKE_DEBUG_BUF(a)
30 # define JPAKE_DEBUG_CTX(a)
31 #else
32 # define JPAKE_DEBUG_BN(a) debug3_bn a
33 # define JPAKE_DEBUG_BUF(a) debug3_buf a
34 # define JPAKE_DEBUG_CTX(a) jpake_dump a
35 #endif /* JPAKE_DEBUG */
37 #define KZP_ID_LEN 16 /* Length of client and server IDs */
39 struct jpake_ctx {
40 /* Parameters */
41 struct modp_group *grp;
43 /* Private values shared by client and server */
44 BIGNUM *s; /* Secret (salted, crypted password) */
45 BIGNUM *k; /* Derived key */
47 /* Client private values (NULL for server) */
48 BIGNUM *x1; /* random in Zq */
49 BIGNUM *x2; /* random in Z*q */
51 /* Server private values (NULL for server) */
52 BIGNUM *x3; /* random in Zq */
53 BIGNUM *x4; /* random in Z*q */
55 /* Step 1: C->S */
56 u_char *client_id; /* Anti-replay nonce */
57 u_int client_id_len;
58 BIGNUM *g_x1; /* g^x1 */
59 BIGNUM *g_x2; /* g^x2 */
61 /* Step 1: S->C */
62 u_char *server_id; /* Anti-replay nonce */
63 u_int server_id_len;
64 BIGNUM *g_x3; /* g^x3 */
65 BIGNUM *g_x4; /* g^x4 */
67 /* Step 2: C->S */
68 BIGNUM *a; /* g^((x1+x3+x4)*x2*s) */
70 /* Step 2: S->C */
71 BIGNUM *b; /* g^((x1+x2+x3)*x4*s) */
73 /* Confirmation: C->S */
74 u_char *h_k_cid_sessid; /* H(k || client_id || session_id) */
75 u_int h_k_cid_sessid_len;
77 /* Confirmation: S->C */
78 u_char *h_k_sid_sessid; /* H(k || server_id || session_id) */
79 u_int h_k_sid_sessid_len;
82 /* jpake.c */
83 struct modp_group *jpake_default_group(void);
84 void jpake_dump(struct jpake_ctx *, const char *, ...)
85 __attribute__((__nonnull__ (2)))
86 __attribute__((format(printf, 2, 3)));
87 struct jpake_ctx *jpake_new(void);
88 void jpake_free(struct jpake_ctx *);
90 void jpake_step1(struct modp_group *, u_char **, u_int *,
91 BIGNUM **, BIGNUM **, BIGNUM **, BIGNUM **,
92 u_char **, u_int *, u_char **, u_int *);
94 void jpake_step2(struct modp_group *, BIGNUM *,
95 BIGNUM *, BIGNUM *, BIGNUM *, BIGNUM *,
96 const u_char *, u_int, const u_char *, u_int,
97 const u_char *, u_int, const u_char *, u_int,
98 BIGNUM **, u_char **, u_int *);
100 void jpake_confirm_hash(const BIGNUM *,
101 const u_char *, u_int,
102 const u_char *, u_int,
103 u_char **, u_int *);
105 void jpake_key_confirm(struct modp_group *, BIGNUM *, BIGNUM *,
106 BIGNUM *, BIGNUM *, BIGNUM *, BIGNUM *, BIGNUM *,
107 const u_char *, u_int, const u_char *, u_int,
108 const u_char *, u_int, const u_char *, u_int,
109 BIGNUM **, u_char **, u_int *);
111 int jpake_check_confirm(const BIGNUM *, const u_char *, u_int,
112 const u_char *, u_int, const u_char *, u_int);
114 #endif /* JPAKE_H */