Keys
====

The (ssh key) module provides procedures for handling of Guile-SSH keys.

Note that Guile-SSH does not support ECDSA keys if libssh 0.6.3 is compiled with GCrypt instead of OpenSSL.

 -- Scheme Procedure: make-keypair type length
     Generate a keypair of specified TYPE and LENGTH (in bits).  This may take some time.

     Possible key types are: dss, rsa, rsa1, ecdsa.

     Return newly generated private key.  Throw guile-ssh-error on error.

 -- Scheme Procedure: key? x
     Return #t if X is a Guile-SSH key, #f otherwise.

 -- Scheme Procedure: public-key? x
     Return #t if X is a Guile-SSH key and it contains a public key, #f otherwise.  What it means is that the procedure will return #t for a private key too (because the private key contains a public key in some sense).

 -- Scheme Procedure: private-key? x
     Return #t if X is a Guile-SSH private key, #f otherwise.

 -- Scheme Procedure: public-key->string public-key
     Convert PUBLIC-KEY to a string.

 -- Scheme Procedure: string->public-key string type
     Convert a public key of TYPE represented as Base64 STRING to a Guile-SSH key.  Throw guile-ssh-error on error.

     The TYPE must be one of the following symbols: dss, rsa, rsa1, ecdsa

 -- Scheme Procedure: private-key-from-file file
     Read private key from a FILE.  If the the key is encrypted the user will be asked for passphrase to decrypt the key.

     Return a new Guile-SSH key of #f on error.

 -- Scheme Procedure: private-key-to-file private-key file-name
     Export PRIVATE-KEY to a PAM file FILE-NAME on a disk.  Throw guile-ssh-error on error.  Return value is undefined.

     Note that this procedure won't work if libssh 0.6.3 is compiled with GCrypt cryptographic library.

 -- Scheme Procedure: private-key->public-key private-key
     Get a public key from the PRIVATE-KEY.

 -- Scheme Procedure: public-key-from-file session file
     Read public key from a FILE.  Return a public key or #f on error.

 -- Scheme Procedure: get-key-type key
     Get a symbol that represents the type of the Guile-SSH KEY. Possible types are: dss, rsa, rsa1, unknown.

 -- Scheme Procedure: get-public-key-hash public-key type
     Get a PUBLIC-KEY hash of TYPE as a bytevector.  Return the bytevector on success, #f on error.

     See also get-server-public-key in see Sessions.

     The TYPE can be one of the following symbols: md5, sha1.

     Example:

          (let ((pubkey (get-server-public-key session)))
            (get-public-key-hash pubkey 'md5))
          => #vu8(15 142 110 203 162 228 250 211 20 212 26 217 118 57 217 66)

 -- Scheme Procedure: bytevector->hex-string bv
     Convert the given bytevector BV to a colon separated string.

     Example:

          (let ((hash (get-public-key-hash pubkey 'md5)))
            (bytevector->hex-string hash))
          => "0f:8e:6e:cb:a2:e4:fa:d3:14:d4:1a:d9:76:39:d9:42"