OpenCoverage

ssh-rsa.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssh/src/ssh-rsa.c
Source codeSwitch to Preprocessed file
LineSourceCount
1/* $OpenBSD: ssh-rsa.c,v 1.67 2018/07/03 11:39:54 djm Exp $ */-
2/*-
3 * Copyright (c) 2000, 2003 Markus Friedl <markus@openbsd.org>-
4 *-
5 * Permission to use, copy, modify, and distribute this software for any-
6 * purpose with or without fee is hereby granted, provided that the above-
7 * copyright notice and this permission notice appear in all copies.-
8 *-
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES-
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF-
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR-
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES-
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN-
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF-
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.-
16 */-
17-
18#include "includes.h"-
19-
20#ifdef WITH_OPENSSL-
21-
22#include <sys/types.h>-
23-
24#include <openssl/evp.h>-
25#include <openssl/err.h>-
26-
27#include <stdarg.h>-
28#include <string.h>-
29-
30#include "sshbuf.h"-
31#include "compat.h"-
32#include "ssherr.h"-
33#define SSHKEY_INTERNAL-
34#include "sshkey.h"-
35#include "digest.h"-
36#include "log.h"-
37-
38#include "openbsd-compat/openssl-compat.h"-
39-
40static int openssh_RSA_verify(int, u_char *, size_t, u_char *, size_t, RSA *);-
41-
42static const char *-
43rsa_hash_alg_ident(int hash_alg)-
44{-
45 switch (hash_alg) {-
46 case SSH_DIGEST_SHA1:
executed 68 times by 3 tests: case 1:
Executed by:
  • ssh-keygen
  • test_kex
  • test_sshkey
68
47 return "ssh-rsa";
executed 68 times by 3 tests: return "ssh-rsa";
Executed by:
  • ssh-keygen
  • test_kex
  • test_sshkey
68
48 case SSH_DIGEST_SHA256:
executed 24 times by 1 test: case 2:
Executed by:
  • test_sshkey
24
49 return "rsa-sha2-256";
executed 24 times by 1 test: return "rsa-sha2-256";
Executed by:
  • test_sshkey
24
50 case SSH_DIGEST_SHA512:
executed 24 times by 1 test: case 4:
Executed by:
  • test_sshkey
24
51 return "rsa-sha2-512";
executed 24 times by 1 test: return "rsa-sha2-512";
Executed by:
  • test_sshkey
24
52 }-
53 return NULL;
never executed: return ((void *)0) ;
0
54}-
55-
56/*-
57 * Returns the hash algorithm ID for a given algorithm identifier as used-
58 * inside the signature blob,-
59 */-
60static int-
61rsa_hash_id_from_ident(const char *ident)-
62{-
63 if (strcmp(ident, "ssh-rsa") == 0)
never executed: __result = (((const unsigned char *) (const char *) ( ident ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( "ssh-rsa" ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
__extension__ ... )))); }) == 0Description
TRUEevaluated 18830 times by 3 tests
Evaluated by:
  • ssh-keygen
  • test_kex
  • test_sshkey
FALSEevaluated 46194 times by 1 test
Evaluated by:
  • test_sshkey
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-46194
64 return SSH_DIGEST_SHA1;
executed 18830 times by 3 tests: return 1;
Executed by:
  • ssh-keygen
  • test_kex
  • test_sshkey
18830
65 if (strcmp(ident, "rsa-sha2-256") == 0)
never executed: __result = (((const unsigned char *) (const char *) ( ident ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( "rsa-sha2-256" ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
__extension__ ... )))); }) == 0Description
TRUEevaluated 18707 times by 1 test
Evaluated by:
  • test_sshkey
FALSEevaluated 27487 times by 1 test
Evaluated by:
  • test_sshkey
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-27487
66 return SSH_DIGEST_SHA256;
executed 18707 times by 1 test: return 2;
Executed by:
  • test_sshkey
18707
67 if (strcmp(ident, "rsa-sha2-512") == 0)
never executed: __result = (((const unsigned char *) (const char *) ( ident ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( "rsa-sha2-512" ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
__extension__ ... )))); }) == 0Description
TRUEevaluated 18708 times by 1 test
Evaluated by:
  • test_sshkey
FALSEevaluated 8779 times by 1 test
Evaluated by:
  • test_sshkey
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-18708
68 return SSH_DIGEST_SHA512;
executed 18708 times by 1 test: return 4;
Executed by:
  • test_sshkey
18708
69 return -1;
executed 8779 times by 1 test: return -1;
Executed by:
  • test_sshkey
8779
70}-
71-
72/*-
73 * Return the hash algorithm ID for the specified key name. This includes-
74 * all the cases of rsa_hash_id_from_ident() but also the certificate key-
75 * types.-
76 */-
77static int-
78rsa_hash_id_from_keyname(const char *alg)-
79{-
80 int r;-
81-
82 if ((r = rsa_hash_id_from_ident(alg)) != -1)
(r = rsa_hash_...nt(alg)) != -1Description
TRUEevaluated 152 times by 2 tests
Evaluated by:
  • test_kex
  • test_sshkey
FALSEnever evaluated
0-152
83 return r;
executed 152 times by 2 tests: return r;
Executed by:
  • test_kex
  • test_sshkey
152
84 if (strcmp(alg, "ssh-rsa-cert-v01@openssh.com") == 0)
never executed: __result = (((const unsigned char *) (const char *) ( alg ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( "ssh-rsa-cert-v01@openssh.com" ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
__extension__ ... )))); }) == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
85 return SSH_DIGEST_SHA1;
never executed: return 1;
0
86 if (strcmp(alg, "rsa-sha2-256-cert-v01@openssh.com") == 0)
never executed: __result = (((const unsigned char *) (const char *) ( alg ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( "rsa-sha2-256-cert-v01@openssh.com" ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
__extension__ ... )))); }) == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
87 return SSH_DIGEST_SHA256;
never executed: return 2;
0
88 if (strcmp(alg, "rsa-sha2-512-cert-v01@openssh.com") == 0)
never executed: __result = (((const unsigned char *) (const char *) ( alg ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( "rsa-sha2-512-cert-v01@openssh.com" ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
__extension__ ... )))); }) == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
89 return SSH_DIGEST_SHA512;
never executed: return 4;
0
90 return -1;
never executed: return -1;
0
91}-
92-
93static int-
94rsa_hash_alg_nid(int type)-
95{-
96 switch (type) {-
97 case SSH_DIGEST_SHA1:
executed 68 times by 3 tests: case 1:
Executed by:
  • ssh-keygen
  • test_kex
  • test_sshkey
68
98 return NID_sha1;
executed 68 times by 3 tests: return 64 ;
Executed by:
  • ssh-keygen
  • test_kex
  • test_sshkey
68
99 case SSH_DIGEST_SHA256:
executed 24 times by 1 test: case 2:
Executed by:
  • test_sshkey
24
100 return NID_sha256;
executed 24 times by 1 test: return 672 ;
Executed by:
  • test_sshkey
24
101 case SSH_DIGEST_SHA512:
executed 24 times by 1 test: case 4:
Executed by:
  • test_sshkey
24
102 return NID_sha512;
executed 24 times by 1 test: return 674 ;
Executed by:
  • test_sshkey
24
103 default:
never executed: default:
0
104 return -1;
never executed: return -1;
0
105 }-
106}-
107-
108int-
109ssh_rsa_complete_crt_parameters(struct sshkey *key, const BIGNUM *iqmp)-
110{-
111 const BIGNUM *rsa_p, *rsa_q, *rsa_d;-
112 BIGNUM *aux = NULL, *d_consttime = NULL;-
113 BIGNUM *rsa_dmq1 = NULL, *rsa_dmp1 = NULL, *rsa_iqmp = NULL;-
114 BN_CTX *ctx = NULL;-
115 int r;-
116-
117 if (key == NULL || key->rsa == NULL ||
key == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 6 times by 3 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_sshkey
key->rsa == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 6 times by 3 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_sshkey
0-6
118 sshkey_type_plain(key->type) != KEY_RSA)
sshkey_type_pl...pe) != KEY_RSADescription
TRUEnever evaluated
FALSEevaluated 6 times by 3 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_sshkey
0-6
119 return SSH_ERR_INVALID_ARGUMENT;
never executed: return -10;
0
120-
121 RSA_get0_key(key->rsa, NULL, NULL, &rsa_d);-
122 RSA_get0_factors(key->rsa, &rsa_p, &rsa_q);-
123-
124 if ((ctx = BN_CTX_new()) == NULL)
(ctx = BN_CTX_...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 6 times by 3 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_sshkey
0-6
125 return SSH_ERR_ALLOC_FAIL;
never executed: return -2;
0
126 if ((aux = BN_new()) == NULL ||
(aux = BN_new(...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 6 times by 3 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_sshkey
0-6
127 (rsa_dmq1 = BN_new()) == NULL ||
(rsa_dmq1 = BN...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 6 times by 3 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_sshkey
0-6
128 (rsa_dmp1 = BN_new()) == NULL)
(rsa_dmp1 = BN...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 6 times by 3 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_sshkey
0-6
129 return SSH_ERR_ALLOC_FAIL;
never executed: return -2;
0
130 if ((d_consttime = BN_dup(rsa_d)) == NULL ||
(d_consttime =...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 6 times by 3 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_sshkey
0-6
131 (rsa_iqmp = BN_dup(iqmp)) == NULL) {
(rsa_iqmp = BN...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 6 times by 3 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_sshkey
0-6
132 r = SSH_ERR_ALLOC_FAIL;-
133 goto out;
never executed: goto out;
0
134 }-
135 BN_set_flags(aux, BN_FLG_CONSTTIME);-
136 BN_set_flags(d_consttime, BN_FLG_CONSTTIME);-
137-
138 if ((BN_sub(aux, rsa_q, BN_value_one()) == 0) ||
(BN_sub(aux, r...e_one()) == 0)Description
TRUEnever evaluated
FALSEevaluated 6 times by 3 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_sshkey
0-6
139 (BN_mod(rsa_dmq1, d_consttime, aux, ctx) == 0) ||
( BN_div(((voi...( ctx )) == 0)Description
TRUEnever evaluated
FALSEevaluated 6 times by 3 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_sshkey
0-6
140 (BN_sub(aux, rsa_p, BN_value_one()) == 0) ||
(BN_sub(aux, r...e_one()) == 0)Description
TRUEnever evaluated
FALSEevaluated 6 times by 3 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_sshkey
0-6
141 (BN_mod(rsa_dmp1, d_consttime, aux, ctx) == 0)) {
( BN_div(((voi...( ctx )) == 0)Description
TRUEnever evaluated
FALSEevaluated 6 times by 3 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_sshkey
0-6
142 r = SSH_ERR_LIBCRYPTO_ERROR;-
143 goto out;
never executed: goto out;
0
144 }-
145 if (!RSA_set0_crt_params(key->rsa, rsa_dmp1, rsa_dmq1, rsa_iqmp)) {
!RSA_set0_crt_...mq1, rsa_iqmp)Description
TRUEnever evaluated
FALSEevaluated 6 times by 3 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_sshkey
0-6
146 r = SSH_ERR_LIBCRYPTO_ERROR;-
147 goto out;
never executed: goto out;
0
148 }-
149 rsa_dmp1 = rsa_dmq1 = rsa_iqmp = NULL; /* transferred */-
150 /* success */-
151 r = 0;-
152 out:
code before this statement executed 6 times by 3 tests: out:
Executed by:
  • ssh-keygen
  • sshd
  • test_sshkey
6
153 BN_clear_free(aux);-
154 BN_clear_free(d_consttime);-
155 BN_clear_free(rsa_dmp1);-
156 BN_clear_free(rsa_dmq1);-
157 BN_clear_free(rsa_iqmp);-
158 BN_CTX_free(ctx);-
159 return r;
executed 6 times by 3 tests: return r;
Executed by:
  • ssh-keygen
  • sshd
  • test_sshkey
6
160}-
161-
162/* RSASSA-PKCS1-v1_5 (PKCS #1 v2.0 signature) with SHA1 */-
163int-
164ssh_rsa_sign(const struct sshkey *key, u_char **sigp, size_t *lenp,-
165 const u_char *data, size_t datalen, const char *alg_ident)-
166{-
167 const BIGNUM *rsa_n;-
168 u_char digest[SSH_DIGEST_MAX_LENGTH], *sig = NULL;-
169 size_t slen = 0;-
170 u_int dlen, len;-
171 int nid, hash_alg, ret = SSH_ERR_INTERNAL_ERROR;-
172 struct sshbuf *b = NULL;-
173-
174 if (lenp != NULL)
lenp != ((void *)0)Description
TRUEevaluated 116 times by 3 tests
Evaluated by:
  • ssh-keygen
  • test_kex
  • test_sshkey
FALSEnever evaluated
0-116
175 *lenp = 0;
executed 116 times by 3 tests: *lenp = 0;
Executed by:
  • ssh-keygen
  • test_kex
  • test_sshkey
116
176 if (sigp != NULL)
sigp != ((void *)0)Description
TRUEevaluated 116 times by 3 tests
Evaluated by:
  • ssh-keygen
  • test_kex
  • test_sshkey
FALSEnever evaluated
0-116
177 *sigp = NULL;
executed 116 times by 3 tests: *sigp = ((void *)0) ;
Executed by:
  • ssh-keygen
  • test_kex
  • test_sshkey
116
178-
179 if (alg_ident == NULL || strlen(alg_ident) == 0)
alg_ident == ((void *)0)Description
TRUEevaluated 4 times by 2 tests
Evaluated by:
  • ssh-keygen
  • test_sshkey
FALSEevaluated 112 times by 2 tests
Evaluated by:
  • test_kex
  • test_sshkey
strlen(alg_ident) == 0Description
TRUEnever evaluated
FALSEevaluated 112 times by 2 tests
Evaluated by:
  • test_kex
  • test_sshkey
0-112
180 hash_alg = SSH_DIGEST_SHA1;
executed 4 times by 2 tests: hash_alg = 1;
Executed by:
  • ssh-keygen
  • test_sshkey
4
181 else-
182 hash_alg = rsa_hash_id_from_keyname(alg_ident);
executed 112 times by 2 tests: hash_alg = rsa_hash_id_from_keyname(alg_ident);
Executed by:
  • test_kex
  • test_sshkey
112
183 if (key == NULL || key->rsa == NULL || hash_alg == -1 ||
key == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 116 times by 3 tests
Evaluated by:
  • ssh-keygen
  • test_kex
  • test_sshkey
key->rsa == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 116 times by 3 tests
Evaluated by:
  • ssh-keygen
  • test_kex
  • test_sshkey
hash_alg == -1Description
TRUEnever evaluated
FALSEevaluated 116 times by 3 tests
Evaluated by:
  • ssh-keygen
  • test_kex
  • test_sshkey
0-116
184 sshkey_type_plain(key->type) != KEY_RSA)
sshkey_type_pl...pe) != KEY_RSADescription
TRUEnever evaluated
FALSEevaluated 116 times by 3 tests
Evaluated by:
  • ssh-keygen
  • test_kex
  • test_sshkey
0-116
185 return SSH_ERR_INVALID_ARGUMENT;
never executed: return -10;
0
186 RSA_get0_key(key->rsa, &rsa_n, NULL, NULL);-
187 if (BN_num_bits(rsa_n) < SSH_RSA_MINIMUM_MODULUS_SIZE)
BN_num_bits(rsa_n) < 1024Description
TRUEnever evaluated
FALSEevaluated 116 times by 3 tests
Evaluated by:
  • ssh-keygen
  • test_kex
  • test_sshkey
0-116
188 return SSH_ERR_KEY_LENGTH;
never executed: return -56;
0
189 slen = RSA_size(key->rsa);-
190 if (slen <= 0 || slen > SSHBUF_MAX_BIGNUM)
slen <= 0Description
TRUEnever evaluated
FALSEevaluated 116 times by 3 tests
Evaluated by:
  • ssh-keygen
  • test_kex
  • test_sshkey
slen > (16384 / 8)Description
TRUEnever evaluated
FALSEevaluated 116 times by 3 tests
Evaluated by:
  • ssh-keygen
  • test_kex
  • test_sshkey
0-116
191 return SSH_ERR_INVALID_ARGUMENT;
never executed: return -10;
0
192-
193 /* hash the data */-
194 nid = rsa_hash_alg_nid(hash_alg);-
195 if ((dlen = ssh_digest_bytes(hash_alg)) == 0)
(dlen = ssh_di...ash_alg)) == 0Description
TRUEnever evaluated
FALSEevaluated 116 times by 3 tests
Evaluated by:
  • ssh-keygen
  • test_kex
  • test_sshkey
0-116
196 return SSH_ERR_INTERNAL_ERROR;
never executed: return -1;
0
197 if ((ret = ssh_digest_memory(hash_alg, data, datalen,
(ret = ssh_dig...digest))) != 0Description
TRUEnever evaluated
FALSEevaluated 116 times by 3 tests
Evaluated by:
  • ssh-keygen
  • test_kex
  • test_sshkey
0-116
198 digest, sizeof(digest))) != 0)
(ret = ssh_dig...digest))) != 0Description
TRUEnever evaluated
FALSEevaluated 116 times by 3 tests
Evaluated by:
  • ssh-keygen
  • test_kex
  • test_sshkey
0-116
199 goto out;
never executed: goto out;
0
200-
201 if ((sig = malloc(slen)) == NULL) {
(sig = malloc(...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 116 times by 3 tests
Evaluated by:
  • ssh-keygen
  • test_kex
  • test_sshkey
0-116
202 ret = SSH_ERR_ALLOC_FAIL;-
203 goto out;
never executed: goto out;
0
204 }-
205-
206 if (RSA_sign(nid, digest, dlen, sig, &len, key->rsa) != 1) {
RSA_sign(nid, ...key->rsa) != 1Description
TRUEnever evaluated
FALSEevaluated 116 times by 3 tests
Evaluated by:
  • ssh-keygen
  • test_kex
  • test_sshkey
0-116
207 ret = SSH_ERR_LIBCRYPTO_ERROR;-
208 goto out;
never executed: goto out;
0
209 }-
210 if (len < slen) {
len < slenDescription
TRUEnever evaluated
FALSEevaluated 116 times by 3 tests
Evaluated by:
  • ssh-keygen
  • test_kex
  • test_sshkey
0-116
211 size_t diff = slen - len;-
212 memmove(sig + diff, sig, len);-
213 explicit_bzero(sig, diff);-
214 } else if (len > slen) {
never executed: end of block
len > slenDescription
TRUEnever evaluated
FALSEevaluated 116 times by 3 tests
Evaluated by:
  • ssh-keygen
  • test_kex
  • test_sshkey
0-116
215 ret = SSH_ERR_INTERNAL_ERROR;-
216 goto out;
never executed: goto out;
0
217 }-
218 /* encode signature */-
219 if ((b = sshbuf_new()) == NULL) {
(b = sshbuf_ne...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 116 times by 3 tests
Evaluated by:
  • ssh-keygen
  • test_kex
  • test_sshkey
0-116
220 ret = SSH_ERR_ALLOC_FAIL;-
221 goto out;
never executed: goto out;
0
222 }-
223 if ((ret = sshbuf_put_cstring(b, rsa_hash_alg_ident(hash_alg))) != 0 ||
(ret = sshbuf_...sh_alg))) != 0Description
TRUEnever evaluated
FALSEevaluated 116 times by 3 tests
Evaluated by:
  • ssh-keygen
  • test_kex
  • test_sshkey
0-116
224 (ret = sshbuf_put_string(b, sig, slen)) != 0)
(ret = sshbuf_...g, slen)) != 0Description
TRUEnever evaluated
FALSEevaluated 116 times by 3 tests
Evaluated by:
  • ssh-keygen
  • test_kex
  • test_sshkey
0-116
225 goto out;
never executed: goto out;
0
226 len = sshbuf_len(b);-
227 if (sigp != NULL) {
sigp != ((void *)0)Description
TRUEevaluated 116 times by 3 tests
Evaluated by:
  • ssh-keygen
  • test_kex
  • test_sshkey
FALSEnever evaluated
0-116
228 if ((*sigp = malloc(len)) == NULL) {
(*sigp = mallo...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 116 times by 3 tests
Evaluated by:
  • ssh-keygen
  • test_kex
  • test_sshkey
0-116
229 ret = SSH_ERR_ALLOC_FAIL;-
230 goto out;
never executed: goto out;
0
231 }-
232 memcpy(*sigp, sshbuf_ptr(b), len);-
233 }
executed 116 times by 3 tests: end of block
Executed by:
  • ssh-keygen
  • test_kex
  • test_sshkey
116
234 if (lenp != NULL)
lenp != ((void *)0)Description
TRUEevaluated 116 times by 3 tests
Evaluated by:
  • ssh-keygen
  • test_kex
  • test_sshkey
FALSEnever evaluated
0-116
235 *lenp = len;
executed 116 times by 3 tests: *lenp = len;
Executed by:
  • ssh-keygen
  • test_kex
  • test_sshkey
116
236 ret = 0;-
237 out:
code before this statement executed 116 times by 3 tests: out:
Executed by:
  • ssh-keygen
  • test_kex
  • test_sshkey
116
238 explicit_bzero(digest, sizeof(digest));-
239 freezero(sig, slen);-
240 sshbuf_free(b);-
241 return ret;
executed 116 times by 3 tests: return ret;
Executed by:
  • ssh-keygen
  • test_kex
  • test_sshkey
116
242}-
243-
244int-
245ssh_rsa_verify(const struct sshkey *key,-
246 const u_char *sig, size_t siglen, const u_char *data, size_t datalen,-
247 const char *alg)-
248{-
249 const BIGNUM *rsa_n;-
250 char *sigtype = NULL;-
251 int hash_alg, want_alg, ret = SSH_ERR_INTERNAL_ERROR;-
252 size_t len = 0, diff, modlen, dlen;-
253 struct sshbuf *b = NULL;-
254 u_char digest[SSH_DIGEST_MAX_LENGTH], *osigblob, *sigblob = NULL;-
255-
256 if (key == NULL || key->rsa == NULL ||
key == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 68896 times by 3 tests
Evaluated by:
  • ssh-keygen
  • test_kex
  • test_sshkey
key->rsa == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 68896 times by 3 tests
Evaluated by:
  • ssh-keygen
  • test_kex
  • test_sshkey
0-68896
257 sshkey_type_plain(key->type) != KEY_RSA ||
sshkey_type_pl...pe) != KEY_RSADescription
TRUEnever evaluated
FALSEevaluated 68896 times by 3 tests
Evaluated by:
  • ssh-keygen
  • test_kex
  • test_sshkey
0-68896
258 sig == NULL || siglen == 0)
sig == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 68896 times by 3 tests
Evaluated by:
  • ssh-keygen
  • test_kex
  • test_sshkey
siglen == 0Description
TRUEnever evaluated
FALSEevaluated 68896 times by 3 tests
Evaluated by:
  • ssh-keygen
  • test_kex
  • test_sshkey
0-68896
259 return SSH_ERR_INVALID_ARGUMENT;
never executed: return -10;
0
260 RSA_get0_key(key->rsa, &rsa_n, NULL, NULL);-
261 if (BN_num_bits(rsa_n) < SSH_RSA_MINIMUM_MODULUS_SIZE)
BN_num_bits(rsa_n) < 1024Description
TRUEnever evaluated
FALSEevaluated 68896 times by 3 tests
Evaluated by:
  • ssh-keygen
  • test_kex
  • test_sshkey
0-68896
262 return SSH_ERR_KEY_LENGTH;
never executed: return -56;
0
263-
264 if ((b = sshbuf_from(sig, siglen)) == NULL)
(b = sshbuf_fr...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 68896 times by 3 tests
Evaluated by:
  • ssh-keygen
  • test_kex
  • test_sshkey
0-68896
265 return SSH_ERR_ALLOC_FAIL;
never executed: return -2;
0
266 if (sshbuf_get_cstring(b, &sigtype, NULL) != 0) {
sshbuf_get_cst...id *)0) ) != 0Description
TRUEevaluated 4024 times by 1 test
Evaluated by:
  • test_sshkey
FALSEevaluated 64872 times by 3 tests
Evaluated by:
  • ssh-keygen
  • test_kex
  • test_sshkey
4024-64872
267 ret = SSH_ERR_INVALID_FORMAT;-
268 goto out;
executed 4024 times by 1 test: goto out;
Executed by:
  • test_sshkey
4024
269 }-
270 if ((hash_alg = rsa_hash_id_from_ident(sigtype)) == -1) {
(hash_alg = rs...igtype)) == -1Description
TRUEevaluated 8779 times by 1 test
Evaluated by:
  • test_sshkey
FALSEevaluated 56093 times by 3 tests
Evaluated by:
  • ssh-keygen
  • test_kex
  • test_sshkey
8779-56093
271 ret = SSH_ERR_KEY_TYPE_MISMATCH;-
272 goto out;
executed 8779 times by 1 test: goto out;
Executed by:
  • test_sshkey
8779
273 }-
274 /*-
275 * Allow ssh-rsa-cert-v01 certs to generate SHA2 signatures for-
276 * legacy reasons, but otherwise the signature type should match.-
277 */-
278 if (alg != NULL && strcmp(alg, "ssh-rsa-cert-v01@openssh.com") != 0) {
never executed: __result = (((const unsigned char *) (const char *) ( alg ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( "ssh-rsa-cert-v01@openssh.com" ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
alg != ((void *)0)Description
TRUEevaluated 40 times by 1 test
Evaluated by:
  • test_kex
FALSEevaluated 56053 times by 2 tests
Evaluated by:
  • ssh-keygen
  • test_sshkey
__extension__ ... )))); }) != 0Description
TRUEevaluated 40 times by 1 test
Evaluated by:
  • test_kex
FALSEnever evaluated
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-56053
279 if ((want_alg = rsa_hash_id_from_keyname(alg)) == -1) {
(want_alg = rs...me(alg)) == -1Description
TRUEnever evaluated
FALSEevaluated 40 times by 1 test
Evaluated by:
  • test_kex
0-40
280 ret = SSH_ERR_INVALID_ARGUMENT;-
281 goto out;
never executed: goto out;
0
282 }-
283 if (hash_alg != want_alg) {
hash_alg != want_algDescription
TRUEnever evaluated
FALSEevaluated 40 times by 1 test
Evaluated by:
  • test_kex
0-40
284 ret = SSH_ERR_SIGNATURE_INVALID;-
285 goto out;
never executed: goto out;
0
286 }-
287 }
executed 40 times by 1 test: end of block
Executed by:
  • test_kex
40
288 if (sshbuf_get_string(b, &sigblob, &len) != 0) {
sshbuf_get_str...ob, &len) != 0Description
TRUEevaluated 2840 times by 1 test
Evaluated by:
  • test_sshkey
FALSEevaluated 53253 times by 3 tests
Evaluated by:
  • ssh-keygen
  • test_kex
  • test_sshkey
2840-53253
289 ret = SSH_ERR_INVALID_FORMAT;-
290 goto out;
executed 2840 times by 1 test: goto out;
Executed by:
  • test_sshkey
2840
291 }-
292 if (sshbuf_len(b) != 0) {
sshbuf_len(b) != 0Description
TRUEevaluated 774 times by 1 test
Evaluated by:
  • test_sshkey
FALSEevaluated 52479 times by 3 tests
Evaluated by:
  • ssh-keygen
  • test_kex
  • test_sshkey
774-52479
293 ret = SSH_ERR_UNEXPECTED_TRAILING_DATA;-
294 goto out;
executed 774 times by 1 test: goto out;
Executed by:
  • test_sshkey
774
295 }-
296 /* RSA_verify expects a signature of RSA_size */-
297 modlen = RSA_size(key->rsa);-
298 if (len > modlen) {
len > modlenDescription
TRUEnever evaluated
FALSEevaluated 52479 times by 3 tests
Evaluated by:
  • ssh-keygen
  • test_kex
  • test_sshkey
0-52479
299 ret = SSH_ERR_KEY_BITS_MISMATCH;-
300 goto out;
never executed: goto out;
0
301 } else if (len < modlen) {
len < modlenDescription
TRUEevaluated 69 times by 1 test
Evaluated by:
  • test_sshkey
FALSEevaluated 52410 times by 3 tests
Evaluated by:
  • ssh-keygen
  • test_kex
  • test_sshkey
69-52410
302 diff = modlen - len;-
303 osigblob = sigblob;-
304 if ((sigblob = realloc(sigblob, modlen)) == NULL) {
(sigblob = rea...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 69 times by 1 test
Evaluated by:
  • test_sshkey
0-69
305 sigblob = osigblob; /* put it back for clear/free */-
306 ret = SSH_ERR_ALLOC_FAIL;-
307 goto out;
never executed: goto out;
0
308 }-
309 memmove(sigblob + diff, sigblob, len);-
310 explicit_bzero(sigblob, diff);-
311 len = modlen;-
312 }
executed 69 times by 1 test: end of block
Executed by:
  • test_sshkey
69
313 if ((dlen = ssh_digest_bytes(hash_alg)) == 0) {
(dlen = ssh_di...ash_alg)) == 0Description
TRUEnever evaluated
FALSEevaluated 52479 times by 3 tests
Evaluated by:
  • ssh-keygen
  • test_kex
  • test_sshkey
0-52479
314 ret = SSH_ERR_INTERNAL_ERROR;-
315 goto out;
never executed: goto out;
0
316 }-
317 if ((ret = ssh_digest_memory(hash_alg, data, datalen,
(ret = ssh_dig...digest))) != 0Description
TRUEnever evaluated
FALSEevaluated 52479 times by 3 tests
Evaluated by:
  • ssh-keygen
  • test_kex
  • test_sshkey
0-52479
318 digest, sizeof(digest))) != 0)
(ret = ssh_dig...digest))) != 0Description
TRUEnever evaluated
FALSEevaluated 52479 times by 3 tests
Evaluated by:
  • ssh-keygen
  • test_kex
  • test_sshkey
0-52479
319 goto out;
never executed: goto out;
0
320-
321 ret = openssh_RSA_verify(hash_alg, digest, dlen, sigblob, len,-
322 key->rsa);-
323 out:
code before this statement executed 52479 times by 3 tests: out:
Executed by:
  • ssh-keygen
  • test_kex
  • test_sshkey
52479
324 freezero(sigblob, len);-
325 free(sigtype);-
326 sshbuf_free(b);-
327 explicit_bzero(digest, sizeof(digest));-
328 return ret;
executed 68896 times by 3 tests: return ret;
Executed by:
  • ssh-keygen
  • test_kex
  • test_sshkey
68896
329}-
330-
331/*-
332 * See:-
333 * http://www.rsasecurity.com/rsalabs/pkcs/pkcs-1/-
334 * ftp://ftp.rsasecurity.com/pub/pkcs/pkcs-1/pkcs-1v2-1.asn-
335 */-
336-
337/*-
338 * id-sha1 OBJECT IDENTIFIER ::= { iso(1) identified-organization(3)-
339 * oiw(14) secsig(3) algorithms(2) 26 }-
340 */-
341static const u_char id_sha1[] = {-
342 0x30, 0x21, /* type Sequence, length 0x21 (33) */-
343 0x30, 0x09, /* type Sequence, length 0x09 */-
344 0x06, 0x05, /* type OID, length 0x05 */-
345 0x2b, 0x0e, 0x03, 0x02, 0x1a, /* id-sha1 OID */-
346 0x05, 0x00, /* NULL */-
347 0x04, 0x14 /* Octet string, length 0x14 (20), followed by sha1 hash */-
348};-
349-
350/*-
351 * See http://csrc.nist.gov/groups/ST/crypto_apps_infra/csor/algorithms.html-
352 * id-sha256 OBJECT IDENTIFIER ::= { joint-iso-itu-t(2) country(16) us(840)-
353 * organization(1) gov(101) csor(3) nistAlgorithm(4) hashAlgs(2)-
354 * id-sha256(1) }-
355 */-
356static const u_char id_sha256[] = {-
357 0x30, 0x31, /* type Sequence, length 0x31 (49) */-
358 0x30, 0x0d, /* type Sequence, length 0x0d (13) */-
359 0x06, 0x09, /* type OID, length 0x09 */-
360 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, /* id-sha256 */-
361 0x05, 0x00, /* NULL */-
362 0x04, 0x20 /* Octet string, length 0x20 (32), followed by sha256 hash */-
363};-
364-
365/*-
366 * See http://csrc.nist.gov/groups/ST/crypto_apps_infra/csor/algorithms.html-
367 * id-sha512 OBJECT IDENTIFIER ::= { joint-iso-itu-t(2) country(16) us(840)-
368 * organization(1) gov(101) csor(3) nistAlgorithm(4) hashAlgs(2)-
369 * id-sha256(3) }-
370 */-
371static const u_char id_sha512[] = {-
372 0x30, 0x51, /* type Sequence, length 0x51 (81) */-
373 0x30, 0x0d, /* type Sequence, length 0x0d (13) */-
374 0x06, 0x09, /* type OID, length 0x09 */-
375 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03, /* id-sha512 */-
376 0x05, 0x00, /* NULL */-
377 0x04, 0x40 /* Octet string, length 0x40 (64), followed by sha512 hash */-
378};-
379-
380static int-
381rsa_hash_alg_oid(int hash_alg, const u_char **oidp, size_t *oidlenp)-
382{-
383 switch (hash_alg) {-
384 case SSH_DIGEST_SHA1:
executed 17522 times by 3 tests: case 1:
Executed by:
  • ssh-keygen
  • test_kex
  • test_sshkey
17522
385 *oidp = id_sha1;-
386 *oidlenp = sizeof(id_sha1);-
387 break;
executed 17522 times by 3 tests: break;
Executed by:
  • ssh-keygen
  • test_kex
  • test_sshkey
17522
388 case SSH_DIGEST_SHA256:
executed 17478 times by 1 test: case 2:
Executed by:
  • test_sshkey
17478
389 *oidp = id_sha256;-
390 *oidlenp = sizeof(id_sha256);-
391 break;
executed 17478 times by 1 test: break;
Executed by:
  • test_sshkey
17478
392 case SSH_DIGEST_SHA512:
executed 17479 times by 1 test: case 4:
Executed by:
  • test_sshkey
17479
393 *oidp = id_sha512;-
394 *oidlenp = sizeof(id_sha512);-
395 break;
executed 17479 times by 1 test: break;
Executed by:
  • test_sshkey
17479
396 default:
never executed: default:
0
397 return SSH_ERR_INVALID_ARGUMENT;
never executed: return -10;
0
398 }-
399 return 0;
executed 52479 times by 3 tests: return 0;
Executed by:
  • ssh-keygen
  • test_kex
  • test_sshkey
52479
400}-
401-
402static int-
403openssh_RSA_verify(int hash_alg, u_char *hash, size_t hashlen,-
404 u_char *sigbuf, size_t siglen, RSA *rsa)-
405{-
406 size_t rsasize = 0, oidlen = 0, hlen = 0;-
407 int ret, len, oidmatch, hashmatch;-
408 const u_char *oid = NULL;-
409 u_char *decrypted = NULL;-
410-
411 if ((ret = rsa_hash_alg_oid(hash_alg, &oid, &oidlen)) != 0)
(ret = rsa_has...&oidlen)) != 0Description
TRUEnever evaluated
FALSEevaluated 52479 times by 3 tests
Evaluated by:
  • ssh-keygen
  • test_kex
  • test_sshkey
0-52479
412 return ret;
never executed: return ret;
0
413 ret = SSH_ERR_INTERNAL_ERROR;-
414 hlen = ssh_digest_bytes(hash_alg);-
415 if (hashlen != hlen) {
hashlen != hlenDescription
TRUEnever evaluated
FALSEevaluated 52479 times by 3 tests
Evaluated by:
  • ssh-keygen
  • test_kex
  • test_sshkey
0-52479
416 ret = SSH_ERR_INVALID_ARGUMENT;-
417 goto done;
never executed: goto done;
0
418 }-
419 rsasize = RSA_size(rsa);-
420 if (rsasize <= 0 || rsasize > SSHBUF_MAX_BIGNUM ||
rsasize <= 0Description
TRUEnever evaluated
FALSEevaluated 52479 times by 3 tests
Evaluated by:
  • ssh-keygen
  • test_kex
  • test_sshkey
rsasize > (16384 / 8)Description
TRUEnever evaluated
FALSEevaluated 52479 times by 3 tests
Evaluated by:
  • ssh-keygen
  • test_kex
  • test_sshkey
0-52479
421 siglen == 0 || siglen > rsasize) {
siglen == 0Description
TRUEnever evaluated
FALSEevaluated 52479 times by 3 tests
Evaluated by:
  • ssh-keygen
  • test_kex
  • test_sshkey
siglen > rsasizeDescription
TRUEnever evaluated
FALSEevaluated 52479 times by 3 tests
Evaluated by:
  • ssh-keygen
  • test_kex
  • test_sshkey
0-52479
422 ret = SSH_ERR_INVALID_ARGUMENT;-
423 goto done;
never executed: goto done;
0
424 }-
425 if ((decrypted = malloc(rsasize)) == NULL) {
(decrypted = m...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 52479 times by 3 tests
Evaluated by:
  • ssh-keygen
  • test_kex
  • test_sshkey
0-52479
426 ret = SSH_ERR_ALLOC_FAIL;-
427 goto done;
never executed: goto done;
0
428 }-
429 if ((len = RSA_public_decrypt(siglen, sigbuf, decrypted, rsa,
(len = RSA_pub... rsa, 1 )) < 0Description
TRUEevaluated 52362 times by 1 test
Evaluated by:
  • test_sshkey
FALSEevaluated 117 times by 3 tests
Evaluated by:
  • ssh-keygen
  • test_kex
  • test_sshkey
117-52362
430 RSA_PKCS1_PADDING)) < 0) {
(len = RSA_pub... rsa, 1 )) < 0Description
TRUEevaluated 52362 times by 1 test
Evaluated by:
  • test_sshkey
FALSEevaluated 117 times by 3 tests
Evaluated by:
  • ssh-keygen
  • test_kex
  • test_sshkey
117-52362
431 ret = SSH_ERR_LIBCRYPTO_ERROR;-
432 goto done;
executed 52362 times by 1 test: goto done;
Executed by:
  • test_sshkey
52362
433 }-
434 if (len < 0 || (size_t)len != hlen + oidlen) {
len < 0Description
TRUEnever evaluated
FALSEevaluated 117 times by 3 tests
Evaluated by:
  • ssh-keygen
  • test_kex
  • test_sshkey
(size_t)len != hlen + oidlenDescription
TRUEnever evaluated
FALSEevaluated 117 times by 3 tests
Evaluated by:
  • ssh-keygen
  • test_kex
  • test_sshkey
0-117
435 ret = SSH_ERR_INVALID_FORMAT;-
436 goto done;
never executed: goto done;
0
437 }-
438 oidmatch = timingsafe_bcmp(decrypted, oid, oidlen) == 0;-
439 hashmatch = timingsafe_bcmp(decrypted + oidlen, hash, hlen) == 0;-
440 if (!oidmatch || !hashmatch) {
!oidmatchDescription
TRUEnever evaluated
FALSEevaluated 117 times by 3 tests
Evaluated by:
  • ssh-keygen
  • test_kex
  • test_sshkey
!hashmatchDescription
TRUEnever evaluated
FALSEevaluated 117 times by 3 tests
Evaluated by:
  • ssh-keygen
  • test_kex
  • test_sshkey
0-117
441 ret = SSH_ERR_SIGNATURE_INVALID;-
442 goto done;
never executed: goto done;
0
443 }-
444 ret = 0;-
445done:
code before this statement executed 117 times by 3 tests: done:
Executed by:
  • ssh-keygen
  • test_kex
  • test_sshkey
117
446 freezero(decrypted, rsasize);-
447 return ret;
executed 52479 times by 3 tests: return ret;
Executed by:
  • ssh-keygen
  • test_kex
  • test_sshkey
52479
448}-
449#endif /* WITH_OPENSSL */-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.2