summaryrefslogtreecommitdiff
path: root/auth-skey.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2000-01-11 10:59:47 +1100
committerDamien Miller <djm@mindrot.org>2000-01-11 10:59:47 +1100
commit25e4256ad4f453d8a7c1866243ec1984f859b1de (patch)
treeac850c8b4ef680968a7bd248a8ff9d7213204195 /auth-skey.c
parentfa824cbb7ed7d296f3984045ee9696a037b0e0f8 (diff)
- Fixes to auth-skey to enable it to use the standard OpenSSL libraries
Diffstat (limited to 'auth-skey.c')
-rw-r--r--auth-skey.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/auth-skey.c b/auth-skey.c
index 4e82bdef6..f403a1962 100644
--- a/auth-skey.c
+++ b/auth-skey.c
@@ -7,10 +7,10 @@ RCSID("$Id: auth-skey.c,v 1.5 1999/12/06 19:04:57 deraadt Exp $");
7#include "packet.h" 7#include "packet.h"
8 8
9#ifdef HAVE_OPENSSL 9#ifdef HAVE_OPENSSL
10#include <openssl/sha1.h> 10#include <openssl/sha.h>
11#endif 11#endif
12#ifdef HAVE_SSL 12#ifdef HAVE_SSL
13#include <ssl/sha1.h> 13#include <ssl/sha.h>
14#endif 14#endif
15 15
16/* from %OpenBSD: skeylogin.c,v 1.32 1999/08/16 14:46:56 millert Exp % */ 16/* from %OpenBSD: skeylogin.c,v 1.32 1999/08/16 14:46:56 millert Exp % */
@@ -79,8 +79,9 @@ skey_fake_keyinfo(char *username)
79 static char skeyprompt[SKEY_MAX_CHALLENGE+1]; 79 static char skeyprompt[SKEY_MAX_CHALLENGE+1];
80 char *secret = NULL; 80 char *secret = NULL;
81 size_t secretlen = 0; 81 size_t secretlen = 0;
82 SHA1_CTX ctx; 82 SHA_CTX ctx;
83 char *p, *u; 83 char *p, *u;
84 char md[SHA_DIGEST_LENGTH];
84 85
85 /* 86 /*
86 * Base first 4 chars of seed on hostname. 87 * Base first 4 chars of seed on hostname.
@@ -97,11 +98,16 @@ skey_fake_keyinfo(char *username)
97 pbuf[4] = '\0'; 98 pbuf[4] = '\0';
98 99
99 /* Hash the username if possible */ 100 /* Hash the username if possible */
100 if ((up = SHA1Data(username, strlen(username), NULL)) != NULL) { 101 up = malloc(SHA_DIGEST_LENGTH);
102 if (up != NULL) {
101 struct stat sb; 103 struct stat sb;
102 time_t t; 104 time_t t;
103 int fd; 105 int fd;
104 106
107 SHA1_Init(&ctx);
108 SHA1_Update(&ctx, username, strlen(username));
109 SHA1_End(&ctx, up);
110
105 /* Collapse the hash */ 111 /* Collapse the hash */
106 ptr = hash_collapse(up); 112 ptr = hash_collapse(up);
107 memset(up, 0, strlen(up)); 113 memset(up, 0, strlen(up));
@@ -131,18 +137,18 @@ skey_fake_keyinfo(char *username)
131 /* Put that in your pipe and smoke it */ 137 /* Put that in your pipe and smoke it */
132 if (flg == 0) { 138 if (flg == 0) {
133 /* Hash secret value with username */ 139 /* Hash secret value with username */
134 SHA1Init(&ctx); 140 SHA1_Init(&ctx);
135 SHA1Update(&ctx, secret, secretlen); 141 SHA1_Update(&ctx, secret, secretlen);
136 SHA1Update(&ctx, username, strlen(username)); 142 SHA1_Update(&ctx, username, strlen(username));
137 SHA1End(&ctx, up); 143 SHA1_End(&ctx, up);
138 144
139 /* Zero out */ 145 /* Zero out */
140 memset(secret, 0, secretlen); 146 memset(secret, 0, secretlen);
141 147
142 /* Now hash the hash */ 148 /* Now hash the hash */
143 SHA1Init(&ctx); 149 SHA1_Init(&ctx);
144 SHA1Update(&ctx, up, strlen(up)); 150 SHA1_Update(&ctx, up, strlen(up));
145 SHA1End(&ctx, up); 151 SHA1_End(&ctx, up);
146 152
147 ptr = hash_collapse(up + 4); 153 ptr = hash_collapse(up + 4);
148 154
@@ -155,7 +161,7 @@ skey_fake_keyinfo(char *username)
155 /* Sequence number */ 161 /* Sequence number */
156 ptr = ((up[2] + up[3]) % 99) + 1; 162 ptr = ((up[2] + up[3]) % 99) + 1;
157 163
158 memset(up, 0, 20); /* SHA1 specific */ 164 memset(up, 0, SHA_DIGEST_LENGTH); /* SHA1 specific */
159 free(up); 165 free(up);
160 166
161 (void)snprintf(skeyprompt, sizeof skeyprompt, 167 (void)snprintf(skeyprompt, sizeof skeyprompt,