+static void *blowfish_make_context(void)
+{
+ return snew(BlowfishContext);
+}
+
+static void *blowfish_ssh1_make_context(void)
+{
+ /* In SSH-1, need one key for each direction */
+ return snewn(2, BlowfishContext);
+}
+
+static void blowfish_free_context(void *handle)
+{
+ sfree(handle);
+}
+
+static void blowfish_key(void *handle, unsigned char *key)
+{
+ BlowfishContext *ctx = (BlowfishContext *)handle;
+ blowfish_setkey(ctx, key, 16);
+}
+
+static void blowfish256_key(void *handle, unsigned char *key)
+{
+ BlowfishContext *ctx = (BlowfishContext *)handle;
+ blowfish_setkey(ctx, key, 32);
+}
+
+static void blowfish_iv(void *handle, unsigned char *key)
+{
+ BlowfishContext *ctx = (BlowfishContext *)handle;
+ ctx->iv0 = GET_32BIT_MSB_FIRST(key);
+ ctx->iv1 = GET_32BIT_MSB_FIRST(key + 4);
+}
+
+static void blowfish_sesskey(void *handle, unsigned char *key)
+{
+ BlowfishContext *ctx = (BlowfishContext *)handle;
+ blowfish_setkey(ctx, key, SSH_SESSION_KEY_LENGTH);
+ ctx->iv0 = 0;
+ ctx->iv1 = 0;
+ ctx[1] = ctx[0]; /* structure copy */
+}
+
+static void blowfish_ssh1_encrypt_blk(void *handle, unsigned char *blk,
+ int len)
+{
+ BlowfishContext *ctx = (BlowfishContext *)handle;
+ blowfish_lsb_encrypt_cbc(blk, len, ctx);
+}
+
+static void blowfish_ssh1_decrypt_blk(void *handle, unsigned char *blk,
+ int len)
+{
+ BlowfishContext *ctx = (BlowfishContext *)handle;
+ blowfish_lsb_decrypt_cbc(blk, len, ctx+1);
+}
+
+static void blowfish_ssh2_encrypt_blk(void *handle, unsigned char *blk,
+ int len)