tests: Add ed25519 encrypted keys import
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Этот коммит содержится в:
родитель
423fa6818b
Коммит
b76d37b341
@ -209,6 +209,16 @@ static const char torture_ed25519_testkey_pub[]=
|
|||||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBWWnxuCYiOyvMYLtkgoEyEKlLV+klM+"
|
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBWWnxuCYiOyvMYLtkgoEyEKlLV+klM+"
|
||||||
"BU6Nh3PmAiqX aris@kalix86";
|
"BU6Nh3PmAiqX aris@kalix86";
|
||||||
|
|
||||||
|
static const char torture_ed25519_testkey_pp[]=
|
||||||
|
"-----BEGIN OPENSSH PRIVATE KEY-----\n"
|
||||||
|
"b3BlbnNzaC1rZXktdjEAAAAACmFlczI1Ni1jYmMAAAAGYmNyeXB0AAAAGAAAABB3FWpQcE\n"
|
||||||
|
"KHKq6PcjkxjmKzAAAAEAAAAAEAAAAzAAAAC3NzaC1lZDI1NTE5AAAAIOGFVuOyZBL0T+NR\n"
|
||||||
|
"C7qEV9qr6QiGhz2XSXrxuQoU84FgAAAAkBlOVfS5U7FxtBEtxfxQhZjrZAj2z9d4OfGRPl\n"
|
||||||
|
"ZfCnAJNEM3BZ3XCabsujhMkqEs9eptRfj41X6NA8aSFs5JYT+JFVfg470FKtpyUmAibMIo\n"
|
||||||
|
"JzI41zAncFd1x7bAgO5HBDe3xNsV159D+sXRkWB9Tzk0l4F8SZvInheIS7VSbqH7t1+yDB\n"
|
||||||
|
"Y3GsmYTDstmicanQ==\n"
|
||||||
|
"-----END OPENSSH PRIVATE KEY-----\n";
|
||||||
|
|
||||||
static int verbosity = 0;
|
static int verbosity = 0;
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
@ -585,24 +595,30 @@ static const char *torture_get_testkey_internal(enum ssh_keytypes_e type,
|
|||||||
if (bits == 521) {
|
if (bits == 521) {
|
||||||
if (pubkey) {
|
if (pubkey) {
|
||||||
return torture_ecdsa521_testkey_pub;
|
return torture_ecdsa521_testkey_pub;
|
||||||
|
} else if (with_passphrase) {
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
return torture_ecdsa521_testkey;
|
return torture_ecdsa521_testkey;
|
||||||
} else if (bits == 384) {
|
} else if (bits == 384) {
|
||||||
if (pubkey) {
|
if (pubkey) {
|
||||||
return torture_ecdsa384_testkey_pub;
|
return torture_ecdsa384_testkey_pub;
|
||||||
|
} else if (with_passphrase){
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
return torture_ecdsa384_testkey;
|
return torture_ecdsa384_testkey;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pubkey) {
|
if (pubkey) {
|
||||||
return torture_ecdsa256_testkey_pub;
|
return torture_ecdsa256_testkey_pub;
|
||||||
|
} else if (with_passphrase){
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
return torture_ecdsa256_testkey;
|
return torture_ecdsa256_testkey;
|
||||||
case SSH_KEYTYPE_ED25519:
|
case SSH_KEYTYPE_ED25519:
|
||||||
if (pubkey) {
|
if (pubkey) {
|
||||||
return torture_ed25519_testkey_pub;
|
return torture_ed25519_testkey_pub;
|
||||||
} else if (with_passphrase) {
|
} else if (with_passphrase) {
|
||||||
return NULL;
|
return torture_ed25519_testkey_pp;
|
||||||
}
|
}
|
||||||
return torture_ed25519_testkey;
|
return torture_ed25519_testkey;
|
||||||
case SSH_KEYTYPE_RSA1:
|
case SSH_KEYTYPE_RSA1:
|
||||||
|
@ -350,6 +350,24 @@ static void torture_pki_import_privkey_base64_passphrase(void **state) {
|
|||||||
assert_true(rc == -1);
|
assert_true(rc == -1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* same for ED25519 */
|
||||||
|
|
||||||
|
rc = ssh_pki_import_privkey_base64(torture_get_testkey(SSH_KEYTYPE_ED25519, 0, 1),
|
||||||
|
passphrase,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
&key);
|
||||||
|
assert_true(rc == 0);
|
||||||
|
ssh_key_free(key);
|
||||||
|
|
||||||
|
/* test if it returns -1 if passphrase is wrong */
|
||||||
|
rc = ssh_pki_import_privkey_base64(torture_get_testkey(SSH_KEYTYPE_ED25519, 0, 1),
|
||||||
|
"wrong passphrase !!",
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
&key);
|
||||||
|
assert_true(rc == -1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void torture_pki_import_privkey_base64_ed25519(void **state){
|
static void torture_pki_import_privkey_base64_ed25519(void **state){
|
||||||
|
Загрузка…
Ссылка в новой задаче
Block a user