summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2014-02-04 11:12:56 +1100
committerDamien Miller <djm@mindrot.org>2014-02-04 11:12:56 +1100
commit7cc194f70d4a5ec9a82d19422eaf18db4a6624c6 (patch)
tree8bf6b25f93b3ee74dc184349a45125738e89df5b
parentb0f26544cf6f4feeb1a4f6db09fca834f5c9867d (diff)
- djm@cvs.openbsd.org 2014/01/29 06:18:35
[Makefile.in auth.h auth2-jpake.c auth2.c jpake.c jpake.h monitor.c] [monitor.h monitor_wrap.c monitor_wrap.h readconf.c readconf.h] [schnorr.c schnorr.h servconf.c servconf.h ssh2.h sshconnect2.c] remove experimental, never-enabled JPAKE code; ok markus@
-rw-r--r--ChangeLog5
-rw-r--r--Makefile.in6
-rw-r--r--auth.h6
-rw-r--r--auth2-jpake.c563
-rw-r--r--auth2.c11
-rw-r--r--jpake.c456
-rw-r--r--jpake.h114
-rw-r--r--monitor.c226
-rw-r--r--monitor.h7
-rw-r--r--monitor_wrap.c165
-rw-r--r--monitor_wrap.h22
-rw-r--r--readconf.c17
-rw-r--r--readconf.h3
-rw-r--r--schnorr.c668
-rw-r--r--schnorr.h60
-rw-r--r--servconf.c21
-rw-r--r--servconf.h4
-rw-r--r--ssh2.h8
-rw-r--r--sshconnect2.c293
19 files changed, 22 insertions, 2633 deletions
diff --git a/ChangeLog b/ChangeLog
index 7a4db10a..25d9c9af 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -20,6 +20,11 @@
they are equivalent, but SUSv2 describes the latter as having undefined
behaviour; from portable; ok dtucker
(Id sync only; change is already in portable)
+ - djm@cvs.openbsd.org 2014/01/29 06:18:35
+ [Makefile.in auth.h auth2-jpake.c auth2.c jpake.c jpake.h monitor.c]
+ [monitor.h monitor_wrap.c monitor_wrap.h readconf.c readconf.h]
+ [schnorr.c schnorr.h servconf.c servconf.h ssh2.h sshconnect2.c]
+ remove experimental, never-enabled JPAKE code; ok markus@
20140131
- (djm) [sandbox-seccomp-filter.c sandbox-systrace.c] Allow shutdown(2)
diff --git a/Makefile.in b/Makefile.in
index 9443c92b..28a8ec41 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1,4 +1,4 @@
-# $Id: Makefile.in,v 1.355 2014/02/04 00:07:14 djm Exp $
+# $Id: Makefile.in,v 1.356 2014/02/04 00:12:56 djm Exp $
# uncomment if you run a non bourne compatable shell. Ie. csh
#SHELL = @SH@
@@ -73,7 +73,7 @@ LIBSSH_OBJS=authfd.o authfile.o bufaux.o bufbn.o buffer.o \
monitor_fdpass.o rijndael.o ssh-dss.o ssh-ecdsa.o ssh-rsa.o dh.o \
kexdh.o kexgex.o kexdhc.o kexgexc.o bufec.o kexecdh.o kexecdhc.o \
msg.o progressmeter.o dns.o entropy.o gss-genr.o umac.o umac128.o \
- jpake.o schnorr.o ssh-pkcs11.o krl.o smult_curve25519_ref.o \
+ ssh-pkcs11.o krl.o smult_curve25519_ref.o \
kexc25519.o kexc25519c.o poly1305.o chacha.o cipher-chachapoly.o \
ssh-ed25519.o digest-openssl.o hmac.o \
sc25519.o ge25519.o fe25519.o ed25519.o verify.o hash.o blocks.o
@@ -88,7 +88,7 @@ SSHDOBJS=sshd.o auth-rhosts.o auth-passwd.o auth-rsa.o auth-rh-rsa.o \
auth.o auth1.o auth2.o auth-options.o session.o \
auth-chall.o auth2-chall.o groupaccess.o \
auth-skey.o auth-bsdauth.o auth2-hostbased.o auth2-kbdint.o \
- auth2-none.o auth2-passwd.o auth2-pubkey.o auth2-jpake.o \
+ auth2-none.o auth2-passwd.o auth2-pubkey.o \
monitor_mm.o monitor.o monitor_wrap.o kexdhs.o kexgexs.o kexecdhs.o \
kexc25519s.o auth-krb5.o \
auth2-gss.o gss-serv.o gss-serv-krb5.o \
diff --git a/auth.h b/auth.h
index 80f08986..124e5974 100644
--- a/auth.h
+++ b/auth.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: auth.h,v 1.76 2013/07/19 07:37:48 markus Exp $ */
+/* $OpenBSD: auth.h,v 1.77 2014/01/29 06:18:35 djm Exp $ */
/*
* Copyright (c) 2000 Markus Friedl. All rights reserved.
@@ -61,7 +61,6 @@ struct Authctxt {
char *style;
void *kbdintctxt;
char *info; /* Extra info for next auth_log */
- void *jpake_ctx;
#ifdef BSD_AUTH
auth_session_t *as;
#endif
@@ -175,9 +174,6 @@ int bsdauth_respond(void *, u_int, char **);
int skey_query(void *, char **, char **, u_int *, char ***, u_int **);
int skey_respond(void *, u_int, char **);
-void auth2_jpake_get_pwdata(Authctxt *, BIGNUM **, char **, char **);
-void auth2_jpake_stop(Authctxt *);
-
int allowed_user(struct passwd *);
struct passwd * getpwnamallow(const char *user);
diff --git a/auth2-jpake.c b/auth2-jpake.c
deleted file mode 100644
index 78a6b881..00000000
--- a/auth2-jpake.c
+++ /dev/null
@@ -1,563 +0,0 @@
-/* $OpenBSD: auth2-jpake.c,v 1.6 2013/05/17 00:13:13 djm Exp $ */
-/*
- * Copyright (c) 2008 Damien Miller. All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-/*
- * Server side of zero-knowledge password auth using J-PAKE protocol
- * as described in:
- *
- * F. Hao, P. Ryan, "Password Authenticated Key Exchange by Juggling",
- * 16th Workshop on Security Protocols, Cambridge, April 2008
- *
- * http://grouper.ieee.org/groups/1363/Research/contributions/hao-ryan-2008.pdf
- */
-
-#ifdef JPAKE
-
-#include <sys/types.h>
-#include <sys/param.h>
-
-#include <pwd.h>
-#include <stdio.h>
-#include <string.h>
-#include <login_cap.h>
-
-#include <openssl/bn.h>
-#include <openssl/evp.h>
-
-#include "xmalloc.h"
-#include "ssh2.h"
-#include "key.h"
-#include "hostfile.h"
-#include "auth.h"
-#include "buffer.h"
-#include "packet.h"
-#include "dispatch.h"
-#include "log.h"
-#include "servconf.h"
-#include "auth-options.h"
-#include "canohost.h"
-#ifdef GSSAPI
-#include "ssh-gss.h"
-#endif
-#include "monitor_wrap.h"
-
-#include "schnorr.h"
-#include "jpake.h"
-
-/*
- * XXX options->permit_empty_passwd (at the moment, they will be refused
- * anyway because they will mismatch on fake salt.
- */
-
-/* Dispatch handlers */
-static void input_userauth_jpake_client_step1(int, u_int32_t, void *);
-static void input_userauth_jpake_client_step2(int, u_int32_t, void *);
-static void input_userauth_jpake_client_confirm(int, u_int32_t, void *);
-
-static int auth2_jpake_start(Authctxt *);
-
-/* import */
-extern ServerOptions options;
-extern u_char *session_id2;
-extern u_int session_id2_len;
-
-/*
- * Attempt J-PAKE authentication.
- */
-static int
-userauth_jpake(Authctxt *authctxt)
-{
- int authenticated = 0;
-
- packet_check_eom();
-
- debug("jpake-01@openssh.com requested");
-
- if (authctxt->user != NULL) {
- if (authctxt->jpake_ctx == NULL)
- authctxt->jpake_ctx = jpake_new();
- if (options.zero_knowledge_password_authentication)
- authenticated = auth2_jpake_start(authctxt);
- }
-
- return authenticated;
-}
-
-Authmethod method_jpake = {
- "jpake-01@openssh.com",
- userauth_jpake,
- &options.zero_knowledge_password_authentication
-};
-
-/* Clear context and callbacks */
-void
-auth2_jpake_stop(Authctxt *authctxt)
-{
- /* unregister callbacks */
- dispatch_set(SSH2_MSG_USERAUTH_JPAKE_CLIENT_STEP1, NULL);
- dispatch_set(SSH2_MSG_USERAUTH_JPAKE_CLIENT_STEP2, NULL);
- dispatch_set(SSH2_MSG_USERAUTH_JPAKE_CLIENT_CONFIRM, NULL);
- if (authctxt->jpake_ctx != NULL) {
- jpake_free(authctxt->jpake_ctx);
- authctxt->jpake_ctx = NULL;
- }
-}
-
-/* Returns 1 if 'c' is a valid crypt(3) salt character, 0 otherwise */
-static int
-valid_crypt_salt(int c)
-{
- if (c >= 'A' && c <= 'Z')
- return 1;
- if (c >= 'a' && c <= 'z')
- return 1;
- if (c >= '.' && c <= '9')
- return 1;
- return 0;
-}
-
-/*
- * Derive fake salt as H(username || first_private_host_key)
- * This provides relatively stable fake salts for non-existent
- * users and avoids the jpake method becoming an account validity
- * oracle.
- */
-static void
-derive_rawsalt(const char *username, u_char *rawsalt, u_int len)
-{
- u_char *digest;
- u_int digest_len;
- Buffer b;
- Key *k;
-
- buffer_init(&b);
- buffer_put_cstring(&b, username);
- if ((k = get_hostkey_by_index(0)) == NULL ||
- (k->flags & KEY_FLAG_EXT))
- fatal("%s: no hostkeys", __func__);
- switch (k->type) {
- case KEY_RSA1:
- case KEY_RSA:
- if (k->rsa->p == NULL || k->rsa->q == NULL)
- fatal("%s: RSA key missing p and/or q", __func__);
- buffer_put_bignum2(&b, k->rsa->p);
- buffer_put_bignum2(&b, k->rsa->q);
- break;
- case KEY_DSA:
- if (k->dsa->priv_key == NULL)
- fatal("%s: DSA key missing priv_key", __func__);
- buffer_put_bignum2(&b, k->dsa->priv_key);
- break;
- case KEY_ECDSA:
- if (EC_KEY_get0_private_key(k->ecdsa) == NULL)
- fatal("%s: ECDSA key missing priv_key", __func__);
- buffer_put_bignum2(&b, EC_KEY_get0_private_key(k->ecdsa));
- break;
- default:
- fatal("%s: unknown key type %d", __func__, k->type);
- }
- if (hash_buffer(buffer_ptr(&b), buffer_len(&b), EVP_sha256(),
- &digest, &digest_len) != 0)
- fatal("%s: hash_buffer", __func__);
- buffer_free(&b);
- if (len > digest_len)
- fatal("%s: not enough bytes for rawsalt (want %u have %u)",
- __func__, len, digest_len);
- memcpy(rawsalt, digest, len);
- bzero(digest, digest_len);
- free(digest);
-}
-
-/* ASCII an integer [0, 64) for inclusion in a password/salt */
-static char
-pw_encode64(u_int i64)
-{
- const u_char e64[] =
- "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
- return e64[i64 % 64];
-}
-
-/* Generate ASCII salt bytes for user */
-static char *
-makesalt(u_int want, const char *user)
-{
- u_char rawsalt[32];
- static char ret[33];
- u_int i;
-
- if (want > sizeof(ret) - 1)
- fatal("%s: want %u", __func__, want);
-
- derive_rawsalt(user, rawsalt, sizeof(rawsalt));
- bzero(ret, sizeof(ret));
- for (i = 0; i < want; i++)
- ret[i] = pw_encode64(rawsalt[i]);
- bzero(rawsalt, sizeof(rawsalt));
-
- return ret;
-}
-
-/*
- * Select the system's default password hashing scheme and generate
- * a stable fake salt under it for use by a non-existent account.
- * Prevents jpake method being used to infer the validity of accounts.
- */
-static void
-fake_salt_and_scheme(Authctxt *authctxt, char **salt, char **scheme)
-{
- char *rounds_s, *style;
- long long rounds;
- login_cap_t *lc;
-
-
- if ((lc = login_getclass(authctxt->pw->pw_class)) == NULL &&
- (lc = login_getclass(NULL)) == NULL)
- fatal("%s: login_getclass failed", __func__);
- style = login_getcapstr(lc, "localcipher", NULL, NULL);
- if (style == NULL)
- style = xstrdup("blowfish,6");
- login_close(lc);
-
- if ((rounds_s = strchr(style, ',')) != NULL)
- *rounds_s++ = '\0';
- rounds = strtonum(rounds_s, 1, 1<<31, NULL);
-
- if (strcmp(style, "md5") == 0) {
- xasprintf(salt, "$1$%s$", makesalt(8, authctxt->user));
- *scheme = xstrdup("md5");
- } else if (strcmp(style, "old") == 0) {
- *salt = xstrdup(makesalt(2, authctxt->user));
- *scheme = xstrdup("crypt");
- } else if (strcmp(style, "newsalt") == 0) {
- rounds = MAX(rounds, 7250);
- rounds = MIN(rounds, (1<<24) - 1);
- xasprintf(salt, "_%c%c%c%c%s",
- pw_encode64(rounds), pw_encode64(rounds >> 6),
- pw_encode64(rounds >> 12), pw_encode64(rounds >> 18),
- makesalt(4, authctxt->user));
- *scheme = xstrdup("crypt-extended");
- } else {
- /* Default to blowfish */
- rounds = MAX(rounds, 3);
- rounds = MIN(rounds, 31);
- xasprintf(salt, "$2a$%02lld$%s", rounds,
- makesalt(22, authctxt->user));
- *scheme = xstrdup("bcrypt");
- }
- free(style);
- debug3("%s: fake %s salt for user %s: %s",
- __func__, *scheme, authctxt->user, *salt);
-}
-
-/*
- * Fetch password hashing scheme, password salt and derive shared secret
- * for user. If user does not exist, a fake but stable and user-unique
- * salt will be returned.
- */
-void
-auth2_jpake_get_pwdata(Authctxt *authctxt, BIGNUM **s,
- char **hash_scheme, char **salt)
-{
- char *cp;
- u_char *secret;
- u_int secret_len, salt_len;
-
-#ifdef JPAKE_DEBUG
- debug3("%s: valid %d pw %.5s...", __func__,
- authctxt->valid, authctxt->pw->pw_passwd);
-#endif
-
- *salt = NULL;
- *hash_scheme = NULL;
- if (authctxt->valid) {
- if (strncmp(authctxt->pw->pw_passwd, "$2$", 3) == 0 &&
- strlen(authctxt->pw->pw_passwd) > 28) {
- /*
- * old-variant bcrypt:
- * "$2$", 2 digit rounds, "$", 22 bytes salt
- */
- salt_len = 3 + 2 + 1 + 22 + 1;
- *salt = xmalloc(salt_len);
- strlcpy(*salt, authctxt->pw->pw_passwd, salt_len);
- *hash_scheme = xstrdup("bcrypt");
- } else if (strncmp(authctxt->pw->pw_passwd, "$2a$", 4) == 0 &&
- strlen(authctxt->pw->pw_passwd) > 29) {
- /*
- * current-variant bcrypt:
- * "$2a$", 2 digit rounds, "$", 22 bytes salt
- */
- salt_len = 4 + 2 + 1 + 22 + 1;
- *salt = xmalloc(salt_len);
- strlcpy(*salt, authctxt->pw->pw_passwd, salt_len);
- *hash_scheme = xstrdup("bcrypt");
- } else if (strncmp(authctxt->pw->pw_passwd, "$1$", 3) == 0 &&
- strlen(authctxt->pw->pw_passwd) > 5) {
- /*
- * md5crypt:
- * "$1$", salt until "$"
- */
- cp = strchr(authctxt->pw->pw_passwd + 3, '$');
- if (cp != NULL) {
- salt_len = (cp - authctxt->pw->pw_passwd) + 1;
- *salt = xmalloc(salt_len);
- strlcpy(*salt, authctxt->pw->pw_passwd,
- salt_len);
- *hash_scheme = xstrdup("md5crypt");
- }
- } else if (strncmp(authctxt->pw->pw_passwd, "_", 1) == 0 &&
- strlen(authctxt->pw->pw_passwd) > 9) {
- /*
- * BSDI extended crypt:
- * "_", 4 digits count, 4 chars salt
- */
- salt_len = 1 + 4 + 4 + 1;
- *salt = xmalloc(salt_len);
- strlcpy(*salt, authctxt->pw->pw_passwd, salt_len);
- *hash_scheme = xstrdup("crypt-extended");
- } else if (strlen(authctxt->pw->pw_passwd) == 13 &&
- valid_crypt_salt(authctxt->pw->pw_passwd[0]) &&
- valid_crypt_salt(authctxt->pw->pw_passwd[1])) {
- /*
- * traditional crypt:
- * 2 chars salt
- */
- salt_len = 2 + 1;
- *salt = xmalloc(salt_len);
- strlcpy(*salt, authctxt->pw->pw_passwd, salt_len);
- *hash_scheme = xstrdup("crypt");
- }
- if (*salt == NULL) {
- debug("%s: unrecognised crypt scheme for user %s",
- __func__, authctxt->pw->pw_name);
- }
- }
- if (*salt == NULL)
- fake_salt_and_scheme(authctxt, salt, hash_scheme);
-
- if (hash_buffer(authctxt->pw->pw_passwd,
- strlen(authctxt->pw->pw_passwd), EVP_sha256(),
- &secret, &secret_len) != 0)
- fatal("%s: hash_buffer", __func__);
- if ((*s = BN_bin2bn(secret, secret_len, NULL)) == NULL)
- fatal("%s: BN_bin2bn (secret)", __func__);
-#ifdef JPAKE_DEBUG
- debug3("%s: salt = %s (len %u)", __func__,
- *salt, (u_int)strlen(*salt));
- debug3("%s: scheme = %s", __func__, *hash_scheme);
- JPAKE_DEBUG_BN((*s, "%s: s = ", __func__));
-#endif
- bzero(secret, secret_len);
- free(secret);
-}
-
-/*
- * Begin authentication attempt.
- * Note, sets authctxt->postponed while in subprotocol
- */
-static int
-auth2_jpake_start(Authctxt *authctxt)
-{
- struct jpake_ctx *pctx = authctxt->jpake_ctx;
- u_char *x3_proof, *x4_proof;
- u_int x3_proof_len, x4_proof_len;
- char *salt, *hash_scheme;
-
- debug("%s: start", __func__);
-
- PRIVSEP(jpake_step1(pctx->grp,
- &pctx->server_id, &pctx->server_id_len,
- &pctx->x3, &pctx->x4, &pctx->g_x3, &pctx->g_x4,
- &x3_proof, &x3_proof_len,
- &x4_proof, &x4_proof_len));
-
- PRIVSEP(auth2_jpake_get_pwdata(authctxt, &pctx->s,
- &hash_scheme, &salt));
-
- if (!use_privsep)
- JPAKE_DEBUG_CTX((pctx, "step 1 sending in %s", __func__));
-
- packet_start(SSH2_MSG_USERAUTH_JPAKE_SERVER_STEP1);
- packet_put_cstring(hash_scheme);
- packet_put_cstring(salt);
- packet_put_string(pctx->server_id, pctx->server_id_len);
- packet_put_bignum2(pctx->g_x3);
- packet_put_bignum2(pctx->g_x4);
- packet_put_string(x3_proof, x3_proof_len);
- packet_put_string(x4_proof, x4_proof_len);
- packet_send();
- packet_write_wait();
-
- bzero(hash_scheme, strlen(hash_scheme));
- bzero(salt, strlen(salt));
- free(hash_scheme);
- free(salt);
- bzero(x3_proof, x3_proof_len);
- bzero(x4_proof, x4_proof_len);
- free(x3_proof);
- free(x4_proof);
-
- /* Expect step 1 packet from peer */
- dispatch_set(SSH2_MSG_USERAUTH_JPAKE_CLIENT_STEP1,
- input_userauth_jpake_client_step1);
-
- authctxt->postponed = 1;
- return 0;
-}
-
-/* ARGSUSED */
-static void
-input_userauth_jpake_client_step1(int type, u_int32_t seq, void *ctxt)
-{
- Authctxt *authctxt = ctxt;
- struct jpake_ctx *pctx = authctxt->jpake_ctx;
- u_char *x1_proof, *x2_proof, *x4_s_proof;
- u_int x1_proof_len, x2_proof_len, x4_s_proof_len;
-
- /* Disable this message */
- dispatch_set(SSH2_MSG_USERAUTH_JPAKE_CLIENT_STEP1, NULL);
-
- /* Fetch step 1 values */
- if ((pctx->g_x1 = BN_new()) == NULL ||
- (pctx->g_x2 = BN_new()) == NULL)
- fatal("%s: BN_new", __func__);
- pctx->client_id = packet_get_string(&pctx->client_id_len);
- packet_get_bignum2(pctx->g_x1);
- packet_get_bignum2(pctx->g_x2);
- x1_proof = packet_get_string(&x1_proof_len);
- x2_proof = packet_get_string(&x2_proof_len);
- packet_check_eom();
-
- if (!use_privsep)
- JPAKE_DEBUG_CTX((pctx, "step 1 received in %s", __func__));
-
- PRIVSEP(jpake_step2(pctx->grp, pctx->s, pctx->g_x3,
- pctx->g_x1, pctx->g_x2, pctx->x4,
- pctx->client_id, pctx->client_id_len,
- pctx->server_id, pctx->server_id_len,
- x1_proof, x1_proof_len,
- x2_proof, x2_proof_len,
- &pctx->b,
- &x4_s_proof, &x4_s_proof_len));
-
- bzero(x1_proof, x1_proof_len);
- bzero(x2_proof, x2_proof_len);
- free(x1_proof);
- free(x2_proof);
-
- if (!use_privsep)
- JPAKE_DEBUG_CTX((pctx, "step 2 sending in %s", __func__));
-
- /* Send values for step 2 */
- packet_start(SSH2_MSG_USERAUTH_JPAKE_SERVER_STEP2);
- packet_put_bignum2(pctx->b);
- packet_put_string(x4_s_proof, x4_s_proof_len);
- packet_send();
- packet_write_wait();
-
- bzero(x4_s_proof, x4_s_proof_len);
- free(x4_s_proof);
-
- /* Expect step 2 packet from peer */
- dispatch_set(SSH2_MSG_USERAUTH_JPAKE_CLIENT_STEP2,
- input_userauth_jpake_client_step2);
-}
-
-/* ARGSUSED */
-static void
-input_userauth_jpake_client_step2(int type, u_int32_t seq, void *ctxt)
-{
- Authctxt *authctxt = ctxt;
- struct jpake_ctx *pctx = authctxt->jpake_ctx;
- u_char *x2_s_proof;
- u_int x2_s_proof_len;
-
- /* Disable this message */
- dispatch_set(SSH2_MSG_USERAUTH_JPAKE_CLIENT_STEP2, NULL);
-
- if ((pctx->a = BN_new()) == NULL)
- fatal("%s: BN_new", __func__);
-
- /* Fetch step 2 values */
- packet_get_bignum2(pctx->a);
- x2_s_proof = packet_get_string(&x2_s_proof_len);
- packet_check_eom();
-
- if (!use_privsep)
- JPAKE_DEBUG_CTX((pctx, "step 2 received in %s", __func__));
-
- /* Derive shared key and calculate confirmation hash */
- PRIVSEP(jpake_key_confirm(pctx->grp, pctx->s, pctx->a,
- pctx->x4, pctx->g_x3, pctx->g_x4, pctx->g_x1, pctx->g_x2,
- pctx->server_id, pctx->server_id_len,
- pctx->client_id, pctx->client_id_len,
- session_id2, session_id2_len,
- x2_s_proof, x2_s_proof_len,
- &pctx->k,
- &pctx->h_k_sid_sessid, &pctx->h_k_sid_sessid_len));
-
- bzero(x2_s_proof, x2_s_proof_len);
- free(x2_s_proof);
-
- if (!use_privsep)
- JPAKE_DEBUG_CTX((pctx, "confirm sending in %s", __func__));
-
- /* Send key confirmation proof */
- packet_start(SSH2_MSG_USERAUTH_JPAKE_SERVER_CONFIRM);
- packet_put_string(pctx->h_k_sid_sessid, pctx->h_k_sid_sessid_len);
- packet_send();
- packet_write_wait();
-
- /* Expect confirmation from peer */
- dispatch_set(SSH2_MSG_USERAUTH_JPAKE_CLIENT_CONFIRM,
- input_userauth_jpake_client_confirm);
-}
-
-/* ARGSUSED */
-static void
-input_userauth_jpake_client_confirm(int type, u_int32_t seq, void *ctxt)
-{
- Authctxt *authctxt = ctxt;
- struct jpake_ctx *pctx = authctxt->jpake_ctx;
- int authenticated = 0;
-
- /* Disable this message */
- dispatch_set(SSH2_MSG_USERAUTH_JPAKE_CLIENT_CONFIRM, NULL);
-
- pctx->h_k_cid_sessid = packet_get_string(&pctx->h_k_cid_sessid_len);
- packet_check_eom();
-
- if (!use_privsep)
- JPAKE_DEBUG_CTX((pctx, "confirm received in %s", __func__));
-
- /* Verify expected confirmation hash */
- if (PRIVSEP(jpake_check_confirm(pctx->k,
- pctx->client_id, pctx->client_id_len,
- session_id2, session_id2_len,
- pctx->h_k_cid_sessid, pctx->h_k_cid_sessid_len)) == 1)
- authenticated = authctxt->valid ? 1 : 0;
- else
- debug("%s: confirmation mismatch", __func__);
-
- /* done */
- authctxt->postponed = 0;
- jpake_free(authctxt->jpake_ctx);
- authctxt->jpake_ctx = NULL;
- userauth_finish(authctxt, authenticated, method_jpake.name, NULL);
-}
-
-#endif /* JPAKE */
-
diff --git a/auth2.c b/auth2.c
index f0cab8cc..a5490c00 100644
--- a/auth2.c
+++ b/auth2.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: auth2.c,v 1.129 2013/05/19 02:42:42 djm Exp $ */
+/* $OpenBSD: auth2.c,v 1.130 2014/01/29 06:18:35 djm Exp $ */
/*
* Copyright (c) 2000 Markus Friedl. All rights reserved.
*
@@ -71,9 +71,6 @@ extern Authmethod method_hostbased;
#ifdef GSSAPI
extern Authmethod method_gssapi;
#endif
-#ifdef JPAKE
-extern Authmethod method_jpake;
-#endif
Authmethod *authmethods[] = {
&method_none,
@@ -81,9 +78,6 @@ Authmethod *authmethods[] = {
#ifdef GSSAPI
&method_gssapi,
#endif
-#ifdef JPAKE
- &method_jpake,
-#endif
&method_passwd,
&method_kbdint,
&method_hostbased,
@@ -270,9 +264,6 @@ input_userauth_request(int type, u_int32_t seq, void *ctxt)
}
/* reset state */
auth2_challenge_stop(authctxt);
-#ifdef JPAKE
- auth2_jpake_stop(authctxt);
-#endif
#ifdef GSSAPI
/* XXX move to auth2_gssapi_stop() */
diff --git a/jpake.c b/jpake.c
deleted file mode 100644
index 3dd87916..00000000
--- a/jpake.c
+++ /dev/null
@@ -1,456 +0,0 @@
-/* $OpenBSD: jpake.c,v 1.8 2013/05/17 00:13:13 djm Exp $ */
-/*
- * Copyright (c) 2008 Damien Miller. All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-/*
- * Shared components of zero-knowledge password auth using J-PAKE protocol
- * as described in:
- *
- * F. Hao, P. Ryan, "Password Authenticated Key Exchange by Juggling",
- * 16th Workshop on Security Protocols, Cambridge, April 2008
- *
- * http://grouper.ieee.org/groups/1363/Research/contributions/hao-ryan-2008.pdf
- */
-
-#include "includes.h"
-
-#include <sys/types.h>
-
-#include <stdio.h>
-#include <string.h>
-#include <stdarg.h>
-
-#include <openssl/bn.h>
-#include <openssl/evp.h>
-
-#include "xmalloc.h"
-#include "ssh2.h"
-#include "key.h"
-#include "hostfile.h"
-#include "auth.h"
-#include "buffer.h"
-#include "packet.h"
-#include "dispatch.h"
-#include "log.h"
-#include "misc.h"
-
-#include "jpake.h"
-#include "schnorr.h"
-
-#ifdef JPAKE
-
-/* RFC3526 group 5, 1536 bits */
-#define JPAKE_GROUP_G "2"
-#define JPAKE_GROUP_P \
- "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74" \
- "020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F1437" \
- "4FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED" \
- "EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF05" \
- "98DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB" \
- "9ED529077096966D670C354E4ABC9804F1746C08CA237327FFFFFFFFFFFFFFFF"
-
-struct modp_group *
-jpake_default_group(void)
-{
- return modp_group_from_g_and_safe_p(JPAKE_GROUP_G, JPAKE_GROUP_P);
-}
-
-struct jpake_ctx *
-jpake_new(void)
-{
- struct jpake_ctx *ret;
-
- ret = xcalloc(1, sizeof(*ret));
-
- ret->grp = jpake_default_group();
-
- ret->s = ret->k = NULL;
- ret->x1 = ret->x2 = ret->x3 = ret->x4 = NULL;
- ret->g_x1 = ret->g_x2 = ret->g_x3 = ret->g_x4 = NULL;
- ret->a = ret->b = NULL;
-
- ret->client_id = ret->server_id = NULL;
- ret->h_k_cid_sessid = ret->h_k_sid_sessid = NULL;
-
- debug3("%s: alloc %p", __func__, ret);
-
- return ret;
-}
-
-void
-jpake_free(struct jpake_ctx *pctx)
-{
- debug3("%s: free %p", __func__, pctx);
-
-#define JPAKE_BN_CLEAR_FREE(v) \
- do { \
- if ((v) != NULL) { \
- BN_clear_free(v); \
- (v) = NULL; \
- } \
- } while (0)
-#define JPAKE_BUF_CLEAR_FREE(v, l) \
- do { \
- if ((v) != NULL) { \
- bzero((v), (l)); \
- free(v); \
- (v) = NULL; \
- (l) = 0; \
- } \
- } while (0)
-
- JPAKE_BN_CLEAR_FREE(pctx->s);
- JPAKE_BN_CLEAR_FREE(pctx->k);
- JPAKE_BN_CLEAR_FREE(pctx->x1);
- JPAKE_BN_CLEAR_FREE(pctx->x2);
- JPAKE_BN_CLEAR_FREE(pctx->x3);
- JPAKE_BN_CLEAR_FREE(pctx->x4);
- JPAKE_BN_CLEAR_FREE(pctx->g_x1);
- JPAKE_BN_CLEAR_FREE(pctx->g_x2);
- JPAKE_BN_CLEAR_FREE(pctx->g_x3);
- JPAKE_BN_CLEAR_FREE(pctx->g_x4);
- JPAKE_BN_CLEAR_FREE(pctx->a);
- JPAKE_BN_CLEAR_FREE(pctx->b);
-
- JPAKE_BUF_CLEAR_FREE(pctx->client_id, pctx->client_id_len);
- JPAKE_BUF_CLEAR_FREE(pctx->server_id, pctx->server_id_len);
- JPAKE_BUF_CLEAR_FREE(pctx->h_k_cid_sessid, pctx->h_k_cid_sessid_len);
- JPAKE_BUF_CLEAR_FREE(pctx->h_k_sid_sessid, pctx->h_k_sid_sessid_len);
-
-#undef JPAKE_BN_CLEAR_FREE
-#undef JPAKE_BUF_CLEAR_FREE
-
- bzero(pctx, sizeof(*pctx));
- free(pctx);
-}
-
-/* dump entire jpake_ctx. NB. includes private values! */
-void
-jpake_dump(struct jpake_ctx *pctx, const char *fmt, ...)
-{
- char *out;
- va_list args;
-
- out = NULL;
- va_start(args, fmt);
- vasprintf(&out, fmt, args);
- va_end(args);
- if (out == NULL)
- fatal("%s: vasprintf failed", __func__);
-
- debug3("%s: %s (ctx at %p)", __func__, out, pctx);
- if (pctx == NULL) {
- free(out);
- return;
- }
-
-#define JPAKE_DUMP_BN(a) do { \
- if ((a) != NULL) \
- JPAKE_DEBUG_BN(((a), "%s = ", #a)); \
- } while (0)
-#define JPAKE_DUMP_BUF(a, b) do { \
- if ((a) != NULL) \
- JPAKE_DEBUG_BUF((a, b, "%s", #a)); \
- } while (0)
-
- JPAKE_DUMP_BN(pctx->s);
- JPAKE_DUMP_BN(pctx->k);
- JPAKE_DUMP_BN(pctx->x1);
- JPAKE_DUMP_BN(pctx->x2);
- JPAKE_DUMP_BN(pctx->x3);
- JPAKE_DUMP_BN(pctx->x4);
- JPAKE_DUMP_BN(pctx->g_x1);
- JPAKE_DUMP_BN(pctx->g_x2);
- JPAKE_DUMP_BN(pctx->g_x3);
- JPAKE_DUMP_BN(pctx->g_x4);
- JPAKE_DUMP_BN(pctx->a);
- JPAKE_DUMP_BN(pctx->b);
-
- JPAKE_DUMP_BUF(pctx->client_id, pctx->client_id_len);
- JPAKE_DUMP_BUF(pctx->server_id, pctx->server_id_len);
- JPAKE_DUMP_BUF(pctx->h_k_cid_sessid, pctx->h_k_cid_sessid_len);
- JPAKE_DUMP_BUF(pctx->h_k_sid_sessid, pctx->h_k_sid_sessid_len);
-
- debug3("%s: %s done", __func__, out);
- free(out);
-}
-
-/* Shared parts of step 1 exchange calculation */
-void
-jpake_step1(struct modp_group *grp,
- u_char **id, u_int *id_len,
- BIGNUM **priv1, BIGNUM **priv2, BIGNUM **g_priv1, BIGNUM **g_priv2,
- u_char **priv1_proof, u_int *priv1_proof_len,
- u_char **priv2_proof, u_int *priv2_proof_len)
-{
- BN_CTX *bn_ctx;
-
- if ((bn_ctx = BN_CTX_new()) == NULL)
- fatal("%s: BN_CTX_new", __func__);
-
- /* Random nonce to prevent replay */
- *id = xmalloc(KZP_ID_LEN);
- *id_len = KZP_ID_LEN;
- arc4random_buf(*id, *id_len);
-
- /*
- * x1/x3 is a random element of Zq
- * x2/x4 is a random element of Z*q
- * We also exclude [1] from x1/x3 candidates and [0, 1] from
- * x2/x4 candiates to avoid possible degeneracy (i.e. g^0, g^1).
- */
- if ((*priv1 = bn_rand_range_gt_one(grp->q)) == NULL ||
- (*priv2 = bn_rand_range_gt_one(grp->q)) == NULL)
- fatal("%s: bn_rand_range_gt_one", __func__);
-
- /*
- * client: g_x1 = g^x1 mod p / server: g_x3 = g^x3 mod p
- * client: g_x2 = g^x2 mod p / server: g_x4 = g^x4 mod p
- */
- if ((*g_priv1 = BN_new()) == NULL ||
- (*g_priv2 = BN_new()) == NULL)
- fatal("%s: BN_new", __func__);
- if (BN_mod_exp(*g_priv1, grp->g, *priv1, grp->p, bn_ctx) == -1)
- fatal("%s: BN_mod_exp", __func__);
- if (BN_mod_exp(*g_priv2, grp->g, *priv2, grp->p, bn_ctx) == -1)
- fatal("%s: BN_mod_exp", __func__);
-
- /* Generate proofs for holding x1/x3 and x2/x4 */
- if (schnorr_sign_buf(grp->p, grp->q, grp->g,
- *priv1, *g_priv1, *id, *id_len,
- priv1_proof, priv1_proof_len) != 0)
- fatal("%s: schnorr_sign", __func__);
- if (schnorr_sign_buf(grp->p, grp->q, grp->g,
- *priv2, *g_priv2, *id, *id_len,
- priv2_proof, priv2_proof_len) != 0)
- fatal("%s: schnorr_sign", __func__);
-
- BN_CTX_free(bn_ctx);
-}
-
-/* Shared parts of step 2 exchange calculation */