Home | History | Annotate | Download | only in dbus

Lines Matching defs:nonce

2 /* dbus-nonce.c  Nonce handling functions used by nonce-tcp (internal to D-Bus implementation)
26 #include "dbus-nonce.h"
34 do_check_nonce (int fd, const DBusString *nonce, DBusError *error)
63 dbus_set_error (error, DBUS_ERROR_IO_ERROR, "Could not read nonce from socket (fd=%d)", fd );
72 dbus_set_error (error, DBUS_ERROR_IO_ERROR, "Could not read nonce from socket (fd=%d)", fd );
82 result = _dbus_string_equal_len (&buffer, nonce, 16);
93 * reads the nonce from the nonce file and stores it in a string
95 * @param fname the file to read the nonce from
96 * @param nonce returns the nonce. Must be an initialized string, the nonce will be appended.
98 * @return FALSE iff reading the nonce fails (error is set then)
101 _dbus_read_nonce (const DBusString *fname, DBusString *nonce, DBusError* error)
111 _dbus_verbose ("reading nonce from file: %s\n", _dbus_string_get_const_data (fname));
121 dbus_set_error (error, DBUS_ERROR_FILE_NOT_FOUND, "Could not read nonce from file %s", _dbus_string_get_const_data (fname));
125 if (!_dbus_string_append_len (nonce, buffer, sizeof buffer - 1 ))
137 DBusString nonce;
140 _dbus_string_init (&nonce);
142 if (_dbus_read_nonce (_dbus_noncefile_get_path(noncefile), &nonce, NULL) != TRUE)
147 if (do_check_nonce(fd, &nonce, NULL) != TRUE) {
148 _dbus_verbose ("nonce check failed. Closing socket.\n");
159 DBusString nonce;
164 _dbus_string_init (&nonce);
166 if (!_dbus_generate_random_bytes (&nonce, 16))
169 _dbus_string_free (&nonce);
173 ret = _dbus_string_save_to_file (&nonce, filename, FALSE, error);
175 _dbus_string_free (&nonce);
181 * sends the nonce over a given socket. Blocks while doing so.
183 * @param fd the file descriptor to write the nonce data to (usually a socket)
184 * @param noncefile the noncefile location to read the nonce from
186 * @return TRUE iff the nonce was successfully sent. Note that this does not
187 * indicate whether the server accepted the nonce.
195 DBusString nonce;
202 if (!_dbus_string_init (&nonce))
208 read_result = _dbus_read_nonce (noncefile, &nonce, error);
212 _dbus_string_free (&nonce);
217 send_result = _dbus_write_socket (fd, &nonce, 0, _dbus_string_get_length (&nonce));
219 _dbus_string_free (&nonce);
225 "Failed to send nonce (fd=%d): %s",
273 || !_dbus_string_append (&noncefile->dir, "/nonce"))
322 * creates a nonce file in a user-readable location and writes a generated nonce to it
324 * @param noncefile returns the nonce file location
325 * @param error error details if creating the nonce file fails
326 * @return TRUE iff the nonce file was successfully created
338 * @param noncefile the nonce file to delete. Contents will be freed.
339 * @param error error details if the nonce file could not be deleted
356 * creates a nonce file in a user-readable location and writes a generated nonce to it.
359 * @param noncefile returns the nonce file location
360 * @param error error details if creating the nonce file fails
361 * @return TRUE iff the nonce file was successfully created
373 * @param noncefile the nonce file to delete. Contents will be freed.
374 * @param error error details if the nonce file could not be deleted
392 * returns the absolute file path of the nonce file
395 * @return the absolute path of the nonce file
408 * @param fd the file descriptor to read the nonce from
409 * @param noncefile the nonce file to check the received data against
411 * @return TRUE iff a nonce could be successfully read from the file descriptor
412 * and matches the nonce from the given nonce file
423 /** @} end of nonce */