cscg24-guacamole

CSCG 2024 Challenge 'Guacamole Mashup'
git clone https://git.sinitax.com/sinitax/cscg24-guacamole
Log | Files | Refs | sfeed.txt

ssh_agent.h (2944B)


      1/*
      2 * Licensed to the Apache Software Foundation (ASF) under one
      3 * or more contributor license agreements.  See the NOTICE file
      4 * distributed with this work for additional information
      5 * regarding copyright ownership.  The ASF licenses this file
      6 * to you under the Apache License, Version 2.0 (the
      7 * "License"); you may not use this file except in compliance
      8 * with the License.  You may obtain a copy of the License at
      9 *
     10 *   http://www.apache.org/licenses/LICENSE-2.0
     11 *
     12 * Unless required by applicable law or agreed to in writing,
     13 * software distributed under the License is distributed on an
     14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
     15 * KIND, either express or implied.  See the License for the
     16 * specific language governing permissions and limitations
     17 * under the License.
     18 */
     19
     20
     21#ifndef _GUAC_SSH_AGENT_H
     22#define _GUAC_SSH_AGENT_H
     23
     24#include "config.h"
     25
     26#include "ssh_key.h"
     27
     28/**
     29 * Packet type of an agent identity request.
     30 */
     31#define SSH2_AGENT_REQUEST_IDENTITIES 0x0B
     32
     33/**
     34 * Packet type of an agent identity response.
     35 */
     36#define SSH2_AGENT_IDENTITIES_ANSWER 0x0C
     37
     38/**
     39 * Packet type of an agent sign request.
     40 */
     41#define SSH2_AGENT_SIGN_REQUEST 0x0D
     42
     43/**
     44 * Packet type of an agent sign response.
     45 */
     46#define SSH2_AGENT_SIGN_RESPONSE 0x0E
     47
     48/**
     49 * The comment to associate with public keys when listed.
     50 */
     51#define SSH_AGENT_COMMENT "Guacamole SSH Agent"
     52
     53/**
     54 * The packet sent by the SSH agent when an operation is not supported.
     55 */
     56#define UNSUPPORTED "\x00\x00\x00\x0C\x05Unsupported"
     57
     58/**
     59 * Data representing an SSH auth agent.
     60 */
     61typedef struct ssh_auth_agent {
     62
     63    /**
     64     * The SSH channel being used for SSH agent protocol.
     65     */
     66    LIBSSH2_CHANNEL* channel;
     67
     68    /**
     69     * The single private key to use for authentication.
     70     */
     71    ssh_key* identity;
     72
     73    /**
     74     * Data read from the agent channel.
     75     */
     76    char buffer[4096];
     77
     78    /**
     79     * The number of bytes of data currently stored in the buffer.
     80     */
     81    int buffer_length;
     82
     83} ssh_auth_agent;
     84
     85/**
     86 * Handler for an agent sign request.
     87 */
     88void ssh_auth_agent_sign(ssh_auth_agent* auth_agent,
     89        char* data, int data_length);
     90
     91/**
     92 * Handler for an agent identity request.
     93 */
     94void ssh_auth_agent_list_identities(ssh_auth_agent* auth_agent);
     95
     96/**
     97 * Generic handler for all packets received over the auth agent channel.
     98 */
     99void ssh_auth_agent_handle_packet(ssh_auth_agent* auth_agent,
    100        uint8_t type, char* data, int data_length);
    101
    102/**
    103 * Reads and handles a single packet from the SSH agent channel associated
    104 * with the given ssh_auth_agent, returning the size of that packet, the size
    105 * of the partial packet read, or a negative value if an error occurs.
    106 */
    107int ssh_auth_agent_read(ssh_auth_agent* auth_agent);
    108
    109/**
    110 * Libssh2 callback, invoked when the auth agent channel is opened.
    111 */
    112void ssh_auth_agent_callback(LIBSSH2_SESSION *session,
    113        LIBSSH2_CHANNEL *channel, void **abstract);
    114
    115#endif
    116