| 1 |
/* |
| 2 |
* This file is part of the SSH Library |
| 3 |
* |
| 4 |
* Copyright (c) 2010 by Aris Adamantiadis |
| 5 |
* |
| 6 |
* The SSH Library is free software; you can redistribute it and/or modify |
| 7 |
* it under the terms of the GNU Lesser General Public License as published by |
| 8 |
* the Free Software Foundation; either version 2.1 of the License, or (at your |
| 9 |
* option) any later version. |
| 10 |
* |
| 11 |
* The SSH Library is distributed in the hope that it will be useful, but |
| 12 |
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 13 |
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public |
| 14 |
* License for more details. |
| 15 |
* |
| 16 |
* You should have received a copy of the GNU Lesser General Public License |
| 17 |
* along with the SSH Library; see the file COPYING. If not, write to |
| 18 |
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, |
| 19 |
* MA 02111-1307, USA. |
| 20 |
*/ |
| 21 |
|
| 22 |
#include "config.h" |
| 23 |
|
| 24 |
#define LIBSSH_STATIC |
| 25 |
|
| 26 |
#include "torture.h" |
| 27 |
#include "libssh/libssh.h" |
| 28 |
#include "libssh/priv.h" |
| 29 |
#include "libssh/session.h" |
| 30 |
|
| 31 |
#include <errno.h> |
| 32 |
#include <sys/types.h> |
| 33 |
#include <pwd.h> |
| 34 |
|
| 35 |
static int sshd_setup(void **state) |
| 36 |
{ |
| 37 |
torture_setup_sshd_server(state, false); |
| 38 |
|
| 39 |
return 0; |
| 40 |
} |
| 41 |
|
| 42 |
static int sshd_teardown(void **state) { |
| 43 |
torture_teardown_sshd_server(state); |
| 44 |
|
| 45 |
return 0; |
| 46 |
} |
| 47 |
|
| 48 |
static int sshd_setup_hmac(void **state) |
| 49 |
{ |
| 50 |
torture_setup_sshd_server(state, false); |
| 51 |
/* Set MAC to be something other than what the client will offer */ |
| 52 |
torture_update_sshd_config(state, "MACs hmac-sha2-512"); |
| 53 |
|
| 54 |
return 0; |
| 55 |
} |
| 56 |
|
| 57 |
|
| 58 |
static int session_setup(void **state) { |
| 59 |
struct torture_state *s = *state; |
| 60 |
int verbosity = torture_libssh_verbosity(); |
| 61 |
struct passwd *pwd; |
| 62 |
bool false_v = false; |
| 63 |
int rc; |
| 64 |
|
| 65 |
pwd = getpwnam("bob"); |
| 66 |
assert_non_null(pwd); |
| 67 |
|
| 68 |
rc = setuid(pwd->pw_uid); |
| 69 |
assert_return_code(rc, errno); |
| 70 |
|
| 71 |
s->ssh.session = ssh_new(); |
| 72 |
assert_non_null(s->ssh.session); |
| 73 |
|
| 74 |
ssh_options_set(s->ssh.session, SSH_OPTIONS_LOG_VERBOSITY, &verbosity); |
| 75 |
ssh_options_set(s->ssh.session, SSH_OPTIONS_HOST, TORTURE_SSH_SERVER); |
| 76 |
/* Prevent parsing configuration files that can introduce different |
| 77 |
* algorithms then we want to test */ |
| 78 |
ssh_options_set(s->ssh.session, SSH_OPTIONS_PROCESS_CONFIG, &false_v); |
| 79 |
|
| 80 |
return 0; |
| 81 |
} |
| 82 |
|
| 83 |
static int session_teardown(void **state) |
| 84 |
{ |
| 85 |
struct torture_state *s = *state; |
| 86 |
|
| 87 |
ssh_disconnect(s->ssh.session); |
| 88 |
ssh_free(s->ssh.session); |
| 89 |
|
| 90 |
return 0; |
| 91 |
} |
| 92 |
|
| 93 |
static void test_algorithm(ssh_session session, |
| 94 |
const char *kex, |
| 95 |
const char *cipher, |
| 96 |
const char *hmac) { |
| 97 |
int rc; |
| 98 |
char data[256]; |
| 99 |
size_t len_to_test[] = { |
| 100 |
1, 2, 3, 4, 5, 6, 7, 8, 10, |
| 101 |
12, 15, 16, 20, |
| 102 |
31, 32, 33, |
| 103 |
63, 64, 65, |
| 104 |
100, 127, 128 |
| 105 |
}; |
| 106 |
unsigned int i; |
| 107 |
|
| 108 |
if (kex != NULL) { |
| 109 |
rc = ssh_options_set(session, SSH_OPTIONS_KEY_EXCHANGE, kex); |
| 110 |
assert_ssh_return_code(session, rc); |
| 111 |
} |
| 112 |
|
| 113 |
if (cipher != NULL) { |
| 114 |
rc = ssh_options_set(session, SSH_OPTIONS_CIPHERS_C_S, cipher); |
| 115 |
assert_ssh_return_code(session, rc); |
| 116 |
rc = ssh_options_set(session, SSH_OPTIONS_CIPHERS_S_C, cipher); |
| 117 |
assert_ssh_return_code(session, rc); |
| 118 |
} |
| 119 |
|
| 120 |
if (hmac != NULL) { |
| 121 |
rc = ssh_options_set(session, SSH_OPTIONS_HMAC_C_S, hmac); |
| 122 |
assert_ssh_return_code(session, rc); |
| 123 |
rc = ssh_options_set(session, SSH_OPTIONS_HMAC_S_C, hmac); |
| 124 |
assert_ssh_return_code(session, rc); |
| 125 |
} |
| 126 |
|
| 127 |
rc = ssh_connect(session); |
| 128 |
assert_ssh_return_code(session, rc); |
| 129 |
|
| 130 |
/* send ignore packets of all sizes */ |
| 131 |
memset(data, 0, sizeof(data)); |
| 132 |
for (i = 0; i < (sizeof(len_to_test) / sizeof(size_t)); i++) { |
| 133 |
memset(data, 'A', len_to_test[i]); |
| 134 |
ssh_send_ignore(session, data); |
| 135 |
ssh_handle_packets(session, 50); |
| 136 |
} |
| 137 |
|
| 138 |
rc = ssh_userauth_none(session, NULL); |
| 139 |
if (rc != SSH_OK) { |
| 140 |
rc = ssh_get_error_code(session); |
| 141 |
assert_int_equal(rc, SSH_REQUEST_DENIED); |
| 142 |
} |
| 143 |
|
| 144 |
ssh_disconnect(session); |
| 145 |
} |
| 146 |
|
| 147 |
static void torture_algorithms_aes128_cbc_hmac_sha1(void **state) { |
| 148 |
struct torture_state *s = *state; |
| 149 |
|
| 150 |
test_algorithm(s->ssh.session, NULL/*kex*/, "aes128-cbc", "hmac-sha1"); |
| 151 |
} |
| 152 |
|
| 153 |
static void torture_algorithms_aes128_cbc_hmac_sha2_256(void **state) { |
| 154 |
struct torture_state *s = *state; |
| 155 |
|
| 156 |
test_algorithm(s->ssh.session, NULL/*kex*/, "aes128-cbc", "hmac-sha2-256"); |
| 157 |
} |
| 158 |
|
| 159 |
static void torture_algorithms_aes128_cbc_hmac_sha2_512(void **state) { |
| 160 |
struct torture_state *s = *state; |
| 161 |
|
| 162 |
test_algorithm(s->ssh.session, NULL/*kex*/, "aes128-cbc", "hmac-sha2-512"); |
| 163 |
} |
| 164 |
|
| 165 |
static void torture_algorithms_aes128_cbc_hmac_sha1_etm(void **state) { |
| 166 |
struct torture_state *s = *state; |
| 167 |
|
| 168 |
test_algorithm(s->ssh.session, NULL/*kex*/, "aes128-cbc", "[email protected]"); |
| 169 |
} |
| 170 |
|
| 171 |
static void torture_algorithms_aes128_cbc_hmac_sha2_256_etm(void **state) { |
| 172 |
struct torture_state *s = *state; |
| 173 |
|
| 174 |
test_algorithm(s->ssh.session, NULL/*kex*/, "aes128-cbc", "[email protected]"); |
| 175 |
} |
| 176 |
|
| 177 |
static void torture_algorithms_aes128_cbc_hmac_sha2_512_etm(void **state) { |
| 178 |
struct torture_state *s = *state; |
| 179 |
|
| 180 |
test_algorithm(s->ssh.session, NULL/*kex*/, "aes128-cbc", "[email protected]"); |
| 181 |
} |
| 182 |
|
| 183 |
static void torture_algorithms_aes192_cbc_hmac_sha1(void **state) { |
| 184 |
struct torture_state *s = *state; |
| 185 |
|
| 186 |
if (ssh_fips_mode()) { |
| 187 |
skip(); |
| 188 |
} |
| 189 |
|
| 190 |
test_algorithm(s->ssh.session, NULL/*kex*/, "aes192-cbc", "hmac-sha1"); |
| 191 |
} |
| 192 |
|
| 193 |
static void torture_algorithms_aes192_cbc_hmac_sha2_256(void **state) { |
| 194 |
struct torture_state *s = *state; |
| 195 |
|
| 196 |
if (ssh_fips_mode()) { |
| 197 |
skip(); |
| 198 |
} |
| 199 |
|
| 200 |
test_algorithm(s->ssh.session, NULL/*kex*/, "aes192-cbc", "hmac-sha2-256"); |
| 201 |
} |
| 202 |
|
| 203 |
static void torture_algorithms_aes192_cbc_hmac_sha2_512(void **state) { |
| 204 |
struct torture_state *s = *state; |
| 205 |
|
| 206 |
if (ssh_fips_mode()) { |
| 207 |
skip(); |
| 208 |
} |
| 209 |
|
| 210 |
test_algorithm(s->ssh.session, NULL/*kex*/, "aes192-cbc", "hmac-sha2-512"); |
| 211 |
} |
| 212 |
|
| 213 |
static void torture_algorithms_aes192_cbc_hmac_sha1_etm(void **state) { |
| 214 |
struct torture_state *s = *state; |
| 215 |
|
| 216 |
if (ssh_fips_mode()) { |
| 217 |
skip(); |
| 218 |
} |
| 219 |
|
| 220 |
test_algorithm(s->ssh.session, NULL/*kex*/, "aes192-cbc", "[email protected]"); |
| 221 |
} |
| 222 |
|
| 223 |
static void torture_algorithms_aes192_cbc_hmac_sha2_256_etm(void **state) { |
| 224 |
struct torture_state *s = *state; |
| 225 |
|
| 226 |
if (ssh_fips_mode()) { |
| 227 |
skip(); |
| 228 |
} |
| 229 |
|
| 230 |
test_algorithm(s->ssh.session, NULL/*kex*/, "aes192-cbc", "[email protected]"); |
| 231 |
} |
| 232 |
|
| 233 |
static void torture_algorithms_aes192_cbc_hmac_sha2_512_etm(void **state) { |
| 234 |
struct torture_state *s = *state; |
| 235 |
|
| 236 |
if (ssh_fips_mode()) { |
| 237 |
skip(); |
| 238 |
} |
| 239 |
|
| 240 |
test_algorithm(s->ssh.session, NULL/*kex*/, "aes192-cbc", "[email protected]"); |
| 241 |
} |
| 242 |
|
| 243 |
static void torture_algorithms_aes256_cbc_hmac_sha1(void **state) { |
| 244 |
struct torture_state *s = *state; |
| 245 |
|
| 246 |
test_algorithm(s->ssh.session, NULL/*kex*/, "aes256-cbc", "hmac-sha1"); |
| 247 |
} |
| 248 |
|
| 249 |
static void torture_algorithms_aes256_cbc_hmac_sha2_256(void **state) { |
| 250 |
struct torture_state *s = *state; |
| 251 |
|
| 252 |
test_algorithm(s->ssh.session, NULL/*kex*/, "aes256-cbc", "hmac-sha2-256"); |
| 253 |
} |
| 254 |
|
| 255 |
static void torture_algorithms_aes256_cbc_hmac_sha2_512(void **state) { |
| 256 |
struct torture_state *s = *state; |
| 257 |
|
| 258 |
test_algorithm(s->ssh.session, NULL/*kex*/, "aes256-cbc", "hmac-sha2-512"); |
| 259 |
} |
| 260 |
|
| 261 |
static void torture_algorithms_aes256_cbc_hmac_sha1_etm(void **state) { |
| 262 |
struct torture_state *s = *state; |
| 263 |
|
| 264 |
test_algorithm(s->ssh.session, NULL/*kex*/, "aes256-cbc", "[email protected]"); |
| 265 |
} |
| 266 |
|
| 267 |
static void torture_algorithms_aes256_cbc_hmac_sha2_256_etm(void **state) { |
| 268 |
struct torture_state *s = *state; |
| 269 |
|
| 270 |
test_algorithm(s->ssh.session, NULL/*kex*/, "aes256-cbc", "[email protected]"); |
| 271 |
} |
| 272 |
|
| 273 |
static void torture_algorithms_aes256_cbc_hmac_sha2_512_etm(void **state) { |
| 274 |
struct torture_state *s = *state; |
| 275 |
|
| 276 |
test_algorithm(s->ssh.session, NULL/*kex*/, "aes256-cbc", "[email protected]"); |
| 277 |
} |
| 278 |
|
| 279 |
static void torture_algorithms_aes128_ctr_hmac_sha1(void **state) { |
| 280 |
struct torture_state *s = *state; |
| 281 |
|
| 282 |
test_algorithm(s->ssh.session, NULL/*kex*/, "aes128-ctr", "hmac-sha1"); |
| 283 |
} |
| 284 |
|
| 285 |
static void torture_algorithms_aes128_ctr_hmac_sha2_256(void **state) { |
| 286 |
struct torture_state *s = *state; |
| 287 |
|
| 288 |
test_algorithm(s->ssh.session, NULL/*kex*/, "aes128-ctr", "hmac-sha2-256"); |
| 289 |
} |
| 290 |
|
| 291 |
static void torture_algorithms_aes128_ctr_hmac_sha2_512(void **state) { |
| 292 |
struct torture_state *s = *state; |
| 293 |
|
| 294 |
test_algorithm(s->ssh.session, NULL/*kex*/, "aes128-ctr", "hmac-sha2-512"); |
| 295 |
} |
| 296 |
|
| 297 |
static void torture_algorithms_aes128_ctr_hmac_sha1_etm(void **state) { |
| 298 |
struct torture_state *s = *state; |
| 299 |
|
| 300 |
test_algorithm(s->ssh.session, NULL/*kex*/, "aes128-ctr", "[email protected]"); |
| 301 |
} |
| 302 |
|
| 303 |
static void torture_algorithms_aes128_ctr_hmac_sha2_256_etm(void **state) { |
| 304 |
struct torture_state *s = *state; |
| 305 |
|
| 306 |
test_algorithm(s->ssh.session, NULL/*kex*/, "aes128-ctr", "[email protected]"); |
| 307 |
} |
| 308 |
|
| 309 |
static void torture_algorithms_aes128_ctr_hmac_sha2_512_etm(void **state) { |
| 310 |
struct torture_state *s = *state; |
| 311 |
|
| 312 |
test_algorithm(s->ssh.session, NULL/*kex*/, "aes128-ctr", "[email protected]"); |
| 313 |
} |
| 314 |
|
| 315 |
static void torture_algorithms_aes192_ctr_hmac_sha1(void **state) { |
| 316 |
struct torture_state *s = *state; |
| 317 |
|
| 318 |
if (ssh_fips_mode()) { |
| 319 |
skip(); |
| 320 |
} |
| 321 |
|
| 322 |
test_algorithm(s->ssh.session, NULL/*kex*/, "aes192-ctr", "hmac-sha1"); |
| 323 |
} |
| 324 |
|
| 325 |
static void torture_algorithms_aes192_ctr_hmac_sha2_256(void **state) { |
| 326 |
struct torture_state *s = *state; |
| 327 |
|
| 328 |
if (ssh_fips_mode()) { |
| 329 |
skip(); |
| 330 |
} |
| 331 |
|
| 332 |
test_algorithm(s->ssh.session, NULL/*kex*/, "aes192-ctr", "hmac-sha2-256"); |
| 333 |
} |
| 334 |
|
| 335 |
static void torture_algorithms_aes192_ctr_hmac_sha2_512(void **state) { |
| 336 |
struct torture_state *s = *state; |
| 337 |
|
| 338 |
if (ssh_fips_mode()) { |
| 339 |
skip(); |
| 340 |
} |
| 341 |
|
| 342 |
test_algorithm(s->ssh.session, NULL/*kex*/, "aes192-ctr", "hmac-sha2-512"); |
| 343 |
} |
| 344 |
|
| 345 |
static void torture_algorithms_aes192_ctr_hmac_sha1_etm(void **state) { |
| 346 |
struct torture_state *s = *state; |
| 347 |
|
| 348 |
if (ssh_fips_mode()) { |
| 349 |
skip(); |
| 350 |
} |
| 351 |
|
| 352 |
test_algorithm(s->ssh.session, NULL/*kex*/, "aes192-ctr", "[email protected]"); |
| 353 |
} |
| 354 |
|
| 355 |
static void torture_algorithms_aes192_ctr_hmac_sha2_256_etm(void **state) { |
| 356 |
struct torture_state *s = *state; |
| 357 |
|
| 358 |
if (ssh_fips_mode()) { |
| 359 |
skip(); |
| 360 |
} |
| 361 |
|
| 362 |
test_algorithm(s->ssh.session, NULL/*kex*/, "aes192-ctr", "[email protected]"); |
| 363 |
} |
| 364 |
|
| 365 |
static void torture_algorithms_aes192_ctr_hmac_sha2_512_etm(void **state) { |
| 366 |
struct torture_state *s = *state; |
| 367 |
|
| 368 |
if (ssh_fips_mode()) { |
| 369 |
skip(); |
| 370 |
} |
| 371 |
|
| 372 |
test_algorithm(s->ssh.session, NULL/*kex*/, "aes192-ctr", "[email protected]"); |
| 373 |
} |
| 374 |
|
| 375 |
static void torture_algorithms_aes256_ctr_hmac_sha1(void **state) { |
| 376 |
struct torture_state *s = *state; |
| 377 |
|
| 378 |
test_algorithm(s->ssh.session, NULL/*kex*/, "aes256-ctr", "hmac-sha1"); |
| 379 |
} |
| 380 |
|
| 381 |
static void torture_algorithms_aes256_ctr_hmac_sha2_256(void **state) { |
| 382 |
struct torture_state *s = *state; |
| 383 |
|
| 384 |
test_algorithm(s->ssh.session, NULL/*kex*/, "aes256-ctr", "hmac-sha2-256"); |
| 385 |
} |
| 386 |
|
| 387 |
static void torture_algorithms_aes256_ctr_hmac_sha2_512(void **state) { |
| 388 |
struct torture_state *s = *state; |
| 389 |
|
| 390 |
test_algorithm(s->ssh.session, NULL/*kex*/, "aes256-ctr", "hmac-sha2-512"); |
| 391 |
} |
| 392 |
|
| 393 |
static void torture_algorithms_aes256_ctr_hmac_sha1_etm(void **state) { |
| 394 |
struct torture_state *s = *state; |
| 395 |
|
| 396 |
test_algorithm(s->ssh.session, NULL/*kex*/, "aes256-ctr", "[email protected]"); |
| 397 |
} |
| 398 |
|
| 399 |
static void torture_algorithms_aes256_ctr_hmac_sha2_256_etm(void **state) { |
| 400 |
struct torture_state *s = *state; |
| 401 |
|
| 402 |
test_algorithm(s->ssh.session, NULL/*kex*/, "aes256-ctr", "[email protected]"); |
| 403 |
} |
| 404 |
|
| 405 |
static void torture_algorithms_aes256_ctr_hmac_sha2_512_etm(void **state) { |
| 406 |
struct torture_state *s = *state; |
| 407 |
|
| 408 |
test_algorithm(s->ssh.session, NULL/*kex*/, "aes256-ctr", "[email protected]"); |
| 409 |
} |
| 410 |
|
| 411 |
static void torture_algorithms_aes128_gcm(void **state) |
| 412 |
{ |
| 413 |
struct torture_state *s = *state; |
| 414 |
|
| 415 |
test_algorithm(s->ssh.session, NULL/*kex*/, "[email protected]", NULL); |
| 416 |
} |
| 417 |
|
| 418 |
static void torture_algorithms_aes256_gcm(void **state) |
| 419 |
{ |
| 420 |
struct torture_state *s = *state; |
| 421 |
|
| 422 |
test_algorithm(s->ssh.session, NULL/*kex*/, "[email protected]", NULL); |
| 423 |
} |
| 424 |
|
| 425 |
static void torture_algorithms_aes128_gcm_mac(void **state) |
| 426 |
{ |
| 427 |
struct torture_state *s = *state; |
| 428 |
|
| 429 |
test_algorithm(s->ssh.session, NULL/*kex*/, "[email protected]", "hmac-sha1"); |
| 430 |
} |
| 431 |
|
| 432 |
static void torture_algorithms_aes256_gcm_mac(void **state) |
| 433 |
{ |
| 434 |
struct torture_state *s = *state; |
| 435 |
|
| 436 |
test_algorithm(s->ssh.session, NULL/*kex*/, "[email protected]", "hmac-sha1"); |
| 437 |
} |
| 438 |
|
| 439 |
static void torture_algorithms_3des_cbc_hmac_sha1(void **state) { |
| 440 |
struct torture_state *s = *state; |
| 441 |
|
| 442 |
if (ssh_fips_mode()) { |
| 443 |
skip(); |
| 444 |
} |
| 445 |
|
| 446 |
test_algorithm(s->ssh.session, NULL/*kex*/, "3des-cbc", "hmac-sha1"); |
| 447 |
} |
| 448 |
|
| 449 |
static void torture_algorithms_3des_cbc_hmac_sha2_256(void **state) { |
| 450 |
struct torture_state *s = *state; |
| 451 |
|
| 452 |
if (ssh_fips_mode()) { |
| 453 |
skip(); |
| 454 |
} |
| 455 |
|
| 456 |
test_algorithm(s->ssh.session, NULL/*kex*/, "3des-cbc", "hmac-sha2-256"); |
| 457 |
} |
| 458 |
|
| 459 |
static void torture_algorithms_3des_cbc_hmac_sha2_512(void **state) { |
| 460 |
struct torture_state *s = *state; |
| 461 |
|
| 462 |
if (ssh_fips_mode()) { |
| 463 |
skip(); |
| 464 |
} |
| 465 |
|
| 466 |
test_algorithm(s->ssh.session, NULL/*kex*/, "3des-cbc", "hmac-sha2-512"); |
| 467 |
} |
| 468 |
|
| 469 |
static void torture_algorithms_3des_cbc_hmac_sha1_etm(void **state) { |
| 470 |
struct torture_state *s = *state; |
| 471 |
|
| 472 |
if (ssh_fips_mode()) { |
| 473 |
skip(); |
| 474 |
} |
| 475 |
|
| 476 |
test_algorithm(s->ssh.session, NULL/*kex*/, "3des-cbc", "[email protected]"); |
| 477 |
} |
| 478 |
|
| 479 |
static void torture_algorithms_3des_cbc_hmac_sha2_256_etm(void **state) { |
| 480 |
struct torture_state *s = *state; |
| 481 |
|
| 482 |
if (ssh_fips_mode()) { |
| 483 |
skip(); |
| 484 |
} |
| 485 |
|
| 486 |
test_algorithm(s->ssh.session, NULL/*kex*/, "3des-cbc", "[email protected]"); |
| 487 |
} |
| 488 |
|
| 489 |
static void torture_algorithms_3des_cbc_hmac_sha2_512_etm(void **state) { |
| 490 |
struct torture_state *s = *state; |
| 491 |
|
| 492 |
if (ssh_fips_mode()) { |
| 493 |
skip(); |
| 494 |
} |
| 495 |
|
| 496 |
test_algorithm(s->ssh.session, NULL/*kex*/, "3des-cbc", "[email protected]"); |
| 497 |
} |
| 498 |
|
| 499 |
#if defined(HAVE_BLOWFISH) && defined(OPENSSH_BLOWFISH_CBC) |
| 500 |
static void torture_algorithms_blowfish_cbc_hmac_sha1(void **state) { |
| 501 |
struct torture_state *s = *state; |
| 502 |
|
| 503 |
if (ssh_fips_mode()) { |
| 504 |
skip(); |
| 505 |
} |
| 506 |
|
| 507 |
test_algorithm(s->ssh.session, NULL/*kex*/, "blowfish-cbc", "hmac-sha1"); |
| 508 |
} |
| 509 |
|
| 510 |
static void torture_algorithms_blowfish_cbc_hmac_sha2_256(void **state) { |
| 511 |
struct torture_state *s = *state; |
| 512 |
|
| 513 |
if (ssh_fips_mode()) { |
| 514 |
skip(); |
| 515 |
} |
| 516 |
|
| 517 |
test_algorithm(s->ssh.session, NULL/*kex*/, "blowfish-cbc", "hmac-sha2-256"); |
| 518 |
} |
| 519 |
|
| 520 |
static void torture_algorithms_blowfish_cbc_hmac_sha2_512(void **state) { |
| 521 |
struct torture_state *s = *state; |
| 522 |
|
| 523 |
if (ssh_fips_mode()) { |
| 524 |
skip(); |
| 525 |
} |
| 526 |
|
| 527 |
test_algorithm(s->ssh.session, NULL/*kex*/, "blowfish-cbc", "hmac-sha2-512"); |
| 528 |
} |
| 529 |
|
| 530 |
static void torture_algorithms_blowfish_cbc_hmac_sha1_etm(void **state) { |
| 531 |
struct torture_state *s = *state; |
| 532 |
|
| 533 |
if (ssh_fips_mode()) { |
| 534 |
skip(); |
| 535 |
} |
| 536 |
|
| 537 |
test_algorithm(s->ssh.session, NULL/*kex*/, "blowfish-cbc", "[email protected]"); |
| 538 |
} |
| 539 |
|
| 540 |
static void torture_algorithms_blowfish_cbc_hmac_sha2_256_etm(void **state) { |
| 541 |
struct torture_state *s = *state; |
| 542 |
|
| 543 |
if (ssh_fips_mode()) { |
| 544 |
skip(); |
| 545 |
} |
| 546 |
|
| 547 |
test_algorithm(s->ssh.session, NULL/*kex*/, "blowfish-cbc", "[email protected]"); |
| 548 |
} |
| 549 |
|
| 550 |
static void torture_algorithms_blowfish_cbc_hmac_sha2_512_etm(void **state) { |
| 551 |
struct torture_state *s = *state; |
| 552 |
|
| 553 |
if (ssh_fips_mode()) { |
| 554 |
skip(); |
| 555 |
} |
| 556 |
|
| 557 |
test_algorithm(s->ssh.session, NULL/*kex*/, "blowfish-cbc", "[email protected]"); |
| 558 |
} |
| 559 |
#endif /* HAVE_BLOWFISH && defined(OPENSSH_BLOWFISH_CBC) */ |
| 560 |
|
| 561 |
#ifdef OPENSSH_CHACHA20_POLY1305_OPENSSH_COM |
| 562 |
static void torture_algorithms_chacha20_poly1305(void **state) |
| 563 |
{ |
| 564 |
struct torture_state *s = *state; |
| 565 |
|
| 566 |
if (ssh_fips_mode()) { |
| 567 |
skip(); |
| 568 |
} |
| 569 |
|
| 570 |
test_algorithm(s->ssh.session, |
| 571 |
NULL, /*kex*/ |
| 572 |
"[email protected]", |
| 573 |
NULL); |
| 574 |
} |
| 575 |
static void torture_algorithms_chacha20_poly1305_mac(void **state) |
| 576 |
{ |
| 577 |
struct torture_state *s = *state; |
| 578 |
|
| 579 |
if (ssh_fips_mode()) { |
| 580 |
skip(); |
| 581 |
} |
| 582 |
|
| 583 |
test_algorithm(s->ssh.session, |
| 584 |
NULL, /*kex*/ |
| 585 |
"[email protected]", |
| 586 |
"hmac-sha1"); /* different from the server */ |
| 587 |
} |
| 588 |
#endif /* OPENSSH_CHACHA20_POLY1305_OPENSSH_COM */ |
| 589 |
|
| 590 |
static void torture_algorithms_zlib(void **state) { |
| 591 |
struct torture_state *s = *state; |
| 592 |
ssh_session session = s->ssh.session; |
| 593 |
int rc; |
| 594 |
|
| 595 |
rc = ssh_options_set(session, SSH_OPTIONS_COMPRESSION_C_S, "zlib"); |
| 596 |
#ifdef WITH_ZLIB |
| 597 |
if (ssh_fips_mode()) { |
| 598 |
assert_int_equal(rc, SSH_ERROR); |
| 599 |
} else { |
| 600 |
assert_int_equal(rc, SSH_OK); |
| 601 |
} |
| 602 |
#else |
| 603 |
assert_int_equal(rc, SSH_ERROR); |
| 604 |
#endif |
| 605 |
|
| 606 |
rc = ssh_options_set(session, SSH_OPTIONS_COMPRESSION_S_C, "zlib"); |
| 607 |
#ifdef WITH_ZLIB |
| 608 |
if (ssh_fips_mode()) { |
| 609 |
assert_int_equal(rc, SSH_ERROR); |
| 610 |
} else { |
| 611 |
assert_int_equal(rc, SSH_OK); |
| 612 |
} |
| 613 |
#else |
| 614 |
assert_int_equal(rc, SSH_ERROR); |
| 615 |
#endif |
| 616 |
|
| 617 |
rc = ssh_connect(session); |
| 618 |
#ifdef WITH_ZLIB |
| 619 |
if (!ssh_fips_mode()) { |
| 620 |
if (ssh_get_openssh_version(session)) { |
| 621 |
assert_false(rc == SSH_OK); |
| 622 |
ssh_disconnect(session); |
| 623 |
return; |
| 624 |
} |
| 625 |
} |
| 626 |
#endif |
| 627 |
assert_int_equal(rc, SSH_OK); |
| 628 |
|
| 629 |
rc = ssh_userauth_none(session, NULL); |
| 630 |
if (rc != SSH_OK) { |
| 631 |
rc = ssh_get_error_code(session); |
| 632 |
assert_int_equal(rc, SSH_REQUEST_DENIED); |
| 633 |
} |
| 634 |
|
| 635 |
ssh_disconnect(session); |
| 636 |
} |
| 637 |
|
| 638 |
static void torture_algorithms_zlib_openssh(void **state) { |
| 639 |
struct torture_state *s = *state; |
| 640 |
ssh_session session = s->ssh.session; |
| 641 |
int rc; |
| 642 |
|
| 643 |
rc = ssh_options_set(session, SSH_OPTIONS_COMPRESSION_C_S, "[email protected]"); |
| 644 |
#ifdef WITH_ZLIB |
| 645 |
assert_int_equal(rc, SSH_OK); |
| 646 |
#else |
| 647 |
assert_int_equal(rc, SSH_ERROR); |
| 648 |
#endif |
| 649 |
|
| 650 |
rc = ssh_options_set(session, SSH_OPTIONS_COMPRESSION_S_C, "[email protected]"); |
| 651 |
#ifdef WITH_ZLIB |
| 652 |
assert_int_equal(rc, SSH_OK); |
| 653 |
#else |
| 654 |
assert_int_equal(rc, SSH_ERROR); |
| 655 |
#endif |
| 656 |
|
| 657 |
rc = ssh_connect(session); |
| 658 |
#ifdef WITH_ZLIB |
| 659 |
if (ssh_get_openssh_version(session)) { |
| 660 |
assert_true(rc==SSH_OK); |
| 661 |
rc = ssh_userauth_none(session, NULL); |
| 662 |
if (rc != SSH_OK) { |
| 663 |
rc = ssh_get_error_code(session); |
| 664 |
assert_int_equal(rc, SSH_REQUEST_DENIED); |
| 665 |
} |
| 666 |
ssh_disconnect(session); |
| 667 |
return; |
| 668 |
} |
| 669 |
assert_false(rc == SSH_OK); |
| 670 |
#else |
| 671 |
assert_int_equal(rc, SSH_OK); |
| 672 |
#endif |
| 673 |
|
| 674 |
ssh_disconnect(session); |
| 675 |
} |
| 676 |
|
| 677 |
#if defined(HAVE_ECC) |
| 678 |
static void torture_algorithms_ecdh_sha2_nistp256(void **state) { |
| 679 |
struct torture_state *s = *state; |
| 680 |
|
| 681 |
test_algorithm(s->ssh.session, "ecdh-sha2-nistp256", NULL/*cipher*/, NULL/*hmac*/); |
| 682 |
} |
| 683 |
|
| 684 |
static void torture_algorithms_ecdh_sha2_nistp384(void **state) { |
| 685 |
struct torture_state *s = *state; |
| 686 |
|
| 687 |
test_algorithm(s->ssh.session, "ecdh-sha2-nistp384", NULL/*cipher*/, NULL/*hmac*/); |
| 688 |
} |
| 689 |
|
| 690 |
static void torture_algorithms_ecdh_sha2_nistp521(void **state) { |
| 691 |
struct torture_state *s = *state; |
| 692 |
|
| 693 |
test_algorithm(s->ssh.session, "ecdh-sha2-nistp521", NULL/*cipher*/, NULL/*hmac*/); |
| 694 |
} |
| 695 |
#endif |
| 696 |
|
| 697 |
#ifdef OPENSSH_CURVE25519_SHA256 |
| 698 |
static void torture_algorithms_ecdh_curve25519_sha256(void **state) { |
| 699 |
struct torture_state *s = *state; |
| 700 |
|
| 701 |
if (ssh_fips_mode()) { |
| 702 |
skip(); |
| 703 |
} |
| 704 |
|
| 705 |
test_algorithm(s->ssh.session, "curve25519-sha256", NULL/*cipher*/, NULL/*hmac*/); |
| 706 |
} |
| 707 |
#endif /* OPENSSH_CURVE25519_SHA256 */ |
| 708 |
|
| 709 |
#ifdef OPENSSH_CURVE25519_SHA256_LIBSSH_ORG |
| 710 |
static void torture_algorithms_ecdh_curve25519_sha256_libssh_org(void **state) { |
| 711 |
struct torture_state *s = *state; |
| 712 |
|
| 713 |
if (ssh_fips_mode()) { |
| 714 |
skip(); |
| 715 |
} |
| 716 |
|
| 717 |
test_algorithm(s->ssh.session, "[email protected]", NULL/*cipher*/, NULL/*hmac*/); |
| 718 |
} |
| 719 |
#endif /* OPENSSH_CURVE25519_SHA256_LIBSSH_ORG */ |
| 720 |
|
| 721 |
#ifdef OPENSSH_SNTRUP761X25519_SHA512_OPENSSH_COM |
| 722 |
static void |
| 723 |
torture_algorithms_ecdh_sntrup761x25519_sha512_openssh_com(void **state) |
| 724 |
{ |
| 725 |
struct torture_state *s = *state; |
| 726 |
|
| 727 |
if (ssh_fips_mode()) { |
| 728 |
skip(); |
| 729 |
} |
| 730 |
|
| 731 |
test_algorithm(s->ssh.session, |
| 732 |
"[email protected]", |
| 733 |
NULL /*cipher*/, |
| 734 |
NULL /*hmac*/); |
| 735 |
} |
| 736 |
#endif /* OPENSSH_SNTRUP761X25519_SHA512_OPENSSH_COM */ |
| 737 |
|
| 738 |
#ifdef OPENSSH_SNTRUP761X25519_SHA512 |
| 739 |
static void |
| 740 |
torture_algorithms_ecdh_sntrup761x25519_sha512(void **state) |
| 741 |
{ |
| 742 |
struct torture_state *s = *state; |
| 743 |
|
| 744 |
if (ssh_fips_mode()) { |
| 745 |
skip(); |
| 746 |
} |
| 747 |
|
| 748 |
test_algorithm(s->ssh.session, |
| 749 |
"sntrup761x25519-sha512", |
| 750 |
NULL /*cipher*/, |
| 751 |
NULL /*hmac*/); |
| 752 |
} |
| 753 |
#endif /* OPENSSH_SNTRUP761X25519_SHA512 */ |
| 754 |
|
| 755 |
#if defined(OPENSSH_MLKEM768X25519_SHA256) |
| 756 |
static void torture_algorithms_ecdh_mlkem768x25519_sha256(void **state) |
| 757 |
{ |
| 758 |
struct torture_state *s = *state; |
| 759 |
|
| 760 |
if (ssh_fips_mode()) { |
| 761 |
skip(); |
| 762 |
} |
| 763 |
|
| 764 |
test_algorithm(s->ssh.session, |
| 765 |
"mlkem768x25519-sha256", |
| 766 |
NULL /*cipher*/, |
| 767 |
NULL /*hmac*/); |
| 768 |
} |
| 769 |
#endif /* defined(OPENSSH_MLKEM768X25519_SHA256) */ |
| 770 |
|
| 771 |
#if defined(OPENSSH_MLKEM768NISTP256_SHA256) |
| 772 |
static void torture_algorithms_ecdh_mlkem768nistp256_sha256(void **state) |
| 773 |
{ |
| 774 |
struct torture_state *s = *state; |
| 775 |
|
| 776 |
if (ssh_fips_mode()) { |
| 777 |
skip(); |
| 778 |
} |
| 779 |
|
| 780 |
test_algorithm(s->ssh.session, |
| 781 |
"mlkem768nistp256-sha256", |
| 782 |
NULL /*cipher*/, |
| 783 |
NULL /*hmac*/); |
| 784 |
} |
| 785 |
#endif /* defined(OPENSSH_MLKEM768NISTP256_SHA256) */ |
| 786 |
|
| 787 |
#if defined(HAVE_MLKEM1024) && defined(OPENSSH_MLKEM1024NISTP384_SHA384) |
| 788 |
static void torture_algorithms_ecdh_mlkem1024nistp384_sha384(void **state) |
| 789 |
{ |
| 790 |
struct torture_state *s = *state; |
| 791 |
|
| 792 |
if (ssh_fips_mode()) { |
| 793 |
skip(); |
| 794 |
} |
| 795 |
|
| 796 |
test_algorithm(s->ssh.session, |
| 797 |
"mlkem1024nistp384-sha384", |
| 798 |
NULL /*cipher*/, |
| 799 |
NULL /*hmac*/); |
| 800 |
} |
| 801 |
#endif /* HAVE_MLKEM1024 && defined(OPENSSH_MLKEM1024NISTP384_SHA384) */ |
| 802 |
|
| 803 |
static void torture_algorithms_dh_group1(void **state) { |
| 804 |
struct torture_state *s = *state; |
| 805 |
|
| 806 |
if (ssh_fips_mode()) { |
| 807 |
skip(); |
| 808 |
} |
| 809 |
|
| 810 |
test_algorithm(s->ssh.session, "diffie-hellman-group1-sha1", NULL/*cipher*/, NULL/*hmac*/); |
| 811 |
} |
| 812 |
|
| 813 |
static void torture_algorithms_dh_group14(void **state) { |
| 814 |
struct torture_state *s = *state; |
| 815 |
|
| 816 |
if (ssh_fips_mode()) { |
| 817 |
skip(); |
| 818 |
} |
| 819 |
|
| 820 |
test_algorithm(s->ssh.session, "diffie-hellman-group14-sha1", NULL/*cipher*/, NULL/*hmac*/); |
| 821 |
} |
| 822 |
|
| 823 |
static void torture_algorithms_dh_group14_sha256(void **state) { |
| 824 |
struct torture_state *s = *state; |
| 825 |
|
| 826 |
if (ssh_fips_mode()) { |
| 827 |
skip(); |
| 828 |
} |
| 829 |
|
| 830 |
test_algorithm(s->ssh.session, "diffie-hellman-group14-sha256", NULL/*cipher*/, NULL/*hmac*/); |
| 831 |
} |
| 832 |
|
| 833 |
static void torture_algorithms_dh_group16(void **state) { |
| 834 |
struct torture_state *s = *state; |
| 835 |
|
| 836 |
test_algorithm(s->ssh.session, "diffie-hellman-group16-sha512", NULL/*cipher*/, NULL/*hmac*/); |
| 837 |
} |
| 838 |
|
| 839 |
static void torture_algorithms_dh_group18(void **state) { |
| 840 |
struct torture_state *s = *state; |
| 841 |
|
| 842 |
test_algorithm(s->ssh.session, "diffie-hellman-group18-sha512", NULL/*cipher*/, NULL/*hmac*/); |
| 843 |
} |
| 844 |
|
| 845 |
#ifdef WITH_GEX |
| 846 |
static void torture_algorithms_dh_gex_sha1(void **state) |
| 847 |
{ |
| 848 |
struct torture_state *s = *state; |
| 849 |
|
| 850 |
if (ssh_fips_mode()) { |
| 851 |
skip(); |
| 852 |
} |
| 853 |
|
| 854 |
test_algorithm(s->ssh.session, |
| 855 |
"diffie-hellman-group-exchange-sha1", |
| 856 |
NULL, /* cipher */ |
| 857 |
NULL); /* hmac */ |
| 858 |
} |
| 859 |
|
| 860 |
static void torture_algorithms_dh_gex_sha256(void **state) |
| 861 |
{ |
| 862 |
struct torture_state *s = *state; |
| 863 |
|
| 864 |
test_algorithm(s->ssh.session, |
| 865 |
"diffie-hellman-group-exchange-sha256", |
| 866 |
NULL, /* cipher */ |
| 867 |
NULL); /* hmac */ |
| 868 |
} |
| 869 |
#endif /* WITH_GEX */ |
| 870 |
|
| 871 |
int torture_run_tests(void) { |
| 872 |
int rc; |
| 873 |
struct CMUnitTest tests[] = { |
| 874 |
cmocka_unit_test_setup_teardown(torture_algorithms_aes128_cbc_hmac_sha1, |
| 875 |
session_setup, |
| 876 |
session_teardown), |
| 877 |
cmocka_unit_test_setup_teardown(torture_algorithms_aes128_cbc_hmac_sha2_256, |
| 878 |
session_setup, |
| 879 |
session_teardown), |
| 880 |
cmocka_unit_test_setup_teardown(torture_algorithms_aes128_cbc_hmac_sha2_512, |
| 881 |
session_setup, |
| 882 |
session_teardown), |
| 883 |
cmocka_unit_test_setup_teardown(torture_algorithms_aes128_cbc_hmac_sha1_etm, |
| 884 |
session_setup, |
| 885 |
session_teardown), |
| 886 |
cmocka_unit_test_setup_teardown(torture_algorithms_aes128_cbc_hmac_sha2_256_etm, |
| 887 |
session_setup, |
| 888 |
session_teardown), |
| 889 |
cmocka_unit_test_setup_teardown(torture_algorithms_aes128_cbc_hmac_sha2_512_etm, |
| 890 |
session_setup, |
| 891 |
session_teardown), |
| 892 |
cmocka_unit_test_setup_teardown(torture_algorithms_aes192_cbc_hmac_sha1, |
| 893 |
session_setup, |
| 894 |
session_teardown), |
| 895 |
cmocka_unit_test_setup_teardown(torture_algorithms_aes192_cbc_hmac_sha2_256, |
| 896 |
session_setup, |
| 897 |
session_teardown), |
| 898 |
cmocka_unit_test_setup_teardown(torture_algorithms_aes192_cbc_hmac_sha2_512, |
| 899 |
session_setup, |
| 900 |
session_teardown), |
| 901 |
cmocka_unit_test_setup_teardown(torture_algorithms_aes192_cbc_hmac_sha1_etm, |
| 902 |
session_setup, |
| 903 |
session_teardown), |
| 904 |
cmocka_unit_test_setup_teardown(torture_algorithms_aes192_cbc_hmac_sha2_256_etm, |
| 905 |
session_setup, |
| 906 |
session_teardown), |
| 907 |
cmocka_unit_test_setup_teardown(torture_algorithms_aes192_cbc_hmac_sha2_512_etm, |
| 908 |
session_setup, |
| 909 |
session_teardown), |
| 910 |
cmocka_unit_test_setup_teardown(torture_algorithms_aes256_cbc_hmac_sha1, |
| 911 |
session_setup, |
| 912 |
session_teardown), |
| 913 |
cmocka_unit_test_setup_teardown(torture_algorithms_aes256_cbc_hmac_sha2_256, |
| 914 |
session_setup, |
| 915 |
session_teardown), |
| 916 |
cmocka_unit_test_setup_teardown(torture_algorithms_aes256_cbc_hmac_sha2_512, |
| 917 |
session_setup, |
| 918 |
session_teardown), |
| 919 |
cmocka_unit_test_setup_teardown(torture_algorithms_aes256_cbc_hmac_sha1_etm, |
| 920 |
session_setup, |
| 921 |
session_teardown), |
| 922 |
cmocka_unit_test_setup_teardown(torture_algorithms_aes256_cbc_hmac_sha2_256_etm, |
| 923 |
session_setup, |
| 924 |
session_teardown), |
| 925 |
cmocka_unit_test_setup_teardown(torture_algorithms_aes256_cbc_hmac_sha2_512_etm, |
| 926 |
session_setup, |
| 927 |
session_teardown), |
| 928 |
cmocka_unit_test_setup_teardown(torture_algorithms_aes128_ctr_hmac_sha1, |
| 929 |
session_setup, |
| 930 |
session_teardown), |
| 931 |
cmocka_unit_test_setup_teardown(torture_algorithms_aes128_ctr_hmac_sha2_256, |
| 932 |
session_setup, |
| 933 |
session_teardown), |
| 934 |
cmocka_unit_test_setup_teardown(torture_algorithms_aes128_ctr_hmac_sha2_512, |
| 935 |
session_setup, |
| 936 |
session_teardown), |
| 937 |
cmocka_unit_test_setup_teardown(torture_algorithms_aes128_ctr_hmac_sha1_etm, |
| 938 |
session_setup, |
| 939 |
session_teardown), |
| 940 |
cmocka_unit_test_setup_teardown(torture_algorithms_aes128_ctr_hmac_sha2_256_etm, |
| 941 |
session_setup, |
| 942 |
session_teardown), |
| 943 |
cmocka_unit_test_setup_teardown(torture_algorithms_aes128_ctr_hmac_sha2_512_etm, |
| 944 |
session_setup, |
| 945 |
session_teardown), |
| 946 |
cmocka_unit_test_setup_teardown(torture_algorithms_aes192_ctr_hmac_sha1, |
| 947 |
session_setup, |
| 948 |
session_teardown), |
| 949 |
cmocka_unit_test_setup_teardown(torture_algorithms_aes192_ctr_hmac_sha2_256, |
| 950 |
session_setup, |
| 951 |
session_teardown), |
| 952 |
cmocka_unit_test_setup_teardown(torture_algorithms_aes192_ctr_hmac_sha2_512, |
| 953 |
session_setup, |
| 954 |
session_teardown), |
| 955 |
cmocka_unit_test_setup_teardown(torture_algorithms_aes192_ctr_hmac_sha1_etm, |
| 956 |
session_setup, |
| 957 |
session_teardown), |
| 958 |
cmocka_unit_test_setup_teardown(torture_algorithms_aes192_ctr_hmac_sha2_256_etm, |
| 959 |
session_setup, |
| 960 |
session_teardown), |
| 961 |
cmocka_unit_test_setup_teardown(torture_algorithms_aes192_ctr_hmac_sha2_512_etm, |
| 962 |
session_setup, |
| 963 |
session_teardown), |
| 964 |
cmocka_unit_test_setup_teardown(torture_algorithms_aes256_ctr_hmac_sha1, |
| 965 |
session_setup, |
| 966 |
session_teardown), |
| 967 |
cmocka_unit_test_setup_teardown(torture_algorithms_aes256_ctr_hmac_sha2_256, |
| 968 |
session_setup, |
| 969 |
session_teardown), |
| 970 |
cmocka_unit_test_setup_teardown(torture_algorithms_aes256_ctr_hmac_sha2_512, |
| 971 |
session_setup, |
| 972 |
session_teardown), |
| 973 |
cmocka_unit_test_setup_teardown(torture_algorithms_aes256_ctr_hmac_sha1_etm, |
| 974 |
session_setup, |
| 975 |
session_teardown), |
| 976 |
cmocka_unit_test_setup_teardown(torture_algorithms_aes256_ctr_hmac_sha2_256_etm, |
| 977 |
session_setup, |
| 978 |
session_teardown), |
| 979 |
cmocka_unit_test_setup_teardown(torture_algorithms_aes256_ctr_hmac_sha2_512_etm, |
| 980 |
session_setup, |
| 981 |
session_teardown), |
| 982 |
cmocka_unit_test_setup_teardown(torture_algorithms_aes128_gcm, |
| 983 |
session_setup, |
| 984 |
session_teardown), |
| 985 |
cmocka_unit_test_setup_teardown(torture_algorithms_aes256_gcm, |
| 986 |
session_setup, |
| 987 |
session_teardown), |
| 988 |
cmocka_unit_test_setup_teardown(torture_algorithms_3des_cbc_hmac_sha1, |
| 989 |
session_setup, |
| 990 |
session_teardown), |
| 991 |
cmocka_unit_test_setup_teardown(torture_algorithms_3des_cbc_hmac_sha2_256, |
| 992 |
session_setup, |
| 993 |
session_teardown), |
| 994 |
cmocka_unit_test_setup_teardown(torture_algorithms_3des_cbc_hmac_sha2_512, |
| 995 |
session_setup, |
| 996 |
session_teardown), |
| 997 |
cmocka_unit_test_setup_teardown(torture_algorithms_3des_cbc_hmac_sha1_etm, |
| 998 |
session_setup, |
| 999 |
session_teardown), |
| 1000 |
cmocka_unit_test_setup_teardown(torture_algorithms_3des_cbc_hmac_sha2_256_etm, |
| 1001 |
session_setup, |
| 1002 |
session_teardown), |
| 1003 |
cmocka_unit_test_setup_teardown(torture_algorithms_3des_cbc_hmac_sha2_512_etm, |
| 1004 |
session_setup, |
| 1005 |
session_teardown), |
| 1006 |
#if defined(HAVE_BLOWFISH) && defined(OPENSSH_BLOWFISH_CBC) |
| 1007 |
cmocka_unit_test_setup_teardown(torture_algorithms_blowfish_cbc_hmac_sha1, |
| 1008 |
session_setup, |
| 1009 |
session_teardown), |
| 1010 |
cmocka_unit_test_setup_teardown(torture_algorithms_blowfish_cbc_hmac_sha2_256, |
| 1011 |
session_setup, |
| 1012 |
session_teardown), |
| 1013 |
cmocka_unit_test_setup_teardown(torture_algorithms_blowfish_cbc_hmac_sha2_512, |
| 1014 |
session_setup, |
| 1015 |
session_teardown), |
| 1016 |
cmocka_unit_test_setup_teardown(torture_algorithms_blowfish_cbc_hmac_sha1_etm, |
| 1017 |
session_setup, |
| 1018 |
session_teardown), |
| 1019 |
cmocka_unit_test_setup_teardown(torture_algorithms_blowfish_cbc_hmac_sha2_256_etm, |
| 1020 |
session_setup, |
| 1021 |
session_teardown), |
| 1022 |
cmocka_unit_test_setup_teardown(torture_algorithms_blowfish_cbc_hmac_sha2_512_etm, |
| 1023 |
session_setup, |
| 1024 |
session_teardown), |
| 1025 |
#endif /* HAVE_BLOWFISH_CIPHER && defined(OPENSSH_BLOWFISH_CBC) */ |
| 1026 |
#ifdef OPENSSH_CHACHA20_POLY1305_OPENSSH_COM |
| 1027 |
cmocka_unit_test_setup_teardown(torture_algorithms_chacha20_poly1305, |
| 1028 |
session_setup, |
| 1029 |
session_teardown), |
| 1030 |
#endif /* OPENSSH_CHACHA20_POLY1305_OPENSSH_COM */ |
| 1031 |
cmocka_unit_test_setup_teardown(torture_algorithms_zlib, |
| 1032 |
session_setup, |
| 1033 |
session_teardown), |
| 1034 |
cmocka_unit_test_setup_teardown(torture_algorithms_zlib_openssh, |
| 1035 |
session_setup, |
| 1036 |
session_teardown), |
| 1037 |
cmocka_unit_test_setup_teardown(torture_algorithms_dh_group1, |
| 1038 |
session_setup, |
| 1039 |
session_teardown), |
| 1040 |
cmocka_unit_test_setup_teardown(torture_algorithms_dh_group14, |
| 1041 |
session_setup, |
| 1042 |
session_teardown), |
| 1043 |
cmocka_unit_test_setup_teardown(torture_algorithms_dh_group14_sha256, |
| 1044 |
session_setup, |
| 1045 |
session_teardown), |
| 1046 |
cmocka_unit_test_setup_teardown(torture_algorithms_dh_group16, |
| 1047 |
session_setup, |
| 1048 |
session_teardown), |
| 1049 |
cmocka_unit_test_setup_teardown(torture_algorithms_dh_group18, |
| 1050 |
session_setup, |
| 1051 |
session_teardown), |
| 1052 |
#ifdef WITH_GEX |
| 1053 |
cmocka_unit_test_setup_teardown(torture_algorithms_dh_gex_sha1, |
| 1054 |
session_setup, |
| 1055 |
session_teardown), |
| 1056 |
cmocka_unit_test_setup_teardown(torture_algorithms_dh_gex_sha256, |
| 1057 |
session_setup, |
| 1058 |
session_teardown), |
| 1059 |
#endif /* WITH_GEX */ |
| 1060 |
#ifdef OPENSSH_CURVE25519_SHA256 |
| 1061 |
cmocka_unit_test_setup_teardown(torture_algorithms_ecdh_curve25519_sha256, |
| 1062 |
session_setup, |
| 1063 |
session_teardown), |
| 1064 |
#endif /* OPENSSH_CURVE25519_SHA256 */ |
| 1065 |
#ifdef OPENSSH_CURVE25519_SHA256_LIBSSH_ORG |
| 1066 |
cmocka_unit_test_setup_teardown(torture_algorithms_ecdh_curve25519_sha256_libssh_org, |
| 1067 |
session_setup, |
| 1068 |
session_teardown), |
| 1069 |
#endif /* OPENSSH_CURVE25519_SHA256_LIBSSH_ORG */ |
| 1070 |
#ifdef OPENSSH_SNTRUP761X25519_SHA512_OPENSSH_COM |
| 1071 |
cmocka_unit_test_setup_teardown(torture_algorithms_ecdh_sntrup761x25519_sha512_openssh_com, |
| 1072 |
session_setup, |
| 1073 |
session_teardown), |
| 1074 |
#endif /* OPENSSH_SNTRUP761X25519_SHA512_OPENSSH_COM */ |
| 1075 |
#ifdef OPENSSH_SNTRUP761X25519_SHA512 |
| 1076 |
cmocka_unit_test_setup_teardown(torture_algorithms_ecdh_sntrup761x25519_sha512, |
| 1077 |
session_setup, |
| 1078 |
session_teardown), |
| 1079 |
#endif /* OPENSSH_SNTRUP761X25519_SHA512 */ |
| 1080 |
#if defined(OPENSSH_MLKEM768X25519_SHA256) |
| 1081 |
cmocka_unit_test_setup_teardown(torture_algorithms_ecdh_mlkem768x25519_sha256, |
| 1082 |
session_setup, |
| 1083 |
session_teardown), |
| 1084 |
#endif /* defined(OPENSSH_MLKEM768X25519_SHA256) */ |
| 1085 |
#if defined(OPENSSH_MLKEM768NISTP256_SHA256) |
| 1086 |
cmocka_unit_test_setup_teardown(torture_algorithms_ecdh_mlkem768nistp256_sha256, |
| 1087 |
session_setup, |
| 1088 |
session_teardown), |
| 1089 |
#endif /* defined(OPENSSH_MLKEM768NISTP256_SHA256) */ |
| 1090 |
#if defined(HAVE_MLKEM1024) && defined(OPENSSH_MLKEM1024NISTP384_SHA384) |
| 1091 |
cmocka_unit_test_setup_teardown(torture_algorithms_ecdh_mlkem1024nistp384_sha384, |
| 1092 |
session_setup, |
| 1093 |
session_teardown), |
| 1094 |
#endif /* defined(HAVE_MLKEM1024) && defined(OPENSSH_MLKEM1024NISTP384_SHA384) */ |
| 1095 |
#if defined(HAVE_ECC) |
| 1096 |
cmocka_unit_test_setup_teardown(torture_algorithms_ecdh_sha2_nistp256, |
| 1097 |
session_setup, |
| 1098 |
session_teardown), |
| 1099 |
cmocka_unit_test_setup_teardown(torture_algorithms_ecdh_sha2_nistp384, |
| 1100 |
session_setup, |
| 1101 |
session_teardown), |
| 1102 |
cmocka_unit_test_setup_teardown(torture_algorithms_ecdh_sha2_nistp521, |
| 1103 |
session_setup, |
| 1104 |
session_teardown), |
| 1105 |
#endif |
| 1106 |
}; |
| 1107 |
|
| 1108 |
struct CMUnitTest tests_hmac[] = { |
| 1109 |
cmocka_unit_test_setup_teardown(torture_algorithms_aes128_gcm_mac, |
| 1110 |
session_setup, |
| 1111 |
session_teardown), |
| 1112 |
cmocka_unit_test_setup_teardown(torture_algorithms_aes256_gcm_mac, |
| 1113 |
session_setup, |
| 1114 |
session_teardown), |
| 1115 |
#ifdef OPENSSH_CHACHA20_POLY1305_OPENSSH_COM |
| 1116 |
cmocka_unit_test_setup_teardown(torture_algorithms_chacha20_poly1305_mac, |
| 1117 |
session_setup, |
| 1118 |
session_teardown), |
| 1119 |
#endif /* OPENSSH_CHACHA20_POLY1305_OPENSSH_COM */ |
| 1120 |
}; |
| 1121 |
|
| 1122 |
ssh_init(); |
| 1123 |
|
| 1124 |
torture_filter_tests(tests); |
| 1125 |
rc = cmocka_run_group_tests(tests, sshd_setup, sshd_teardown); |
| 1126 |
if (rc != 0) { |
| 1127 |
return rc; |
| 1128 |
} |
| 1129 |
|
| 1130 |
torture_filter_tests(tests); |
| 1131 |
rc = cmocka_run_group_tests(tests_hmac, sshd_setup_hmac, sshd_teardown); |
| 1132 |
|
| 1133 |
ssh_finalize(); |
| 1134 |
|
| 1135 |
return rc; |
| 1136 |
} |