Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:00:17

0001 /*
0002  * Copyright (C) 2003-2012 Free Software Foundation, Inc.
0003  *
0004  * Author: Nikos Mavrogiannopoulos
0005  *
0006  * This file is part of GnuTLS.
0007  *
0008  * The GnuTLS is free software; you can redistribute it and/or
0009  * modify it under the terms of the GNU Lesser General Public License
0010  * as published by the Free Software Foundation; either version 2.1 of
0011  * the License, or (at your option) any later version.
0012  *
0013  * This library is distributed in the hope that it will be useful, but
0014  * WITHOUT ANY WARRANTY; without even the implied warranty of
0015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0016  * Lesser General Public License for more details.
0017  *
0018  * You should have received a copy of the GNU Lesser General Public License
0019  * along with this program.  If not, see <https://www.gnu.org/licenses/>
0020  *
0021  */
0022 
0023 /* This file contains the types and prototypes for the OpenPGP
0024  * key and private key parsing functions.
0025  */
0026 
0027 #ifndef GNUTLS_OPENPGP_H
0028 #define GNUTLS_OPENPGP_H
0029 
0030 #include <gnutls/gnutls.h>
0031 #include <limits.h>
0032 
0033 #ifdef __cplusplus
0034 extern "C" {
0035 #endif
0036 
0037 /* Openpgp certificate stuff
0038  */
0039 
0040 /**
0041  * gnutls_openpgp_crt_fmt_t:
0042  * @GNUTLS_OPENPGP_FMT_RAW: OpenPGP certificate in raw format.
0043  * @GNUTLS_OPENPGP_FMT_BASE64: OpenPGP certificate in base64 format.
0044  *
0045  * Enumeration of different OpenPGP key formats.
0046  */
0047 typedef enum gnutls_openpgp_crt_fmt {
0048     GNUTLS_OPENPGP_FMT_RAW,
0049     GNUTLS_OPENPGP_FMT_BASE64
0050 } gnutls_openpgp_crt_fmt_t;
0051 
0052 #define GNUTLS_OPENPGP_KEYID_SIZE 8
0053 #define GNUTLS_OPENPGP_V4_FINGERPRINT_SIZE 20
0054 typedef unsigned char gnutls_openpgp_keyid_t[GNUTLS_OPENPGP_KEYID_SIZE];
0055 
0056 /* gnutls_openpgp_cert_t should be defined in gnutls.h
0057  */
0058 
0059 /* initializes the memory for gnutls_openpgp_crt_t struct */
0060 int gnutls_openpgp_crt_init(gnutls_openpgp_crt_t *key)
0061     _GNUTLS_GCC_ATTR_DEPRECATED;
0062 /* frees all memory */
0063 void gnutls_openpgp_crt_deinit(gnutls_openpgp_crt_t key)
0064     _GNUTLS_GCC_ATTR_DEPRECATED;
0065 
0066 int gnutls_openpgp_crt_import(
0067     gnutls_openpgp_crt_t key, const gnutls_datum_t *data,
0068     gnutls_openpgp_crt_fmt_t format) _GNUTLS_GCC_ATTR_DEPRECATED;
0069 int gnutls_openpgp_crt_export(gnutls_openpgp_crt_t key,
0070                   gnutls_openpgp_crt_fmt_t format,
0071                   void *output_data, size_t *output_data_size)
0072     _GNUTLS_GCC_ATTR_DEPRECATED;
0073 int gnutls_openpgp_crt_export2(gnutls_openpgp_crt_t key,
0074                    gnutls_openpgp_crt_fmt_t format,
0075                    gnutls_datum_t *out) _GNUTLS_GCC_ATTR_DEPRECATED;
0076 
0077 int gnutls_openpgp_crt_print(gnutls_openpgp_crt_t cert,
0078                  gnutls_certificate_print_formats_t format,
0079                  gnutls_datum_t *out) _GNUTLS_GCC_ATTR_DEPRECATED;
0080 
0081 /* The key_usage flags are defined in gnutls.h. They are
0082  * the GNUTLS_KEY_* definitions.
0083  */
0084 #define GNUTLS_OPENPGP_MASTER_KEYID_IDX INT_MAX
0085 
0086 int gnutls_openpgp_crt_get_key_usage(gnutls_openpgp_crt_t key,
0087                      unsigned int *key_usage)
0088     _GNUTLS_GCC_ATTR_DEPRECATED;
0089 int gnutls_openpgp_crt_get_fingerprint(gnutls_openpgp_crt_t key, void *fpr,
0090                        size_t *fprlen)
0091     _GNUTLS_GCC_ATTR_DEPRECATED;
0092 int gnutls_openpgp_crt_get_subkey_fingerprint(
0093     gnutls_openpgp_crt_t key, unsigned int idx, void *fpr,
0094     size_t *fprlen) _GNUTLS_GCC_ATTR_DEPRECATED;
0095 
0096 int gnutls_openpgp_crt_get_name(gnutls_openpgp_crt_t key, int idx, char *buf,
0097                 size_t *sizeof_buf) _GNUTLS_GCC_ATTR_DEPRECATED;
0098 
0099 gnutls_pk_algorithm_t gnutls_openpgp_crt_get_pk_algorithm(
0100     gnutls_openpgp_crt_t key,
0101     unsigned int *bits) _GNUTLS_GCC_ATTR_DEPRECATED;
0102 
0103 int gnutls_openpgp_crt_get_version(gnutls_openpgp_crt_t key)
0104     _GNUTLS_GCC_ATTR_DEPRECATED;
0105 
0106 time_t gnutls_openpgp_crt_get_creation_time(gnutls_openpgp_crt_t key)
0107     _GNUTLS_GCC_ATTR_DEPRECATED;
0108 time_t gnutls_openpgp_crt_get_expiration_time(gnutls_openpgp_crt_t key)
0109     _GNUTLS_GCC_ATTR_DEPRECATED;
0110 
0111 int gnutls_openpgp_crt_get_key_id(gnutls_openpgp_crt_t key,
0112                   gnutls_openpgp_keyid_t keyid)
0113     _GNUTLS_GCC_ATTR_DEPRECATED;
0114 
0115 int gnutls_openpgp_crt_check_hostname(gnutls_openpgp_crt_t key,
0116                       const char *hostname)
0117     _GNUTLS_GCC_ATTR_DEPRECATED;
0118 int gnutls_openpgp_crt_check_hostname2(gnutls_openpgp_crt_t key,
0119                        const char *hostname, unsigned int flags)
0120     _GNUTLS_GCC_ATTR_DEPRECATED;
0121 int gnutls_openpgp_crt_check_email(gnutls_openpgp_crt_t key, const char *email,
0122                    unsigned flags) _GNUTLS_GCC_ATTR_DEPRECATED;
0123 
0124 int gnutls_openpgp_crt_get_revoked_status(gnutls_openpgp_crt_t key)
0125     _GNUTLS_GCC_ATTR_DEPRECATED;
0126 
0127 int gnutls_openpgp_crt_get_subkey_count(gnutls_openpgp_crt_t key)
0128     _GNUTLS_GCC_ATTR_DEPRECATED;
0129 int gnutls_openpgp_crt_get_subkey_idx(gnutls_openpgp_crt_t key,
0130                       const gnutls_openpgp_keyid_t keyid)
0131     _GNUTLS_GCC_ATTR_DEPRECATED;
0132 int gnutls_openpgp_crt_get_subkey_revoked_status(
0133     gnutls_openpgp_crt_t key, unsigned int idx) _GNUTLS_GCC_ATTR_DEPRECATED;
0134 gnutls_pk_algorithm_t gnutls_openpgp_crt_get_subkey_pk_algorithm(
0135     gnutls_openpgp_crt_t key, unsigned int idx,
0136     unsigned int *bits) _GNUTLS_GCC_ATTR_DEPRECATED;
0137 time_t gnutls_openpgp_crt_get_subkey_creation_time(
0138     gnutls_openpgp_crt_t key, unsigned int idx) _GNUTLS_GCC_ATTR_DEPRECATED;
0139 time_t gnutls_openpgp_crt_get_subkey_expiration_time(
0140     gnutls_openpgp_crt_t key, unsigned int idx) _GNUTLS_GCC_ATTR_DEPRECATED;
0141 int gnutls_openpgp_crt_get_subkey_id(gnutls_openpgp_crt_t key, unsigned int idx,
0142                      gnutls_openpgp_keyid_t keyid)
0143     _GNUTLS_GCC_ATTR_DEPRECATED;
0144 int gnutls_openpgp_crt_get_subkey_usage(
0145     gnutls_openpgp_crt_t key, unsigned int idx,
0146     unsigned int *key_usage) _GNUTLS_GCC_ATTR_DEPRECATED;
0147 
0148 int gnutls_openpgp_crt_get_subkey_pk_dsa_raw(
0149     gnutls_openpgp_crt_t crt, unsigned int idx, gnutls_datum_t *p,
0150     gnutls_datum_t *q, gnutls_datum_t *g,
0151     gnutls_datum_t *y) _GNUTLS_GCC_ATTR_DEPRECATED;
0152 int gnutls_openpgp_crt_get_subkey_pk_rsa_raw(
0153     gnutls_openpgp_crt_t crt, unsigned int idx, gnutls_datum_t *m,
0154     gnutls_datum_t *e) _GNUTLS_GCC_ATTR_DEPRECATED;
0155 int gnutls_openpgp_crt_get_pk_dsa_raw(
0156     gnutls_openpgp_crt_t crt, gnutls_datum_t *p, gnutls_datum_t *q,
0157     gnutls_datum_t *g, gnutls_datum_t *y) _GNUTLS_GCC_ATTR_DEPRECATED;
0158 int gnutls_openpgp_crt_get_pk_rsa_raw(gnutls_openpgp_crt_t crt,
0159                       gnutls_datum_t *m, gnutls_datum_t *e)
0160     _GNUTLS_GCC_ATTR_DEPRECATED;
0161 
0162 int gnutls_openpgp_crt_get_preferred_key_id(gnutls_openpgp_crt_t key,
0163                         gnutls_openpgp_keyid_t keyid)
0164     _GNUTLS_GCC_ATTR_DEPRECATED;
0165 int gnutls_openpgp_crt_set_preferred_key_id(gnutls_openpgp_crt_t key,
0166                         const gnutls_openpgp_keyid_t keyid)
0167     _GNUTLS_GCC_ATTR_DEPRECATED;
0168 
0169 /* privkey stuff.
0170  */
0171 int gnutls_openpgp_privkey_init(gnutls_openpgp_privkey_t *key)
0172     _GNUTLS_GCC_ATTR_DEPRECATED;
0173 void gnutls_openpgp_privkey_deinit(gnutls_openpgp_privkey_t key)
0174     _GNUTLS_GCC_ATTR_DEPRECATED;
0175 gnutls_pk_algorithm_t gnutls_openpgp_privkey_get_pk_algorithm(
0176     gnutls_openpgp_privkey_t key,
0177     unsigned int *bits) _GNUTLS_GCC_ATTR_DEPRECATED;
0178 
0179 gnutls_sec_param_t gnutls_openpgp_privkey_sec_param(
0180     gnutls_openpgp_privkey_t key) _GNUTLS_GCC_ATTR_DEPRECATED;
0181 int gnutls_openpgp_privkey_import(
0182     gnutls_openpgp_privkey_t key, const gnutls_datum_t *data,
0183     gnutls_openpgp_crt_fmt_t format, const char *password,
0184     unsigned int flags) _GNUTLS_GCC_ATTR_DEPRECATED;
0185 
0186 int gnutls_openpgp_privkey_get_fingerprint(gnutls_openpgp_privkey_t key,
0187                        void *fpr, size_t *fprlen)
0188     _GNUTLS_GCC_ATTR_DEPRECATED;
0189 int gnutls_openpgp_privkey_get_subkey_fingerprint(
0190     gnutls_openpgp_privkey_t key, unsigned int idx, void *fpr,
0191     size_t *fprlen) _GNUTLS_GCC_ATTR_DEPRECATED;
0192 int gnutls_openpgp_privkey_get_key_id(gnutls_openpgp_privkey_t key,
0193                       gnutls_openpgp_keyid_t keyid)
0194     _GNUTLS_GCC_ATTR_DEPRECATED;
0195 int gnutls_openpgp_privkey_get_subkey_count(gnutls_openpgp_privkey_t key)
0196     _GNUTLS_GCC_ATTR_DEPRECATED;
0197 int gnutls_openpgp_privkey_get_subkey_idx(gnutls_openpgp_privkey_t key,
0198                       const gnutls_openpgp_keyid_t keyid)
0199     _GNUTLS_GCC_ATTR_DEPRECATED;
0200 
0201 int gnutls_openpgp_privkey_get_subkey_revoked_status(
0202     gnutls_openpgp_privkey_t key,
0203     unsigned int idx) _GNUTLS_GCC_ATTR_DEPRECATED;
0204 
0205 int gnutls_openpgp_privkey_get_revoked_status(gnutls_openpgp_privkey_t key)
0206     _GNUTLS_GCC_ATTR_DEPRECATED;
0207 
0208 gnutls_pk_algorithm_t gnutls_openpgp_privkey_get_subkey_pk_algorithm(
0209     gnutls_openpgp_privkey_t key, unsigned int idx,
0210     unsigned int *bits) _GNUTLS_GCC_ATTR_DEPRECATED;
0211 
0212 time_t gnutls_openpgp_privkey_get_subkey_expiration_time(
0213     gnutls_openpgp_privkey_t key,
0214     unsigned int idx) _GNUTLS_GCC_ATTR_DEPRECATED;
0215 
0216 int gnutls_openpgp_privkey_get_subkey_id(
0217     gnutls_openpgp_privkey_t key, unsigned int idx,
0218     gnutls_openpgp_keyid_t keyid) _GNUTLS_GCC_ATTR_DEPRECATED;
0219 
0220 time_t gnutls_openpgp_privkey_get_subkey_creation_time(
0221     gnutls_openpgp_privkey_t key,
0222     unsigned int idx) _GNUTLS_GCC_ATTR_DEPRECATED;
0223 
0224 int gnutls_openpgp_privkey_export_subkey_dsa_raw(
0225     gnutls_openpgp_privkey_t pkey, unsigned int idx, gnutls_datum_t *p,
0226     gnutls_datum_t *q, gnutls_datum_t *g, gnutls_datum_t *y,
0227     gnutls_datum_t *x) _GNUTLS_GCC_ATTR_DEPRECATED;
0228 int gnutls_openpgp_privkey_export_subkey_rsa_raw(
0229     gnutls_openpgp_privkey_t pkey, unsigned int idx, gnutls_datum_t *m,
0230     gnutls_datum_t *e, gnutls_datum_t *d, gnutls_datum_t *p,
0231     gnutls_datum_t *q, gnutls_datum_t *u) _GNUTLS_GCC_ATTR_DEPRECATED;
0232 
0233 int gnutls_openpgp_privkey_export_dsa_raw(
0234     gnutls_openpgp_privkey_t pkey, gnutls_datum_t *p, gnutls_datum_t *q,
0235     gnutls_datum_t *g, gnutls_datum_t *y,
0236     gnutls_datum_t *x) _GNUTLS_GCC_ATTR_DEPRECATED;
0237 int gnutls_openpgp_privkey_export_rsa_raw(
0238     gnutls_openpgp_privkey_t pkey, gnutls_datum_t *m, gnutls_datum_t *e,
0239     gnutls_datum_t *d, gnutls_datum_t *p, gnutls_datum_t *q,
0240     gnutls_datum_t *u) _GNUTLS_GCC_ATTR_DEPRECATED;
0241 
0242 int gnutls_openpgp_privkey_export(
0243     gnutls_openpgp_privkey_t key, gnutls_openpgp_crt_fmt_t format,
0244     const char *password, unsigned int flags, void *output_data,
0245     size_t *output_data_size) _GNUTLS_GCC_ATTR_DEPRECATED;
0246 int gnutls_openpgp_privkey_export2(
0247     gnutls_openpgp_privkey_t key, gnutls_openpgp_crt_fmt_t format,
0248     const char *password, unsigned int flags,
0249     gnutls_datum_t *out) _GNUTLS_GCC_ATTR_DEPRECATED;
0250 
0251 int gnutls_openpgp_privkey_set_preferred_key_id(
0252     gnutls_openpgp_privkey_t key,
0253     const gnutls_openpgp_keyid_t keyid) _GNUTLS_GCC_ATTR_DEPRECATED;
0254 int gnutls_openpgp_privkey_get_preferred_key_id(gnutls_openpgp_privkey_t key,
0255                         gnutls_openpgp_keyid_t keyid)
0256     _GNUTLS_GCC_ATTR_DEPRECATED;
0257 
0258 int gnutls_openpgp_crt_get_auth_subkey(
0259     gnutls_openpgp_crt_t crt, gnutls_openpgp_keyid_t keyid,
0260     unsigned int flag) _GNUTLS_GCC_ATTR_DEPRECATED;
0261 
0262 /* Keyring stuff.
0263  */
0264 
0265 int gnutls_openpgp_keyring_init(gnutls_openpgp_keyring_t *keyring)
0266     _GNUTLS_GCC_ATTR_DEPRECATED;
0267 void gnutls_openpgp_keyring_deinit(gnutls_openpgp_keyring_t keyring)
0268     _GNUTLS_GCC_ATTR_DEPRECATED;
0269 
0270 int gnutls_openpgp_keyring_import(
0271     gnutls_openpgp_keyring_t keyring, const gnutls_datum_t *data,
0272     gnutls_openpgp_crt_fmt_t format) _GNUTLS_GCC_ATTR_DEPRECATED;
0273 
0274 int gnutls_openpgp_keyring_check_id(
0275     gnutls_openpgp_keyring_t ring, const gnutls_openpgp_keyid_t keyid,
0276     unsigned int flags) _GNUTLS_GCC_ATTR_DEPRECATED;
0277 
0278 int gnutls_openpgp_crt_verify_ring(gnutls_openpgp_crt_t key,
0279                    gnutls_openpgp_keyring_t keyring,
0280                    unsigned int flags, unsigned int *verify
0281                    /* the output of the verification */
0282                    ) _GNUTLS_GCC_ATTR_DEPRECATED;
0283 
0284 int gnutls_openpgp_crt_verify_self(gnutls_openpgp_crt_t key, unsigned int flags,
0285                    unsigned int *verify)
0286     _GNUTLS_GCC_ATTR_DEPRECATED;
0287 
0288 int gnutls_openpgp_keyring_get_crt(gnutls_openpgp_keyring_t ring,
0289                    unsigned int idx, gnutls_openpgp_crt_t *cert)
0290     _GNUTLS_GCC_ATTR_DEPRECATED;
0291 
0292 int gnutls_openpgp_keyring_get_crt_count(gnutls_openpgp_keyring_t ring)
0293     _GNUTLS_GCC_ATTR_DEPRECATED;
0294 
0295 /**
0296  * gnutls_openpgp_recv_key_func:
0297  * @session: a TLS session
0298  * @keyfpr: key fingerprint
0299  * @keyfpr_length: length of key fingerprint
0300  * @key: output key.
0301  *
0302  * A callback of this type is used to retrieve OpenPGP keys.  Only
0303  * useful on the server, and will only be used if the peer send a key
0304  * fingerprint instead of a full key.  See also
0305  * gnutls_openpgp_set_recv_key_function().
0306  *
0307  * The variable @key must be allocated using gnutls_malloc().
0308  *
0309  * Returns: On success, %GNUTLS_E_SUCCESS (zero) is returned,
0310  *   otherwise an error code is returned.
0311  */
0312 typedef int (*gnutls_openpgp_recv_key_func)(gnutls_session_t session,
0313                         const unsigned char *keyfpr,
0314                         unsigned int keyfpr_length,
0315                         gnutls_datum_t *key);
0316 
0317 void gnutls_openpgp_set_recv_key_function(gnutls_session_t session,
0318                       gnutls_openpgp_recv_key_func func)
0319     _GNUTLS_GCC_ATTR_DEPRECATED;
0320 
0321 /* certificate authentication stuff.
0322  */
0323 int gnutls_certificate_set_openpgp_key(
0324     gnutls_certificate_credentials_t res, gnutls_openpgp_crt_t crt,
0325     gnutls_openpgp_privkey_t pkey) _GNUTLS_GCC_ATTR_DEPRECATED;
0326 
0327 int gnutls_certificate_get_openpgp_key(
0328     gnutls_certificate_credentials_t res, unsigned index,
0329     gnutls_openpgp_privkey_t *key) _GNUTLS_GCC_ATTR_DEPRECATED;
0330 int gnutls_certificate_get_openpgp_crt(
0331     gnutls_certificate_credentials_t res, unsigned index,
0332     gnutls_openpgp_crt_t **crt_list,
0333     unsigned *crt_list_size) _GNUTLS_GCC_ATTR_DEPRECATED;
0334 
0335 int gnutls_certificate_set_openpgp_key_file(
0336     gnutls_certificate_credentials_t res, const char *certfile,
0337     const char *keyfile,
0338     gnutls_openpgp_crt_fmt_t format) _GNUTLS_GCC_ATTR_DEPRECATED;
0339 int gnutls_certificate_set_openpgp_key_mem(
0340     gnutls_certificate_credentials_t res, const gnutls_datum_t *cert,
0341     const gnutls_datum_t *key,
0342     gnutls_openpgp_crt_fmt_t format) _GNUTLS_GCC_ATTR_DEPRECATED;
0343 
0344 int gnutls_certificate_set_openpgp_key_file2(
0345     gnutls_certificate_credentials_t res, const char *certfile,
0346     const char *keyfile, const char *subkey_id,
0347     gnutls_openpgp_crt_fmt_t format) _GNUTLS_GCC_ATTR_DEPRECATED;
0348 int gnutls_certificate_set_openpgp_key_mem2(
0349     gnutls_certificate_credentials_t res, const gnutls_datum_t *cert,
0350     const gnutls_datum_t *key, const char *subkey_id,
0351     gnutls_openpgp_crt_fmt_t format) _GNUTLS_GCC_ATTR_DEPRECATED;
0352 
0353 int gnutls_certificate_set_openpgp_keyring_mem(
0354     gnutls_certificate_credentials_t c, const unsigned char *data,
0355     size_t dlen,
0356     gnutls_openpgp_crt_fmt_t format) _GNUTLS_GCC_ATTR_DEPRECATED;
0357 
0358 int gnutls_certificate_set_openpgp_keyring_file(
0359     gnutls_certificate_credentials_t c, const char *file,
0360     gnutls_openpgp_crt_fmt_t format) _GNUTLS_GCC_ATTR_DEPRECATED;
0361 
0362 #ifdef __cplusplus
0363 }
0364 #endif
0365 
0366 #endif /* GNUTLS_OPENPGP_H */