+/*
+ * Copyright (c) 1999,2000 Markus Friedl. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
#include "includes.h"
+RCSID("$OpenBSD: auth-skey.c,v 1.8 2000/09/07 20:27:49 deraadt Exp $");
#ifdef SKEY
-RCSID("$Id$");
-
#include "ssh.h"
#include "packet.h"
-
-#ifdef HAVE_OPENSSL
-#include <openssl/sha1.h>
-#endif
-#ifdef HAVE_SSL
-#include <ssl/sha1.h>
-#endif
+#include <openssl/sha.h>
/* from %OpenBSD: skeylogin.c,v 1.32 1999/08/16 14:46:56 millert Exp % */
-/*
+/*
* try skey authentication,
- * return 1 on success, 0 on failure, -1 if skey is not available
+ * return 1 on success, 0 on failure, -1 if skey is not available
*/
-int
+int
auth_skey_password(struct passwd * pw, const char *password)
{
if (strncasecmp(password, "s/key", 5) == 0) {
*/
static u_int32_t
hash_collapse(s)
- u_char *s;
+ u_char *s;
{
- int len, target;
+ int len, target;
u_int32_t i;
if ((strlen(s) % sizeof(u_int32_t)) == 0)
- target = strlen(s); /* Multiple of 4 */
+ target = strlen(s); /* Multiple of 4 */
else
target = strlen(s) - (strlen(s) % sizeof(u_int32_t));
-
+
for (i = 0, len = 0; len < target; len += 4)
- i ^= ROUND(s + len);
+ i ^= ROUND(s + len);
return i;
}
static char skeyprompt[SKEY_MAX_CHALLENGE+1];
char *secret = NULL;
size_t secretlen = 0;
- SHA1_CTX ctx;
+ SHA_CTX ctx;
char *p, *u;
/*
pbuf[4] = '\0';
/* Hash the username if possible */
- if ((up = SHA1Data(username, strlen(username), NULL)) != NULL) {
+ up = malloc(SHA_DIGEST_LENGTH);
+ if (up != NULL) {
struct stat sb;
time_t t;
int fd;
+ SHA1_Init(&ctx);
+ SHA1_Update(&ctx, username, strlen(username));
+ SHA1_Final(up, &ctx);
+
/* Collapse the hash */
ptr = hash_collapse(up);
memset(up, 0, strlen(up));
/* Put that in your pipe and smoke it */
if (flg == 0) {
/* Hash secret value with username */
- SHA1Init(&ctx);
- SHA1Update(&ctx, secret, secretlen);
- SHA1Update(&ctx, username, strlen(username));
- SHA1End(&ctx, up);
+ SHA1_Init(&ctx);
+ SHA1_Update(&ctx, secret, secretlen);
+ SHA1_Update(&ctx, username, strlen(username));
+ SHA1_Final(up, &ctx);
/* Zero out */
memset(secret, 0, secretlen);
/* Now hash the hash */
- SHA1Init(&ctx);
- SHA1Update(&ctx, up, strlen(up));
- SHA1End(&ctx, up);
+ SHA1_Init(&ctx);
+ SHA1_Update(&ctx, up, strlen(up));
+ SHA1_Final(up, &ctx);
ptr = hash_collapse(up + 4);
/* Sequence number */
ptr = ((up[2] + up[3]) % 99) + 1;
- memset(up, 0, 20); /* SHA1 specific */
+ memset(up, 0, SHA_DIGEST_LENGTH); /* SHA1 specific */
free(up);
(void)snprintf(skeyprompt, sizeof skeyprompt,