Fix the cavs test and avoid it crashing (#1628962)

Patch from Stephan Mueller, adjusted by myselt
This commit is contained in:
Jakub Jelen 2018-09-14 16:53:22 +02:00
parent 8b9448c5ba
commit 178f3a4f56

View File

@ -40,7 +40,7 @@ diff -up openssh-6.8p1/Makefile.in.kdf-cavs openssh-6.8p1/Makefile.in
diff -up openssh-6.8p1/ssh-cavs.c.kdf-cavs openssh-6.8p1/ssh-cavs.c diff -up openssh-6.8p1/ssh-cavs.c.kdf-cavs openssh-6.8p1/ssh-cavs.c
--- openssh-6.8p1/ssh-cavs.c.kdf-cavs 2015-03-18 11:23:46.348049354 +0100 --- openssh-6.8p1/ssh-cavs.c.kdf-cavs 2015-03-18 11:23:46.348049354 +0100
+++ openssh-6.8p1/ssh-cavs.c 2015-03-18 11:23:46.348049354 +0100 +++ openssh-6.8p1/ssh-cavs.c 2015-03-18 11:23:46.348049354 +0100
@@ -0,0 +1,380 @@ @@ -0,0 +1,377 @@
+/* +/*
+ * Copyright (C) 2015, Stephan Mueller <smueller@chronox.de> + * Copyright (C) 2015, Stephan Mueller <smueller@chronox.de>
+ * + *
@ -93,6 +93,7 @@ diff -up openssh-6.8p1/ssh-cavs.c.kdf-cavs openssh-6.8p1/ssh-cavs.c
+#include "cipher.h" +#include "cipher.h"
+#include "kex.h" +#include "kex.h"
+#include "packet.h" +#include "packet.h"
+#include "digest.h"
+ +
+static int bin_char(unsigned char hex) +static int bin_char(unsigned char hex)
+{ +{
@ -234,16 +235,16 @@ diff -up openssh-6.8p1/ssh-cavs.c.kdf-cavs openssh-6.8p1/ssh-cavs.c
+ /* select the right hash based on struct ssh_digest digests */ + /* select the right hash based on struct ssh_digest digests */
+ switch (test->ik_len) { + switch (test->ik_len) {
+ case 20: + case 20:
+ kex.hash_alg = 2; + kex.hash_alg = SSH_DIGEST_SHA1;
+ break; + break;
+ case 32: + case 32:
+ kex.hash_alg = 3; + kex.hash_alg = SSH_DIGEST_SHA256;
+ break; + break;
+ case 48: + case 48:
+ kex.hash_alg = 4; + kex.hash_alg = SSH_DIGEST_SHA384;
+ break; + break;
+ case 64: + case 64:
+ kex.hash_alg = 5; + kex.hash_alg = SSH_DIGEST_SHA512;
+ break; + break;
+ default: + default:
+ printf("Wrong hash type %u\n", test->ik_len); + printf("Wrong hash type %u\n", test->ik_len);
@ -320,10 +321,6 @@ diff -up openssh-6.8p1/ssh-cavs.c.kdf-cavs openssh-6.8p1/ssh-cavs.c
+out: +out:
+ if (Kbn) + if (Kbn)
+ BN_free(Kbn); + BN_free(Kbn);
+ if (kex.newkeys[0])
+ free(kex.newkeys[0]);
+ if (kex.newkeys[1])
+ free(kex.newkeys[1]);
+ if (ssh) + if (ssh)
+ ssh_packet_close(ssh); + ssh_packet_close(ssh);
+ return ret; + return ret;