summaryrefslogtreecommitdiff
path: root/usr.bin/ssh/ssh-dss.c
diff options
context:
space:
mode:
authorDamien Miller <djm@cvs.openbsd.org>2018-01-23 05:27:22 +0000
committerDamien Miller <djm@cvs.openbsd.org>2018-01-23 05:27:22 +0000
commit350394e9345181dbe9b52e7518cf02cd0cc0634d (patch)
treec44bb296efacd5731f90540850c0b7af595e55b4 /usr.bin/ssh/ssh-dss.c
parentaa23a9b92e6f114f66ba0cb01e7c1097297cdd50 (diff)
Drop compatibility hacks for some ancient SSH implementations, including
ssh.com <=2.* and OpenSSH <= 3.*. These versions were all released in or before 2001 and predate the final SSH RFCs. The hacks in question aren't necessary for RFC- compliant SSH implementations. ok markus@
Diffstat (limited to 'usr.bin/ssh/ssh-dss.c')
-rw-r--r--usr.bin/ssh/ssh-dss.c81
1 files changed, 30 insertions, 51 deletions
diff --git a/usr.bin/ssh/ssh-dss.c b/usr.bin/ssh/ssh-dss.c
index b45e698481d..6c9604b3d9e 100644
--- a/usr.bin/ssh/ssh-dss.c
+++ b/usr.bin/ssh/ssh-dss.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssh-dss.c,v 1.35 2016/04/21 06:08:02 djm Exp $ */
+/* $OpenBSD: ssh-dss.c,v 1.36 2018/01/23 05:27:21 djm Exp $ */
/*
* Copyright (c) 2000 Markus Friedl. All rights reserved.
*
@@ -80,38 +80,25 @@ ssh_dss_sign(const struct sshkey *key, u_char **sigp, size_t *lenp,
BN_bn2bin(sig->r, sigblob + SIGBLOB_LEN - INTBLOB_LEN - rlen);
BN_bn2bin(sig->s, sigblob + SIGBLOB_LEN - slen);
- if (compat & SSH_BUG_SIGBLOB) {
- if (sigp != NULL) {
- if ((*sigp = malloc(SIGBLOB_LEN)) == NULL) {
- ret = SSH_ERR_ALLOC_FAIL;
- goto out;
- }
- memcpy(*sigp, sigblob, SIGBLOB_LEN);
- }
- if (lenp != NULL)
- *lenp = SIGBLOB_LEN;
- ret = 0;
- } else {
- /* ietf-drafts */
- if ((b = sshbuf_new()) == NULL) {
+ if ((b = sshbuf_new()) == NULL) {
+ ret = SSH_ERR_ALLOC_FAIL;
+ goto out;
+ }
+ if ((ret = sshbuf_put_cstring(b, "ssh-dss")) != 0 ||
+ (ret = sshbuf_put_string(b, sigblob, SIGBLOB_LEN)) != 0)
+ goto out;
+
+ len = sshbuf_len(b);
+ if (sigp != NULL) {
+ if ((*sigp = malloc(len)) == NULL) {
ret = SSH_ERR_ALLOC_FAIL;
goto out;
}
- if ((ret = sshbuf_put_cstring(b, "ssh-dss")) != 0 ||
- (ret = sshbuf_put_string(b, sigblob, SIGBLOB_LEN)) != 0)
- goto out;
- len = sshbuf_len(b);
- if (sigp != NULL) {
- if ((*sigp = malloc(len)) == NULL) {
- ret = SSH_ERR_ALLOC_FAIL;
- goto out;
- }
- memcpy(*sigp, sshbuf_ptr(b), len);
- }
- if (lenp != NULL)
- *lenp = len;
- ret = 0;
+ memcpy(*sigp, sshbuf_ptr(b), len);
}
+ if (lenp != NULL)
+ *lenp = len;
+ ret = 0;
out:
explicit_bzero(digest, sizeof(digest));
if (sig != NULL)
@@ -140,28 +127,20 @@ ssh_dss_verify(const struct sshkey *key,
return SSH_ERR_INTERNAL_ERROR;
/* fetch signature */
- if (compat & SSH_BUG_SIGBLOB) {
- if ((sigblob = malloc(signaturelen)) == NULL)
- return SSH_ERR_ALLOC_FAIL;
- memcpy(sigblob, signature, signaturelen);
- len = signaturelen;
- } else {
- /* ietf-drafts */
- if ((b = sshbuf_from(signature, signaturelen)) == NULL)
- return SSH_ERR_ALLOC_FAIL;
- if (sshbuf_get_cstring(b, &ktype, NULL) != 0 ||
- sshbuf_get_string(b, &sigblob, &len) != 0) {
- ret = SSH_ERR_INVALID_FORMAT;
- goto out;
- }
- if (strcmp("ssh-dss", ktype) != 0) {
- ret = SSH_ERR_KEY_TYPE_MISMATCH;
- goto out;
- }
- if (sshbuf_len(b) != 0) {
- ret = SSH_ERR_UNEXPECTED_TRAILING_DATA;
- goto out;
- }
+ if ((b = sshbuf_from(signature, signaturelen)) == NULL)
+ return SSH_ERR_ALLOC_FAIL;
+ if (sshbuf_get_cstring(b, &ktype, NULL) != 0 ||
+ sshbuf_get_string(b, &sigblob, &len) != 0) {
+ ret = SSH_ERR_INVALID_FORMAT;
+ goto out;
+ }
+ if (strcmp("ssh-dss", ktype) != 0) {
+ ret = SSH_ERR_KEY_TYPE_MISMATCH;
+ goto out;
+ }
+ if (sshbuf_len(b) != 0) {
+ ret = SSH_ERR_UNEXPECTED_TRAILING_DATA;
+ goto out;
}
if (len != SIGBLOB_LEN) {