X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=ssh.h;h=0b6b4f8ebc9aab85ce0bd45e28214b6bab043173;hb=89da2ddf564a93414ee9ab2df3f053608094e417;hp=ec4f1f996896040aadb9b20786a608760466e7fd;hpb=f274b56a5751437e8de13c33f73c33bdd33dbc31;p=PuTTY.git diff --git a/ssh.h b/ssh.h index ec4f1f99..0b6b4f8e 100644 --- a/ssh.h +++ b/ssh.h @@ -133,6 +133,7 @@ struct ec_ecurve struct ec_curve { enum { EC_WEIERSTRASS, EC_MONTGOMERY, EC_EDWARDS } type; + const char *name; unsigned int fieldBits; Bignum p; union { @@ -142,21 +143,20 @@ struct ec_curve { }; }; -extern unsigned char nistp256_oid[]; -extern unsigned char nistp384_oid[]; -extern unsigned char nistp521_oid[]; -extern unsigned char curve25519_oid[]; -extern int nistp256_oid_len; -extern int nistp384_oid_len; -extern int nistp521_oid_len; -extern int curve25519_oid_len; -struct ec_curve *ec_p256(void); -struct ec_curve *ec_p384(void); -struct ec_curve *ec_p521(void); -struct ec_curve *ec_ed25519(void); -struct ec_curve *ec_curve25519(void); +const struct ssh_signkey *ec_alg_by_oid(int len, const void *oid, + const struct ec_curve **curve); +const unsigned char *ec_alg_oid(const struct ssh_signkey *alg, int *oidlen); +const int ec_nist_alg_and_curve_by_bits(int bits, + const struct ec_curve **curve, + const struct ssh_signkey **alg); +const int ec_ed_alg_and_curve_by_bits(int bits, + const struct ec_curve **curve, + const struct ssh_signkey **alg); + +struct ssh_signkey; struct ec_key { + const struct ssh_signkey *signalg; struct ec_point publicKey; Bignum privateKey; }; @@ -208,7 +208,8 @@ void ssh_rsakex_encrypt(const struct ssh_hash *h, unsigned char *in, int inlen, /* * SSH2 ECDH key exchange functions */ -void *ssh_ecdhkex_newkey(const char *name); +struct ssh_kex; +void *ssh_ecdhkex_newkey(const struct ssh_kex *kex); void ssh_ecdhkex_freekey(void *key); char *ssh_ecdhkex_getpublic(void *key, int *len); Bignum ssh_ecdhkex_getkey(void *key, char *remoteKey, int remoteKeyLen); @@ -293,7 +294,7 @@ struct ssh_cipher { void (*encrypt) (void *, unsigned char *blk, int len); void (*decrypt) (void *, unsigned char *blk, int len); int blksize; - char *text_name; + const char *text_name; }; struct ssh2_cipher { @@ -303,12 +304,12 @@ struct ssh2_cipher { void (*setkey) (void *, unsigned char *key);/* for SSH-2 */ void (*encrypt) (void *, unsigned char *blk, int len); void (*decrypt) (void *, unsigned char *blk, int len); - char *name; + const char *name; int blksize; int keylen; unsigned int flags; #define SSH_CIPHER_IS_CBC 1 - char *text_name; + const char *text_name; }; struct ssh2_ciphers { @@ -328,26 +329,24 @@ struct ssh_mac { void (*bytes) (void *, unsigned char const *, int); void (*genresult) (void *, unsigned char *); int (*verresult) (void *, unsigned char const *); - char *name, *etm_name; + const char *name, *etm_name; int len; - char *text_name; + const char *text_name; }; struct ssh_hash { void *(*init)(void); /* also allocates context */ - void (*bytes)(void *, void *, int); + void (*bytes)(void *, const void *, int); void (*final)(void *, unsigned char *); /* also frees context */ int hlen; /* output length in bytes */ - char *text_name; + const char *text_name; }; struct ssh_kex { - char *name, *groupname; + const char *name, *groupname; enum { KEXTYPE_DH, KEXTYPE_RSA, KEXTYPE_ECDH } main_type; - /* For DH */ - const unsigned char *pdata, *gdata; /* NULL means group exchange */ - int plen, glen; const struct ssh_hash *hash; + const void *extra; /* private to the kex methods */ }; struct ssh_kexes { @@ -356,14 +355,17 @@ struct ssh_kexes { }; struct ssh_signkey { - void *(*newkey) (const char *data, int len); + void *(*newkey) (const struct ssh_signkey *self, + const char *data, int len); void (*freekey) (void *key); char *(*fmtkey) (void *key); unsigned char *(*public_blob) (void *key, int *len); unsigned char *(*private_blob) (void *key, int *len); - void *(*createkey) (const unsigned char *pub_blob, int pub_len, + void *(*createkey) (const struct ssh_signkey *self, + const unsigned char *pub_blob, int pub_len, const unsigned char *priv_blob, int priv_len); - void *(*openssh_createkey) (const unsigned char **blob, int *len); + void *(*openssh_createkey) (const struct ssh_signkey *self, + const unsigned char **blob, int *len); int (*openssh_fmtkey) (void *key, unsigned char *blob, int len); /* OpenSSH private key blobs, as created by openssh_fmtkey and * consumed by openssh_createkey, always (at least so far...) take @@ -374,21 +376,22 @@ struct ssh_signkey { * skip over the right number to find the next key in the file. * openssh_private_npieces gives that information. */ int openssh_private_npieces; - int (*pubkey_bits) (const void *blob, int len); - char *(*fingerprint) (void *key); + int (*pubkey_bits) (const struct ssh_signkey *self, + const void *blob, int len); int (*verifysig) (void *key, const char *sig, int siglen, const char *data, int datalen); unsigned char *(*sign) (void *key, const char *data, int datalen, int *siglen); - char *name; - char *keytype; /* for host key cache */ + const char *name; + const char *keytype; /* for host key cache */ + const void *extra; /* private to the public key methods */ }; struct ssh_compress { - char *name; + const char *name; /* For zlib@openssh.com: if non-NULL, this name will be considered once * userauth has completed successfully. */ - char *delayed_name; + const char *delayed_name; void *(*compress_init) (void); void (*compress_cleanup) (void *); int (*compress) (void *, unsigned char *block, int len, @@ -398,7 +401,7 @@ struct ssh_compress { int (*decompress) (void *, unsigned char *block, int len, unsigned char **outblock, int *outlen); int (*disable_compression) (void *); - char *text_name; + const char *text_name; }; struct ssh2_userkey { @@ -475,7 +478,8 @@ struct PortForwarding; /* Allocate and register a new channel for port forwarding */ void *new_sock_channel(void *handle, struct PortForwarding *pf); -void ssh_send_port_open(void *channel, char *hostname, int port, char *org); +void ssh_send_port_open(void *channel, const char *hostname, int port, + const char *org); /* Exports from portfwd.c */ extern char *pfd_connect(struct PortForwarding **pf, char *hostname, int port, @@ -636,6 +640,7 @@ Bignum bignum_from_decimal(const char *decimal); void diagbn(char *prefix, Bignum md); #endif +int dh_is_gex(const struct ssh_kex *kex); void *dh_setup_group(const struct ssh_kex *kex); void *dh_setup_gex(Bignum pval, Bignum gval); void dh_cleanup(void *); @@ -716,8 +721,16 @@ enum { 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); +char *ssh2_fingerprint_blob(const void *blob, int bloblen); +char *ssh2_fingerprint(const struct ssh_signkey *alg, void *data); int key_type(const Filename *filename); -char *key_type_to_str(int type); +const char *key_type_to_str(int type); int import_possible(int type); int import_target_type(int type);