summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1999-09-30 17:08:54 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1999-09-30 17:08:54 +0000
commitd3a68f6219de2d67f87950397fd565053cb7a7f0 (patch)
treeb556b46bcc43b6ab851356032bfd69584e9c57ba /usr.bin
parentdf99f93221606bc387239dd3989f74c1d1e02411 (diff)
use libc md5
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/ssh/auth-rsa.c6
-rw-r--r--usr.bin/ssh/cipher.c7
-rw-r--r--usr.bin/ssh/mpaux.c7
-rw-r--r--usr.bin/ssh/ssh-add/Makefile2
-rw-r--r--usr.bin/ssh/ssh-agent.c7
-rw-r--r--usr.bin/ssh/ssh-agent/Makefile2
-rw-r--r--usr.bin/ssh/ssh-keygen/Makefile2
-rw-r--r--usr.bin/ssh/ssh/Makefile2
-rw-r--r--usr.bin/ssh/ssh_md5.c237
-rw-r--r--usr.bin/ssh/ssh_md5.h20
-rw-r--r--usr.bin/ssh/sshconnect.c7
-rw-r--r--usr.bin/ssh/sshd/Makefile2
12 files changed, 24 insertions, 277 deletions
diff --git a/usr.bin/ssh/auth-rsa.c b/usr.bin/ssh/auth-rsa.c
index 5c58d4fb5a2..c30d213393d 100644
--- a/usr.bin/ssh/auth-rsa.c
+++ b/usr.bin/ssh/auth-rsa.c
@@ -16,17 +16,17 @@ validity of the host key.
*/
#include "includes.h"
-RCSID("$Id: auth-rsa.c,v 1.2 1999/09/29 21:14:15 deraadt Exp $");
+RCSID("$Id: auth-rsa.c,v 1.3 1999/09/30 17:08:51 deraadt Exp $");
#include "rsa.h"
#include "packet.h"
#include "xmalloc.h"
#include "ssh.h"
-#include "ssh_md5.h"
#include "mpaux.h"
#include "uidswap.h"
#include <ssl/rsa.h>
+#include <md5.h>
/* Flags that may be set in authorized_keys options. */
extern int no_port_forwarding_flag;
@@ -60,7 +60,7 @@ auth_rsa_challenge_dialog(unsigned int bits, BIGNUM *e, BIGNUM *n)
RSA *pk;
BN_CTX *ctx = BN_CTX_new();
unsigned char buf[32], mdbuf[16], response[16];
- struct MD5Context md;
+ MD5_CTX md;
unsigned int i;
int plen, len;
diff --git a/usr.bin/ssh/cipher.c b/usr.bin/ssh/cipher.c
index 4a846890094..a9e2edbc525 100644
--- a/usr.bin/ssh/cipher.c
+++ b/usr.bin/ssh/cipher.c
@@ -12,11 +12,12 @@ Created: Wed Apr 19 17:41:39 1995 ylo
*/
#include "includes.h"
-RCSID("$Id: cipher.c,v 1.7 1999/09/30 14:05:41 provos Exp $");
+RCSID("$Id: cipher.c,v 1.8 1999/09/30 17:08:52 deraadt Exp $");
#include "ssh.h"
#include "cipher.h"
-#include "ssh_md5.h"
+
+#include <md5.h>
/*
* What kind of tripple DES are these 2 routines?
@@ -172,7 +173,7 @@ cipher_number(const char *name)
void cipher_set_key_string(CipherContext *context, int cipher,
const char *passphrase, int for_encryption)
{
- struct MD5Context md;
+ MD5_CTX md;
unsigned char digest[16];
MD5Init(&md);
diff --git a/usr.bin/ssh/mpaux.c b/usr.bin/ssh/mpaux.c
index 2f7836baf7b..6b02ca2f2a9 100644
--- a/usr.bin/ssh/mpaux.c
+++ b/usr.bin/ssh/mpaux.c
@@ -15,12 +15,13 @@ precision integers.
*/
#include "includes.h"
-RCSID("$Id: mpaux.c,v 1.2 1999/09/28 04:45:36 provos Exp $");
+RCSID("$Id: mpaux.c,v 1.3 1999/09/30 17:08:52 deraadt Exp $");
#include <ssl/bn.h>
#include "getput.h"
#include "xmalloc.h"
-#include "ssh_md5.h"
+
+#include <md5.h>
void
compute_session_id(unsigned char session_id[16],
@@ -32,7 +33,7 @@ compute_session_id(unsigned char session_id[16],
{
unsigned int bytes = (host_key_bits + 7) / 8 + (session_key_bits + 7) / 8 + 8;
unsigned char *buf = xmalloc(bytes);
- struct MD5Context md;
+ MD5_CTX md;
BN_bn2bin(host_key_n, buf);
BN_bn2bin(session_key_n, buf + (host_key_bits + 7 ) / 8);
diff --git a/usr.bin/ssh/ssh-add/Makefile b/usr.bin/ssh/ssh-add/Makefile
index b40858b8e77..438cfee3f70 100644
--- a/usr.bin/ssh/ssh-add/Makefile
+++ b/usr.bin/ssh/ssh-add/Makefile
@@ -8,7 +8,7 @@ LDADD= -lcrypto -ldes -lutil -lz
DPADD= ${LIBCRYPTO} ${LIBDES} ${LIBUTIL} ${LIBZ}
MAN= ssh-add.1
-SRCS= ssh-add.c log-client.c readpass.c rsa.c ssh_md5.c buffer.c \
+SRCS= ssh-add.c log-client.c readpass.c rsa.c buffer.c \
xmalloc.c bufaux.c authfd.c authfile.c crc32.c match.c \
mpaux.c minfd.c cipher.c compress.c
diff --git a/usr.bin/ssh/ssh-agent.c b/usr.bin/ssh/ssh-agent.c
index 255ebd5b207..d024f44580d 100644
--- a/usr.bin/ssh/ssh-agent.c
+++ b/usr.bin/ssh/ssh-agent.c
@@ -14,7 +14,7 @@ The authentication agent program.
*/
#include "includes.h"
-RCSID("$Id: ssh-agent.c,v 1.6 1999/09/30 08:34:25 deraadt Exp $");
+RCSID("$Id: ssh-agent.c,v 1.7 1999/09/30 17:08:52 deraadt Exp $");
#include "ssh.h"
#include "rsa.h"
@@ -23,10 +23,11 @@ RCSID("$Id: ssh-agent.c,v 1.6 1999/09/30 08:34:25 deraadt Exp $");
#include "bufaux.h"
#include "xmalloc.h"
#include "packet.h"
-#include "ssh_md5.h"
#include "getput.h"
#include "mpaux.h"
+#include <md5.h>
+
typedef struct
{
int fd;
@@ -78,7 +79,7 @@ process_authentication_challenge(SocketEntry *e)
int i, pub_bits, len;
BIGNUM *pub_e, *pub_n, *challenge;
Buffer msg;
- struct MD5Context md;
+ MD5_CTX md;
unsigned char buf[32], mdbuf[16], session_id[16];
unsigned int response_type;
diff --git a/usr.bin/ssh/ssh-agent/Makefile b/usr.bin/ssh/ssh-agent/Makefile
index e39b07c457c..cf778f842b5 100644
--- a/usr.bin/ssh/ssh-agent/Makefile
+++ b/usr.bin/ssh/ssh-agent/Makefile
@@ -8,7 +8,7 @@ LDADD= -lcrypto -ldes -lutil -lz
DPADD= ${LIBCRYPTO} ${LIBDES} ${LIBUTIL} ${LIBZ}
MAN= ssh-agent.1
-SRCS= ssh-agent.c log-client.c rsa.c ssh_md5.c buffer.c \
+SRCS= ssh-agent.c log-client.c rsa.c buffer.c \
xmalloc.c bufaux.c authfd.c authfile.c \
mpaux.c crc32.c match.c minfd.c cipher.c compress.c
diff --git a/usr.bin/ssh/ssh-keygen/Makefile b/usr.bin/ssh/ssh-keygen/Makefile
index 42620bc8b9b..9cfa09467c8 100644
--- a/usr.bin/ssh/ssh-keygen/Makefile
+++ b/usr.bin/ssh/ssh-keygen/Makefile
@@ -8,7 +8,7 @@ LDADD= -lcrypto -ldes -lutil -lz
DPADD= ${LIBCRYPTO} ${LIBDES} ${LIBUTIL} ${LIBZ}
MAN= ssh-keygen.1
-SRCS= ssh-keygen.c log-client.c readpass.c rsa.c ssh_md5.c \
+SRCS= ssh-keygen.c log-client.c readpass.c rsa.c \
buffer.c xmalloc.c authfile.c mpaux.c bufaux.c \
crc32.c match.c minfd.c cipher.c compress.c
diff --git a/usr.bin/ssh/ssh/Makefile b/usr.bin/ssh/ssh/Makefile
index 301b8710c14..b54097303e8 100644
--- a/usr.bin/ssh/ssh/Makefile
+++ b/usr.bin/ssh/ssh/Makefile
@@ -12,7 +12,7 @@ MLINKS= ssh.1 slogin.1
SRCS= ssh.c sshconnect.c log-client.c readconf.c hostfile.c readpass.c \
tildexpand.c uidswap.c clientloop.c canohost.c rsa.c \
- ssh_md5.c buffer.c packet.c xmalloc.c ttymodes.c channels.c bufaux.c \
+ buffer.c packet.c xmalloc.c ttymodes.c channels.c bufaux.c \
authfd.c authfile.c crc32.c match.c mpaux.c minfd.c cipher.c \
compress.c
diff --git a/usr.bin/ssh/ssh_md5.c b/usr.bin/ssh/ssh_md5.c
deleted file mode 100644
index e1659dc3335..00000000000
--- a/usr.bin/ssh/ssh_md5.c
+++ /dev/null
@@ -1,237 +0,0 @@
-/* This code has been heavily hacked by Tatu Ylonen <ylo@cs.hut.fi> to
- make it compile on machines like Cray that don't have a 32 bit integer
- type. */
-/*
- * This code implements the MD5 message-digest algorithm.
- * The algorithm is due to Ron Rivest. This code was
- * written by Colin Plumb in 1993, no copyright is claimed.
- * This code is in the public domain; do with it what you wish.
- *
- * Equivalent code is available from RSA Data Security, Inc.
- * This code has been tested against that, and is equivalent,
- * except that you don't need to include two pages of legalese
- * with every copy.
- *
- * To compute the message digest of a chunk of bytes, declare an
- * MD5Context structure, pass it to MD5Init, call MD5Update as
- * needed on buffers full of bytes, and then call MD5Final, which
- * will fill a supplied 16-byte array with the digest.
- */
-
-#include "includes.h"
-#include "ssh_md5.h"
-#include "getput.h"
-
-/*
- * Start MD5 accumulation. Set bit count to 0 and buffer to mysterious
- * initialization constants.
- */
-void MD5Init(struct MD5Context *ctx)
-{
- ctx->buf[0] = 0x67452301;
- ctx->buf[1] = 0xefcdab89;
- ctx->buf[2] = 0x98badcfe;
- ctx->buf[3] = 0x10325476;
-
- ctx->bits[0] = 0;
- ctx->bits[1] = 0;
-}
-
-/*
- * Update context to reflect the concatenation of another buffer full
- * of bytes.
- */
-void MD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len)
-{
- u_int32_t t;
-
- /* Update bitcount */
-
- t = ctx->bits[0];
- if ((ctx->bits[0] = (t + ((u_int32_t)len << 3)) & 0xffffffff) < t)
- ctx->bits[1]++; /* Carry from low to high */
- ctx->bits[1] += len >> 29;
-
- t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */
-
- /* Handle any leading odd-sized chunks */
-
- if (t) {
- unsigned char *p = ctx->in + t;
-
- t = 64 - t;
- if (len < t) {
- memcpy(p, buf, len);
- return;
- }
- memcpy(p, buf, t);
- MD5Transform(ctx->buf, ctx->in);
- buf += t;
- len -= t;
- }
- /* Process data in 64-byte chunks */
-
- while (len >= 64) {
- memcpy(ctx->in, buf, 64);
- MD5Transform(ctx->buf, ctx->in);
- buf += 64;
- len -= 64;
- }
-
- /* Handle any remaining bytes of data. */
-
- memcpy(ctx->in, buf, len);
-}
-
-/*
- * Final wrapup - pad to 64-byte boundary with the bit pattern
- * 1 0* (64-bit count of bits processed, MSB-first)
- */
-void MD5Final(unsigned char digest[16], struct MD5Context *ctx)
-{
- unsigned count;
- unsigned char *p;
-
- /* Compute number of bytes mod 64 */
- count = (ctx->bits[0] >> 3) & 0x3F;
-
- /* Set the first char of padding to 0x80. This is safe since there is
- always at least one byte free */
- p = ctx->in + count;
- *p++ = 0x80;
-
- /* Bytes of padding needed to make 64 bytes */
- count = 64 - 1 - count;
-
- /* Pad out to 56 mod 64 */
- if (count < 8) {
- /* Two lots of padding: Pad the first block to 64 bytes */
- memset(p, 0, count);
- MD5Transform(ctx->buf, ctx->in);
-
- /* Now fill the next block with 56 bytes */
- memset(ctx->in, 0, 56);
- } else {
- /* Pad block to 56 bytes */
- memset(p, 0, count - 8);
- }
-
- /* Append length in bits and transform */
- PUT_32BIT_LSB_FIRST(ctx->in + 56, ctx->bits[0]);
- PUT_32BIT_LSB_FIRST(ctx->in + 60, ctx->bits[1]);
-
- MD5Transform(ctx->buf, ctx->in);
- PUT_32BIT_LSB_FIRST(digest, ctx->buf[0]);
- PUT_32BIT_LSB_FIRST(digest + 4, ctx->buf[1]);
- PUT_32BIT_LSB_FIRST(digest + 8, ctx->buf[2]);
- PUT_32BIT_LSB_FIRST(digest + 12, ctx->buf[3]);
- memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */
-}
-
-#ifndef ASM_MD5
-
-/* The four core functions - F1 is optimized somewhat */
-
-/* #define F1(x, y, z) (x & y | ~x & z) */
-#define F1(x, y, z) (z ^ (x & (y ^ z)))
-#define F2(x, y, z) F1(z, x, y)
-#define F3(x, y, z) (x ^ y ^ z)
-#define F4(x, y, z) (y ^ (x | ~z))
-
-/* This is the central step in the MD5 algorithm. */
-#define MD5STEP(f, w, x, y, z, data, s) \
- ( w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x )
-
-/*
- * The core of the MD5 algorithm, this alters an existing MD5 hash to
- * reflect the addition of 16 longwords of new data. MD5Update blocks
- * the data and converts bytes into longwords for this routine.
- */
-void MD5Transform(u_int32_t buf[4], const unsigned char inext[64])
-{
- register u_int32_t a, b, c, d, i;
- u_int32_t in[16];
-
- for (i = 0; i < 16; i++)
- in[i] = GET_32BIT_LSB_FIRST(inext + 4 * i);
-
- a = buf[0];
- b = buf[1];
- c = buf[2];
- d = buf[3];
-
- MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7);
- MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
- MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17);
- MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
- MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
- MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12);
- MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17);
- MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22);
- MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7);
- MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
- MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
- MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22);
- MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7);
- MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12);
- MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17);
- MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22);
-
- MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5);
- MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9);
- MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14);
- MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
- MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5);
- MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9);
- MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
- MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
- MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
- MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9);
- MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
- MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20);
- MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
- MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
- MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14);
- MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
-
- MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4);
- MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11);
- MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
- MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23);
- MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4);
- MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
- MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
- MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
- MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
- MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
- MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
- MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23);
- MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
- MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
- MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
- MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
-
- MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6);
- MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10);
- MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15);
- MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21);
- MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6);
- MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
- MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15);
- MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21);
- MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
- MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
- MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15);
- MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
- MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6);
- MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10);
- MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
- MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21);
-
- buf[0] += a;
- buf[1] += b;
- buf[2] += c;
- buf[3] += d;
-}
-
-#endif
diff --git a/usr.bin/ssh/ssh_md5.h b/usr.bin/ssh/ssh_md5.h
deleted file mode 100644
index f0933e993e7..00000000000
--- a/usr.bin/ssh/ssh_md5.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef MD5_H
-#define MD5_H
-
-struct MD5Context {
- u_int32_t buf[4];
- u_int32_t bits[2];
- unsigned char in[64];
-};
-
-#define MD5Init ssh_MD5Init
-void MD5Init(struct MD5Context *context);
-#define MD5Update ssh_MD5Update
-void MD5Update(struct MD5Context *context, unsigned char const *buf,
- unsigned len);
-#define MD5Final ssh_MD5Final
-void MD5Final(unsigned char digest[16], struct MD5Context *context);
-#define MD5Transform ssh_MD5Transform
-void MD5Transform(u_int32_t buf[4], const unsigned char in[64]);
-
-#endif /* !MD5_H */
diff --git a/usr.bin/ssh/sshconnect.c b/usr.bin/ssh/sshconnect.c
index a746ab935c7..bbb1e00abb6 100644
--- a/usr.bin/ssh/sshconnect.c
+++ b/usr.bin/ssh/sshconnect.c
@@ -15,7 +15,7 @@ login (authentication) dialog.
*/
#include "includes.h"
-RCSID("$Id: sshconnect.c,v 1.9 1999/09/30 06:06:31 deraadt Exp $");
+RCSID("$Id: sshconnect.c,v 1.10 1999/09/30 17:08:52 deraadt Exp $");
#include <ssl/bn.h>
#include "xmalloc.h"
@@ -24,10 +24,11 @@ RCSID("$Id: sshconnect.c,v 1.9 1999/09/30 06:06:31 deraadt Exp $");
#include "packet.h"
#include "authfd.h"
#include "cipher.h"
-#include "ssh_md5.h"
#include "mpaux.h"
#include "uidswap.h"
+#include <md5.h>
+
/* Session id for the current session. */
unsigned char session_id[16];
@@ -438,7 +439,7 @@ void
respond_to_rsa_challenge(BIGNUM *challenge, RSA *prv)
{
unsigned char buf[32], response[16];
- struct MD5Context md;
+ MD5_CTX md;
int i, len;
/* Decrypt the challenge using the private key. */
diff --git a/usr.bin/ssh/sshd/Makefile b/usr.bin/ssh/sshd/Makefile
index ca6eab1d419..e36de051933 100644
--- a/usr.bin/ssh/sshd/Makefile
+++ b/usr.bin/ssh/sshd/Makefile
@@ -11,7 +11,7 @@ MAN= sshd.8
SRCS= sshd.c auth-rhosts.c auth-passwd.c auth-rsa.c auth-rh-rsa.c \
pty.c log-server.c login.c hostfile.c canohost.c \
servconf.c tildexpand.c uidswap.c serverloop.c rsa.c \
- ssh_md5.c buffer.c packet.c xmalloc.c ttymodes.c channels.c bufaux.c \
+ buffer.c packet.c xmalloc.c ttymodes.c channels.c bufaux.c \
authfd.c authfile.c crc32.c match.c mpaux.c minfd.c cipher.c \
compress.c