[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Querying session parameters


On Mon, Dec 06, 2010 at 04:25:53PM +0100, Aris Adamantiadis wrote:

> This is a good question. The data exists but there is no accessors for it.
>
> I don't have so much time right now, so a patch would be welcome of
> course :) This would not be very complicated to implement.

Got it working, not too painful indeed. I tried to stick to the
dominant style.

IN libssh.h, I added one line:

   LIBSSH_API char *ssh_get_encryption_algo(ssh_session session);


IN client.c after ssh_get_issue_banner(), but it could go
anywhere there, I added following function. I went overboard with
all the NULL checks because I had a silly error, the checks could
be summarized in a single statement. Also, we could also return
the 'in_cipher->name', and maybe I'll add that (it could be
different, right?).

   /**
    * @brief Get info on currently used encryption algo
    *
    * Get info on currently used encryption algo
    *
    * @param session       The SSH session to use.
    *
    * @return A pointer to a string with the info (do NOT free it!)
    */

   const char *ssh_get_encryption_algo(ssh_session session) {
     if (session == NULL) {
       return "no session";
     }
     if (session->current_crypto == NULL) {
       return "no current_crypto";
     }
     if (session->current_crypto->out_cipher == NULL) {
       return "no out_cipher";
     }
     if (session->current_crypto->out_cipher->name == NULL) {
       return "no out_cipher->name";
     }
     return session->current_crypto->out_cipher->name;
   }

And that gave me the current encryption algo ("aes256-ctr" on
all hosts I've tried so far). I haven't yet bothered with the
authentication stuff (I'm less curious about that). I might
have trouble finding a host that returns something else!

I won't provide this as a patch because I just don't understand
the source management stuff well enough, but it's simple enough
that you could just include it as part of your work at some
point.

Cheers,
Pierre


References:
libssh sftp download performance"Mark Riordan" <mriordan@xxxxxxxxxxxx>
Re: libssh sftp download performanceAndreas Schneider <asn@xxxxxxxxxxxx>
Querying session parametersPierre Lewis <leware@xxxxxxxxxxxxxxxx>
Re: Querying session parametersAris Adamantiadis <aris@xxxxxxxxxxxx>
Archive administrator: postmaster@lists.cynapses.org