From 5f547a9974db6f8c43e85443add1fb17f2722507 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Fri, 10 Jul 2015 17:26:04 -0700 Subject: [PATCH] GUAC-1171: Fix naming of guac_common_ssh_buffer_*() functions. --- src/common-ssh/guac_ssh_buffer.c | 32 +++++++++++++++++--------------- src/common-ssh/guac_ssh_buffer.h | 16 ++++++++-------- src/common-ssh/guac_ssh_key.c | 16 ++++++++-------- 3 files changed, 33 insertions(+), 31 deletions(-) diff --git a/src/common-ssh/guac_ssh_buffer.c b/src/common-ssh/guac_ssh_buffer.c index cd07a307..0390c403 100644 --- a/src/common-ssh/guac_ssh_buffer.c +++ b/src/common-ssh/guac_ssh_buffer.c @@ -29,7 +29,7 @@ #include #include -void guac_common_buffer_write_byte(char** buffer, uint8_t value) { +void guac_common_ssh_buffer_write_byte(char** buffer, uint8_t value) { uint8_t* data = (uint8_t*) *buffer; *data = value; @@ -38,7 +38,7 @@ void guac_common_buffer_write_byte(char** buffer, uint8_t value) { } -void guac_common_buffer_write_uint32(char** buffer, uint32_t value) { +void guac_common_ssh_buffer_write_uint32(char** buffer, uint32_t value) { uint8_t* data = (uint8_t*) *buffer; @@ -51,19 +51,20 @@ void guac_common_buffer_write_uint32(char** buffer, uint32_t value) { } -void guac_common_buffer_write_data(char** buffer, const char* data, int length) { +void guac_common_ssh_buffer_write_data(char** buffer, const char* data, + int length) { memcpy(*buffer, data, length); *buffer += length; } -void guac_common_buffer_write_bignum(char** buffer, BIGNUM* value) { +void guac_common_ssh_buffer_write_bignum(char** buffer, BIGNUM* value) { unsigned char* bn_buffer; int length; /* If zero, just write zero length */ if (BN_is_zero(value)) { - guac_common_buffer_write_uint32(buffer, 0); + guac_common_ssh_buffer_write_uint32(buffer, 0); return; } @@ -76,11 +77,11 @@ void guac_common_buffer_write_bignum(char** buffer, BIGNUM* value) { /* If first byte has high bit set, write padding byte */ if (bn_buffer[0] & 0x80) { - guac_common_buffer_write_uint32(buffer, length+1); - guac_common_buffer_write_byte(buffer, 0); + guac_common_ssh_buffer_write_uint32(buffer, length+1); + guac_common_ssh_buffer_write_byte(buffer, 0); } else - guac_common_buffer_write_uint32(buffer, length); + guac_common_ssh_buffer_write_uint32(buffer, length); /* Write data */ memcpy(*buffer, bn_buffer, length); @@ -90,12 +91,13 @@ void guac_common_buffer_write_bignum(char** buffer, BIGNUM* value) { } -void guac_common_buffer_write_string(char** buffer, const char* string, int length) { - guac_common_buffer_write_uint32(buffer, length); - guac_common_buffer_write_data(buffer, string, length); +void guac_common_ssh_buffer_write_string(char** buffer, const char* string, + int length) { + guac_common_ssh_buffer_write_uint32(buffer, length); + guac_common_ssh_buffer_write_data(buffer, string, length); } -uint8_t guac_common_buffer_read_byte(char** buffer) { +uint8_t guac_common_ssh_buffer_read_byte(char** buffer) { uint8_t* data = (uint8_t*) *buffer; uint8_t value = *data; @@ -106,7 +108,7 @@ uint8_t guac_common_buffer_read_byte(char** buffer) { } -uint32_t guac_common_buffer_read_uint32(char** buffer) { +uint32_t guac_common_ssh_buffer_read_uint32(char** buffer) { uint8_t* data = (uint8_t*) *buffer; uint32_t value = @@ -121,11 +123,11 @@ uint32_t guac_common_buffer_read_uint32(char** buffer) { } -char* guac_common_buffer_read_string(char** buffer, int* length) { +char* guac_common_ssh_buffer_read_string(char** buffer, int* length) { char* value; - *length = guac_common_buffer_read_uint32(buffer); + *length = guac_common_ssh_buffer_read_uint32(buffer); value = *buffer; *buffer += *length; diff --git a/src/common-ssh/guac_ssh_buffer.h b/src/common-ssh/guac_ssh_buffer.h index 750c625e..0c77bba8 100644 --- a/src/common-ssh/guac_ssh_buffer.h +++ b/src/common-ssh/guac_ssh_buffer.h @@ -38,7 +38,7 @@ * @param value * The value to write. */ -void guac_common_buffer_write_byte(char** buffer, uint8_t value); +void guac_common_ssh_buffer_write_byte(char** buffer, uint8_t value); /** * Writes the given integer to the given buffer, advancing the buffer pointer @@ -50,7 +50,7 @@ void guac_common_buffer_write_byte(char** buffer, uint8_t value); * @param value * The value to write. */ -void guac_common_buffer_write_uint32(char** buffer, uint32_t value); +void guac_common_ssh_buffer_write_uint32(char** buffer, uint32_t value); /** * Writes the given string and its length to the given buffer, advancing the @@ -66,7 +66,7 @@ void guac_common_buffer_write_uint32(char** buffer, uint32_t value); * @param length * The length of the string to write, in bytes. */ -void guac_common_buffer_write_string(char** buffer, const char* string, +void guac_common_ssh_buffer_write_string(char** buffer, const char* string, int length); /** @@ -79,7 +79,7 @@ void guac_common_buffer_write_string(char** buffer, const char* string, * @param value * The value to write. */ -void guac_common_buffer_write_bignum(char** buffer, BIGNUM* value); +void guac_common_ssh_buffer_write_bignum(char** buffer, BIGNUM* value); /** * Writes the given data the given buffer, advancing the buffer pointer by the @@ -91,7 +91,7 @@ void guac_common_buffer_write_bignum(char** buffer, BIGNUM* value); * @param length * The length of data to write, in bytes. */ -void guac_common_buffer_write_data(char** buffer, const char* data, int length); +void guac_common_ssh_buffer_write_data(char** buffer, const char* data, int length); /** * Reads a single byte from the given buffer, advancing the buffer by one byte. @@ -102,7 +102,7 @@ void guac_common_buffer_write_data(char** buffer, const char* data, int length); * @return * The value read from the buffer. */ -uint8_t guac_common_buffer_read_byte(char** buffer); +uint8_t guac_common_ssh_buffer_read_byte(char** buffer); /** * Reads an integer from the given buffer, advancing the buffer by four bytes. @@ -113,7 +113,7 @@ uint8_t guac_common_buffer_read_byte(char** buffer); * @return * The value read from the buffer. */ -uint32_t guac_common_buffer_read_uint32(char** buffer); +uint32_t guac_common_ssh_buffer_read_uint32(char** buffer); /** * Reads a string and its length from the given buffer, advancing the buffer @@ -131,7 +131,7 @@ uint32_t guac_common_buffer_read_uint32(char** buffer); * @return * A pointer to the value within the buffer. */ -char* guac_common_buffer_read_string(char** buffer, int* length); +char* guac_common_ssh_buffer_read_string(char** buffer, int* length); #endif diff --git a/src/common-ssh/guac_ssh_key.c b/src/common-ssh/guac_ssh_key.c index fb9d0f78..30594492 100644 --- a/src/common-ssh/guac_ssh_key.c +++ b/src/common-ssh/guac_ssh_key.c @@ -73,9 +73,9 @@ guac_common_ssh_key* guac_common_ssh_key_alloc(char* data, int length, pos = public_key; /* Derive public key */ - guac_common_buffer_write_string(&pos, "ssh-rsa", sizeof("ssh-rsa")-1); - guac_common_buffer_write_bignum(&pos, rsa_key->e); - guac_common_buffer_write_bignum(&pos, rsa_key->n); + guac_common_ssh_buffer_write_string(&pos, "ssh-rsa", sizeof("ssh-rsa")-1); + guac_common_ssh_buffer_write_bignum(&pos, rsa_key->e); + guac_common_ssh_buffer_write_bignum(&pos, rsa_key->n); /* Save public key to structure */ key->public_key = public_key; @@ -107,11 +107,11 @@ guac_common_ssh_key* guac_common_ssh_key_alloc(char* data, int length, pos = public_key; /* Derive public key */ - guac_common_buffer_write_string(&pos, "ssh-dss", sizeof("ssh-dss")-1); - guac_common_buffer_write_bignum(&pos, dsa_key->p); - guac_common_buffer_write_bignum(&pos, dsa_key->q); - guac_common_buffer_write_bignum(&pos, dsa_key->g); - guac_common_buffer_write_bignum(&pos, dsa_key->pub_key); + guac_common_ssh_buffer_write_string(&pos, "ssh-dss", sizeof("ssh-dss")-1); + guac_common_ssh_buffer_write_bignum(&pos, dsa_key->p); + guac_common_ssh_buffer_write_bignum(&pos, dsa_key->q); + guac_common_ssh_buffer_write_bignum(&pos, dsa_key->g); + guac_common_ssh_buffer_write_bignum(&pos, dsa_key->pub_key); /* Save public key to structure */ key->public_key = public_key;