]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
inlined several small functions.
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Mon, 7 Feb 2011 08:24:24 +0000 (09:24 +0100)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Mon, 7 Feb 2011 08:24:24 +0000 (09:24 +0100)
lib/gnutls_cipher_int.c
lib/gnutls_cipher_int.h
lib/gnutls_hash_int.c
lib/gnutls_hash_int.h

index 98ee868d75e03c1c31a9276f4959fcbafba98fce..8689a683ec07243ebd53b189cf2b0983a1dea036 100644 (file)
@@ -108,67 +108,6 @@ cc_cleanup:
   return ret;
 }
 
-void _gnutls_cipher_setiv (const cipher_hd_st * handle, 
-    const void *iv, int ivlen)
-{
-  handle->setiv(handle->handle, iv, ivlen);
-}
-
-int
-_gnutls_cipher_encrypt2 (const cipher_hd_st * handle, const void *text,
-                         int textlen, void *ciphertext, int ciphertextlen)
-{
-  if (handle != NULL && handle->handle != NULL)
-    {
-      return handle->encrypt (handle->handle, text, textlen, ciphertext,
-                              ciphertextlen);
-    }
-
-  return 0;
-}
-
-int
-_gnutls_cipher_decrypt2 (const cipher_hd_st * handle, const void *ciphertext,
-                         int ciphertextlen, void *text, int textlen)
-{
-  if (handle != NULL && handle->handle != NULL)
-    {
-      return handle->decrypt (handle->handle, ciphertext, ciphertextlen,
-                              text, textlen);
-    }
-
-  return 0;
-}
-
-void
-_gnutls_cipher_deinit (cipher_hd_st * handle)
-{
-  if (handle != NULL && handle->handle != NULL)
-    {
-      handle->deinit (handle->handle);
-      handle->handle = NULL;
-    }
-}
-
-/* returns the tag in AUTHENC ciphers */
-void _gnutls_cipher_tag( const cipher_hd_st * handle, void* tag, int tag_size)
-{
-  if (handle != NULL && handle->handle != NULL)
-    {
-      handle->tag (handle->handle, tag, tag_size);
-    }
-}
-
-int _gnutls_cipher_auth (const cipher_hd_st * handle, const void *text,
-                             int textlen)
-{
-  if (handle != NULL && handle->handle != NULL)
-    {
-      return handle->auth (handle->handle, text, textlen);
-    }
-  return GNUTLS_E_INTERNAL_ERROR;
-}
-
 /* Auth_cipher API 
  */
 int _gnutls_auth_cipher_init (auth_cipher_hd_st * handle, 
index e5423f37674978c162a4f3c68049116bc7c14bf4..989076182d463eabf302c9fd30f9d4b2487e3821 100644 (file)
@@ -57,29 +57,72 @@ int _gnutls_cipher_init (cipher_hd_st *, gnutls_cipher_algorithm_t cipher,
                          const gnutls_datum_t * key,
                          const gnutls_datum_t * iv);
 
-/* Add auth data for AUTHENC ciphers
- */
-int _gnutls_cipher_auth (const cipher_hd_st * handle, const void *text,
-                             int textlen);
+inline static void _gnutls_cipher_setiv (const cipher_hd_st * handle, 
+    const void *iv, int ivlen)
+{
+  handle->setiv(handle->handle, iv, ivlen);
+}
 
-void _gnutls_cipher_setiv (const cipher_hd_st * handle, const void *iv,
-                            int ivlen);
+inline static int
+_gnutls_cipher_encrypt2 (const cipher_hd_st * handle, const void *text,
+                         int textlen, void *ciphertext, int ciphertextlen)
+{
+  if (handle != NULL && handle->handle != NULL)
+    {
+      return handle->encrypt (handle->handle, text, textlen, ciphertext,
+                              ciphertextlen);
+    }
 
-int _gnutls_cipher_encrypt2 (const cipher_hd_st * handle, const void *text,
-                             int textlen, void *ciphertext,
-                             int ciphertextlen);
-int _gnutls_cipher_decrypt2 (const cipher_hd_st * handle,
-                             const void *ciphertext, int ciphertextlen,
-                             void *text, int textlen);
+  return 0;
+}
+
+inline static int
+_gnutls_cipher_decrypt2 (const cipher_hd_st * handle, const void *ciphertext,
+                         int ciphertextlen, void *text, int textlen)
+{
+  if (handle != NULL && handle->handle != NULL)
+    {
+      return handle->decrypt (handle->handle, ciphertext, ciphertextlen,
+                              text, textlen);
+    }
+
+  return 0;
+}
+
+inline static void
+_gnutls_cipher_deinit (cipher_hd_st * handle)
+{
+  if (handle != NULL && handle->handle != NULL)
+    {
+      handle->deinit (handle->handle);
+      handle->handle = NULL;
+    }
+}
 
 /* returns the tag in AUTHENC ciphers */
-void _gnutls_cipher_tag( const cipher_hd_st * handle, void* tag, int tag_size);
+inline static void _gnutls_cipher_tag( const cipher_hd_st * handle, void* tag, int tag_size)
+{
+  if (handle != NULL && handle->handle != NULL)
+    {
+      handle->tag (handle->handle, tag, tag_size);
+    }
+}
+
+/* Add auth data for AUTHENC ciphers
+ */
+inline static int _gnutls_cipher_auth (const cipher_hd_st * handle, const void *text,
+                             int textlen)
+{
+  if (handle != NULL && handle->handle != NULL)
+    {
+      return handle->auth (handle->handle, text, textlen);
+    }
+  return GNUTLS_E_INTERNAL_ERROR;
+}
 
 #define _gnutls_cipher_encrypt(x,y,z) _gnutls_cipher_encrypt2(x,y,z,y,z)
 #define _gnutls_cipher_decrypt(x,y,z) _gnutls_cipher_decrypt2(x,y,z,y,z)
 
-void _gnutls_cipher_deinit (cipher_hd_st * handle);
-
 /* auth_cipher API. Allows combining a cipher with a MAC.
  */
 
index 645f5f10e5c5779ddb308b6b32b08302fec71d2e..54f3a7aa7a272622bc5f435ab81252f4255cb585 100644 (file)
@@ -103,6 +103,21 @@ _gnutls_hash_init (digest_hd_st * dig, gnutls_digest_algorithm_t algorithm)
   return 0;
 }
 
+void
+_gnutls_hash_deinit (digest_hd_st * handle, void *digest)
+{
+  if (handle->handle == NULL)
+    {
+      return;
+    }
+
+  if (digest != NULL)
+    _gnutls_hash_output (handle, digest);
+
+  handle->deinit (handle->handle);
+  handle->handle = NULL;
+}
+
 /* returns the output size of the given hash/mac algorithm
  */
 int
@@ -111,16 +126,6 @@ _gnutls_hash_get_algo_len (gnutls_digest_algorithm_t algorithm)
   return digest_length (algorithm);
 }
 
-int
-_gnutls_hash (digest_hd_st * handle, const void *text, size_t textlen)
-{
-  if (textlen > 0)
-    {
-      handle->hash (handle->handle, text, textlen);
-    }
-  return 0;
-}
-
 int
 _gnutls_hash_copy (digest_hd_st * dst, digest_hd_st * src)
 {
@@ -136,46 +141,7 @@ _gnutls_hash_copy (digest_hd_st * dst, digest_hd_st * src)
   return src->copy (&dst->handle, src->handle);
 }
 
-/* when the current output is needed without calling deinit
- */
-void
-_gnutls_hash_output (digest_hd_st * handle, void *digest)
-{
-  size_t maclen;
 
-  maclen = _gnutls_hash_get_algo_len (handle->algorithm);
-
-  if (digest != NULL)
-    {
-      handle->output (handle->handle, digest, maclen);
-    }
-}
-
-void
-_gnutls_hash_deinit (digest_hd_st * handle, void *digest)
-{
-  if (handle->handle == NULL)
-    {
-      return;
-    }
-
-  if (digest != NULL)
-    _gnutls_hash_output (handle, digest);
-
-  handle->deinit (handle->handle);
-  handle->handle = NULL;
-}
-
-void
-_gnutls_hash_reset (digest_hd_st * handle)
-{
-  if (handle->handle == NULL)
-    {
-      return;
-    }
-
-  handle->reset (handle->handle);
-}
 
 int
 _gnutls_hash_fast (gnutls_digest_algorithm_t algorithm,
@@ -206,12 +172,6 @@ _gnutls_hash_fast (gnutls_digest_algorithm_t algorithm,
 
 /* HMAC interface */
 
-int
-_gnutls_hmac_get_algo_len (gnutls_mac_algorithm_t algorithm)
-{
-  return digest_length (algorithm);
-}
-
 int
 _gnutls_hmac_fast (gnutls_mac_algorithm_t algorithm, const void *key,
                    int keylen, const void *text, size_t textlen, void *digest)
@@ -297,29 +257,6 @@ _gnutls_hmac_init (digest_hd_st * dig, gnutls_mac_algorithm_t algorithm,
   return 0;
 }
 
-int
-_gnutls_hmac (digest_hd_st * handle, const void *text, size_t textlen)
-{
-  if (textlen > 0)
-    {
-      return handle->hash (handle->handle, text, textlen);
-    }
-  return 0;
-}
-
-void
-_gnutls_hmac_output (digest_hd_st * handle, void *digest)
-{
-  int maclen;
-
-  maclen = _gnutls_hmac_get_algo_len (handle->algorithm);
-
-  if (digest != NULL)
-    {
-      handle->output (handle->handle, digest, maclen);
-    }
-}
-
 void
 _gnutls_hmac_deinit (digest_hd_st * handle, void *digest)
 {
@@ -335,17 +272,6 @@ _gnutls_hmac_deinit (digest_hd_st * handle, void *digest)
   handle->handle = NULL;
 }
 
-void
-_gnutls_hmac_reset (digest_hd_st * handle)
-{
-  if (handle->handle == NULL)
-    {
-      return;
-    }
-
-  handle->reset (handle->handle);
-}
-
 inline static int
 get_padsize (gnutls_mac_algorithm_t algorithm)
 {
@@ -360,7 +286,6 @@ get_padsize (gnutls_mac_algorithm_t algorithm)
     }
 }
 
-
 /* Special functions for SSL3 MAC
  */
 
index f191bb04cf1a1e28f5d232982cd99d5d60aabaaa..d0bcf145c6bf13f6cbd4a284384c3f9a75e614ff 100644 (file)
@@ -62,23 +62,91 @@ typedef struct
 /* basic functions */
 int _gnutls_hmac_init (digest_hd_st *, gnutls_mac_algorithm_t algorithm,
                        const void *key, int keylen);
-int _gnutls_hmac_get_algo_len (gnutls_mac_algorithm_t algorithm);
-int _gnutls_hmac (digest_hd_st * handle, const void *text, size_t textlen);
-void _gnutls_hmac_reset (digest_hd_st * handle);
-
+int _gnutls_hash_get_algo_len (gnutls_digest_algorithm_t algorithm);
+#define _gnutls_hmac_get_algo_len _gnutls_hash_get_algo_len
 int _gnutls_hmac_fast (gnutls_mac_algorithm_t algorithm, const void *key,
                        int keylen, const void *text, size_t textlen,
                        void *digest);
 
-void _gnutls_hmac_deinit (digest_hd_st * handle, void *digest);
-void _gnutls_hmac_output (digest_hd_st * handle, void *digest);
+inline static int
+_gnutls_hmac (digest_hd_st * handle, const void *text, size_t textlen)
+{
+  if (textlen > 0)
+    {
+      return handle->hash (handle->handle, text, textlen);
+    }
+  return 0;
+}
+
+inline static void
+_gnutls_hmac_output (digest_hd_st * handle, void *digest)
+{
+  int maclen;
+
+  maclen = _gnutls_hmac_get_algo_len (handle->algorithm);
+
+  if (digest != NULL)
+    {
+      handle->output (handle->handle, digest, maclen);
+    }
+}
+
+void
+_gnutls_hmac_deinit (digest_hd_st * handle, void *digest);
+
+inline static void
+_gnutls_hmac_reset (digest_hd_st * handle)
+{
+  if (handle->handle == NULL)
+    {
+      return;
+    }
+
+  handle->reset (handle->handle);
+}
+
 
+/* Hash interface */
 int _gnutls_hash_init (digest_hd_st *, gnutls_digest_algorithm_t algorithm);
-int _gnutls_hash_get_algo_len (gnutls_digest_algorithm_t algorithm);
-int _gnutls_hash (digest_hd_st * handle, const void *text, size_t textlen);
-void _gnutls_hash_deinit (digest_hd_st * handle, void *digest);
-void _gnutls_hash_reset (digest_hd_st * handle);
-void _gnutls_hash_output (digest_hd_st * handle, void *digest);
+
+inline static int
+_gnutls_hash (digest_hd_st * handle, const void *text, size_t textlen)
+{
+  if (textlen > 0)
+    {
+      handle->hash (handle->handle, text, textlen);
+    }
+  return 0;
+}
+
+/* when the current output is needed without calling deinit
+ */
+inline static void
+_gnutls_hash_output (digest_hd_st * handle, void *digest)
+{
+  size_t maclen;
+
+  maclen = _gnutls_hash_get_algo_len (handle->algorithm);
+
+  if (digest != NULL)
+    {
+      handle->output (handle->handle, digest, maclen);
+    }
+}
+
+inline static void
+_gnutls_hash_reset (digest_hd_st * handle)
+{
+  if (handle->handle == NULL)
+    {
+      return;
+    }
+
+  handle->reset (handle->handle);
+}
+
+void
+_gnutls_hash_deinit (digest_hd_st * handle, void *digest);
 
 int
 _gnutls_hash_fast (gnutls_digest_algorithm_t algorithm,