1
0
mirror of https://github.com/libssh2/libssh2.git synced 2025-07-29 13:01:14 +03:00
Files
libssh2/tests/test_auth_pubkey_ok_rsa_encrypted.c
Viktor Szakats eb9f9de2c1 md5: allow disabling old-style encrypted private keys at build-time
Before this patch, this happened at runtime when using an old (pre-3.0),
FIPS-enabled OpenSSL backend.

This patch makes it possible to disable this via the build-time option
`LIBSSH2_NO_MD5_PEM`.

Also:
- make sure to exclude all MD5 internal APIs when both the above and
  `LIBSSH2_NO_MD5` are enabled.
- fix tests to support build with`LIBSSH2_NO_MD5`, `LIBSSH2_NO_MD5_PEM`
  and `LIBSSH2_NO_3DES`.
- add FIXME to apply this change to `os400qc3.*`.

Old-style encrypted private keys require MD5 and they look like this:
```
-----BEGIN RSA PRIVATE KEY-----
 Proc-Type: 4,ENCRYPTED
 DEK-Info: AES-128-CBC,<MD5-hex>

 <base64>
 -----END RSA PRIVATE KEY-----
```

E.g.: `tests/key_rsa_encrypted`

Ref: https://github.com/libssh2/www/issues/20
Closes #1181
2023-08-28 22:57:26 +00:00

22 lines
503 B
C

/* Copyright (C) The libssh2 project and its contributors.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include "runner.h"
int test(LIBSSH2_SESSION *session)
{
#if LIBSSH2_RSA_SHA1 && LIBSSH2_MD5_PEM
/* set in Dockerfile */
return test_auth_pubkey(session, 0,
"libssh2",
"libssh2",
"key_rsa_encrypted.pub",
"key_rsa_encrypted");
#else
(void)session;
return 0;
#endif
}