Greenbone Vulnerability Management Libraries: util/sshutils_tests.c File Reference

Greenbone Vulnerability Management Libraries 23.1.1

Functions | Variables
sshutils_tests.c File Reference
`#include "sshutils.c"`
`#include <cgreen/cgreen.h>`
`#include <cgreen/mocks.h>`
`#include <glib.h>`
`#include <string.h>`

## Functions
| Describe (sshutils)
| BeforeEach (sshutils)
| AfterEach (sshutils)
| Ensure (sshutils, gvm_ssh_pkcs8_decrypt_returns_null_for_null_pkcs8_key)
| Ensure (sshutils, gvm_ssh_pkcs8_decrypt_handles_empty_passphrase)
| Ensure (sshutils, gvm_ssh_pkcs8_decrypt_handles_null_passphrase)
| Ensure (sshutils, gvm_ssh_pkcs8_decrypt_returns_null_for_invalid_key)
| Ensure (sshutils, gvm_ssh_pkcs8_decrypt_decrypts_rsa_key_correctly)
| Ensure (sshutils, gvm_ssh_pkcs8_decrypt_decrypts_ecdsa_key_correctly)
| Ensure (sshutils, gvm_ssh_pkcs8_decrypt_decrypts_ed25519_key_correctly)
| Ensure (sshutils, gvm_ssh_pkcs8_decrypt_handles_unencrypted_keys)
| Ensure (sshutils, gvm_ssh_public_from_private_returns_null_for_null_private_key)
| Ensure (sshutils, gvm_ssh_public_from_private_handles_invalid_private_key)
| Ensure (sshutils, gvm_ssh_public_from_private_handles_null_passphrase)
| Ensure (sshutils, gvm_ssh_public_from_private_handles_empty_passphrase)
| Ensure (sshutils, gvm_ssh_public_from_private_generates_rsa_public_key)
| Ensure (sshutils, gvm_ssh_public_from_private_generates_ecdsa_public_key)
| Ensure (sshutils, gvm_ssh_public_from_private_generates_ed25519_public_key)
| Ensure (sshutils, gvm_ssh_public_from_private_handles_encrypted_keys)
| Ensure (sshutils, gvm_ssh_public_from_private_handles_wrong_passphrase)
| Ensure (sshutils, gvm_ssh_private_key_info_returns_minus_one_for_null_private_key)
| Ensure (sshutils, gvm_ssh_private_key_info_handles_null_type_and_hash_pointers)
| Ensure (sshutils, gvm_ssh_private_key_info_handles_null_type_pointer)
| Ensure (sshutils, gvm_ssh_private_key_info_handles_null_hash_pointer)
| Ensure (sshutils, gvm_ssh_private_key_info_handles_invalid_private_key)
| Ensure (sshutils, gvm_ssh_private_key_info_handles_null_passphrase)
| Ensure (sshutils, gvm_ssh_private_key_info_handles_empty_passphrase)
| Ensure (sshutils, gvm_ssh_private_key_info_gets_rsa_key_type_and_hash)
| Ensure (sshutils, gvm_ssh_private_key_info_gets_ecdsa_key_type_and_hash)
| Ensure (sshutils, gvm_ssh_private_key_info_gets_ed25519_key_type_and_hash)
| Ensure (sshutils, gvm_ssh_private_key_info_handles_encrypted_keys)
| Ensure (sshutils, gvm_ssh_private_key_info_handles_wrong_passphrase)
| Ensure (sshutils, gvm_ssh_private_key_info_can_get_just_type)
| Ensure (sshutils, gvm_ssh_private_key_info_can_get_just_hash)
int | main (int argc, char **argv)

## Variables
static const char * | test_rsa_pkcs8_encrypted
static const char * | test_rsa_pkcs8_unencrypted
static const char * | test_ecdsa_pkcs8_encrypted
static const char * | test_ecdsa_openssh_private
static const char * | test_ed25519_pkcs8_encrypted
static const char * | test_ed25519_openssh_private
static const char * | test_rsa_public_expected
static const char * | test_ecdsa_public_expected
static const char * | test_ed25519_public_expected
static const char * | expected_rsa_sha256_hash
static const char * | expected_ecdsa_sha256_hash
static const char * | expected_ed25519_sha256_hash

## Function Documentation

## ◆ AfterEach()

AfterEach | ( | sshutils |  | ) |

## ◆ BeforeEach()

BeforeEach | ( | sshutils |  | ) |

## ◆ Describe()

Describe | ( | sshutils |  | ) |

## ◆ Ensure() [1/31]

Ensure | ( | sshutils | ,
|  | gvm_ssh_pkcs8_decrypt_decrypts_ecdsa_key_correctly | )

## ◆ Ensure() [2/31]

Ensure | ( | sshutils | ,
|  | gvm_ssh_pkcs8_decrypt_decrypts_ed25519_key_correctly | )

## ◆ Ensure() [3/31]

Ensure | ( | sshutils | ,
|  | gvm_ssh_pkcs8_decrypt_decrypts_rsa_key_correctly | )

## ◆ Ensure() [4/31]

Ensure | ( | sshutils | ,
|  | gvm_ssh_pkcs8_decrypt_handles_empty_passphrase | )

## ◆ Ensure() [5/31]

Ensure | ( | sshutils | ,
|  | gvm_ssh_pkcs8_decrypt_handles_null_passphrase | )

## ◆ Ensure() [6/31]

Ensure | ( | sshutils | ,
|  | gvm_ssh_pkcs8_decrypt_handles_unencrypted_keys | )

## ◆ Ensure() [7/31]

Ensure | ( | sshutils | ,
|  | gvm_ssh_pkcs8_decrypt_returns_null_for_invalid_key | )

## ◆ Ensure() [8/31]

Ensure | ( | sshutils | ,
|  | gvm_ssh_pkcs8_decrypt_returns_null_for_null_pkcs8_key | )

## ◆ Ensure() [9/31]

Ensure | ( | sshutils | ,
|  | gvm_ssh_private_key_info_can_get_just_hash | )

## ◆ Ensure() [10/31]

Ensure | ( | sshutils | ,
|  | gvm_ssh_private_key_info_can_get_just_type | )

## ◆ Ensure() [11/31]

Ensure | ( | sshutils | ,
|  | gvm_ssh_private_key_info_gets_ecdsa_key_type_and_hash | )

## ◆ Ensure() [12/31]

Ensure | ( | sshutils | ,
|  | gvm_ssh_private_key_info_gets_ed25519_key_type_and_hash | )

## ◆ Ensure() [13/31]

Ensure | ( | sshutils | ,
|  | gvm_ssh_private_key_info_gets_rsa_key_type_and_hash | )

## ◆ Ensure() [14/31]

Ensure | ( | sshutils | ,
|  | gvm_ssh_private_key_info_handles_empty_passphrase | )

## ◆ Ensure() [15/31]

Ensure | ( | sshutils | ,
|  | gvm_ssh_private_key_info_handles_encrypted_keys | )

## ◆ Ensure() [16/31]

Ensure | ( | sshutils | ,
|  | gvm_ssh_private_key_info_handles_invalid_private_key | )

## ◆ Ensure() [17/31]

Ensure | ( | sshutils | ,
|  | gvm_ssh_private_key_info_handles_null_hash_pointer | )

## ◆ Ensure() [18/31]

Ensure | ( | sshutils | ,
|  | gvm_ssh_private_key_info_handles_null_passphrase | )

## ◆ Ensure() [19/31]

Ensure | ( | sshutils | ,
|  | gvm_ssh_private_key_info_handles_null_type_and_hash_pointers | )

## ◆ Ensure() [20/31]

Ensure | ( | sshutils | ,
|  | gvm_ssh_private_key_info_handles_null_type_pointer | )

## ◆ Ensure() [21/31]

Ensure | ( | sshutils | ,
|  | gvm_ssh_private_key_info_handles_wrong_passphrase | )

## ◆ Ensure() [22/31]

Ensure | ( | sshutils | ,
|  | gvm_ssh_private_key_info_returns_minus_one_for_null_private_key | )

## ◆ Ensure() [23/31]

Ensure | ( | sshutils | ,
|  | gvm_ssh_public_from_private_generates_ecdsa_public_key | )

## ◆ Ensure() [24/31]

Ensure | ( | sshutils | ,
|  | gvm_ssh_public_from_private_generates_ed25519_public_key | )

## ◆ Ensure() [25/31]

Ensure | ( | sshutils | ,
|  | gvm_ssh_public_from_private_generates_rsa_public_key | )

## ◆ Ensure() [26/31]

Ensure | ( | sshutils | ,
|  | gvm_ssh_public_from_private_handles_empty_passphrase | )

## ◆ Ensure() [27/31]

Ensure | ( | sshutils | ,
|  | gvm_ssh_public_from_private_handles_encrypted_keys | )

## ◆ Ensure() [28/31]

Ensure | ( | sshutils | ,
|  | gvm_ssh_public_from_private_handles_invalid_private_key | )

## ◆ Ensure() [29/31]

Ensure | ( | sshutils | ,
|  | gvm_ssh_public_from_private_handles_null_passphrase | )

## ◆ Ensure() [30/31]

Ensure | ( | sshutils | ,
|  | gvm_ssh_public_from_private_handles_wrong_passphrase | )

## ◆ Ensure() [31/31]

Ensure | ( | sshutils | ,
|  | gvm_ssh_public_from_private_returns_null_for_null_private_key | )

## ◆ main()

int main | ( | int | argc,
|  | char ** | argv )

## Variable Documentation

## ◆ expected_ecdsa_sha256_hash

const char* expected_ecdsa_sha256_hash
| static

Initial value:
=
"e176454f3e3de11a826e3b72a7a3971fbf823dbd464512f14340378b647c209a"

## ◆ expected_ed25519_sha256_hash

const char* expected_ed25519_sha256_hash
| static

Initial value:
=
"62ff0717d25f334662fc5d0ca4ecac4db7b5c1cf57f599aa59f664014a2898ec"

## ◆ expected_rsa_sha256_hash

const char* expected_rsa_sha256_hash
| static

Initial value:
=
"a581ce248a4a7e7a49603712d9ac4c83fdc491cc908eb430af566cb1975d7f3c"

## ◆ test_ecdsa_openssh_private

const char* test_ecdsa_openssh_private
| static

Initial value:
=
"-----BEGIN OPENSSH PRIVATE KEY-----\n"
"b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAaAAAABNlY2RzYS\n"
"1zaGEyLW5pc3RwMjU2AAAACG5pc3RwMjU2AAAAQQTBttsbosZ3Owlvc5aumQJd1W0LMd3X\n"
"gi3XxeQmwiGhFd0R1SahBmxMQdp6VXCyOnuUvrTGstFrQi0t3UsAII45AAAAoHkGdWV5Bn\n"
"VlAAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBMG22xuixnc7CW9z\n"
"lq6ZAl3VbQsx3deCLdfF5CbCIaEV3RHVJqEGbExB2npVcLI6e5S+tMay0WtCLS3dSwAgjj\n"
"kAAAAhAOuN88lVWbYX99J/AgA+VPGoBkO2oN2v1kq7wRBSNI2HAAAAAAECAwQFBgc=\n"
"-----END OPENSSH PRIVATE KEY-----"

## ◆ test_ecdsa_pkcs8_encrypted

const char* test_ecdsa_pkcs8_encrypted
| static

Initial value:
=
"-----BEGIN ENCRYPTED PRIVATE KEY-----\n"
"MIHsMFcGCSqGSIb3DQEFDTBKMCkGCSqGSIb3DQEFDDAcBAjlyxUA9O2PHAICCAAw\n"
"DAYIKoZIhvcNAgkFADAdBglghkgBZQMEAQIEEO719labTRMgZ32j+ZnBT4YEgZBm\n"
"xdt/8ovIPzp07r4rrOJC1tZmoZXeRW8uDMm3OxHx7lV+obwqVh+ZfJHRvFe7ggvT\n"
"riL2tGh/eyTV5F/7mtGGhOFyjMAEgE2vT9TCwYwheQ0R690G5K+Mw3vt4xvVVtgD\n"
"6XoSuak8bnkXri/KmSFaWD650TMmLYGqGTlAzanoNuU7+8IERwYwvOg7QXaGSbA=\n"
"-----END ENCRYPTED PRIVATE KEY-----"

## ◆ test_ecdsa_public_expected

const char* test_ecdsa_public_expected
| static

Initial value:
=
"ecdsa-sha2-nistp256 "
"AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBMG22xuixnc7CW9zlq6ZAl3V"
"bQsx3deCLdfF5CbCIaEV3RHVJqEGbExB2npVcLI6e5S+tMay0WtCLS3dSwAgjjk="

## ◆ test_ed25519_openssh_private

const char* test_ed25519_openssh_private
| static

Initial value:
=
"-----BEGIN OPENSSH PRIVATE KEY-----\n"
"b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW\n"
"QyNTUxOQAAACDc//VteiCk/grV3VBgQZpTZcClYUSe/Jah00ZaETd8BAAAAIgYiPkgGIj5\n"
"IAAAAAtzc2gtZWQyNTUxOQAAACDc//VteiCk/grV3VBgQZpTZcClYUSe/Jah00ZaETd8BA\n"
"AAAEBFmyjnCahpsDze3hjhZTQlH3o+r3/x1b+UX/Pzbx+C2tz/9W16IKT+CtXdUGBBmlNl\n"
"wKVhRJ78lqHTRloRN3wEAAAAAAECAwQF\n"
"-----END OPENSSH PRIVATE KEY-----"

## ◆ test_ed25519_pkcs8_encrypted

const char* test_ed25519_pkcs8_encrypted
| static

Initial value:
=
"-----BEGIN ENCRYPTED PRIVATE KEY-----\n"
"MIGbMFcGCSqGSIb3DQEFDTBKMCkGCSqGSIb3DQEFDDAcBAjJzcFV4nR8QgICCAAw\n"
"DAYIKoZIhvcNAgkFADAdBglghkgBZQMEASoEELktrSEPHfD5f7p/W2OAyusEQC8R\n"
"d20mo9N7ywH+619oLIA52Xn7jXefbT/GXBmBPo0GaQV0f0ueg9R0g9rXXu2EgIIG\n"
"LQXgDsbD4kdN6Op41FY=\n"
"-----END ENCRYPTED PRIVATE KEY-----"

## ◆ test_ed25519_public_expected

const char* test_ed25519_public_expected
| static

Initial value:
=
"ssh-ed25519 "
"AAAAC3NzaC1lZDI1NTE5AAAAINz/9W16IKT+CtXdUGBBmlNlwK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EZB6IgV\n"
"dlEZR+MS94rDuR5JwlyCd4wScg8uVL0SwOe7WFXhYDPVf3NeiHQc7ae7fE+IpJGy\n"
"RKqIeOPYWQcUa4NgMAv3qMA=\n"
"-----END ENCRYPTED PRIVATE KEY-----"

## ◆ test_rsa_pkcs8_unencrypted

const char* test_rsa_pkcs8_unencrypted
| static

Initial value:
=
"-----BEGIN PRIVATE KEY-----\n"
"MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAM1akpXjXsXSgeKC\n"
"FTc+k9x97hGN5bECPYTvP07rod0/UeDI5GQpcA8bpyB8v1QQatYRKRIIcLt+qW3r\n"
"qBiXDVG5WN9+ei8m3hvKzjGenbPfP9a50t86df5te1RAWbncZJPHPr4TjgFVh64+\n"
"7QVv5HrqXLVSKczVKwLtXJaHzi/fAgMBAAECgYBrTNwzPa8Tpr7/YAE98JDKMXLn\n"
"8UEHkKgcgfaOgkj9lkxuLApK2+wVuNlG/GfswPdSC31uUsK09aYKLYyT7Lmj/Zcb\n"
"NnrDDcVxK3AtQIlvIgEwO766riv91vPXRiig2xHkyzFJnyDjev9F5gB36LbMU5ZN\n"
"3lJswD6lgw30BlDMYQJBAPt2W6ws1AbfoJQJTob2hLRSAmCf/x+Fvv2lb5YINogj\n"
"2P+vq51i4YQhYOiIO1vdl0qhfhj+TdyIQ/A7jsb5+B0CQQDRDzbHhbY0p0MUT4rX\n"
"2Ysfrt3pEe8cHVdtT6RMiw3IUODWhlWXQJrmV1BgyEM05mgbRWMGz5xgOXG8it0y\n"
"/h8rAkBgm1YYzZgfk+aDORgcLbVJ+X/EU3OWTrHTjK1T/I/Guc7yXDEYZBazxocO\n"
"jtgPMRCgsW5ad8i+AvPm5VqzAvHZAkEAsWLvYCycheDGkh1L+gqkeaWutWx6LqjW\n"
"3fGNv0Td1PKLVHt3dHdk971ufjBulhxKiZk+hTDzxtH3J7vMJNBrMQJBAL/r0j0+\n"
"DgBywIZkjLzJwn3w4/wRl6YSr8DRgu8CtTFVozjkA177NpVzznlvfQU8RdNG3bbt\n"
"nw3vL7hUSbuvhmY=\n"
"-----END PRIVATE KEY-----"

## ◆ test_rsa_public_expected

const char* test_rsa_public_expected
| static

Initial value:
=
"ssh-rsa "
"AAAAB3NzaC1yc2EAAAADAQABAAAAgQDNWpKV417F0oHighU3PpPcfe4RjeWxAj2E7z9O66HdP1Hg"
"yORkKXAPG6cgfL9UEGrWESkSCHC7fqlt66gYlw1RuVjffnovJt4bys4xnp2z3z/"
"WudLfOnX+bXtUQFm53GSTxz6+E44BVYeuPu0Fb+R66ly1UinM1SsC7VyWh84v3w=="