use bc_envelope::prelude::*;
use indoc::indoc;

mod common;
use common::*;

const SEED: &str = "ur:seed/oyadhdcxhsinuesrennenlhfaopycnrfrkdmfnsrvltowmtbmyfwdafxvwmthersktcpetdweocfztrd";
const PRVKEYS: &str = "ur:crypto-prvkeys/lftansgohdcxpfsndiahcxsfrhjoltglmebwwnnstovocffejytdbwihdkrtdykebkiebglbtteetansgehdcxvsdapeurgauovlbsvdfhvdcevywlptspfgnejpbksadehkhkfzehhfaysrsrbsdstbtagyeh";
// const PUBKEYS: &str =
// "ur:crypto-pubkeys/
// lftanshfhdcxayvazmflzsfrotemfxvoghtbynbsgywztlheisvapypmidzmaoldisdybkvdlerytansgrhdcxfdgwgacloxsrmupdcybdchfylewsdilrbestjodpwnknndjoztjprfkkjopkdejobebtdlhd"
// ;
const COMMENT: &str = "comment";

#[test]
fn test_generate_random_private_key_base() {
    let prvkeys = run_cli(&["generate", "prvkeys"]).unwrap();
    assert_eq!(
        UR::from_ur_string(prvkeys).unwrap().ur_type_str(),
        "crypto-prvkeys"
    );
}

#[test]
fn test_generate_private_key_base_from_seed() {
    let prvkeys = run_cli(&["generate", "prvkeys", SEED]).unwrap();
    assert_eq!(prvkeys, PRVKEYS);
}

#[test]
fn test_generate_keypairs_random() {
    bc_envelope::register_tags();

    // Test with default algorithms (schnorr + x25519)
    let output = run_cli(&["generate", "keypairs"]).unwrap();
    let parts: Vec<&str> = output.split_whitespace().collect();
    assert_eq!(parts.len(), 2, "Expected two URs separated by a space");

    // Verify both are valid URs with correct types
    let prv_ur = UR::from_ur_string(parts[0]).unwrap();
    let pub_ur = UR::from_ur_string(parts[1]).unwrap();
    assert_eq!(prv_ur.ur_type_str(), "crypto-prvkeys");
    assert_eq!(pub_ur.ur_type_str(), "crypto-pubkeys");

    // Verify the keys can be parsed and are compatible
    let prvkeys_ur_string = parts[0];
    let pubkeys_ur_string = parts[1];
    println!("{}", prvkeys_ur_string);
    println!("{}", pubkeys_ur_string);
    let private_keys =
        bc_components::PrivateKeys::from_ur_string(prvkeys_ur_string).unwrap();
    let public_keys =
        bc_components::PublicKeys::from_ur_string(pubkeys_ur_string).unwrap();
    // Verify we can derive the same public keys from private keys
    let derived_public_keys = private_keys.public_keys().unwrap();
    assert_eq!(derived_public_keys.ur_string(), public_keys.ur_string());
}

fn test_keys(
    key_type: &str,
    expected_prvkeys: &str,
    expected_pubkeys: &str,
    expected_signature_summary: &str,
) {
    // Generate prvkeys with the appropriate signing type
    let prvkeys =
        run_cli(&["generate", "prvkeys", "--signing", key_type, SEED]).unwrap();
    assert_eq!(prvkeys, expected_prvkeys);

    let pubkeys =
        run_cli(&["generate", "pubkeys", &prvkeys, "--comment", COMMENT])
            .unwrap();
    assert_eq!(pubkeys, expected_pubkeys);

    let signed = run_cli(&[
        "sign",
        "--signer",
        &prvkeys,
        "--namespace",
        "test",
        ALICE_KNOWS_BOB_EXAMPLE,
    ])
    .unwrap();

    #[rustfmt::skip]
    let expected_format = indoc!(r#"
        "Alice" [
            "knows": "Bob"
            'signed': {}
        ]
    "#);
    let expected_format =
        expected_format.replace("{}", expected_signature_summary);
    run_cli_expect(&["format", &signed], &expected_format).unwrap();

    run_cli(&["verify", &signed, "--verifier", &pubkeys]).unwrap();
}

#[test]
fn test_schnorr() {
    test_keys(
        "schnorr",
        "ur:crypto-prvkeys/lftansgohdcxpfsndiahcxsfrhjoltglmebwwnnstovocffejytdbwihdkrtdykebkiebglbtteetansgehdcxvsdapeurgauovlbsvdfhvdcevywlptspfgnejpbksadehkhkfzehhfaysrsrbsdstbtagyeh",
        "ur:crypto-pubkeys/lftanshfhdcxayvazmflzsfrotemfxvoghtbynbsgywztlheisvapypmidzmaoldisdybkvdlerytansgrhdcxfdgwgacloxsrmupdcybdchfylewsdilrbestjodpwnknndjoztjprfkkjopkdejobebtdlhd",
        "Signature",
    );
}

#[test]
fn test_ecdsa() {
    test_keys(
        "ecdsa",
        "ur:crypto-prvkeys/lftansgolfadhdcxpfsndiahcxsfrhjoltglmebwwnnstovocffejytdbwihdkrtdykebkiebglbtteetansgehdcxvsdapeurgauovlbsvdfhvdcevywlptspfgnejpbksadehkhkfzehhfaysrsrbsdsuoamcehg",
        "ur:crypto-pubkeys/lftanshflfadhdclaoayvazmflzsfrotemfxvoghtbynbsgywztlheisvapypmidzmaoldisdybkvdlerytansgrhdcxfdgwgacloxsrmupdcybdchfylewsdilrbestjodpwnknndjoztjprfkkjopkdejomecapkpr",
        "Signature(Ecdsa)",
    );
}

#[test]
fn test_ssh_ed25519() {
    test_keys(
        "ssh-ed25519",
        "ur:crypto-prvkeys/lftansgotanehnkkadlsdpdpdpdpdpfwfeflgaglcxgwgdfeglgugufdcxgdgmgahffpghfecxgrfehkdpdpdpdpdpbkideofwjzidjtglknhsfxehjphthdjejyieimfefpfpfpfpfpfwfleckoidjngofpfpfpfpfeidjneskphtgyfpfpfpfpfpfpfpfpfpfwfpfpfpfpgtktfpfpfpfpjykniaeyiojyhthgbkgykkglghgoksgwgyfpfpfpfxfpiheskokkdliekogwkokoeyfyemjyeckoihidkkjnemhsjnisjehtjnecghehjtknfyeyimjnhggwdlesgshdktfpfpfpgaimjkeejpgyjlemgwgrdybkgrfpfpfpfpfpjykniaeyiojyhthggykkglghgoksgwgyfpfpfpfxfpiheskokkdliekogwkokoeyfyemjyeckoihidkkjnemhsjnisjehtjnecghehjtknfyeyimjnhggwdlesgshdktbkfpfpfpfefyidiaesjpgdjojpioioidjkkokpiaghgugsjsjlflkphdidiahtecihgyktjsinfxecehfgfykpdygheciegwfwemeydlgseseyetendndlhkgdkpeojneseckogridjyjsbkhsflgmjnidjzgdhgiygtgdhsgwhthkemdldyjyiyfpfpfpfpfpfpfefxfpktgyfgbkdpdpdpdpdpfeglfycxgwgdfeglgugufdcxgdgmgahffpghfecxgrfehkdpdpdpdpdpbktansgehdcxvsdapeurgauovlbsvdfhvdcevywlptspfgnejpbksadehkhkfzehhfaysrsrbsdsmejlckmn",
        "ur:crypto-pubkeys/lftanshftanehskshdjkjkisdpihieeyececehescxfpfpfpfpfxeoglknhsfxehjzhtfygaehglghfeecfpfpfpfpgafwemeydlgseseyetendndlhkgdkpeojneseckogridjyjshsflgmjnidjzgdhgiygtgdhsgwhthkemdldyjyiycxiajljnjnihjtjytansgrhdcxfdgwgacloxsrmupdcybdchfylewsdilrbestjodpwnknndjoztjprfkkjopkdejogoimkkkt",
        "Signature(SshEd25519)",
    );
}

#[test]
fn test_ssh_ecdsa_nistp256() {
    test_keys(
        "ssh-ecdsa-p256",
        "ur:crypto-prvkeys/lftansgotanehnkkadvtdpdpdpdpdpfwfeflgaglcxgwgdfeglgugufdcxgdgmgahffpghfecxgrfehkdpdpdpdpdpbkideofwjzidjtglknhsfxehjphthdjejyieimfefpfpfpfpfpfwfleckoidjngofpfpfpfpfeidjneskphtgyfpfpfpfpfpfpfpfpfpfwfpfpfpfphsfpfpfpfpfwgljzhkeygmknhkgubkehknhsflfekkgshgecjoiaeogmktgtimgoeyfpfpfpfpfxflecjoiaeogmktgtimgoeyfpfpfpfpgygygmkpingsisjefgfdgeesjyjygheygakninhdjegohkinhdeoeyhthtjkgyjpbkgwktihjpjninethtdygljlgdglemeyjnemidjygheoineodykpjsjoehgrgmhsfwguglgegdkkjlgdfxfgdnemhdjseefleceyemingsfygufwgtfpfpfpfpjngwhggsfxgykojzinktbkjegsfpfpfpfpfeeyhfimhtfdglisgshdgljlhkghgajyidjnjzkniefdfpkkglghhkfpfpfpfpgaidjnjzkniefdfpkkglghhkfpfpfpfwfwfwflengakpflgygoiajteyeyehgdhkimbkgwgeihgmgmingeiyiyhtjzjnksfxjkemfwenkphsgsksjtgyeyioeteokohsidjykpehgdihgsiyguenjsjtgojofgjlfggadyjedlgrioetgahdemjyihjpioidjtidkpgajkglgafebkktfpfpfpfpiofdjeeegreeengtktgleejpeoiaesimjnjtjteyjzglkkghimhkiydnemdlgaghgdindngsiojlkkgoflghfxfpfpfpfpfpfpbkdpdpdpdpdpfeglfycxgwgdfeglgugufdcxgdgmgahffpghfecxgrfehkdpdpdpdpdpbktansgehdcxvsdapeurgauovlbsvdfhvdcevywlptspfgnejpbksadehkhkfzehhfaysrsrbsdshprhjszt",
        "ur:crypto-pubkeys/lftanshftanehskspdihiaiejkhsdpjkishseydpjtinjkjyjoeyecencxfpfpfpfpfeeyhfimhtfdglisgshdgljlhkghgajyidjnjzkniefdfpkkglghhkfpfpfpfpgaidjnjzkniefdfpkkglghhkfpfpfpfwfwfwflengakpflgygoiajteyeyehgdhkimgwgeihgmgmingeiyiyhtjzjnksfxjkemfwenkphsgsksjtgyeyioeteokohsidjykpehgdihgsiyguenjsjtgojofgjlfggadyjedlgrioetgahdemjyihjpioidjtidkpgajkglgafektfscxiajljnjnihjtjytansgrhdcxfdgwgacloxsrmupdcybdchfylewsdilrbestjodpwnknndjoztjprfkkjopkdejodlztswca",
        "Signature(SshEcdsaP256)",
    );
}

#[test]
fn test_ssh_ecdsa_nistp384() {
    test_keys(
        "ssh-ecdsa-p384",
        "ur:crypto-prvkeys/lftansgotanehnkkaohtdpdpdpdpdpfwfeflgaglcxgwgdfeglgugufdcxgdgmgahffpghfecxgrfehkdpdpdpdpdpbkideofwjzidjtglknhsfxehjphthdjejyieimfefpfpfpfpfpfwfleckoidjngofpfpfpfpfeidjneskphtgyfpfpfpfpfpfpfpfpfpfwfpfpfpfpinfpfpfpfpfwgljzhkeygmknhkgubkehknhsflfekkgshgecjoiaeogmktgtkniodyfpfpfpfpfxflecjoiaeogmktgtkniodyfpfpfpfphkgygmgwglfwiegthsgujehffeeyfdhgeekokkjlgmghengyhdjyghjnenhginknbkieenfyjsfwjzehhtflgsetihgohgeyetkpimemfdfwinhgihksimglgaindyjtjljshsgrgdgtjzdygwksfphffeiahkisingajzgsenfdehjpemiygeihfwgoiegmjyjkgugafxglgabkeogyjliyglisguidfdhfgliaishkdlflhdgsfygakoeehtkpgodljoeyjlfpfpfpfygyioeseefegtgagdihfwfyfpfpfpfpfpghhthggljeiaeyfejyiaeyisisgtinehkphshdgldybkiafygteeglfpfpfpfpfpiskphshdgldyiafygteeglfpfpfpfpflfefeghimgyhdghfljejofggmglisehkpgsetjsfegodnjefgemgoeckpjzjljkeoihioeniohtiehggmindlfdjzbkfgjykogsjldnkskthkjzjtjkhkkngugajygeengrjninimkngeiefyjkgyfggmfdflgahkingegudniseshsdneokkhdiohffdgoididfeinfpimgugldygrfdknhkgojnksehghhdgabkhggdksjzkkktkkgsdnflidjzgdeniejsfpfpfpfpgtgyfxjljejtjygdinidgmfejliaiadlehglioiejofddnhdkojleejpjejehdenglesjyjofldliagrjljkgeisdyjeksjekojybkdyfgihkkesktknhkioehfpetkshtkojseefpfpfpfpfpfpgygafyfwfpgoflfwktfsfsbkdpdpdpdpdpfeglfycxgwgdfeglgugufdcxgdgmgahffpghfecxgrfehkdpdpdpdpdpbktansgehdcxvsdapeurgauovlbsvdfhvdcevywlptspfgnejpbksadehkhkfzehhfaysrsrbsdswnecfzhf",
        "ur:crypto-pubkeys/lftanshftanehskstyihiaiejkhsdpjkishseydpjtinjkjyjoeoeteecxfpfpfpfpfeeyhfimhtfdglisgshdgljlhkghgajyidjnjzkniefdfpkngwfygyfpfpfpfpgaidjnjzkniefdfpkngwfygyfpfpfpfwisfwfeeedyfgdyksjogrgmgoghhkieidindlgrisfggdjofwihehgwidjohsgsgleojlgwjlflhdhfjehkkoksecgmididkkengdjkiaflgehtemflgtdyingsguihinjojljletkkhdgyemfefwgogmksinflgaingokojliyhgkojyetjzeefggmehfleyksgaiogadyimiefxiseteyfggejkiegoehkkfgimethtiajkgtindlisjnecghdnjthsiofsfscxiajljnjnihjtjytansgrhdcxfdgwgacloxsrmupdcybdchfylewsdilrbestjodpwnknndjoztjprfkkjopkdejoltvdgula",
        "Signature(SshEcdsaP384)",
    );
}

// Disabled due to a bug in the ssh-key crate.
// See: https://github.com/RustCrypto/SSH/issues/232
// #[test]
// #[ignore]
// fn test_ssh_ecdsa_nistp521() {
// }

// Particularly slow, so disabled by default.
#[test]
#[ignore]
fn test_ssh_dsa() {
    test_keys(
        "ssh-dsa",
        "ur:crypto-prvkeys/lftansgotanehnkkahgydpdpdpdpdpfwfeflgaglcxgwgdfeglgugufdcxgdgmgahffpghfecxgrfehkdpdpdpdpdpbkideofwjzidjtglknhsfxehjphthdjejyieimfefpfpfpfpfpfwfleckoidjngofpfpfpfpfeidjneskphtgyfpfpfpfpfpfpfpfpfpfwfpfpfpfwjkiofpfpfpfpiekniaeyiojyhtfdbkglknfpfpfpfpiogyfyktgukogeeneyhtfgeoeoiaidiaglingajehfeyfdgaeydnktkshgioidfdhtiaeygrhfjkgodyiekohtgtjefefwjpiejngwkpgajkiekokoiojoiojsgwgdgubkiygofejsgmetfgjlflhffwihhfgyhfhffektdyksisjkghdnetiagmfekphdindykoeyfdeoemjeihdlflfgeeflgmflktfekphsjnknhgeheyfweyflgmfghfjtkniseodyenjegyktbkjegohsecfxfxiyguhfgajoksjektghguiykkgtktdljseojyihkokteoghguetjojzhgiaglemiojpgyfpfpfpfwgofpehfwkofejkisfdkoiofgjoeeghgrhkgdetjpidknidkpguetbkgtdlgtfpfpfpfxfpgoiddyhdglghhfjnhggrfxioisiyfdgheyfgfxishfehiohgjsjljlguehhgiseyjkfdeeiafwecfgktgdgrjlgugdidenkpdyjsiheykoemjnjojohdgoguemenbkgsksktiddnhsgwgujefwendyjzkpeegrfygyhgetinfwgwjlecgyeeghjyeohfhfjkfpjljnemgoiokthdgtgughidhfimfxgdgsdngrjtflfwiyjpkpgtjofwhkjehdgeiohtgtfegrbkhdkpdyjkknhsfygmehgyjyisiogujykngmhtjleteoguhkgyhfdyihiokseygtihgwgyfeeoiahdjlfpfpfpfxfwfpgrflkngmkoeshgktgwgskkesehdnhggmkteyhgimioiyfeihenbkehenhfjtjtiniyjlhfioiafljlktfwdlehjleojyeejoieghhthsfefdisfdineegrknjlenhfhtisiydleyeofehkhdhdetjpksdyeodygrfxjyjlgtgdihfwieghjtgsjngodnetfwbkjkjeglecghkkfljoguiehtgriakkkogrkojlktkndlimhdfxjnineefeeejyhkenjtfxjnkngojpiogyhsgakogljygyfgdyeeeyehjyeyfykshfhgkpjzhfknjoknfehtiohkjphthtbkgykkjsieiodlfpfpfpfweygegtgegtfwgrghfxghfpgufpfpfpfpfweoglknhsfxehjeiaeogtfpfpfpfxfwfpgdfwgretjtjphtjehdiyieksjykteygaingmhdhkiaimidemfyfghsbkfwjkiejzknhkjohgksghgmeyesjekkgygyfljyeyhkeneeinkseydndnfxjnfxjleeesgeesgygujofdkthgiohtgofgechffwhfgoghfyghflflksgdemksksfeguecihgsgudlhkiybkiykpgmemethkhdiohtfeidfpguecjsidglidhdhkfdhkhtfehfhgiygwfdiyghjsgmfyfxgmgmjpjegageesgegoinjtflghfwglgedlgaknfydnjpihehendlfyieglgskkjnhfhtktbkeokpfxjyfpfpfpfpfggyfygofletgukkfeihdnfphgjtisgtjoiodlkkjykoglkpecgsktknetktfpfpfpgafwgmkogmiaehglhghthkjlgrfxfgetiegdhkgogrfghdhgfwhsjsinisbkgshfhsfdhsktiyisktfdjehdfpetjsisgaeskojsemgujoemhsdlkphsjnjziegmgskojlkofdfwkoecjlecgrgyfdjpguhgemiojlglfwidkkgafeenimjzfyisgweoiehfhgktfxinbkidjygufyfwiaksgegljyhggtgaetkoeejsiahkfgdnkpeekkjefgingmiajnfwjektgyjoihemgukngljlglfdhffxeyflfwgreoglfgjnimkniegeisfwhdgmenfyfdhkkseeecfpghbkieksihiofpfpfpgafefpjlidglfldlehidfpeekogseohdechtfdfyhthsgwfwetgmemjphdjohgihihgednishgfwkthsimfpfddlhgimiheoinjzehgljzjlgyihfeihgsiojpgwimbkjohfjnfgdldlidiagmisieiykkkofdghiygyjlgreyiokteseefgehgwiakphtghemktflkkgyeojzgdgahsjzgeehjejokngretjsdnimfygddngliagrhsgsioghinehimjsiagridbkglgukpfwfwjlineteyehfphdghimidhgeohkgdfghfhsenhfhdgwjtgtgmjnfwinjyjzjzfygrjoeyfyetfpfpfpfpgogygtgoflioesfxiefxiyeoeojzgejsfgetgsingdjyfpgmesbkgrjzdyfpfpfpfpfpfpgygafsbkdpdpdpdpdpfeglfycxgwgdfeglgugufdcxgdgmgahffpghfecxgrfehkdpdpdpdpdpbktansgehdcxvsdapeurgauovlbsvdfhvdcevywlptspfgnejpbksadehkhkfzehhfaysrsrbsdstbtlcwiy",
        "ur:crypto-pubkeys/lftanshftanehskkaoghjkjkisdpiejkjkcxfpfpfpfpfweoglknhsfxehjeiaeogtfpfpfpfxfwfpgdfwgretjtjphtjehdiyieksjykteygaingmhdhkiaimidemfyfghsfwjkiejzknhkjohgksghgmeyesjekkgygyfljyeyhkeneeinkseydndnfxjnfxjleeesgeesgygujofdkthgiohtgofgechffwhfgoghfyghflflksgdemksksfeguecihgsgudlhkiyiykpgmemethkhdiohtfeidfpguecjsidglidhdhkfdhkhtfehfhgiygwfdiyghjsgmfyfxgmgmjpjegageesgegoinjtflghfwglgedlgaknfydnjpihehendlfyieglgskkjnhfhtkteokpfxjyfpfpfpfpfggyfygofletgukkfeihdnfphgjtisgtjoiodlkkjykoglkpecgsktknetktfpfpfpgafwgmkogmiaehglhghthkjlgrfxfgetiegdhkgogrfghdhgfwhsjsinisgshfhsfdhsktiyisktfdjehdfpetjsisgaeskojsemgujoemhsdlkphsjnjziegmgskojlkofdfwkoecjlecgrgyfdjpguhgemiojlglfwidkkgafeenimjzfyisgweoiehfhgktfxinidjygufyfwiaksgegljyhggtgaetkoeejsiahkfgdnkpeekkjefgingmiajnfwjektgyjoihemgukngljlglfdhffxeyflfwgreoglfgjnimkniegeisfwhdgmenfyfdhkkseeecfpghieksihiofpfpfpgafefpjlidglfldlehidfpeekogseohdechtfdfyhthsgwfwetgmemjphdjohgihihgednishgfwkthsimfpfddlhgimiheoinjzehgljzjlgyihfeihgsiojpgwimjohfjnfgdldlidiagmisieiykkkofdghiygyjlgreyiokteseefgehgwiakphtghemktflkkgyeojzgdgahsjzgeehjejokngretjsdnimfygddngliagrhsgsioghinehimjsiagridglgukpfwfwjlineteyehfphdghimidhgeohkgdfghfhsenhfhdgwjtgtgmjnfwinjyjzjzfygrjoeyfyetfscxiajljnjnihjtjytansgrhdcxfdgwgacloxsrmupdcybdchfylewsdilrbestjodpwnknndjoztjprfkkjopkdejomsaadihh",
        "Signature(SshDsa)",
    );
}

// Disabled due to tests not working correctly for undiagnosed reasons.
// Particularly slow, so disabled by default.
// #[test]
// #[ignore]
// fn test_ssh_rsa_sha256() {
//     test_keys(
//         "ssh-rsa-sha256",
//         "ur:crypto-prvkeys/lftansgotanehnkkatatdpdpdpdpdpfwfeflgaglcxgwgdfeglgugufdcxgdgmgahffpghfecxgrfehkdpdpdpdpdpbkideofwjzidjtglknhsfxehjphthdjejyieimfefpfpfpfpfpfwfleckoidjngofpfpfpfpfeidjneskphtgyfpfpfpfpfpfpfpfpfpfwfpfpfpfwfgktfpfpfpfpiekniaeyiojyiajtbkglisfpfpfpfpfpktfefpfpgyfpfpfpgyfefpeciagajkjyfghkhfjyfgiogyjnkpgsfphgethsioeyehgsihjsjtkpgwjsishsgojokpihidiaimguenjndliejnfljpgdgmhdecgeisbkgsineogsktfxesieeskpfgeofgiefxgmkkhkglgyflktjtgwjoeoguidgwfxfljngujphdhfjsjzjkgudlkpeshkjyjygsgtgajniykshtingsetfxfwfpksknimimjnhseydnjyfejybkjlehisdljehgfggdhsfxiegdjkieeyfpkketjngajzjpiygyjpknjtgrghgahdjpjzdlglghfyglfwjngrksecidhkfggahkiyiagedninisidhtgtenjnjojsfxgwjlimgmhsimfgiebkgwghgugugukpgaktdyfxfgemfdhsglgrfpdlfpkkjlkkfyeojpehjodyjlfweehkfpeckshgdyihgdiojpjngwjyfygrhgdlhffxeseejyetfwioeteoecisjlinhtecgletjlgteyehbkgdgeiyieihjzgegdfgfdjpeykteyihhfgrhsiakohfehecjyhkfwfpiyiodyfdhtiahghgguiaecfdeegydyiogdetihjeknenidghgljlgdgudlfwdyjeiekkhtkpgdgsfygwiykpjpbkgriehfkkkthtflesisktfpfpfpemimhkghfykpdleyfektemkoktfpfpfpfpiekniaeyiojyiajtglisfpfpfpfwfpgyfyjzktinkkdyhfishgdyhgfwfxhseejkfwidksjsfyidgojybkenjsiheeenjsfgjogujnececjykkglgsjsideseyhkhsjkesfgiyjejnfekpgsiakofpgseheoeyeehdiahfdygefdgeioehfpidfxiaenjtiegejkeegahshtgrjyiehgjshgksgsdnbkemehineydyjkktinhtdlfgjngakoktgafefyfdgwgwgwhtjpidendygueyimhgfddngmhkgoesjlgedydnkseohkfygskkhkinhgjyesfxkogwiajogtisihkphdetehgtgtdyflhkjpbkfdjzjyiogoisisesktjtengrfgjyjeknjshsjnjlgaeninglfgjsgthfdyecglgegegreeimfygygahdjkiejldyjlfyetfygrimgagdihkohgjtguiofdisiofyjtfgidgmeednfxkpbkhkendygtjoidesgogseoineoktflfykniyjnflingejtjeeokkioknidgoetjzesehengojeetgoihkoidfyhtecgojojokkeshdhdjnehiofefwdnfygyiejzkshthtgeknjeiyisfybkgufpdlksenghgdjojygteyioesgsetfdgugmeogejneeetjkgtecdnenjkjoehhdgsfwjeideyfdfpfpfpfpfpktfefpfpgyfpfpfpgyfefpkpiygogleoenkpjofweodyidiheofxecbkgmiaenihehgtghihkkhfiahfjlieenfxehfpdnkkkshteyieksenkshggsgeingsisjtfdioguesgskofygyengehgetetinhtimjshkglflgyihinjpgdflhgiaksgsetgyglkngeksbkidfxeceeeyjketknesiygrkkflknemgtimenfdidgwfgfyknhgjeguioiygljtkojehfgwgrgdenfdhsgeisehdlihjljlgwkpengdgwjlhsfdjkesinihkkglgefwkpisjpetfwidjkbkkphgehhffeenkndlehguetiagwioghflgrjsgoimhgfejsfpgyenjkehioememhdjpjohfjskshfjsfljniydyfxflktgmhdfeenfpeciofweygtfejlehgyjtinjyglgwemimktknecbkkkinimetdngugmjejnfwihgtjlhsgmjeidgednenjykneoeejtkohkjeiehsfejtenfggsidgagrjlgrjkfgglgaesjsgskohsjofpecgthsechsemeyisjtjsehjkgsenfdjtgahkkkbkfxehetdnghfggwkpeofehgjtjpehehgeeegoguengsgejohsjeksgtinfdgtisimdlglguhkdygtkpjlisjydyisfpgyfpfpfpgafefpjefpdyinfegajektjofdiehsimjpghknemgrbkgeeydyhdktjnfdkpeyguhgjtesgtfxgletkkihdlihimhdioguetjtfgjyeshdiajtjtecjoiseeiajsimkpgsknenjygskkiajoeyjefwgegsiefwfwkpfygukkfwfxgefpihetghhfbkgljygegtjyideekkdngsfljzghecjtkodyfyguguiefwgyfydnhsiyghetflknfdfgeoiadyiygajyethsfdfxfxgajsididfyimecidihghidgtjoeogwfyjlglgaghgtehiefdihhtbkgldlgrkofeisgljnidhkhtdlktfpfpfpfxfwfpgdksimeyidkpidjogliafphkihghhkfpjeemkneskngajsesiejkjkgrgegtetgahtflfwfyimflhgfejokngykthsgshffwdngrhfbkeneyfxineeksjliafgesesesimeshshsjziejzdyjofpeofwgsiajyfdgohdjlendngujkjtjyjsfpiheoehhdjojsgtfpgdiojeghhffdgtisjneoemecgagseokkfxgygsfleciyeebkisihgojthgesjedlecjygsgdhggeglgljnidingmjyhghfjohkfdgljphtgaiohdgdjkjyfyghhgehjsjzgejnetgagmfdjngufwfpfpfpfpiogyfyjofxeoghjegteodleeimioktgabkjnkthtihkpgrfljzisknkpdlgoemiojkfximimgleefpeniahgfwgtioioeeeneofxgogljzfygeingwkkgogujzechkisjygyflehgogsflfdjnjthfimiekojlgujnfxiejskkkkghbkhgingehtjeimhkjsjodyjykpgddlfdguguieinhsemjyiaeygueekpjofgjtkkhdgudndnkpkoeefwhdgdingsgsjsgtemkoesidknehjejogdfgjojsdygdkkfxihidglehhshtemdlbkdyknjpecenguiaisetiaesiahseehddnfwktfpfpfpfpfpfwbkdpdpdpdpdpfeglfycxgwgdfeglgugufdcxgdgmgahffpghfecxgrfehkdpdpdpdpdpbktansgehdcxvsdapeurgauovlbsvdfhvdcevywlptspfgnejpbksadehkhkfzehhfaysrsrbsdsvatohkoe",
//         "ur:crypto-pubkeys/lftanshftanehskkadlrjkjkisdpjpjkhscxfpfpfpfpfweoglknhsfxehkkiaeyfefpfpfpfpfyfpgyfpfwfpfpfpfwfpgyfyjzktinkkdyhfishgdyhgfwfxhseejkfwidksjsfyidgojyenjsiheeenjsfgjogujnececjykkglgsjsideseyhkhsjkesfgiyjejnfekpgsiakofpgseheoeyeehdiahfdygefdgeioehfpidfxiaenjtiegejkeegahshtgrjyiehgjshgksgsdnemehineydyjkktinhtdlfgjngakoktgafefyfdgwgwgwhtjpidendygueyimhgfddngmhkgoesjlgedydnkseohkfygskkhkinhgjyesfxkogwiajogtisihkphdetehgtgtdyflhkjpfdjzjyiogoisisesktjtengrfgjyjeknjshsjnjlgaeninglfgjsgthfdyecglgegegreeimfygygahdjkiejldyjlfyetfygrimgagdihkohgjtguiofdisiofyjtfgidgmeednfxkphkendygtjoidesgogseoineoktflfykniyjnflingejtjeeokkioknidgoetjzesehengojeetgoihkoidfyhtecgojojokkeshdhdjnehiofefwdnfygyiejzkshthtgeknjeiyisfygufpdlksenghgdjojygteyioesgsetfdgugmeogejneeetjkgtecdnenjkjoehhdgsfwjeideyfdcxiajljnjnihjtjytansgrhdcxfdgwgacloxsrmupdcybdchfylewsdilrbestjodpwnknndjoztjprfkkjopkdejotpgdosen",
//         "Signature",
//     );
// }

// Disabled due to tests not working correctly for undiagnosed reasons.
// Particularly slow, so disabled by default.
// #[test]
// #[ignore]
// fn test_ssh_rsa_sha512() {
//     test_keys(
//         "ssh-rsa-sha512",
//         "ur:crypto-prvkeys/lftansgotanehnkkatatdpdpdpdpdpfwfeflgaglcxgwgdfeglgugufdcxgdgmgahffpghfecxgrfehkdpdpdpdpdpbkideofwjzidjtglknhsfxehjphthdjejyieimfefpfpfpfpfpfwfleckoidjngofpfpfpfpfeidjneskphtgyfpfpfpfpfpfpfpfpfpfwfpfpfpfwfgktfpfpfpfpiekniaeyiojyiajtbkglisfpfpfpfpfpktfefpfpgyfpfpfpgyfefpksdyjkglinisjtghfphdeyjzghhfgaehhkgdeohsguenfxglioesknhtiseeinkokkeeimiohfemknjoeyfpdljkguknkkgsetjnghjebkemkoiahggmkokketgtktglgsfxjedyenineciodneeetghjnfwfeisgmihjngweskofpiygejskpisghgmjkiniainehjlksgweteseohdeyfyjkimglgujeetfxioiohkeejziheygybkgohdksiofgghhsieglfyhffeihhdfyhgiektetdlkneteciohdjygegrksimfyesemjygtinfdeciokkjngoisgdeoesinkpghemktkkjygrioetdyjzgmksjeinjyfgjpjzgteoghecbkhgkseyjyiyjykphgetgmiyeyjnjyhgjneoktdnknjteyjtgmfximehjtjejtidetjnfwglesisgtktehgdeeehfwdyeckpeogrfdgtkpdyihfekngdiyisfwfddngtjogmhgeejngreybkjoecktfyisjpidisfwiygofwdnjpeniajyflidfxfygdiahdenecgagwgefpgagagdjnemgadlfxdlkndnfphskofekpghdnihiyemenimgahkfdhgflgyjtgshtfggtgoglimidfyjpbkjtjnioemgaflhdinfggyfpfpfpemimfpimioeygmktgaeegljegyfpfpfpfpiekniaeyiojyiajtglisfpfpfpfwfpgyfyfdgukteygrfliegtfwiyhshfglgoimhfiodliejogsjlgabkeyfyeogljnfdingrdlgsingwfwhdkogwjthkfydnksgsgdgakokkhtgwghkpeskshtfldlgsktknfpdyjkgrghghjsgsjnfyemimksgwhkfegufgfgenhkemeyetfwetjnjsenfgglflbkkkgekkgshgimfeemkneoieiyhkgwkkgtehgrghktgrfxfwiminhfemhtfwgmiyflfphfgljodydyglgogmeciaglhteofykndlgdknjnfwihdyjejpflgtgdeokpdykkgaiyjnfygrhtbkgufedliyeygrecgdkofygrdyjsfyknguhffdflgugrdyhgkpgokniegdjzidfdhsehdneyecidksfgdlhshsehhsidiyfyemgwiyhsiefegrgdhgihguiekokkhkfeeoeyfeknfygodlbkimgofdghjnemiajliakkemgmeeghgtesdnfefeiyeekkjzfgidinhkjphsjtjtfpgwfljykpfefgesgyfdenkojokkdyhtjkgagtesksiyjpjeioeejefpioiodnidjkimetgsdlgdeebkfwjsetguecgdececdlkojsgtisioiehkhtfxiajyjegoksgyeygljkgwkpihhsfyjkiohtihgahffpfpfpfpfpktfefpfpgyfpfpfpgyfpgwiehsinhgdyeeidhgkoiejlfdioguhtdybkgoisidgsjednkpgyjtgrecdlktiyfphdgohgiogljzhtkshfeyesjtjnfdeeesemehetktktiejnidethkhkkoenfleektgdgmfejekkgehsjskkieihdlfliaiaghgdjteojpesjkgabkideygujlgseegugtiyjsenfdfghkfxgehtesjsisihiyjofygagdhtjsjtjsemkphgiedyehkofgglkthfjogoghhgenhkgsglhtdnjoeciahthkihjteoglioeyecdliagtfxgseyjnbkdlgahkgydngukshkieihfeeyihhkgdkoeeetkshsgugudlesfyjzflgmgdiadljykpiygefxjeguhshghfhtgleydlisgsglfeiefgjkjpjpjljkgljehfisfxfeiyksgyemgteckkgsbkghjtgyhkhtfpflgsjzethgksgujsglihguhgkkksflfwhgjedliajnkpfyfdeoehimeodlfljzgygwiainkogsfweciyfpguecdleniogwiegdetfeksgwgwgahggwiyjtktisiyjtjnbkfddlhdjeglfgetknghghfdesdyjohgeojyisiefghdjskniniykokogogafwjpfegoflhdiaishfjzdyjydnjefwfpfpfpfpiofdgskkhgktgoidiadnjljsjlhgjyghhseyinjpehglbkhkfykohtetgaemghgwjoemhggrjnkkfdgaksidihjngakpfleyktjpidjeesjnidfefgdnhdgmdygefggegdkngsgegdiafydyfefgemjsiejtesjpgdgojejeeeiydldnihimglinidbkguimengaidenisjogehtdlghingwjnjsjsfdgyguisjzesjtknglksgrhgidihjehgjpemioiykoflhtgofdkoioksjnecjnfygsetdnishdhskkglgdgwfwgmgrgdiyfeksinjegsdybkjtjyflkndnktgtgseyhsfpfpfpfpiogyfyishtgsecjeemjoieiejljtjtjliskkiyjsesjogdemfwgljnfweefpdlgoglfwetgeesdlhddyhkenfxehhgioimjkeedyecieiyimkofxbkisfgjsfygeghiagaglhdeogseygofgfyknecjyechkgsjtjyjsglhsjngwfwesdnfgfwesguinhdfejtfxjlhfjyfxhtecgmktgugldyeekokogegegajyjpktjyghhdimjkjejoecktbkjzimknidgtgahtgwghinktioieihfxdnemjlhfeefxeyiejlfxdyfgehfefgfxiygrflfygyemdlkkfpiaglgakkjziehfgyfpfpfpgafefpeejzjpdnieimeydlihecksgyiheefgesbkgliohdiaesglhfeyjshkhfemjyjyknenfdjpgrjpgweojeiagyfdendnesdnghkkgokkjzjljkhtgegtjpfygdhdeyjsgaehgmksgujnghjsjpjshtjpesjnfwdnjogyfdfwfeemdygabkgygtehflktieinimkkfwgegdetinfwghgheseskphteneehtenihjpiyjpjeemgtglidgdjsetgyktflgafwiyesjyguisgsgegyghimfehkeeisksgefejykpksgsetiniejzhsglhtbkhtjegtgahseygehkeeetkodyiaiafefpfpfpfpfpfpgygafybkdpdpdpdpdpfeglfycxgwgdfeglgugufdcxgdgmgahffpghfecxgrfehkdpdpdpdpdpbktansgehdcxvsdapeurgauovlbsvdfhvdcevywlptspfgnejpbksadehkhkfzehhfaysrsrbsdsrldpsogu",
//         "ur:crypto-pubkeys/lftanshftanehskkadlrjkjkisdpjpjkhscxfpfpfpfpfweoglknhsfxehkkiaeyfefpfpfpfpfyfpgyfpfwfpfpfpfwfpgyfyfdgukteygrfliegtfwiyhshfglgoimhfiodliejogsjlgaeyfyeogljnfdingrdlgsingwfwhdkogwjthkfydnksgsgdgakokkhtgwghkpeskshtfldlgsktknfpdyjkgrghghjsgsjnfyemimksgwhkfegufgfgenhkemeyetfwetjnjsenfgglflkkgekkgshgimfeemkneoieiyhkgwkkgtehgrghktgrfxfwiminhfemhtfwgmiyflfphfgljodydyglgogmeciaglhteofykndlgdknjnfwihdyjejpflgtgdeokpdykkgaiyjnfygrhtgufedliyeygrecgdkofygrdyjsfyknguhffdflgugrdyhgkpgokniegdjzidfdhsehdneyecidksfgdlhshsehhsidiyfyemgwiyhsiefegrgdhgihguiekokkhkfeeoeyfeknfygodlimgofdghjnemiajliakkemgmeeghgtesdnfefeiyeekkjzfgidinhkjphsjtjtfpgwfljykpfefgesgyfdenkojokkdyhtjkgagtesksiyjpjeioeejefpioiodnidjkimetgsdlgdeefwjsetguecgdececdlkojsgtisioiehkhtfxiajyjegoksgyeygljkgwkpihhsfyjkiohtihgahfcxiajljnjnihjtjytansgrhdcxfdgwgacloxsrmupdcybdchfylewsdilrbestjodpwnknndjoztjprfkkjopkdejovyotplpd",
//         "Signature",
//     );
// }
