Skip to content
This repository has been archived by the owner on Apr 19, 2024. It is now read-only.

Commit

Permalink
Revert "Provide SHA-384 and SHA-512 as hashes usable in SSH KEX."
Browse files Browse the repository at this point in the history
This reverts commit 66970c4.
  • Loading branch information
FauxFaux committed Sep 20, 2015
1 parent 507935f commit b92b72c
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 100 deletions.
7 changes: 0 additions & 7 deletions ssh.h
Expand Up @@ -205,15 +205,10 @@ typedef struct {
int blkused;
uint32 len[4];
} SHA512_State;
#define SHA384_State SHA512_State
void SHA512_Init(SHA512_State * s);
void SHA512_Bytes(SHA512_State * s, const void *p, int len);
void SHA512_Final(SHA512_State * s, unsigned char *output);
void SHA512_Simple(const void *p, int len, unsigned char *output);
void SHA384_Init(SHA384_State * s);
#define SHA384_Bytes(s, p, len) SHA512_Bytes(s, p, len)
void SHA384_Final(SHA384_State * s, unsigned char *output);
void SHA384_Simple(const void *p, int len, unsigned char *output);

struct ssh_cipher {
void *(*make_context)(void);
Expand Down Expand Up @@ -340,8 +335,6 @@ extern const struct ssh2_ciphers ssh2_blowfish;
extern const struct ssh2_ciphers ssh2_arcfour;
extern const struct ssh_hash ssh_sha1;
extern const struct ssh_hash ssh_sha256;
extern const struct ssh_hash ssh_sha384;
extern const struct ssh_hash ssh_sha512;
extern const struct ssh_kexes ssh_diffiehellman_group1;
extern const struct ssh_kexes ssh_diffiehellman_group14;
extern const struct ssh_kexes ssh_diffiehellman_gex;
Expand Down
93 changes: 0 additions & 93 deletions sshsh512.c
Expand Up @@ -2,8 +2,6 @@
* SHA-512 algorithm as described at
*
* http://csrc.nist.gov/cryptval/shs.html
*
* Modifications made for SHA-384 also
*/

#include "ssh.h"
Expand Down Expand Up @@ -63,22 +61,6 @@ static void SHA512_Core_Init(SHA512_State *s) {
s->h[i] = iv[i];
}

static void SHA384_Core_Init(SHA512_State *s) {
static const uint64 iv[] = {
INIT(0xcbbb9d5d, 0xc1059ed8),
INIT(0x629a292a, 0x367cd507),
INIT(0x9159015a, 0x3070dd17),
INIT(0x152fecd8, 0xf70e5939),
INIT(0x67332667, 0xffc00b31),
INIT(0x8eb44a87, 0x68581511),
INIT(0xdb0c2e0d, 0x64f98fa7),
INIT(0x47b5481d, 0xbefa4fa4),
};
int i;
for (i = 0; i < 8; i++)
s->h[i] = iv[i];
}

static void SHA512_Block(SHA512_State *s, uint64 *block) {
uint64 w[80];
uint64 a,b,c,d,e,f,g,h;
Expand Down Expand Up @@ -193,14 +175,6 @@ void SHA512_Init(SHA512_State *s) {
s->len[i] = 0;
}

void SHA384_Init(SHA512_State *s) {
int i;
SHA384_Core_Init(s);
s->blkused = 0;
for (i = 0; i < 4; i++)
s->len[i] = 0;
}

void SHA512_Bytes(SHA512_State *s, const void *p, int len) {
unsigned char *q = (unsigned char *)p;
uint64 wordblock[16];
Expand Down Expand Up @@ -294,12 +268,6 @@ void SHA512_Final(SHA512_State *s, unsigned char *digest) {
}
}

void SHA384_Final(SHA512_State *s, unsigned char *digest) {
unsigned char biggerDigest[512 / 8];
SHA512_Final(s, biggerDigest);
memcpy(digest, biggerDigest, 384 / 8);
}

void SHA512_Simple(const void *p, int len, unsigned char *output) {
SHA512_State s;

Expand All @@ -309,67 +277,6 @@ void SHA512_Simple(const void *p, int len, unsigned char *output) {
smemclr(&s, sizeof(s));
}

void SHA384_Simple(const void *p, int len, unsigned char *output) {
SHA512_State s;

SHA384_Init(&s);
SHA512_Bytes(&s, p, len);
SHA384_Final(&s, output);
}

/*
* Thin abstraction for things where hashes are pluggable.
*/

static void *sha512_init(void)
{
SHA512_State *s;

s = snew(SHA512_State);
SHA512_Init(s);
return s;
}

static void sha512_bytes(void *handle, void *p, int len)
{
SHA512_State *s = handle;

SHA512_Bytes(s, p, len);
}

static void sha512_final(void *handle, unsigned char *output)
{
SHA512_State *s = handle;

SHA512_Final(s, output);
sfree(s);
}

const struct ssh_hash ssh_sha512 = {
sha512_init, sha512_bytes, sha512_final, 64, "SHA-512"
};

static void *sha384_init(void)
{
SHA512_State *s;

s = snew(SHA512_State);
SHA384_Init(s);
return s;
}

static void sha384_final(void *handle, unsigned char *output)
{
SHA512_State *s = handle;

SHA384_Final(s, output);
sfree(s);
}

const struct ssh_hash ssh_sha384 = {
sha384_init, sha512_bytes, sha384_final, 48, "SHA-384"
};

#ifdef TEST

#include <stdio.h>
Expand Down

0 comments on commit b92b72c

Please sign in to comment.