GUAC-1171: Fix naming of guac_common_ssh_buffer_*() functions.

This commit is contained in:
Michael Jumper 2015-07-10 17:26:04 -07:00
parent 3d1d2ea334
commit 5f547a9974
3 changed files with 33 additions and 31 deletions

View File

@ -29,7 +29,7 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
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; uint8_t* data = (uint8_t*) *buffer;
*data = value; *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; 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); memcpy(*buffer, data, length);
*buffer += 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; unsigned char* bn_buffer;
int length; int length;
/* If zero, just write zero length */ /* If zero, just write zero length */
if (BN_is_zero(value)) { if (BN_is_zero(value)) {
guac_common_buffer_write_uint32(buffer, 0); guac_common_ssh_buffer_write_uint32(buffer, 0);
return; 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 first byte has high bit set, write padding byte */
if (bn_buffer[0] & 0x80) { if (bn_buffer[0] & 0x80) {
guac_common_buffer_write_uint32(buffer, length+1); guac_common_ssh_buffer_write_uint32(buffer, length+1);
guac_common_buffer_write_byte(buffer, 0); guac_common_ssh_buffer_write_byte(buffer, 0);
} }
else else
guac_common_buffer_write_uint32(buffer, length); guac_common_ssh_buffer_write_uint32(buffer, length);
/* Write data */ /* Write data */
memcpy(*buffer, bn_buffer, length); 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) { void guac_common_ssh_buffer_write_string(char** buffer, const char* string,
guac_common_buffer_write_uint32(buffer, length); int length) {
guac_common_buffer_write_data(buffer, string, 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* data = (uint8_t*) *buffer;
uint8_t value = *data; 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; uint8_t* data = (uint8_t*) *buffer;
uint32_t value = 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; char* value;
*length = guac_common_buffer_read_uint32(buffer); *length = guac_common_ssh_buffer_read_uint32(buffer);
value = *buffer; value = *buffer;
*buffer += *length; *buffer += *length;

View File

@ -38,7 +38,7 @@
* @param value * @param value
* The value to write. * 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 * 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 * @param value
* The value to write. * 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 * 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 * @param length
* The length of the string to write, in bytes. * 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); int length);
/** /**
@ -79,7 +79,7 @@ void guac_common_buffer_write_string(char** buffer, const char* string,
* @param value * @param value
* The value to write. * 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 * 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 * @param length
* The length of data to write, in bytes. * 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. * 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 * @return
* The value read from the buffer. * 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. * 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 * @return
* The value read from the buffer. * 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 * 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 * @return
* A pointer to the value within the buffer. * 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 #endif

View File

@ -73,9 +73,9 @@ guac_common_ssh_key* guac_common_ssh_key_alloc(char* data, int length,
pos = public_key; pos = public_key;
/* Derive public key */ /* Derive public key */
guac_common_buffer_write_string(&pos, "ssh-rsa", sizeof("ssh-rsa")-1); guac_common_ssh_buffer_write_string(&pos, "ssh-rsa", sizeof("ssh-rsa")-1);
guac_common_buffer_write_bignum(&pos, rsa_key->e); guac_common_ssh_buffer_write_bignum(&pos, rsa_key->e);
guac_common_buffer_write_bignum(&pos, rsa_key->n); guac_common_ssh_buffer_write_bignum(&pos, rsa_key->n);
/* Save public key to structure */ /* Save public key to structure */
key->public_key = public_key; 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; pos = public_key;
/* Derive public key */ /* Derive public key */
guac_common_buffer_write_string(&pos, "ssh-dss", sizeof("ssh-dss")-1); guac_common_ssh_buffer_write_string(&pos, "ssh-dss", sizeof("ssh-dss")-1);
guac_common_buffer_write_bignum(&pos, dsa_key->p); guac_common_ssh_buffer_write_bignum(&pos, dsa_key->p);
guac_common_buffer_write_bignum(&pos, dsa_key->q); guac_common_ssh_buffer_write_bignum(&pos, dsa_key->q);
guac_common_buffer_write_bignum(&pos, dsa_key->g); guac_common_ssh_buffer_write_bignum(&pos, dsa_key->g);
guac_common_buffer_write_bignum(&pos, dsa_key->pub_key); guac_common_ssh_buffer_write_bignum(&pos, dsa_key->pub_key);
/* Save public key to structure */ /* Save public key to structure */
key->public_key = public_key; key->public_key = public_key;