public static PasswordAuthenticatedEntry decode(DataInputStream in) throws IOException {
   PasswordAuthenticatedEntry entry = new PasswordAuthenticatedEntry();
   entry.defaultDecode(in);
   if (!entry.properties.containsKey("mac")) {
     throw new MalformedKeyringException("no MAC");
   }
   if (!entry.properties.containsKey("maclen")) {
     throw new MalformedKeyringException("no MAC length");
   }
   if (!entry.properties.containsKey("salt")) {
     throw new MalformedKeyringException("no salt");
   }
   return entry;
 }
 public static PasswordAuthenticatedEntry decode(DataInputStream in, char[] password)
     throws IOException {
   PasswordAuthenticatedEntry entry = new PasswordAuthenticatedEntry();
   entry.properties.decode(in);
   IMac mac = entry.getMac(password);
   int len = in.readInt() - mac.macSize();
   MeteredInputStream min = new MeteredInputStream(in, len);
   MacInputStream macin = new MacInputStream(min, mac);
   DataInputStream in2 = new DataInputStream(macin);
   entry.setMasked(false);
   entry.decodeEnvelope(in2);
   byte[] macValue = new byte[mac.macSize()];
   in.readFully(macValue);
   if (!Arrays.equals(macValue, mac.digest())) {
     throw new MalformedKeyringException("MAC verification failed");
   }
   return entry;
 }