[Spice-devel] [PATCH 4/9] Move ticket decryption to helper function
Christophe Fergeau
cfergeau at redhat.com
Wed Mar 12 11:27:38 PDT 2014
---
server/reds.c | 23 +++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/server/reds.c b/server/reds.c
index 19a3298..f45092b 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -1843,15 +1843,11 @@ static void reds_handle_link(RedLinkInfo *link)
}
}
-static void reds_handle_ticket(void *opaque)
+static char *reds_get_ticket(RedLinkInfo *link)
{
- RedLinkInfo *link = (RedLinkInfo *)opaque;
char *password;
- time_t ltime;
int password_size;
- //todo: use monotonic time
- time(<ime);
if (RSA_size(link->tiTicketing.rsa) < SPICE_MAX_PASSWORD_LENGTH) {
spice_warning("RSA modulus size is smaller than SPICE_MAX_PASSWORD_LENGTH (%d < %d), "
"SPICE ticket sent from client may be truncated",
@@ -1867,10 +1863,25 @@ static void reds_handle_ticket(void *opaque)
if (password_size == -1) {
spice_warning("failed to decrypt RSA encrypted password: %s",
ERR_error_string(ERR_get_error(), NULL));
- goto error;
+ return NULL;
}
password[password_size] = '\0';
+ return password;
+}
+
+
+static void reds_handle_ticket(void *opaque)
+{
+ RedLinkInfo *link = (RedLinkInfo *)opaque;
+ char *password;
+ time_t ltime;
+
+ //todo: use monotonic time
+ time(<ime);
+
+ password = reds_get_ticket(link);
+
if (ticketing_enabled && !link->skip_auth) {
int expired = taTicket.expiration_time < ltime;
--
1.8.5.3
More information about the Spice-devel
mailing list