summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2010-07-03 10:37:45 +0200
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2010-07-03 10:38:15 +0200
commitba349b1a8751d6830fdeace466909d2cc6178cd1 (patch)
tree514725e560a65931aabbdeef7413fafc4d705d23
parent82e5b85de5ee9ac86cfb4f90a2e77c72a685df86 (diff)
downloadgnutls-ba349b1a8751d6830fdeace466909d2cc6178cd1.tar.gz
Allow encryption and decryption that are not in-place only.
-rw-r--r--lib/crypto-api.c46
-rw-r--r--lib/gnutls_cipher_int.c21
-rw-r--r--lib/gnutls_cipher_int.h4
-rw-r--r--lib/includes/gnutls/crypto.h5
-rw-r--r--lib/libgnutls.map2
5 files changed, 78 insertions, 0 deletions
diff --git a/lib/crypto-api.c b/lib/crypto-api.c
index cad9914132..1e61e4181b 100644
--- a/lib/crypto-api.c
+++ b/lib/crypto-api.c
@@ -102,6 +102,52 @@ gnutls_cipher_decrypt (gnutls_cipher_hd_t handle, void *ciphertext,
}
/**
+ * gnutls_cipher_encrypt2:
+ * @handle: is a #gnutls_cipher_hd_t structure.
+ * @text: the data to encrypt
+ * @textlen: The length of data to encrypt
+ * @ciphertext: the encrypted data
+ * @ciphertextlen: The available length for encrypted data
+ *
+ * This function will encrypt the given data using the algorithm
+ * specified by the context.
+ *
+ * Returns: Zero or a negative value on error.
+ *
+ * Since: 2.10.0
+ **/
+int
+gnutls_cipher_encrypt2 (gnutls_cipher_hd_t handle, void *text, size_t textlen,
+ void* ciphertext, size_t ciphertextlen)
+{
+ return _gnutls_cipher_encrypt2 ((cipher_hd_st *) handle, text, textlen,
+ ciphertext, ciphertextlen);
+}
+
+/**
+ * gnutls_cipher_decrypt2:
+ * @handle: is a #gnutls_cipher_hd_t structure.
+ * @ciphertext: the data to encrypt
+ * @ciphertextlen: The length of data to encrypt
+ * @text: the decrypted data
+ * @textlen: The available length for decrypted data
+ *
+ * This function will decrypt the given data using the algorithm
+ * specified by the context.
+ *
+ * Returns: Zero or a negative value on error.
+ *
+ * Since: 2.10.0
+ **/
+int
+gnutls_cipher_decrypt2 (gnutls_cipher_hd_t handle, const void *ciphertext,
+ size_t ciphertextlen, void* text, size_t textlen)
+{
+ return _gnutls_cipher_decrypt2 ((cipher_hd_st *) handle, ciphertext,
+ ciphertextlen, text, textlen);
+}
+
+/**
* gnutls_cipher_deinit:
* @handle: is a #gnutls_cipher_hd_t structure.
*
diff --git a/lib/gnutls_cipher_int.c b/lib/gnutls_cipher_int.c
index 4a830b8c19..023e459007 100644
--- a/lib/gnutls_cipher_int.c
+++ b/lib/gnutls_cipher_int.c
@@ -113,6 +113,27 @@ int _gnutls_cipher_decrypt (const cipher_hd_st * handle, void *ciphertext,
return 0;
}
+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)
diff --git a/lib/gnutls_cipher_int.h b/lib/gnutls_cipher_int.h
index 81950f10fa..3131746a12 100644
--- a/lib/gnutls_cipher_int.h
+++ b/lib/gnutls_cipher_int.h
@@ -50,6 +50,10 @@ int _gnutls_cipher_encrypt (const cipher_hd_st * handle, void *text,
int textlen);
int _gnutls_cipher_decrypt (const cipher_hd_st * handle, void *ciphertext,
int 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);
void _gnutls_cipher_deinit (cipher_hd_st * handle);
#endif /* GNUTLS_CIPHER_INT */
diff --git a/lib/includes/gnutls/crypto.h b/lib/includes/gnutls/crypto.h
index 31352dd534..d121490f0d 100644
--- a/lib/includes/gnutls/crypto.h
+++ b/lib/includes/gnutls/crypto.h
@@ -35,6 +35,11 @@ int gnutls_cipher_encrypt (const gnutls_cipher_hd_t handle,
void *text, size_t textlen);
int gnutls_cipher_decrypt (const gnutls_cipher_hd_t handle,
void *ciphertext, size_t ciphertextlen);
+int gnutls_cipher_decrypt2 (gnutls_cipher_hd_t handle, const void *ciphertext,
+ size_t ciphertextlen, void* text, size_t textlen);
+int gnutls_cipher_encrypt2 (gnutls_cipher_hd_t handle, void *text, size_t textlen,
+ void* ciphertext, size_t ciphertextlen);
+
void gnutls_cipher_deinit (gnutls_cipher_hd_t handle);
int gnutls_cipher_get_block_size (gnutls_cipher_algorithm_t algorithm);
diff --git a/lib/libgnutls.map b/lib/libgnutls.map
index 47eed0cbcc..9b25b299e0 100644
--- a/lib/libgnutls.map
+++ b/lib/libgnutls.map
@@ -681,6 +681,8 @@ GNUTLS_2_11
gnutls_pk_bits_to_sec_param;
gnutls_rnd;
gnutls_x509_crq_get_preferred_hash_algorithm;
+ gnutls_cipher_encrypt2;
+ gnutls_cipher_decrypt2;
} GNUTLS_2_10;
GNUTLS_PRIVATE {