public void setup(Map attributes) {
      Map macAttrib = new HashMap();
      macAttrib.put(HMac.USE_WITH_PKCS5_V2, Boolean.TRUE);

      byte[] s = (byte[]) attributes.get(IPBE.SALT);
      if (s == null) {
         if (salt == null) {
            throw new IllegalArgumentException("no salt specified");
         } // Otherwise re-use.
      } else {
         salt = s;
      }

      char[] password = (char[]) attributes.get(IPBE.PASSWORD);
      if (password != null) {
         try {
            macAttrib.put(IMac.MAC_KEY_MATERIAL, new String(password).getBytes("UTF-8"));
         } catch (UnsupportedEncodingException uee) {
            throw new Error(uee.getMessage());
         }
      } else if (!initialised) {
         throw new IllegalArgumentException("no password specified");
      } // otherwise re-use previous password.

      try {
         mac.init(macAttrib);
      } catch (Exception x) {
         throw new IllegalArgumentException(x.getMessage());
      }

      Integer ic = (Integer) attributes.get(IPBE.ITERATION_COUNT);
      if (ic != null) {
         iterationCount = ic.intValue();
      }
      if (iterationCount <= 0) {
         throw new IllegalArgumentException("bad iteration count");
      }

      count = 0L;
      buffer = new byte[mac.macSize()];
      try {
         fillBlock();
//      } catch (Exception x) {
      } catch (LimitReachedException x) {
//         x.printStackTrace(System.err);
         throw new Error(x.getMessage());
      }
   }