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,
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.
*/
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
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)
{
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,
/* 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)
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)
{
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)
{
}
}
-
/* Special functions for SSL3 MAC
*/
/* 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,