nm-setting-8021x.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. /* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
  2. /*
  3. * This library is free software; you can redistribute it and/or
  4. * modify it under the terms of the GNU Lesser General Public
  5. * License as published by the Free Software Foundation; either
  6. * version 2 of the License, or (at your option) any later version.
  7. *
  8. * This library is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. * Lesser General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU Lesser General Public
  14. * License along with this library; if not, write to the
  15. * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  16. * Boston, MA 02110-1301 USA.
  17. *
  18. * Copyright 2007 - 2014 Red Hat, Inc.
  19. * Copyright 2007 - 2008 Novell, Inc.
  20. */
  21. #ifndef NM_SETTING_8021X_H
  22. #define NM_SETTING_8021X_H
  23. #include "nm-setting.h"
  24. G_BEGIN_DECLS
  25. /**
  26. * NMSetting8021xCKFormat:
  27. * @NM_SETTING_802_1X_CK_FORMAT_UNKNOWN: unknown file format
  28. * @NM_SETTING_802_1X_CK_FORMAT_X509: file contains an X.509 format certificate
  29. * @NM_SETTING_802_1X_CK_FORMAT_RAW_KEY: file contains an old-style OpenSSL PEM
  30. * or DER private key
  31. * @NM_SETTING_802_1X_CK_FORMAT_PKCS12: file contains a PKCS#<!-- -->12 certificate
  32. * and private key
  33. *
  34. * #NMSetting8021xCKFormat values indicate the general type of a certificate
  35. * or private key
  36. */
  37. typedef enum { /*< underscore_name=nm_setting_802_1x_ck_format >*/
  38. NM_SETTING_802_1X_CK_FORMAT_UNKNOWN = 0,
  39. NM_SETTING_802_1X_CK_FORMAT_X509,
  40. NM_SETTING_802_1X_CK_FORMAT_RAW_KEY,
  41. NM_SETTING_802_1X_CK_FORMAT_PKCS12
  42. } NMSetting8021xCKFormat;
  43. /**
  44. * NMSetting8021xCKScheme:
  45. * @NM_SETTING_802_1X_CK_SCHEME_UNKNOWN: unknown certificate or private key
  46. * scheme
  47. * @NM_SETTING_802_1X_CK_SCHEME_BLOB: certificate or key is stored as the raw
  48. * item data
  49. * @NM_SETTING_802_1X_CK_SCHEME_PATH: certificate or key is stored as a path
  50. * to a file containing the certificate or key data
  51. *
  52. * #NMSetting8021xCKScheme values indicate how a certificate or private key is
  53. * stored in the setting properties, either as a blob of the item's data, or as
  54. * a path to a certificate or private key file on the filesystem
  55. */
  56. typedef enum { /*< underscore_name=nm_setting_802_1x_ck_scheme >*/
  57. NM_SETTING_802_1X_CK_SCHEME_UNKNOWN = 0,
  58. NM_SETTING_802_1X_CK_SCHEME_BLOB,
  59. NM_SETTING_802_1X_CK_SCHEME_PATH
  60. } NMSetting8021xCKScheme;
  61. #define NM_TYPE_SETTING_802_1X (nm_setting_802_1x_get_type ())
  62. #define NM_SETTING_802_1X(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTING_802_1X, NMSetting8021x))
  63. #define NM_SETTING_802_1X_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SETTING_802_1X, NMSetting8021xClass))
  64. #define NM_IS_SETTING_802_1X(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTING_802_1X))
  65. #define NM_IS_SETTING_802_1X_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SETTING_802_1X))
  66. #define NM_SETTING_802_1X_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SETTING_802_1X, NMSetting8021xClass))
  67. #define NM_SETTING_802_1X_SETTING_NAME "802-1x"
  68. /**
  69. * NMSetting8021xError:
  70. * @NM_SETTING_802_1X_ERROR_UNKNOWN: unknown or unclassified error
  71. * @NM_SETTING_802_1X_ERROR_INVALID_PROPERTY: the property was invalid
  72. * @NM_SETTING_802_1X_ERROR_MISSING_PROPERTY: the property was missing and is
  73. * required
  74. */
  75. typedef enum { /*< underscore_name=nm_setting_802_1x_error >*/
  76. NM_SETTING_802_1X_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
  77. NM_SETTING_802_1X_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/
  78. NM_SETTING_802_1X_ERROR_MISSING_PROPERTY /*< nick=MissingProperty >*/
  79. } NMSetting8021xError;
  80. #define NM_SETTING_802_1X_ERROR nm_setting_802_1x_error_quark ()
  81. GQuark nm_setting_802_1x_error_quark (void);
  82. #define NM_SETTING_802_1X_EAP "eap"
  83. #define NM_SETTING_802_1X_IDENTITY "identity"
  84. #define NM_SETTING_802_1X_ANONYMOUS_IDENTITY "anonymous-identity"
  85. #define NM_SETTING_802_1X_PAC_FILE "pac-file"
  86. #define NM_SETTING_802_1X_CA_CERT "ca-cert"
  87. #define NM_SETTING_802_1X_CA_PATH "ca-path"
  88. #define NM_SETTING_802_1X_SUBJECT_MATCH "subject-match"
  89. #define NM_SETTING_802_1X_ALTSUBJECT_MATCHES "altsubject-matches"
  90. #define NM_SETTING_802_1X_CLIENT_CERT "client-cert"
  91. #define NM_SETTING_802_1X_PHASE1_PEAPVER "phase1-peapver"
  92. #define NM_SETTING_802_1X_PHASE1_PEAPLABEL "phase1-peaplabel"
  93. #define NM_SETTING_802_1X_PHASE1_FAST_PROVISIONING "phase1-fast-provisioning"
  94. #define NM_SETTING_802_1X_PHASE2_AUTH "phase2-auth"
  95. #define NM_SETTING_802_1X_PHASE2_AUTHEAP "phase2-autheap"
  96. #define NM_SETTING_802_1X_PHASE2_CA_CERT "phase2-ca-cert"
  97. #define NM_SETTING_802_1X_PHASE2_CA_PATH "phase2-ca-path"
  98. #define NM_SETTING_802_1X_PHASE2_SUBJECT_MATCH "phase2-subject-match"
  99. #define NM_SETTING_802_1X_PHASE2_ALTSUBJECT_MATCHES "phase2-altsubject-matches"
  100. #define NM_SETTING_802_1X_PHASE2_CLIENT_CERT "phase2-client-cert"
  101. #define NM_SETTING_802_1X_PASSWORD "password"
  102. #define NM_SETTING_802_1X_PASSWORD_FLAGS "password-flags"
  103. #define NM_SETTING_802_1X_PASSWORD_RAW "password-raw"
  104. #define NM_SETTING_802_1X_PASSWORD_RAW_FLAGS "password-raw-flags"
  105. #define NM_SETTING_802_1X_PRIVATE_KEY "private-key"
  106. #define NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD "private-key-password"
  107. #define NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD_FLAGS "private-key-password-flags"
  108. #define NM_SETTING_802_1X_PHASE2_PRIVATE_KEY "phase2-private-key"
  109. #define NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD "phase2-private-key-password"
  110. #define NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD_FLAGS "phase2-private-key-password-flags"
  111. #define NM_SETTING_802_1X_PIN "pin"
  112. #define NM_SETTING_802_1X_PIN_FLAGS "pin-flags"
  113. #define NM_SETTING_802_1X_SYSTEM_CA_CERTS "system-ca-certs"
  114. /* PRIVATE KEY NOTE: when setting PKCS#12 private keys directly via properties
  115. * using the "blob" scheme, the data must be passed in PKCS#12 binary format.
  116. * In this case, the appropriate "client-cert" (or "phase2-client-cert")
  117. * property of the NMSetting8021x object must also contain the exact same
  118. * PKCS#12 binary data that the private key does. This is because the
  119. * PKCS#12 file contains both the private key and client certificate, so both
  120. * properties need to be set to the same thing. When using the "path" scheme,
  121. * just set both the private-key and client-cert properties to the same path.
  122. *
  123. * When setting OpenSSL-derived "traditional" format (ie S/MIME style, not
  124. * PKCS#8) RSA and DSA keys directly via properties with the "blob" scheme, they
  125. * should be passed to NetworkManager in PEM format with the "DEK-Info" and
  126. * "Proc-Type" tags intact. Decrypted private keys should not be used as this
  127. * is insecure and could allow unprivileged users to access the decrypted
  128. * private key data.
  129. *
  130. * When using the "path" scheme, just set the private-key and client-cert
  131. * properties to the paths to their respective objects.
  132. */
  133. typedef struct {
  134. NMSetting parent;
  135. } NMSetting8021x;
  136. typedef struct {
  137. NMSettingClass parent;
  138. /* Padding for future expansion */
  139. void (*_reserved1) (void);
  140. void (*_reserved2) (void);
  141. void (*_reserved3) (void);
  142. void (*_reserved4) (void);
  143. } NMSetting8021xClass;
  144. GType nm_setting_802_1x_get_type (void);
  145. NMSetting *nm_setting_802_1x_new (void);
  146. guint32 nm_setting_802_1x_get_num_eap_methods (NMSetting8021x *setting);
  147. const char * nm_setting_802_1x_get_eap_method (NMSetting8021x *setting, guint32 i);
  148. gboolean nm_setting_802_1x_add_eap_method (NMSetting8021x *setting, const char *eap);
  149. void nm_setting_802_1x_remove_eap_method (NMSetting8021x *setting, guint32 i);
  150. NM_AVAILABLE_IN_0_9_10
  151. gboolean nm_setting_802_1x_remove_eap_method_by_value (NMSetting8021x *setting, const char *eap);
  152. void nm_setting_802_1x_clear_eap_methods (NMSetting8021x *setting);
  153. const char * nm_setting_802_1x_get_identity (NMSetting8021x *setting);
  154. const char * nm_setting_802_1x_get_anonymous_identity (NMSetting8021x *setting);
  155. const char * nm_setting_802_1x_get_pac_file (NMSetting8021x *setting);
  156. gboolean nm_setting_802_1x_get_system_ca_certs (NMSetting8021x *setting);
  157. const char * nm_setting_802_1x_get_ca_path (NMSetting8021x *setting);
  158. const char * nm_setting_802_1x_get_phase2_ca_path (NMSetting8021x *setting);
  159. NMSetting8021xCKScheme nm_setting_802_1x_get_ca_cert_scheme (NMSetting8021x *setting);
  160. const GByteArray * nm_setting_802_1x_get_ca_cert_blob (NMSetting8021x *setting);
  161. const char * nm_setting_802_1x_get_ca_cert_path (NMSetting8021x *setting);
  162. gboolean nm_setting_802_1x_set_ca_cert (NMSetting8021x *setting,
  163. const char *cert_path,
  164. NMSetting8021xCKScheme scheme,
  165. NMSetting8021xCKFormat *out_format,
  166. GError **error);
  167. const char * nm_setting_802_1x_get_subject_match (NMSetting8021x *setting);
  168. guint32 nm_setting_802_1x_get_num_altsubject_matches (NMSetting8021x *setting);
  169. const char * nm_setting_802_1x_get_altsubject_match (NMSetting8021x *setting,
  170. guint32 i);
  171. gboolean nm_setting_802_1x_add_altsubject_match (NMSetting8021x *setting,
  172. const char *altsubject_match);
  173. void nm_setting_802_1x_remove_altsubject_match (NMSetting8021x *setting,
  174. guint32 i);
  175. NM_AVAILABLE_IN_0_9_10
  176. gboolean nm_setting_802_1x_remove_altsubject_match_by_value (NMSetting8021x *setting,
  177. const char *altsubject_match);
  178. void nm_setting_802_1x_clear_altsubject_matches (NMSetting8021x *setting);
  179. NMSetting8021xCKScheme nm_setting_802_1x_get_client_cert_scheme (NMSetting8021x *setting);
  180. const GByteArray * nm_setting_802_1x_get_client_cert_blob (NMSetting8021x *setting);
  181. const char * nm_setting_802_1x_get_client_cert_path (NMSetting8021x *setting);
  182. gboolean nm_setting_802_1x_set_client_cert (NMSetting8021x *setting,
  183. const char *cert_path,
  184. NMSetting8021xCKScheme scheme,
  185. NMSetting8021xCKFormat *out_format,
  186. GError **error);
  187. const char * nm_setting_802_1x_get_phase1_peapver (NMSetting8021x *setting);
  188. const char * nm_setting_802_1x_get_phase1_peaplabel (NMSetting8021x *setting);
  189. const char * nm_setting_802_1x_get_phase1_fast_provisioning (NMSetting8021x *setting);
  190. const char * nm_setting_802_1x_get_phase2_auth (NMSetting8021x *setting);
  191. const char * nm_setting_802_1x_get_phase2_autheap (NMSetting8021x *setting);
  192. NMSetting8021xCKScheme nm_setting_802_1x_get_phase2_ca_cert_scheme (NMSetting8021x *setting);
  193. const GByteArray * nm_setting_802_1x_get_phase2_ca_cert_blob (NMSetting8021x *setting);
  194. const char * nm_setting_802_1x_get_phase2_ca_cert_path (NMSetting8021x *setting);
  195. gboolean nm_setting_802_1x_set_phase2_ca_cert (NMSetting8021x *setting,
  196. const char *cert_path,
  197. NMSetting8021xCKScheme scheme,
  198. NMSetting8021xCKFormat *out_format,
  199. GError **error);
  200. const char * nm_setting_802_1x_get_phase2_subject_match (NMSetting8021x *setting);
  201. guint32 nm_setting_802_1x_get_num_phase2_altsubject_matches (NMSetting8021x *setting);
  202. const char * nm_setting_802_1x_get_phase2_altsubject_match (NMSetting8021x *setting,
  203. guint32 i);
  204. gboolean nm_setting_802_1x_add_phase2_altsubject_match (NMSetting8021x *setting,
  205. const char *phase2_altsubject_match);
  206. void nm_setting_802_1x_remove_phase2_altsubject_match (NMSetting8021x *setting,
  207. guint32 i);
  208. NM_AVAILABLE_IN_0_9_10
  209. gboolean nm_setting_802_1x_remove_phase2_altsubject_match_by_value (NMSetting8021x *setting,
  210. const char *phase2_altsubject_match);
  211. void nm_setting_802_1x_clear_phase2_altsubject_matches (NMSetting8021x *setting);
  212. NMSetting8021xCKScheme nm_setting_802_1x_get_phase2_client_cert_scheme (NMSetting8021x *setting);
  213. const GByteArray * nm_setting_802_1x_get_phase2_client_cert_blob (NMSetting8021x *setting);
  214. const char * nm_setting_802_1x_get_phase2_client_cert_path (NMSetting8021x *setting);
  215. gboolean nm_setting_802_1x_set_phase2_client_cert (NMSetting8021x *setting,
  216. const char *cert_path,
  217. NMSetting8021xCKScheme scheme,
  218. NMSetting8021xCKFormat *out_format,
  219. GError **error);
  220. const char * nm_setting_802_1x_get_password (NMSetting8021x *setting);
  221. NMSettingSecretFlags nm_setting_802_1x_get_password_flags (NMSetting8021x *setting);
  222. const GByteArray * nm_setting_802_1x_get_password_raw (NMSetting8021x *setting);
  223. NMSettingSecretFlags nm_setting_802_1x_get_password_raw_flags (NMSetting8021x *setting);
  224. const char * nm_setting_802_1x_get_pin (NMSetting8021x *setting);
  225. NMSettingSecretFlags nm_setting_802_1x_get_pin_flags (NMSetting8021x *setting);
  226. NMSetting8021xCKScheme nm_setting_802_1x_get_private_key_scheme (NMSetting8021x *setting);
  227. const GByteArray * nm_setting_802_1x_get_private_key_blob (NMSetting8021x *setting);
  228. const char * nm_setting_802_1x_get_private_key_path (NMSetting8021x *setting);
  229. gboolean nm_setting_802_1x_set_private_key (NMSetting8021x *setting,
  230. const char *key_path,
  231. const char *password,
  232. NMSetting8021xCKScheme scheme,
  233. NMSetting8021xCKFormat *out_format,
  234. GError **error);
  235. const char * nm_setting_802_1x_get_private_key_password (NMSetting8021x *setting);
  236. NMSettingSecretFlags nm_setting_802_1x_get_private_key_password_flags (NMSetting8021x *setting);
  237. NMSetting8021xCKFormat nm_setting_802_1x_get_private_key_format (NMSetting8021x *setting);
  238. NMSetting8021xCKScheme nm_setting_802_1x_get_phase2_private_key_scheme (NMSetting8021x *setting);
  239. const GByteArray * nm_setting_802_1x_get_phase2_private_key_blob (NMSetting8021x *setting);
  240. const char * nm_setting_802_1x_get_phase2_private_key_path (NMSetting8021x *setting);
  241. gboolean nm_setting_802_1x_set_phase2_private_key (NMSetting8021x *setting,
  242. const char *key_path,
  243. const char *password,
  244. NMSetting8021xCKScheme scheme,
  245. NMSetting8021xCKFormat *out_format,
  246. GError **error);
  247. const char * nm_setting_802_1x_get_phase2_private_key_password (NMSetting8021x *setting);
  248. NMSettingSecretFlags nm_setting_802_1x_get_phase2_private_key_password_flags (NMSetting8021x *setting);
  249. NMSetting8021xCKFormat nm_setting_802_1x_get_phase2_private_key_format (NMSetting8021x *setting);
  250. G_END_DECLS
  251. #endif /* NM_SETTING_8021X_H */