X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=ssh.h;h=4e36ad4584ae8aa2893ab7e154926fcce11ca746;hb=eef0235a0f79e92f25f34782fc486c101fa703ee;hp=bb2668473ec96466172c3d8d15175840a5726d73;hpb=76a4b576e58fa3b245b02f9fbb052e4651acbfa9;p=PuTTY.git diff --git a/ssh.h b/ssh.h index bb266847..4e36ad45 100644 --- a/ssh.h +++ b/ssh.h @@ -630,6 +630,7 @@ Bignum bignum_rshift(Bignum number, int shift); Bignum bignum_lshift(Bignum number, int shift); int bignum_cmp(Bignum a, Bignum b); char *bignum_decimal(Bignum x); +Bignum bignum_from_decimal(const char *decimal); #ifdef DEBUG void diagbn(char *prefix, Bignum md); @@ -643,17 +644,18 @@ const char *dh_validate_f(void *handle, Bignum f); Bignum dh_find_K(void *, Bignum f); int loadrsakey(const Filename *filename, struct RSAKey *key, - char *passphrase, const char **errorstr); + const char *passphrase, const char **errorstr); int rsakey_encrypted(const Filename *filename, char **comment); int rsakey_pubblob(const Filename *filename, void **blob, int *bloblen, char **commentptr, const char **errorstr); int saversakey(const Filename *filename, struct RSAKey *key, char *passphrase); -extern int base64_decode_atom(char *atom, unsigned char *out); +extern int base64_decode_atom(const char *atom, unsigned char *out); extern int base64_lines(int datalen); -extern void base64_encode_atom(unsigned char *data, int n, char *out); -extern void base64_encode(FILE *fp, unsigned char *data, int datalen, int cpl); +extern void base64_encode_atom(const unsigned char *data, int n, char *out); +extern void base64_encode(FILE *fp, const unsigned char *data, int datalen, + int cpl); /* ssh2_load_userkey can return this as an error */ extern struct ssh2_userkey ssh2_wrong_passphrase; @@ -661,7 +663,8 @@ extern struct ssh2_userkey ssh2_wrong_passphrase; int ssh2_userkey_encrypted(const Filename *filename, char **comment); struct ssh2_userkey *ssh2_load_userkey(const Filename *filename, - char *passphrase, const char **errorstr); + const char *passphrase, + const char **errorstr); unsigned char *ssh2_userkey_loadpub(const Filename *filename, char **algorithm, int *pub_blob_len, char **commentptr, const char **errorstr); @@ -674,10 +677,51 @@ enum { SSH_KEYTYPE_UNOPENABLE, SSH_KEYTYPE_UNKNOWN, SSH_KEYTYPE_SSH1, SSH_KEYTYPE_SSH2, + /* + * The OpenSSH key types deserve a little explanation. OpenSSH has + * two physical formats for private key storage: an old PEM-based + * one largely dictated by their use of OpenSSL and full of ASN.1, + * and a new one using the same private key formats used over the + * wire for talking to ssh-agent. The old format can only support + * a subset of the key types, because it needs redesign for each + * key type, and after a while they decided to move to the new + * format so as not to have to do that. + * + * On input, key files are identified as either + * SSH_KEYTYPE_OPENSSH_PEM or SSH_KEYTYPE_OPENSSH_NEW, describing + * accurately which actual format the keys are stored in. + * + * On output, however, we default to following OpenSSH's own + * policy of writing out PEM-style keys for maximum backwards + * compatibility if the key type supports it, and otherwise + * switching to the new format. So the formats you can select for + * output are SSH_KEYTYPE_OPENSSH_NEW (forcing the new format for + * any key type), and SSH_KEYTYPE_OPENSSH_AUTO to use the oldest + * format supported by whatever key type you're writing out. + * + * So we have three type codes, but only two of them usable in any + * given circumstance. An input key file will never be identified + * as AUTO, only PEM or NEW; key export UIs should not be able to + * select PEM, only AUTO or NEW. + */ + SSH_KEYTYPE_OPENSSH_AUTO, SSH_KEYTYPE_OPENSSH_PEM, SSH_KEYTYPE_OPENSSH_NEW, - SSH_KEYTYPE_SSHCOM + SSH_KEYTYPE_SSHCOM, + /* + * Public-key-only formats, which we still want to be able to read + * for various purposes. + */ + SSH_KEYTYPE_SSH1_PUBLIC, + SSH_KEYTYPE_SSH2_PUBLIC_RFC4716, + SSH_KEYTYPE_SSH2_PUBLIC_OPENSSH }; +char *ssh1_pubkey_str(struct RSAKey *ssh1key); +void ssh1_write_pubkey(FILE *fp, struct RSAKey *ssh1key); +char *ssh2_pubkey_openssh_str(struct ssh2_userkey *key); +void ssh2_write_pubkey(FILE *fp, const char *comment, + const void *v_pub_blob, int pub_len, + int keytype); int key_type(const Filename *filename); char *key_type_to_str(int type);