aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/crypt.c24
-rw-r--r--src/main.c12
-rw-r--r--src/uccs-server.c16
3 files changed, 26 insertions, 26 deletions
diff --git a/src/crypt.c b/src/crypt.c
index 4e8775f..146aa7e 100644
--- a/src/crypt.c
+++ b/src/crypt.c
@@ -28,10 +28,10 @@ setup_cipher (const gchar * password)
{
gcry_error_t gcryError;
gcry_cipher_hd_t gcryHandle;
-
+
const size_t keyLength = gcry_cipher_get_algo_keylen(GCRY_CIPHER_AES);
const size_t blkLength = gcry_cipher_get_algo_blklen(GCRY_CIPHER_AES);
-
+
// We are assuming keyLength and blkLength are the same, check it
if (keyLength != blkLength)
return NULL;
@@ -42,7 +42,7 @@ setup_cipher (const gchar * password)
size_t i;
for (i = passwordLength; i < blkLength; ++i)
aesSymKey[i] = 0;
-
+
gcryError = gcry_cipher_open(&gcryHandle, GCRY_CIPHER_AES, GCRY_CIPHER_MODE_CBC, 0);
if (gcryError) {
g_warning("gcry_cipher_open failed: %s/%s\n", gcry_strsource(gcryError), gcry_strerror(gcryError));
@@ -80,12 +80,12 @@ do_aes_encrypt(const gchar *origBuffer, const gchar * password, size_t *outBuffe
{
gcry_error_t gcryError;
gcry_cipher_hd_t gcryHandle;
-
+
gcryHandle = setup_cipher (password);
if (gcryHandle == NULL) {
return NULL;
}
-
+
const size_t blkLength = gcry_cipher_get_algo_blklen(GCRY_CIPHER_AES);
const size_t origBufferLength = strlen(origBuffer);
const size_t bufferLength = ceil((double)origBufferLength / blkLength) * blkLength;
@@ -94,7 +94,7 @@ do_aes_encrypt(const gchar *origBuffer, const gchar * password, size_t *outBuffe
int i;
for (i = origBufferLength; i < bufferLength; ++i)
buffer[i] = 0;
-
+
char * encBuffer = malloc(bufferLength);
size_t lengthDone = 0;
while (lengthDone < bufferLength) {
@@ -107,9 +107,9 @@ do_aes_encrypt(const gchar *origBuffer, const gchar * password, size_t *outBuffe
}
lengthDone += blkLength;
}
-
+
gcry_cipher_close(gcryHandle);
-
+
*outBufferLength = bufferLength;
return encBuffer;
}
@@ -127,13 +127,13 @@ do_aes_decrypt(const gchar *encBuffer, const gchar * password, const size_t encB
{
gcry_error_t gcryError;
gcry_cipher_hd_t gcryHandle;
-
+
gcryHandle = setup_cipher (password);
if (gcryHandle == NULL) {
return NULL;
}
-
- const size_t blkLength = gcry_cipher_get_algo_blklen(GCRY_CIPHER_AES128);
+
+ const size_t blkLength = gcry_cipher_get_algo_blklen(GCRY_CIPHER_AES128);
const size_t bufferLength = encBufferLength;
char * outBuffer = malloc(bufferLength);
size_t lengthDone = 0;
@@ -146,7 +146,7 @@ do_aes_decrypt(const gchar *encBuffer, const gchar * password, const size_t encB
}
lengthDone += blkLength;
}
-
+
gcry_cipher_close(gcryHandle);
char *result = g_strndup(outBuffer, bufferLength);
free(outBuffer);
diff --git a/src/main.c b/src/main.c
index 5fa4187..9a17576 100644
--- a/src/main.c
+++ b/src/main.c
@@ -342,11 +342,11 @@ handle_set_last_used_server (RemoteLogon * rl, GDBusMethodInvocation * invocatio
child = g_variant_get_child_value(params, 0);
uccsUri = g_variant_get_string(child, NULL);
g_variant_unref(child); /* fine as we know params is still ref'd */
-
+
child = g_variant_get_child_value(params, 1);
serverUri = g_variant_get_string(child, NULL);
g_variant_unref(child); /* fine as we know params is still ref'd */
-
+
GList * lserver = NULL;
Server * server = NULL;
for (lserver = config_file_servers; lserver != NULL; lserver = g_list_next(lserver)) {
@@ -364,13 +364,13 @@ handle_set_last_used_server (RemoteLogon * rl, GDBusMethodInvocation * invocatio
break;
}
}
-
+
if (server != NULL) {
server_set_last_used_server (server, serverUri);
}
-
+
g_dbus_method_invocation_return_value(invocation, NULL);
-
+
return TRUE;
}
@@ -404,7 +404,7 @@ main (int argc, char * argv[])
#endif
/* Setup i18n */
- setlocale (LC_ALL, "");
+ setlocale (LC_ALL, "");
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
textdomain (GETTEXT_PACKAGE);
diff --git a/src/uccs-server.c b/src/uccs-server.c
index 69c716b..8365489 100644
--- a/src/uccs-server.c
+++ b/src/uccs-server.c
@@ -542,7 +542,7 @@ parse_json (UccsServer * server, GInputStream * json)
g_warning("Malformed 'RemoteDesktopServer' entry. Not an array but a: %s", json_node_type_name(rds_node));
passed = FALSE;
}
-
+
if (json_object_has_member(root_object, "DefaultServer")) {
JsonNode * ds_node = json_object_get_member(root_object, "DefaultServer");
if (JSON_NODE_TYPE(ds_node) == JSON_NODE_VALUE && json_node_get_value_type(ds_node) == G_TYPE_STRING) {
@@ -551,7 +551,7 @@ parse_json (UccsServer * server, GInputStream * json)
GList * lserver;
for (lserver = server->subservers; lserver != NULL; lserver = g_list_next(lserver)) {
Server * serv = SERVER(lserver->data);
-
+
if (g_strcmp0(serv->name, default_server_name) == 0) {
serv->last_used = TRUE;
break;
@@ -803,7 +803,7 @@ uccs_server_get_servers (UccsServer * server, const gchar * address)
g_warning("Address '%s' is not authorized", address);
return null_server_array();
}
-
+
gchar *last_used_server_name = NULL;
if (server->username != NULL && server->password != NULL) {
gchar *username_sha = g_compute_checksum_for_string (G_CHECKSUM_SHA256, server->username, -1);
@@ -830,7 +830,7 @@ uccs_server_get_servers (UccsServer * server, const gchar * address)
g_variant_builder_init(&array, G_VARIANT_TYPE_ARRAY);
GList * lserver;
gint servercnt = 0;
-
+
Server * last_used_server = NULL;
if (last_used_server_name != NULL) {
for (lserver = server->subservers; last_used_server == NULL && lserver != NULL; lserver = g_list_next(lserver)) {
@@ -853,7 +853,7 @@ uccs_server_get_servers (UccsServer * server, const gchar * address)
if (serv->state != SERVER_STATE_ALLGOOD) {
continue;
}
-
+
if (last_used_server != NULL)
serv->last_used = last_used_server == serv;
@@ -916,10 +916,10 @@ static void
set_last_used_server (Server * server, const gchar * uri)
{
Server * subserver = server_find_uri(server, uri);
-
+
if (subserver != NULL) {
subserver->last_used = TRUE;
-
+
/* Write to disk */
if (UCCS_SERVER(server)->username != NULL && UCCS_SERVER(server)->password) {
GKeyFile * key_file = g_key_file_new();
@@ -927,7 +927,7 @@ set_last_used_server (Server * server, const gchar * uri)
gsize data_length;
gchar *data = g_key_file_to_data (key_file, &data_length, NULL);
g_key_file_free (key_file);
-
+
size_t enc_data_length;
gchar *enc_data = do_aes_encrypt(data, UCCS_SERVER(server)->password, &enc_data_length);
g_free (data);