monotone

monotone Mtn Source Tree

Root/ssh_agent.hh

1// Copyright (C) 2007 Justin Patrin <papercrane@reversefold.com>
2//
3// This program is made available under the GNU GPL version 2.0 or
4// greater. See the accompanying file COPYING for details.
5//
6// This program is distributed WITHOUT ANY WARRANTY; without even the
7// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8// PURPOSE.
9
10#ifndef __SSH_AGENT_H__
11#define __SSH_AGENT_H__
12
13#include "numeric_vocab.hh"
14#include "netxx/stream.h"
15#include "botan/rsa.h"
16#include "botan/bigint.h"
17#include <boost/shared_ptr.hpp>
18#include <vector>
19#include "platform.hh"
20
21class ssh_agent : ssh_agent_platform
22{
23public:
24 ssh_agent();
25 ~ssh_agent();
26 std::vector<Botan::RSA_PublicKey> const get_keys();
27 void sign_data(Botan::RSA_PublicKey const & key,
28 std::string const & data,
29 std::string & out);
30 void add_identity(Botan::RSA_PrivateKey const & key, std::string const & comment);
31 bool connected();
32
33private:
34 std::vector<Botan::RSA_PublicKey> keys;
35
36 //helper functions for reading and unpacking data from ssh-agent
37 void fetch_packet(std::string & packet);
38 u32 get_long(char const * buf);
39 u32 get_long_from_buf(std::string const & buf, u32 & loc);
40 void get_string_from_buf(std::string const & buf,
41 u32 & loc,
42 u32 & len,
43 std::string & out);
44
45 //helper functions for packing data to send to ssh-agent
46 void put_long(u32 l, char * buf);
47 void put_long_into_buf(u32 l, std::string & buf);
48 void put_string_into_buf(std::string const & str, std::string & buf);
49 void put_bigint_into_buf(Botan::BigInt const & bi, std::string & buf);
50 void put_public_key_into_buf(Botan::RSA_PublicKey const & key, std::string & buf);
51 void put_private_key_into_buf(Botan::RSA_PrivateKey const & key, std::string & buf);
52};
53
54// Local Variables:
55// mode: C++
56// fill-column: 76
57// c-file-style: "gnu"
58// indent-tabs-mode: nil
59// End:
60// vim: et:sw=2:sts=2:ts=2:cino=>2s,{s,\:s,+s,t0,g0,^-2,e-2,n-2,p2s,(0,=s:
61
62#endif

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status