private IMac getMac(char[] password) throws MalformedKeyringException {
      if (!properties.containsKey("salt")) {
         throw new MalformedKeyringException("no salt");
      }
      byte[] salt = Util.toBytesFromString(properties.get("salt"));
      IMac mac = MacFactory.getInstance(properties.get("mac"));
      if (mac == null) {
         throw new MalformedKeyringException("no such mac: " + properties.get("mac"));
      }
      int keylen = mac.macSize();
      int maclen = 0;
      if (!properties.containsKey("maclen")) {
         throw new MalformedKeyringException("no MAC length");
      }
      try {
         maclen = Integer.parseInt(properties.get("maclen"));
      } catch (NumberFormatException nfe) {
         throw new MalformedKeyringException("bad MAC length");
      }

      HashMap pbAttr = new HashMap();
      pbAttr.put(IPBE.PASSWORD, password);
      pbAttr.put(IPBE.SALT, salt);
      pbAttr.put(IPBE.ITERATION_COUNT, ITERATION_COUNT);
      IRandom kdf = PRNGFactory.getInstance("PBKDF2-HMAC-SHA");
      kdf.init(pbAttr);

      byte[] dk = new byte[keylen];
      try {
         kdf.nextBytes(dk, 0, keylen);
      } catch (LimitReachedException shouldNotHappen) {
         throw new Error(shouldNotHappen.toString());
      }

      HashMap macAttr = new HashMap();
      macAttr.put(IMac.MAC_KEY_MATERIAL, dk);
      macAttr.put(IMac.TRUNCATED_SIZE, new Integer(maclen));
      try {
         mac.init(macAttr);
      } catch (InvalidKeyException shouldNotHappen) {
         throw new Error(shouldNotHappen.toString());
      }
      return mac;
   }