Major restructuring of the internals of SILC Cipher API
[crypto.git] / lib / silccrypt / blowfish.c
index c1b11b29fe268371f1e2df7d26e0dd9580adc22a..862f1c2015f0ac980b90998d542bbaf92a1bdf44 100644 (file)
@@ -33,7 +33,7 @@
  *
  */
 
-#include "silc.h"
+#include "silccrypto.h"
 #include "blowfish_internal.h"
 #include "blowfish.h"
 
@@ -56,11 +56,20 @@ SILC_CIPHER_API_SET_IV(blowfish_cbc)
 
 }
 
-/* Returns the size of the cipher context. */
+/* Initialize */
 
-SILC_CIPHER_API_CONTEXT_LEN(blowfish_cbc)
+SILC_CIPHER_API_INIT(blowfish_cbc)
 {
-  return sizeof(BlowfishContext);
+  return silc_calloc(1, sizeof(BlowfishContext));
+}
+
+/* Unnitialize */
+
+SILC_CIPHER_API_UNINIT(blowfish_cbc)
+{
+  BlowfishContext *b = context;
+  memset(b, 0, sizeof(*b));
+  silc_free(b);
 }
 
 /* Encrypts with the cipher in CBC mode. Source and destination buffers