Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-17 09:55:47

0001 /* Copyright (C) Sara Golemon <sarag@libssh2.org>
0002  * All rights reserved.
0003  *
0004  * Redistribution and use in source and binary forms,
0005  * with or without modification, are permitted provided
0006  * that the following conditions are met:
0007  *
0008  *   Redistributions of source code must retain the above
0009  *   copyright notice, this list of conditions and the
0010  *   following disclaimer.
0011  *
0012  *   Redistributions in binary form must reproduce the above
0013  *   copyright notice, this list of conditions and the following
0014  *   disclaimer in the documentation and/or other materials
0015  *   provided with the distribution.
0016  *
0017  *   Neither the name of the copyright holder nor the names
0018  *   of any other contributors may be used to endorse or
0019  *   promote products derived from this software without
0020  *   specific prior written permission.
0021  *
0022  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
0023  * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
0024  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
0025  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0026  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
0027  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
0028  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
0029  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
0030  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0031  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
0032  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
0033  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
0034  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
0035  * OF SUCH DAMAGE.
0036  */
0037 
0038 /* Note: This include file is only needed for using the
0039  * publickey SUBSYSTEM which is not the same as publickey
0040  * authentication.  For authentication you only need libssh2.h
0041  *
0042  * For more information on the publickey subsystem,
0043  * refer to IETF draft: secsh-publickey
0044  *
0045  * SPDX-License-Identifier: BSD-3-Clause
0046  */
0047 
0048 #ifndef LIBSSH2_PUBLICKEY_H
0049 #define LIBSSH2_PUBLICKEY_H 1
0050 
0051 #include "libssh2.h"
0052 
0053 typedef struct _LIBSSH2_PUBLICKEY               LIBSSH2_PUBLICKEY;
0054 
0055 typedef struct _libssh2_publickey_attribute {
0056     const char *name;
0057     unsigned long name_len;
0058     const char *value;
0059     unsigned long value_len;
0060     char mandatory;
0061 } libssh2_publickey_attribute;
0062 
0063 typedef struct _libssh2_publickey_list {
0064     unsigned char *packet; /* For freeing */
0065 
0066     const unsigned char *name;
0067     unsigned long name_len;
0068     const unsigned char *blob;
0069     unsigned long blob_len;
0070     unsigned long num_attrs;
0071     libssh2_publickey_attribute *attrs; /* free me */
0072 } libssh2_publickey_list;
0073 
0074 /* Generally use the first macro here, but if both name and value are string
0075    literals, you can use _fast() to take advantage of preprocessing */
0076 #define libssh2_publickey_attribute(name, value, mandatory) \
0077     { (name), strlen(name), (value), strlen(value), (mandatory) },
0078 #define libssh2_publickey_attribute_fast(name, value, mandatory) \
0079     { (name), sizeof(name) - 1, (value), sizeof(value) - 1, (mandatory) },
0080 
0081 #ifdef __cplusplus
0082 extern "C" {
0083 #endif
0084 
0085 /* Publickey Subsystem */
0086 LIBSSH2_API LIBSSH2_PUBLICKEY *
0087 libssh2_publickey_init(LIBSSH2_SESSION *session);
0088 
0089 LIBSSH2_API int
0090 libssh2_publickey_add_ex(LIBSSH2_PUBLICKEY *pkey,
0091                          const unsigned char *name,
0092                          unsigned long name_len,
0093                          const unsigned char *blob,
0094                          unsigned long blob_len, char overwrite,
0095                          unsigned long num_attrs,
0096                          const libssh2_publickey_attribute attrs[]);
0097 #define libssh2_publickey_add(pkey, name, blob, blob_len, overwrite, \
0098                               num_attrs, attrs) \
0099     libssh2_publickey_add_ex((pkey), \
0100                              (name), strlen(name), \
0101                              (blob), (blob_len), \
0102                              (overwrite), (num_attrs), (attrs))
0103 
0104 LIBSSH2_API int libssh2_publickey_remove_ex(LIBSSH2_PUBLICKEY *pkey,
0105                                             const unsigned char *name,
0106                                             unsigned long name_len,
0107                                             const unsigned char *blob,
0108                                             unsigned long blob_len);
0109 #define libssh2_publickey_remove(pkey, name, blob, blob_len) \
0110     libssh2_publickey_remove_ex((pkey), \
0111                                 (name), strlen(name), \
0112                                 (blob), (blob_len))
0113 
0114 LIBSSH2_API int
0115 libssh2_publickey_list_fetch(LIBSSH2_PUBLICKEY *pkey,
0116                              unsigned long *num_keys,
0117                              libssh2_publickey_list **pkey_list);
0118 LIBSSH2_API void
0119 libssh2_publickey_list_free(LIBSSH2_PUBLICKEY *pkey,
0120                             libssh2_publickey_list *pkey_list);
0121 
0122 LIBSSH2_API int libssh2_publickey_shutdown(LIBSSH2_PUBLICKEY *pkey);
0123 
0124 #ifdef __cplusplus
0125 } /* extern "C" */
0126 #endif
0127 
0128 #endif /* LIBSSH2_PUBLICKEY_H */