include/libssh/keys.h

00001 /*
00002  * This file is part of the SSH Library
00003  *
00004  * Copyright (c) 2009 by Aris Adamantiadis
00005  *
00006  * The SSH Library is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU Lesser General Public License as published by
00008  * the Free Software Foundation; either version 2.1 of the License, or (at your
00009  * option) any later version.
00010  *
00011  * The SSH Library is distributed in the hope that it will be useful, but
00012  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
00013  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
00014  * License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public License
00017  * along with the SSH Library; see the file COPYING.  If not, write to
00018  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00019  * MA 02111-1307, USA.
00020  */
00021 
00022 #ifndef KEYS_H_
00023 #define KEYS_H_
00024 
00025 #include "config.h"
00026 #include "libssh/libssh.h"
00027 #include "libssh/wrapper.h"
00028 
00029 struct ssh_public_key_struct {
00030     int type;
00031     const char *type_c; /* Don't free it ! it is static */
00032 #ifdef HAVE_LIBGCRYPT
00033     gcry_sexp_t dsa_pub;
00034     gcry_sexp_t rsa_pub;
00035 #elif HAVE_LIBCRYPTO
00036     DSA *dsa_pub;
00037     RSA *rsa_pub;
00038 #endif
00039 };
00040 
00041 struct ssh_private_key_struct {
00042     int type;
00043 #ifdef HAVE_LIBGCRYPT
00044     gcry_sexp_t dsa_priv;
00045     gcry_sexp_t rsa_priv;
00046 #elif defined HAVE_LIBCRYPTO
00047     DSA *dsa_priv;
00048     RSA *rsa_priv;
00049 #endif
00050 };
00051 
00052 typedef struct signature_struct {
00053     int type;
00054 #ifdef HAVE_LIBGCRYPT
00055     gcry_sexp_t dsa_sign;
00056     gcry_sexp_t rsa_sign;
00057 #elif defined HAVE_LIBCRYPTO
00058     DSA_SIG *dsa_sign;
00059     ssh_string rsa_sign;
00060 #endif
00061 } SIGNATURE;
00062 
00063 const char *ssh_type_to_char(int type);
00064 int ssh_type_from_name(const char *name);
00065 ssh_buffer ssh_userauth_build_digest(ssh_session session, ssh_message msg, char *service);
00066 
00067 ssh_private_key privatekey_make_dss(ssh_session session, ssh_buffer buffer);
00068 ssh_private_key privatekey_make_rsa(ssh_session session, ssh_buffer buffer,
00069     const char *type);
00070 ssh_private_key privatekey_from_string(ssh_session session, ssh_string privkey_s);
00071 
00072 ssh_public_key publickey_make_dss(ssh_session session, ssh_buffer buffer);
00073 ssh_public_key publickey_make_rsa(ssh_session session, ssh_buffer buffer, int type);
00074 ssh_public_key publickey_from_string(ssh_session session, ssh_string pubkey_s);
00075 SIGNATURE *signature_from_string(ssh_session session, ssh_string signature,ssh_public_key pubkey,int needed_type);
00076 void signature_free(SIGNATURE *sign);
00077 ssh_string ssh_do_sign_with_agent(struct ssh_session_struct *session,
00078     struct ssh_buffer_struct *buf, struct ssh_public_key_struct *publickey);
00079 ssh_string ssh_do_sign(ssh_session session,ssh_buffer sigbuf,
00080         ssh_private_key privatekey);
00081 ssh_string ssh_sign_session_id(ssh_session session, ssh_private_key privatekey);
00082 ssh_string ssh_encrypt_rsa1(ssh_session session, ssh_string data, ssh_public_key key);
00083 
00084 #endif /* KEYS_H_ */

Generated on 19 Dec 2014 for libssh by  doxygen 1.4.7