summaryrefslogtreecommitdiffstats
path: root/src/userpref.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/userpref.c')
-rw-r--r--src/userpref.c44
1 files changed, 29 insertions, 15 deletions
diff --git a/src/userpref.c b/src/userpref.c
index 3a8a9d6..59c61b6 100644
--- a/src/userpref.c
+++ b/src/userpref.c
@@ -42,7 +42,8 @@
42#define LIBIMOBILEDEVICE_HOST_CERTIF "HostCertificate.pem" 42#define LIBIMOBILEDEVICE_HOST_CERTIF "HostCertificate.pem"
43 43
44 44
45/** Creates a freedesktop compatible configuration directory. 45/**
46 * Creates a freedesktop compatible configuration directory.
46 */ 47 */
47static void userpref_create_config_dir(void) 48static void userpref_create_config_dir(void)
48{ 49{
@@ -60,7 +61,8 @@ static int get_rand(int min, int max)
60 return retval; 61 return retval;
61} 62}
62 63
63/** Generates a valid HostID (which is actually a UUID). 64/**
65 * Generates a valid HostID (which is actually a UUID).
64 * 66 *
65 * @return A null terminated string containing a valid HostID. 67 * @return A null terminated string containing a valid HostID.
66 */ 68 */
@@ -85,7 +87,8 @@ static char *userpref_generate_host_id()
85 return hostid; 87 return hostid;
86} 88}
87 89
88/** Store HostID in config file. 90/**
91 * Store HostID in config file.
89 * 92 *
90 * @param host_id A null terminated string containing a valid HostID. 93 * @param host_id A null terminated string containing a valid HostID.
91 */ 94 */
@@ -123,7 +126,8 @@ static int userpref_set_host_id(const char *host_id)
123 return 1; 126 return 1;
124} 127}
125 128
126/** Reads the HostID from a previously generated configuration file. 129/**
130 * Reads the HostID from a previously generated configuration file.
127 * 131 *
128 * @note It is the responsibility of the calling function to free the returned host_id 132 * @note It is the responsibility of the calling function to free the returned host_id
129 * 133 *
@@ -158,7 +162,8 @@ void userpref_get_host_id(char **host_id)
158 debug_info("Using %s as HostID", *host_id); 162 debug_info("Using %s as HostID", *host_id);
159} 163}
160 164
161/** Determines whether this device has been connected to this system before. 165/**
166 * Determines whether this device has been connected to this system before.
162 * 167 *
163 * @param uid The device uid as given by the device. 168 * @param uid The device uid as given by the device.
164 * 169 *
@@ -180,8 +185,9 @@ int userpref_has_device_public_key(const char *uuid)
180 return ret; 185 return ret;
181} 186}
182 187
183/** Mark the device (as represented by the key) as having connected to this 188/**
184 * configuration. 189 * Mark the device (as represented by the key) as having connected to this
190 * configuration.
185 * 191 *
186 * @param public_key The public key given by the device 192 * @param public_key The public key given by the device
187 * 193 *
@@ -213,7 +219,8 @@ userpref_error_t userpref_set_device_public_key(const char *uuid, gnutls_datum_t
213 return USERPREF_E_SUCCESS; 219 return USERPREF_E_SUCCESS;
214} 220}
215 221
216/** Remove the public key stored for the device with uuid from this host. 222/**
223 * Remove the public key stored for the device with uuid from this host.
217 * 224 *
218 * @param uuid The uuid of the device 225 * @param uuid The uuid of the device
219 * 226 *
@@ -237,7 +244,8 @@ userpref_error_t userpref_remove_device_public_key(const char *uuid)
237 return USERPREF_E_SUCCESS; 244 return USERPREF_E_SUCCESS;
238} 245}
239 246
240/** Private function which reads the given file into a gnutls structure. 247/**
248 * Private function which reads the given file into a gnutls structure.
241 * 249 *
242 * @param file The filename of the file to read 250 * @param file The filename of the file to read
243 * @param data The pointer at which to store the data. 251 * @param data The pointer at which to store the data.
@@ -266,7 +274,8 @@ static int userpref_get_file_contents(const char *file, gnutls_datum_t * data)
266 return success; 274 return success;
267} 275}
268 276
269/** Private function which generate private keys and certificates. 277/**
278 * Private function which generate private keys and certificates.
270 * 279 *
271 * @return 1 if keys were successfully generated, 0 otherwise 280 * @return 1 if keys were successfully generated, 0 otherwise
272 */ 281 */
@@ -365,7 +374,8 @@ static userpref_error_t userpref_gen_keys_and_cert(void)
365 return ret; 374 return ret;
366} 375}
367 376
368/** Private function which import the given key into a gnutls structure. 377/**
378 * Private function which import the given key into a gnutls structure.
369 * 379 *
370 * @param key_name The filename of the private key to import. 380 * @param key_name The filename of the private key to import.
371 * @param key the gnutls key structure. 381 * @param key the gnutls key structure.
@@ -387,7 +397,8 @@ static userpref_error_t userpref_import_key(const char* key_name, gnutls_x509_pr
387 return ret; 397 return ret;
388} 398}
389 399
390/** Private function which import the given certificate into a gnutls structure. 400/**
401 * Private function which import the given certificate into a gnutls structure.
391 * 402 *
392 * @param crt_name The filename of the certificate to import. 403 * @param crt_name The filename of the certificate to import.
393 * @param cert the gnutls certificate structure. 404 * @param cert the gnutls certificate structure.
@@ -409,7 +420,8 @@ static userpref_error_t userpref_import_crt(const char* crt_name, gnutls_x509_cr
409 return ret; 420 return ret;
410} 421}
411 422
412/** Function to retrieve host keys and certificates. 423/**
424 * Function to retrieve host keys and certificates.
413 * This function trigger key generation if they do not exists yet or are invalid. 425 * This function trigger key generation if they do not exists yet or are invalid.
414 * 426 *
415 * @note This function can take few seconds to complete (typically 5 seconds) 427 * @note This function can take few seconds to complete (typically 5 seconds)
@@ -459,7 +471,8 @@ userpref_error_t userpref_get_keys_and_certs(gnutls_x509_privkey_t root_privkey,
459 return ret; 471 return ret;
460} 472}
461 473
462/** Function to retrieve certificates encoded in PEM format. 474/**
475 * Function to retrieve certificates encoded in PEM format.
463 * 476 *
464 * @param pem_root_cert The root certificate. 477 * @param pem_root_cert The root certificate.
465 * @param pem_host_cert The host certificate. 478 * @param pem_host_cert The host certificate.
@@ -480,7 +493,8 @@ userpref_error_t userpref_get_certs_as_pem(gnutls_datum_t *pem_root_cert, gnutls
480 return USERPREF_E_INVALID_CONF; 493 return USERPREF_E_INVALID_CONF;
481} 494}
482 495
483/** Create and save a configuration file containing the given data. 496/**
497 * Create and save a configuration file containing the given data.
484 * 498 *
485 * @note: All fields must specified and be non-null 499 * @note: All fields must specified and be non-null
486 * 500 *