diff --git a/src/crypt.c b/src/crypt.c index 967bb57..f562d50 100644 --- a/src/crypt.c +++ b/src/crypt.c @@ -90,14 +90,14 @@ static int init (LIBSSH2_SESSION *session, return 0; } -int crypt(LIBSSH2_SESSION *session, unsigned char *block, void **abstract) +static int crypt(LIBSSH2_SESSION *session, unsigned char *block, void **abstract) { struct crypt_ctx *cctx = *(struct crypt_ctx **)abstract; return _libssh2_cipher_crypt(&cctx->h, cctx->algo, cctx->encrypt, block); } -int dtor(LIBSSH2_SESSION *session, void **abstract) +static int dtor(LIBSSH2_SESSION *session, void **abstract) { struct crypt_ctx **cctx = (struct crypt_ctx **)abstract; if (cctx && *cctx) { diff --git a/src/hostkey.c b/src/hostkey.c index 9593885..d82dad2 100644 --- a/src/hostkey.c +++ b/src/hostkey.c @@ -301,7 +301,7 @@ static int libssh2_hostkey_method_ssh_dss_sig_verify(LIBSSH2_SESSION *session, c libssh2_error(session, LIBSSH2_ERROR_PROTO, "Invalid DSS signature length", 0); return -1; } - return _libssh2_dsa_sha1_verify(dsactx, sig, sig_len, m, m_len); + return _libssh2_dsa_sha1_verify(dsactx, sig, m, m_len); } /* }}} */ diff --git a/src/libgcrypt.c b/src/libgcrypt.c index 4105e55..5b31ff3 100644 --- a/src/libgcrypt.c +++ b/src/libgcrypt.c @@ -79,7 +79,6 @@ int _libssh2_rsa_new(libssh2_rsa_ctx **rsa, int _libssh2_rsa_sha1_verify(libssh2_rsa_ctx *rsa, const unsigned char *sig, - unsigned long sig_len, const unsigned char *m, unsigned long m_len) { diff --git a/src/libgcrypt.h b/src/libgcrypt.h index 250c259..f6ec8bf 100644 --- a/src/libgcrypt.h +++ b/src/libgcrypt.h @@ -145,9 +145,8 @@ int _libssh2_dsa_new_private (libssh2_dsa_ctx **dsa, LIBSSH2_SESSION *session, FILE *fp, unsigned const char *passphrase); - int _libssh2_dsa_sha1_verify(libssh2_dsa_ctx *dsa, +int _libssh2_dsa_sha1_verify(libssh2_dsa_ctx *dsa, const unsigned char *sig, - unsigned long sig_len, const unsigned char *m, unsigned long m_len); int _libssh2_dsa_sign(libssh2_dsa_ctx *dsactx, diff --git a/src/libssh2_priv.h b/src/libssh2_priv.h index 8be69e9..8f971d6 100644 --- a/src/libssh2_priv.h +++ b/src/libssh2_priv.h @@ -260,7 +260,7 @@ struct _LIBSSH2_SESSION { /* libssh2 extensible ssh api, ultimately I'd like to allow loading additional methods via .so/.dll */ struct _LIBSSH2_KEX_METHOD { - char *name; + const char *name; /* Key exchange, populates session->* and returns 0 on success, non-0 on error */ int (*exchange_keys)(LIBSSH2_SESSION *session); @@ -269,11 +269,11 @@ struct _LIBSSH2_KEX_METHOD { }; struct _LIBSSH2_HOSTKEY_METHOD { - char *name; + const char *name; unsigned long hash_len; int (*init)(LIBSSH2_SESSION *session, unsigned char *hostkey_data, unsigned long hostkey_data_len, void **abstract); - int (*initPEM)(LIBSSH2_SESSION *session, unsigned const char *privkeyfile, unsigned const char *passphrase, void **abstract); + int (*initPEM)(LIBSSH2_SESSION *session, const char *privkeyfile, unsigned const char *passphrase, void **abstract); int (*sig_verify)(LIBSSH2_SESSION *session, const unsigned char *sig, unsigned long sig_len, const unsigned char *m, unsigned long m_len, void **abstract); int (*signv)(LIBSSH2_SESSION *session, unsigned char **signature, unsigned long *signature_len, unsigned long veccount, const struct iovec datavec[], void **abstract); int (*encrypt)(LIBSSH2_SESSION *session, unsigned char **dst, unsigned long *dst_len, const unsigned char *src, unsigned long src_len, void **abstract); @@ -281,7 +281,7 @@ struct _LIBSSH2_HOSTKEY_METHOD { }; struct _LIBSSH2_CRYPT_METHOD { - char *name; + const char *name; int blocksize; @@ -299,7 +299,7 @@ struct _LIBSSH2_CRYPT_METHOD { }; struct _LIBSSH2_COMP_METHOD { - char *name; + const char *name; int (*init)(LIBSSH2_SESSION *session, int compress, void **abstract); int (*comp)(LIBSSH2_SESSION *session, int compress, unsigned char **dest, unsigned long *dest_len, unsigned long payload_limit, int *free_dest, @@ -308,7 +308,7 @@ struct _LIBSSH2_COMP_METHOD { }; struct _LIBSSH2_MAC_METHOD { - char *name; + const char *name; /* The length of a given MAC packet */ int mac_len; diff --git a/src/openssl.c b/src/openssl.c index 996aff3..f53ffae 100644 --- a/src/openssl.c +++ b/src/openssl.c @@ -139,7 +139,6 @@ int _libssh2_dsa_new(libssh2_dsa_ctx **dsactx, int _libssh2_dsa_sha1_verify(libssh2_dsa_ctx *dsactx, const unsigned char *sig, - unsigned long sig_len, const unsigned char *m, unsigned long m_len) { diff --git a/src/openssl.h b/src/openssl.h index da49143..de4aad0 100644 --- a/src/openssl.h +++ b/src/openssl.h @@ -127,7 +127,7 @@ #define libssh2_hmac_final(ctx, data) HMAC_Final(&(ctx), data, NULL) #define libssh2_hmac_cleanup(ctx) HMAC_cleanup(ctx) -#define libssh2_crypto_init() 1 +#define libssh2_crypto_init() #define libssh2_rsa_ctx RSA @@ -148,11 +148,21 @@ int _libssh2_rsa_new(libssh2_rsa_ctx **rsa, unsigned long e2len, const unsigned char *coeffdata, unsigned long coefflen); +int _libssh2_rsa_new_private (libssh2_rsa_ctx **rsa, + LIBSSH2_SESSION *session, + FILE *fp, + unsigned const char *passphrase); int _libssh2_rsa_sha1_verify(libssh2_rsa_ctx *rsa, const unsigned char *sig, unsigned long sig_len, const unsigned char *m, unsigned long m_len); +int _libssh2_rsa_sha1_sign(LIBSSH2_SESSION *session, + libssh2_rsa_ctx *rsactx, + const unsigned char *hash, + unsigned long hash_len, + unsigned char **signature, + unsigned long *signature_len); #define _libssh2_rsa_free(rsactx) RSA_free(rsactx) @@ -169,9 +179,12 @@ int _libssh2_dsa_new(libssh2_dsa_ctx **dsa, unsigned long ylen, const unsigned char *x, unsigned long x_len); +int _libssh2_dsa_new_private (libssh2_dsa_ctx **dsa, + LIBSSH2_SESSION *session, + FILE *fp, + unsigned const char *passphrase); int _libssh2_dsa_sha1_verify(libssh2_dsa_ctx *dsactx, const unsigned char *sig, - unsigned long sig_len, const unsigned char *m, unsigned long m_len); int _libssh2_dsa_sha1_sign(libssh2_dsa_ctx *dsactx,