KiCad PCB EDA Suite
Loading...
Searching...
No Matches
kigit_known_hosts.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.TXT for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 3
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#ifndef KIGIT_KNOWN_HOSTS_H_
21#define KIGIT_KNOWN_HOSTS_H_
22
23#include <import_export.h>
24
25#include <array>
26#include <cstdint>
27#include <string>
28
29#include <wx/string.h>
30
31namespace KIGIT
32{
33
43
44
47{
49 wxString host;
50 int port = 22;
51 wxString keyType;
52 std::string rawKey;
53 wxString fingerprint;
54};
55
56
58APIEXPORT std::array<uint8_t, 20> HmacSha1( const std::string& aKey, const std::string& aData );
59
70APIEXPORT KNOWN_HOST_STATE LookupKnownHost( const wxString& aKnownHostsText, const wxString& aHost, int aPort,
71 const wxString& aKeyType, const std::string& aRawKey );
72
74APIEXPORT wxString FormatKnownHostsLine( const wxString& aHost, int aPort, const wxString& aKeyType,
75 const wxString& aBase64Key );
76
78APIEXPORT wxString HostKeyType( const std::string& aRawKey );
79
81APIEXPORT wxString HostKeyFingerprint( const std::string& aRawKey );
82
84APIEXPORT wxString KnownHostsPath();
85
90APIEXPORT bool MayOfferTrust( const HOST_KEY_FAILURE& aFailure, bool aRetriedAfterTrust );
91
93APIEXPORT wxString HostKeyRefusalMessage( const HOST_KEY_FAILURE& aFailure );
94
102APIEXPORT wxString Libgit2LegacyHome( int aRevision );
103
105APIEXPORT wxString ReadKnownHosts();
106
111APIEXPORT bool AddKnownHost( const HOST_KEY_FAILURE& aKey );
112
113} // namespace KIGIT
114
115#endif // KIGIT_KNOWN_HOSTS_H_
#define APIEXPORT
Macros which export functions from a DLL/DSO.
APIEXPORT bool AddKnownHost(const HOST_KEY_FAILURE &aKey)
Append the refused key to KnownHostsPath(), creating the file and its folder when missing.
KNOWN_HOST_STATE
How a server's host key stands against known_hosts.
@ OTHER_KEY_TYPE
Entries name the host only with keys of other types.
@ MISMATCH
Entries name the host with another key of this type, and none with this one.
@ UNKNOWN
No entry names the host with a key of this type.
@ MATCH
An entry names the host with this key.
@ REVOKED
A @revoked entry carries this key.
APIEXPORT wxString Libgit2LegacyHome(int aRevision)
The home folder libgit2 1.5 reads .ssh/known_hosts under, which it has no option to report.
APIEXPORT wxString FormatKnownHostsLine(const wxString &aHost, int aPort, const wxString &aKeyType, const wxString &aBase64Key)
The known_hosts line ssh would write for a key, without a line ending.
APIEXPORT KNOWN_HOST_STATE LookupKnownHost(const wxString &aKnownHostsText, const wxString &aHost, int aPort, const wxString &aKeyType, const std::string &aRawKey)
Classify a server's key against the text of a known_hosts file, as OpenSSH reads it.
APIEXPORT wxString ReadKnownHosts()
The text of KnownHostsPath(). Empty when it is missing or cannot be read.
APIEXPORT bool MayOfferTrust(const HOST_KEY_FAILURE &aFailure, bool aRetriedAfterTrust)
Whether the user may be asked to trust a refused key.
APIEXPORT wxString HostKeyType(const std::string &aRawKey)
The type a raw SSH key names for itself, such as ssh-ed25519. Empty when the key is malformed.
APIEXPORT wxString HostKeyFingerprint(const std::string &aRawKey)
SHA256 of a raw key in unpadded base64, as ssh shows it after "SHA256:".
APIEXPORT wxString HostKeyRefusalMessage(const HOST_KEY_FAILURE &aFailure)
Why a key the user may not trust was refused, and what to do next.
APIEXPORT std::array< uint8_t, 20 > HmacSha1(const std::string &aKey, const std::string &aData)
HMAC-SHA1 (RFC 2104), as OpenSSH hashes host names in known_hosts.
APIEXPORT wxString KnownHostsPath()
The known_hosts file libgit2 checks host keys against. Empty when it has no home folder.
A server key the connection refused, for the UI to offer to trust or to report.
wxString keyType
As known_hosts names it, such as ssh-ed25519.
wxString fingerprint
SHA256 in unpadded base64, as ssh shows it after "SHA256:".
std::string rawKey
The key as the server sent it.