- if (match_ssh_id(stringlen, string, "ssh-rsa")) {
- alg = &ssh_rsa;
- npieces = 6; /* n,e,d,iqmp,q,p */
- } else if (match_ssh_id(stringlen, string, "ssh-dss")) {
- alg = &ssh_dss;
- npieces = 5; /* p,q,g,y,x */
- } else if (match_ssh_id(stringlen, string,
- "ecdsa-sha2-nistp256")) {
- alg = &ssh_ecdsa_nistp256;
- npieces = 3; /* curve name, point, private exponent */
- } else if (match_ssh_id(stringlen, string,
- "ecdsa-sha2-nistp384")) {
- alg = &ssh_ecdsa_nistp384;
- npieces = 3; /* curve name, point, private exponent */
- } else if (match_ssh_id(stringlen, string,
- "ecdsa-sha2-nistp521")) {
- alg = &ssh_ecdsa_nistp521;
- npieces = 3; /* curve name, point, private exponent */
- } else {
- errmsg = "private key did not start with type string\n";
+ {
+ /* find_pubkey_alg needs a zero-terminated copy of the
+ * algorithm name */
+ char *name_zt = dupprintf("%.*s", stringlen, (char *)string);
+ alg = find_pubkey_alg(name_zt);
+ sfree(name_zt);
+ }
+
+ if (!alg) {
+ errmsg = "private key type not recognised\n";