Major restructuring of the internals of SILC Cipher API
[crypto.git] / lib / silccrypt / blowfish.c
index 25b9deab08da1082cbe6a93de645a298562e42b4..862f1c2015f0ac980b90998d542bbaf92a1bdf44 100644 (file)
@@ -33,7 +33,7 @@
  *
  */
 
-#include "silc.h"
+#include "silccrypto.h"
 #include "blowfish_internal.h"
 #include "blowfish.h"
 
 
 /* Sets the key for the cipher. */
 
-SILC_CIPHER_API_SET_KEY(blowfish)
+SILC_CIPHER_API_SET_KEY(blowfish_cbc)
 {
   blowfish_set_key((BlowfishContext *)context, (unsigned char *)key, keylen);
   return TRUE;
 }
 
-/* Returns the size of the cipher context. */
+/* Sets IV for the cipher. */
 
-SILC_CIPHER_API_CONTEXT_LEN(blowfish)
+SILC_CIPHER_API_SET_IV(blowfish_cbc)
 {
-  return sizeof(BlowfishContext);
+
+}
+
+/* Initialize */
+
+SILC_CIPHER_API_INIT(blowfish_cbc)
+{
+  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
    maybe one and same. */
 
-SILC_CIPHER_API_ENCRYPT_CBC(blowfish)
+SILC_CIPHER_API_ENCRYPT(blowfish_cbc)
 {
   SilcUInt32 tiv[4];
   int i;
@@ -84,7 +100,7 @@ SILC_CIPHER_API_ENCRYPT_CBC(blowfish)
 /* Decrypts with the cipher in CBC mode. Source and destination buffers
    maybe one and same. */
 
-SILC_CIPHER_API_DECRYPT_CBC(blowfish)
+SILC_CIPHER_API_DECRYPT(blowfish_cbc)
 {
   SilcUInt32 tmp[4], tmp2[4], tiv[4];
   int i;