Ignore:
Timestamp:
01/20/20 15:04:45 (4 years ago)
Author:
bnemhaus
Message:

org.expeditee.auth.account.Password =>
org.expeditee.encryption.EncryptedExpReader =>

When performing account recovery, the username of the account you are trying to recover now actually needs to match the recovered key.
Also, the order that the password pieces are entered no longer matters.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/encryption/io/EncryptedExpReader.java

    r1461 r1500  
    22
    33import java.io.BufferedReader;
     4import java.io.File;
    45import java.io.FileInputStream;
    56import java.io.FileReader;
     
    7778                        return true;
    7879                }
     80        }       
     81       
     82        public static boolean isAccessibleExpediteeFile(String path, SecretKey key) throws IOException {
     83                try (BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(path), "UTF-8"))) {
     84                        String firstLine = in.readLine();
     85                        if (firstLine == null) return false;           
     86                       
     87                        if (firstLine.startsWith(ENCRYPTED_EXP_FLAG)) {
     88                                String secondLine = in.readLine();
     89                                byte[] toDecrypt = Base64.getDecoder().decode(secondLine);
     90                                byte[] decrypted = DecryptSymmetric(toDecrypt, key);
     91                                return decrypted != null;
     92                        } else {
     93                                // Not encrypted.  Returns false because the caller of this
     94                                // function is asking if this key is used to decrypt this file.
     95                                return false;
     96                        }
     97                }
    7998        }
    8099       
     
    326345                } catch (final NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException
    327346                                | IllegalBlockSizeException | BadPaddingException e) {
    328                         e.printStackTrace();
     347                        //e.printStackTrace();
     348                        System.err.println("Failed to decrypt '" + new String(toDecrypt) + "' with key " + new String(key.getEncoded()));
    329349                        return null;
    330350                }
     
    337357                        super(in);
    338358                }
    339                
     359                               
    340360                @Override
    341361                /**
Note: See TracChangeset for help on using the changeset viewer.