public Object makeKey(byte[] k, int bs) {
      Context ctx = new Context();
      System.arraycopy(P,   0, ctx.p,  0, P.length);
      System.arraycopy(KS0, 0, ctx.s0, 0, KS0.length);
      System.arraycopy(KS1, 0, ctx.s1, 0, KS1.length);
      System.arraycopy(KS2, 0, ctx.s2, 0, KS2.length);
      System.arraycopy(KS3, 0, ctx.s3, 0, KS3.length);

      // XOR the key with the P-box
      int l = 0;
      for (int i = 0; i < ctx.p.length; i++) {
         int data = 0;
         for (int j = 0; j < 4; j++) {
            data = (data << 8) | (k[l++]&0xff);
            if (l >= k.length) {
               l = 0;
            }
         }
         ctx.p[i] ^= data;
      }

      // We swap the left and right words here only, so we can avoid
      // swapping altogether during encryption/decryption.
      int t;
      Block x = new Block();
      x.left = x.right = 0;
      for (int i = 0; i < ctx.p.length; i += 2) {
         blowfishEncrypt(x, ctx);
         ctx.p[i  ] = x.right;
         ctx.p[i+1] = x.left;
         t = x.right;
         x.right = x.left;
         x.left = t;
      }
      for (int i = 0; i < ctx.s0.length; i += 2) {
         blowfishEncrypt(x, ctx);
         ctx.s0[i  ] = x.right;
         ctx.s0[i+1] = x.left;
         t = x.right;
         x.right = x.left;
         x.left = t;
      }
      for (int i = 0; i < ctx.s1.length; i += 2) {
         blowfishEncrypt(x, ctx);
         ctx.s1[i  ] = x.right;
         ctx.s1[i+1] = x.left;
         t = x.right;
         x.right = x.left;
         x.left = t;
      }
      for (int i = 0; i < ctx.s2.length; i += 2) {
         blowfishEncrypt(x, ctx);
         ctx.s2[i  ] = x.right;
         ctx.s2[i+1] = x.left;
         t = x.right;
         x.right = x.left;
         x.left = t;
      }
      for (int i = 0; i < ctx.s3.length; i += 2) {
         blowfishEncrypt(x, ctx);
         ctx.s3[i  ] = x.right;
         ctx.s3[i+1] = x.left;
         t = x.right;
         x.right = x.left;
         x.left = t;
      }
      x.left = x.right = 0;
      return ctx;
   }