]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
Moved gnutls_hex_(en|de)code functions from lib/gnutls_psk.c to lib/gnutls_str.c...
authorJaak Ristioja <jaak.ristioja@cyber.ee>
Wed, 20 Feb 2013 10:46:34 +0000 (12:46 +0200)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Thu, 21 Feb 2013 20:26:25 +0000 (21:26 +0100)
These are rather generic functions by nature, so it would be reasonable
to include them in GnuTLS even if PSK support is disabled.

Signed-off-by: Nikos Mavrogiannopoulos <nmav@gnutls.org>
lib/gnutls_psk.c
lib/gnutls_str.c

index 9b1c5b3627efc51fc080a7af1d303c4ca4538d64..496e94fac598c37a1a166aeed5430ad0010cd01b 100644 (file)
@@ -365,65 +365,6 @@ gnutls_psk_client_get_hint (gnutls_session_t session)
   return NULL;
 }
 
-/**
- * gnutls_hex_decode:
- * @hex_data: contain the encoded data
- * @result: the place where decoded data will be copied
- * @result_size: holds the size of the result
- *
- * This function will decode the given encoded data, using the hex
- * encoding used by PSK password files.
- *
- * Note that hex_data should be null terminated.
- *
- * Returns: %GNUTLS_E_SHORT_MEMORY_BUFFER if the buffer given is not
- *   long enough, or 0 on success.
- **/
-int
-gnutls_hex_decode (const gnutls_datum_t * hex_data, void *result,
-                   size_t * result_size)
-{
-  int ret;
-
-  ret =
-    _gnutls_hex2bin ((char*)hex_data->data, hex_data->size, (uint8_t *) result,
-                     result_size);
-  if (ret < 0)
-    return ret;
-
-  return 0;
-}
-
-/**
- * gnutls_hex_encode:
- * @data: contain the raw data
- * @result: the place where hex data will be copied
- * @result_size: holds the size of the result
- *
- * This function will convert the given data to printable data, using
- * the hex encoding, as used in the PSK password files.
- *
- * Returns: %GNUTLS_E_SHORT_MEMORY_BUFFER if the buffer given is not
- * long enough, or 0 on success.
- **/
-int
-gnutls_hex_encode (const gnutls_datum_t * data, char *result,
-                   size_t * result_size)
-{
-  size_t res = data->size + data->size + 1;
-
-  if (*result_size < res)
-    {
-      gnutls_assert ();
-      return GNUTLS_E_SHORT_MEMORY_BUFFER;
-    }
-
-  _gnutls_bin2hex (data->data, data->size, result, *result_size, NULL);
-  *result_size = res;
-
-  return 0;
-}
-
 /**
  * gnutls_psk_set_server_dh_params:
  * @res: is a gnutls_psk_server_credentials_t structure
index 5756ce3951cc8340241660fe2fe0d24be658ceb2..d678d9998a61002224f32c797a23f37757278f78 100644 (file)
@@ -534,6 +534,65 @@ _gnutls_hex2bin (const char * hex_data, size_t hex_size, uint8_t * bin_data,
   return 0;
 }
 
+/**
+ * gnutls_hex_decode:
+ * @hex_data: contain the encoded data
+ * @result: the place where decoded data will be copied
+ * @result_size: holds the size of the result
+ *
+ * This function will decode the given encoded data, using the hex
+ * encoding used by PSK password files.
+ *
+ * Note that hex_data should be null terminated.
+ *
+ * Returns: %GNUTLS_E_SHORT_MEMORY_BUFFER if the buffer given is not
+ *   long enough, or 0 on success.
+ **/
+int
+gnutls_hex_decode (const gnutls_datum_t * hex_data, void *result,
+                   size_t * result_size)
+{
+  int ret;
+
+  ret =
+    _gnutls_hex2bin ((char*)hex_data->data, hex_data->size, (uint8_t *) result,
+                     result_size);
+  if (ret < 0)
+    return ret;
+
+  return 0;
+}
+
+/**
+ * gnutls_hex_encode:
+ * @data: contain the raw data
+ * @result: the place where hex data will be copied
+ * @result_size: holds the size of the result
+ *
+ * This function will convert the given data to printable data, using
+ * the hex encoding, as used in the PSK password files.
+ *
+ * Returns: %GNUTLS_E_SHORT_MEMORY_BUFFER if the buffer given is not
+ * long enough, or 0 on success.
+ **/
+int
+gnutls_hex_encode (const gnutls_datum_t * data, char *result,
+                   size_t * result_size)
+{
+  size_t res = data->size + data->size + 1;
+
+  if (*result_size < res)
+    {
+      gnutls_assert ();
+      return GNUTLS_E_SHORT_MEMORY_BUFFER;
+    }
+
+  _gnutls_bin2hex (data->data, data->size, result, *result_size, NULL);
+  *result_size = res;
+
+  return 0;
+}
+
 
 /* compare hostname against certificate, taking account of wildcards
  * return 1 on success or 0 on error