jpayne@69: /* Copyright (c) 2004-2006, Sara Golemon jpayne@69: * All rights reserved. jpayne@69: * jpayne@69: * Redistribution and use in source and binary forms, jpayne@69: * with or without modification, are permitted provided jpayne@69: * that the following conditions are met: jpayne@69: * jpayne@69: * Redistributions of source code must retain the above jpayne@69: * copyright notice, this list of conditions and the jpayne@69: * following disclaimer. jpayne@69: * jpayne@69: * Redistributions in binary form must reproduce the above jpayne@69: * copyright notice, this list of conditions and the following jpayne@69: * disclaimer in the documentation and/or other materials jpayne@69: * provided with the distribution. jpayne@69: * jpayne@69: * Neither the name of the copyright holder nor the names jpayne@69: * of any other contributors may be used to endorse or jpayne@69: * promote products derived from this software without jpayne@69: * specific prior written permission. jpayne@69: * jpayne@69: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND jpayne@69: * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, jpayne@69: * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES jpayne@69: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE jpayne@69: * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR jpayne@69: * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, jpayne@69: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, jpayne@69: * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR jpayne@69: * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS jpayne@69: * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, jpayne@69: * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING jpayne@69: * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE jpayne@69: * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY jpayne@69: * OF SUCH DAMAGE. jpayne@69: */ jpayne@69: jpayne@69: /* Note: This include file is only needed for using the jpayne@69: * publickey SUBSYSTEM which is not the same as publickey jpayne@69: * authentication. For authentication you only need libssh2.h jpayne@69: * jpayne@69: * For more information on the publickey subsystem, jpayne@69: * refer to IETF draft: secsh-publickey jpayne@69: */ jpayne@69: jpayne@69: #ifndef LIBSSH2_PUBLICKEY_H jpayne@69: #define LIBSSH2_PUBLICKEY_H 1 jpayne@69: jpayne@69: #include "libssh2.h" jpayne@69: jpayne@69: typedef struct _LIBSSH2_PUBLICKEY LIBSSH2_PUBLICKEY; jpayne@69: jpayne@69: typedef struct _libssh2_publickey_attribute { jpayne@69: const char *name; jpayne@69: unsigned long name_len; jpayne@69: const char *value; jpayne@69: unsigned long value_len; jpayne@69: char mandatory; jpayne@69: } libssh2_publickey_attribute; jpayne@69: jpayne@69: typedef struct _libssh2_publickey_list { jpayne@69: unsigned char *packet; /* For freeing */ jpayne@69: jpayne@69: const unsigned char *name; jpayne@69: unsigned long name_len; jpayne@69: const unsigned char *blob; jpayne@69: unsigned long blob_len; jpayne@69: unsigned long num_attrs; jpayne@69: libssh2_publickey_attribute *attrs; /* free me */ jpayne@69: } libssh2_publickey_list; jpayne@69: jpayne@69: /* Generally use the first macro here, but if both name and value are string jpayne@69: literals, you can use _fast() to take advantage of preprocessing */ jpayne@69: #define libssh2_publickey_attribute(name, value, mandatory) \ jpayne@69: { (name), strlen(name), (value), strlen(value), (mandatory) }, jpayne@69: #define libssh2_publickey_attribute_fast(name, value, mandatory) \ jpayne@69: { (name), sizeof(name) - 1, (value), sizeof(value) - 1, (mandatory) }, jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: extern "C" { jpayne@69: #endif jpayne@69: jpayne@69: /* Publickey Subsystem */ jpayne@69: LIBSSH2_API LIBSSH2_PUBLICKEY * jpayne@69: libssh2_publickey_init(LIBSSH2_SESSION *session); jpayne@69: jpayne@69: LIBSSH2_API int jpayne@69: libssh2_publickey_add_ex(LIBSSH2_PUBLICKEY *pkey, jpayne@69: const unsigned char *name, jpayne@69: unsigned long name_len, jpayne@69: const unsigned char *blob, jpayne@69: unsigned long blob_len, char overwrite, jpayne@69: unsigned long num_attrs, jpayne@69: const libssh2_publickey_attribute attrs[]); jpayne@69: #define libssh2_publickey_add(pkey, name, blob, blob_len, overwrite, \ jpayne@69: num_attrs, attrs) \ jpayne@69: libssh2_publickey_add_ex((pkey), (name), strlen(name), (blob), (blob_len), \ jpayne@69: (overwrite), (num_attrs), (attrs)) jpayne@69: jpayne@69: LIBSSH2_API int libssh2_publickey_remove_ex(LIBSSH2_PUBLICKEY *pkey, jpayne@69: const unsigned char *name, jpayne@69: unsigned long name_len, jpayne@69: const unsigned char *blob, jpayne@69: unsigned long blob_len); jpayne@69: #define libssh2_publickey_remove(pkey, name, blob, blob_len) \ jpayne@69: libssh2_publickey_remove_ex((pkey), (name), strlen(name), (blob), (blob_len)) jpayne@69: jpayne@69: LIBSSH2_API int jpayne@69: libssh2_publickey_list_fetch(LIBSSH2_PUBLICKEY *pkey, jpayne@69: unsigned long *num_keys, jpayne@69: libssh2_publickey_list **pkey_list); jpayne@69: LIBSSH2_API void jpayne@69: libssh2_publickey_list_free(LIBSSH2_PUBLICKEY *pkey, jpayne@69: libssh2_publickey_list *pkey_list); jpayne@69: jpayne@69: LIBSSH2_API int libssh2_publickey_shutdown(LIBSSH2_PUBLICKEY *pkey); jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: } /* extern "C" */ jpayne@69: #endif jpayne@69: jpayne@69: #endif /* ifndef: LIBSSH2_PUBLICKEY_H */