Debian Codegraph @

contrib/mod_sftp/keys.h

raw symbols SCIP
1 /*
2 * ProFTPD - mod_sftp key mgmt (keys)
3 * Copyright (c) 2008-2023 TJ Saunders
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
18 *
19 * As a special exemption, TJ Saunders and other respective copyright holders
20 * give permission to link this program with OpenSSL, and distribute the
21 * resulting executable, without including the source code for OpenSSL in the
22 * source distribution.
23 */
24
25 #ifndef MOD_SFTP_KEYS_H
26 #define MOD_SFTP_KEYS_H
27
28 #include "mod_sftp.h"
29
30 enum sftp_key_type_e {
31 SFTP_KEY_UNKNOWN = 0,
32 SFTP_KEY_DSA,
33 SFTP_KEY_RSA,
34 SFTP_KEY_ECDSA_256,
35 SFTP_KEY_ECDSA_384,
36 SFTP_KEY_ECDSA_521,
37 SFTP_KEY_ED25519,
38 SFTP_KEY_ED448,
39 SFTP_KEY_RSA_SHA256,
40 SFTP_KEY_RSA_SHA512,
41
42 /* OpenSSH security keys */
43 SFTP_KEY_ECDSA_256_SK,
44 SFTP_KEY_ED25519_SK
45 };
46
47 /* Details learned during verification of signed data, such as for
48 * Security Keys (SK).
49 */
50 struct sftp_verify_details {
51 int is_security_key;
52 const char *sk_application;
53 uint32_t sk_counter;
54 unsigned char sk_flags;
55 };
56
57 /* Returns a string of colon-separated lowercase hex characters, representing
58 * the key "fingerprint" which has been run through the specified digest
59 * algorithm.
60 *
61 * As per draft-ietf-secsh-fingerprint-00, only MD5 fingerprints are currently
62 * supported.
63 */
64 const char *sftp_keys_get_fingerprint(pool *, unsigned char *, uint32_t, int);
65 #define SFTP_KEYS_FP_DIGEST_MD5 1
66 #define SFTP_KEYS_FP_DIGEST_SHA1 2
67 #define SFTP_KEYS_FP_DIGEST_SHA256 3
68
69 /* Security Key flags */
70 #define SFTP_KEYS_SK_USER_PRESENCE_REQUIRED 0x001
71 #define SFTP_KEYS_SK_USER_VERIFICATION_REQUIRED 0x004
72
73 void sftp_keys_free(void);
74 int sftp_keys_get_hostkey(pool *p, const char *);
75 const unsigned char *sftp_keys_get_hostkey_data(pool *, enum sftp_key_type_e,
76 uint32_t *);
77 void sftp_keys_get_passphrases(void);
78 int sftp_keys_set_passphrase_provider(const char *);
79 const unsigned char *sftp_keys_sign_data(pool *, enum sftp_key_type_e,
80 const unsigned char *, size_t, size_t *);
81 #ifdef PR_USE_OPENSSL_ECC
82 int sftp_keys_validate_ecdsa_params(const EC_GROUP *, const EC_POINT *);
83 #endif /* PR_USE_OPENSSL_ECC */
84 int sftp_keys_verify_pubkey_type(pool *, unsigned char *, uint32_t,
85 enum sftp_key_type_e);
86 int sftp_keys_verify_signed_data(pool *, const char *,
87 unsigned char *, uint32_t, unsigned char *, uint32_t,
88 unsigned char *, size_t, struct sftp_verify_details *);
89 int sftp_keys_permit_key(pool *, const char *, const char *,
90 struct sftp_verify_details *, pr_table_t *);
91
92 /* Sets minimum key sizes. */
93 int sftp_keys_set_key_limits(int rsa_min, int dsa_min, int ec_min);
94
95 /* Used for supporting the OpenSSH hostkey rotation mechanism. */
96 int sftp_keys_send_hostkeys(pool *p);
97 int sftp_keys_prove_hostkeys(pool *p, int want_reply, unsigned char *buf,
98 uint32_t buflen);
99
100 int sftp_keys_clear_dsa_hostkey(void);
101 int sftp_keys_clear_ecdsa_hostkey(void);
102 int sftp_keys_clear_ed25519_hostkey(void);
103 int sftp_keys_clear_ed448_hostkey(void);
104 int sftp_keys_clear_rsa_hostkey(void);
105 int sftp_keys_have_dsa_hostkey(void);
106 int sftp_keys_have_ecdsa_hostkey(pool *, int **);
107 int sftp_keys_have_ed25519_hostkey(void);
108 int sftp_keys_have_ed448_hostkey(void);
109 int sftp_keys_have_rsa_hostkey(void);
110 #endif /* MOD_SFTP_KEYS_H */