Major restructuring of the internals of SILC Cipher API
[crypto.git] / lib / silccrypt / rc5.c
index 30c5dffd396075c05a3fe137976607e3bb8b66b3..3e93da32c49c1b95aa5f5d27372043853f377d82 100644 (file)
@@ -38,7 +38,7 @@
  *
  */
 
-#include "silc.h"
+#include "silccrypto.h"
 #include "rc5_internal.h"
 #include "rc5.h"
 
@@ -48,7 +48,7 @@
 
 /* Sets the key for the cipher. */
 
-SILC_CIPHER_API_SET_KEY(rc5)
+SILC_CIPHER_API_SET_KEY(rc5_cbc)
 {
   SilcUInt32 k[8];
 
@@ -58,17 +58,33 @@ SILC_CIPHER_API_SET_KEY(rc5)
   return TRUE;
 }
 
-/* Returns the size of the cipher context. */
+/* Sets IV for the cipher. */
 
-SILC_CIPHER_API_CONTEXT_LEN(rc5)
+SILC_CIPHER_API_SET_IV(rc5_cbc)
 {
-  return sizeof(RC5Context);
+
+}
+
+/* Initialize */
+
+SILC_CIPHER_API_INIT(rc5_cbc)
+{
+  return silc_calloc(1, sizeof(RC5Context));
+}
+
+/* Initialize */
+
+SILC_CIPHER_API_UNINIT(rc5_cbc)
+{
+  RC5Context *rc5 = context;
+  memset(rc5, 0, sizeof(*rc5));
+  silc_free(rc5);
 }
 
 /* Encrypts with the cipher in CBC mode. Source and destination buffers
    maybe one and same. */
 
-SILC_CIPHER_API_ENCRYPT_CBC(rc5)
+SILC_CIPHER_API_ENCRYPT(rc5_cbc)
 {
   SilcUInt32 tiv[4];
   int i;
@@ -93,7 +109,7 @@ SILC_CIPHER_API_ENCRYPT_CBC(rc5)
 /* Decrypts with the cipher in CBC mode. Source and destination buffers
    maybe one and same. */
 
-SILC_CIPHER_API_DECRYPT_CBC(rc5)
+SILC_CIPHER_API_DECRYPT(rc5_cbc)
 {
   SilcUInt32 tmp[4], tmp2[4], tiv[4];
   int i;