Skip to content

Commit

Permalink
All passwords because passphrases except in file names. WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
evpo committed Aug 20, 2016
1 parent 346df2e commit 8cbe9ff
Show file tree
Hide file tree
Showing 36 changed files with 362 additions and 362 deletions.
4 changes: 2 additions & 2 deletions back_end_src/encryptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ const string &Encryptor::GetX2KeyLocation() const
return this->mX2KeyLocation;
}

void Encryptor::SetPassword(const char *pwd, EncryptPad::PacketMetadata *metadata)
void Encryptor::SetPassphrase(const char *pwd, EncryptPad::PacketMetadata *metadata)
{

key_service_.Clear();
Expand Down Expand Up @@ -400,7 +400,7 @@ Result Encryptor::Load(const std::string &fileName, SecureVector<byte> &content,
return Result::OK;
}

// phase 1 decrypt with the password
// phase 1 decrypt with the passphrase
Pipe pipe;

try
Expand Down
2 changes: 1 addition & 1 deletion back_end_src/encryptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ namespace EncryptPadEncryptor
return kf_key_service_;
}

void SetPassword(const char *pwd, EncryptPad::PacketMetadata *metadata = nullptr);
void SetPassphrase(const char *pwd, EncryptPad::PacketMetadata *metadata = nullptr);
void SetIsPlainText();
bool GetIsPlainText();
bool UnusedKeysExist();
Expand Down
2 changes: 1 addition & 1 deletion back_end_src/packet_typedef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace EncryptPad
case PacketResult::UnexpectedError:
return "Unexpected error";
case PacketResult::InvalidSurrogateIV:
return "Incorrect password";
return "Incorrect passphrase";
case PacketResult::Empty:
return "Composite packet is empty";
case PacketResult::UnexpectedFormat:
Expand Down
2 changes: 1 addition & 1 deletion back_end_src/password_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ namespace

namespace EncryptPad
{
vector<string> GeneratePasswords(const vector<CharSet> &char_sets, int pwd_length, int pwd_count)
vector<string> GeneratePassphrases(const vector<CharSet> &char_sets, int pwd_length, int pwd_count)
{
assert(pwd_length > 0);
assert(pwd_count > 0);
Expand Down
2 changes: 1 addition & 1 deletion back_end_src/password_generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ namespace EncryptPad
:chars(chars_p), min(min_p), max(max_p), range(range){}
};

std::vector<std::string> GeneratePasswords(const std::vector<CharSet> &char_sets, int pwd_length, int pwd_count);
std::vector<std::string> GeneratePassphrases(const std::vector<CharSet> &char_sets, int pwd_length, int pwd_count);

const std::string &GetLowerAtoZ();
const std::string &GetUpperAtoZ();
Expand Down
20 changes: 10 additions & 10 deletions cli/get_password.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ namespace

namespace EncryptPad
{
void GetPassword(const std::string &prompt, std::string &password)
void GetPassphrase(const std::string &prompt, std::string &passphrase)
{
const char kBackSpace=8;
const char kReturn=13;

password.clear();
passphrase.clear();

unsigned char ch=0;

Expand All @@ -77,14 +77,14 @@ namespace EncryptPad
{
if(ch == kBackSpace)
{
if(password.length() != 0)
if(passphrase.length() != 0)
{
password.resize(password.length() - 1);
passphrase.resize(passphrase.length() - 1);
}
}
else
{
password+=ch;
passphrase+=ch;
}
}

Expand Down Expand Up @@ -128,9 +128,9 @@ namespace

namespace EncryptPad
{
void GetPassword(const std::string &prompt, std::string &password)
void GetPassphrase(const std::string &prompt, std::string &passphrase)
{
password.clear();
passphrase.clear();
unsigned char ch=0;

const char *termid = ctermid(NULL);
Expand All @@ -143,14 +143,14 @@ namespace EncryptPad
{
if(ch == kBackspace)
{
if(password.length() != 0)
if(passphrase.length() != 0)
{
password.resize(password.length() - 1);
passphrase.resize(passphrase.length() - 1);
}
}
else
{
password += ch;
passphrase += ch;
}
}

Expand Down
2 changes: 1 addition & 1 deletion cli/get_password.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@

namespace EncryptPad
{
void GetPassword(const std::string &prompt, std::string &password);
void GetPassphrase(const std::string &prompt, std::string &passphrase);
}
32 changes: 16 additions & 16 deletions cli/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ namespace EncryptPad
"--key-only key only, no passphrase\n"
"--persist-key persist key location in the encrypted file\n"
"--key-pwd-fd <file-descriptor> file descriptor from which to read the key file passphrase\n"
"--key-pwd-file <file> file with key password\n"
"--key-pwd-file <file> file with key passphrase\n"
"--libcurl-path <libcurl-path> path to libcurl executable to download a remote key file\n"
"--force-key-pwd force key password entry\n"
"--force-key-pwd force key passphrase entry\n"
"--plain-text-key plain text key (not recommended)\n"
"--pwd-fd <file-descriptor> password file descriptor\n"
"--pwd-file <file> file with password\n"
"--pwd-fd <file-descriptor> passphrase file descriptor\n"
"--pwd-file <file> file with passphrase\n"
"--cipher-algo <cipher-algo> cipher algorithm (CAST5, AES, AES256, 3DES; default: AES256)\n"
"--compress-algo <compression-algo> compression algorithm (ZIP, ZLIB, NONE; default: ZIP)\n"
"--s2k-digest-algo <s2k-digest-algo> s2k digest algorithm (SHA1, SHA256; default: SHA256)\n"
Expand Down Expand Up @@ -257,7 +257,7 @@ int main(int argc, char *argv[])
"force-key-pwd",
cli_kind_t::cli_switch_kind,
cli_mode_t::cli_single_mode,
"request key password entry",
"request key passphrase entry",
""
},
{
Expand All @@ -271,14 +271,14 @@ int main(int argc, char *argv[])
"pwd-fd",
cli_kind_t::cli_value_kind,
cli_mode_t::cli_single_mode,
"password file descriptor",
"passphrase file descriptor",
""
},
{
"pwd-file",
cli_kind_t::cli_value_kind,
cli_mode_t::cli_single_mode,
"password file",
"passphrase file",
""
},
{
Expand Down Expand Up @@ -459,7 +459,7 @@ int main(int argc, char *argv[])
out_file_ext = extension_part(out_file);
}

// Disable password entry when gpg format and key provided
// Disable passphrase entry when gpg format and key provided
if(encrypt && !key_only && !key_file.empty() && !out_file_ext.empty() &&
(out_file_ext == "gpg" || out_file_ext == "GPG"))
{
Expand Down Expand Up @@ -575,15 +575,15 @@ int main(int argc, char *argv[])

if(passphrase_fd_str.empty() && passphrase_file.empty() && !key_only && !(generate_kf && !encrypted_kf))
{
GetPassword("Password: ", passphrase);
GetPassphrase("Passphrase: ", passphrase);

if(encrypt || generate_kf)
{
std::string confirmed;
GetPassword("Confirm: ", confirmed);
GetPassphrase("Confirm: ", confirmed);
if(passphrase != confirmed)
{
std::cerr << "Passwords don't match. Please try again.";
std::cerr << "Passphrases don't match. Please try again.";
exit(1);
}
}
Expand Down Expand Up @@ -627,28 +627,28 @@ int main(int argc, char *argv[])
if(key_file_passphrase_required && key_file_passphrase_fd_str.empty() &&
key_file_passphrase_file.empty())
{
GetPassword("Key file password: ", key_file_passphrase);
GetPassphrase("Key file passphrase: ", key_file_passphrase);
}
else if(!key_file_passphrase_fd_str.empty())
{
if(!LoadStringFromDescriptor(key_file_passphrase_fd, key_file_passphrase))
{
std::cerr << "Cannot read from the specified key file password file descriptor" << std::endl;
std::cerr << "Cannot read from the specified key file passphrase file descriptor" << std::endl;
exit(1);
}
}
else if(!key_file_passphrase_file.empty())
{
if(!LoadStringFromFile(key_file_passphrase_file, key_file_passphrase))
{
std::cerr << "Cannot read from the specified key file password file" << std::endl;
std::cerr << "Cannot read from the specified key file passphrase file" << std::endl;
exit(1);
}
}

if(encrypt && key_only && key_file.empty())
{
std::cerr << "Invalid arguments: --key-only (key only, no password) requires --key-file (key file) option" << std::endl;
std::cerr << "Invalid arguments: --key-only (key only, no passphrase) requires --key-file (key file) option" << std::endl;
PrintUsage();
exit(1);
}
Expand Down Expand Up @@ -722,7 +722,7 @@ int main(int argc, char *argv[])

if(metadata.cannot_use_wad && !passphrase.empty() && !metadata.key_only && !metadata.key_file.empty())
{
std::cerr << "GPG format does not support password and key protection together. Use either or use EPD extension." << std::endl;
std::cerr << "GPG format does not support passphrase and key protection together. Use either or use EPD extension." << std::endl;
exit(1);
}

Expand Down
12 changes: 6 additions & 6 deletions func_tests/epd_encryption_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ mkdir -p $TMP_DIR
RESULT=0

############
# Password only
# Passphrase only
############
echo "Password only"
echo "Passphrase only"

cat $PASSPHRASE_FILE | $ENCRYPT_CLI -e --pwd-fd 0 -o $TMP_DIR/out_file.gpg $FILE
if ! [ -r $TMP_DIR/out_file.gpg ]
Expand Down Expand Up @@ -113,9 +113,9 @@ rm $TMP_DIR/out_file.epd
rm $TMP_DIR/out_file.txt

############
# Key and password
# Key and passphrase
############
echo "Key and password"
echo "Key and passphrase"

cat $PASSPHRASE_FILE | $ENCRYPT_CLI -e -k $KEY_FILE --plain-text-key --pwd-fd 0 -o $TMP_DIR/out_file.epd $FILE
cat $PASSPHRASE_FILE | $ENCRYPT_CLI -d -k $KEY_FILE --plain-text-key --pwd-fd 0 -o $TMP_DIR/out_file.txt $TMP_DIR/out_file.epd
Expand All @@ -131,9 +131,9 @@ rm $TMP_DIR/out_file.epd
rm $TMP_DIR/out_file.txt

############
# Key (persisted) and password
# Key (persisted) and passphrase
############
echo "Key (persisted) and password"
echo "Key (persisted) and passphrase"

cat $PASSPHRASE_FILE | $ENCRYPT_CLI -e --persist-key --plain-text-key -k $KEY_FILE --pwd-fd 0 -o $TMP_DIR/out_file.epd $FILE
cat $PASSPHRASE_FILE | $ENCRYPT_CLI -d --pwd-fd 0 --plain-text-key -o $TMP_DIR/out_file.txt $TMP_DIR/out_file.epd
Expand Down
18 changes: 9 additions & 9 deletions qt_ui/confirm_password_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,33 +22,33 @@
#include <QMessageBox>
#include "common_definitions.h"

ConfirmPasswordDialog::ConfirmPasswordDialog(QWidget *parent) :
ConfirmPassphraseDialog::ConfirmPassphraseDialog(QWidget *parent) :
QDialog(parent, kDefaultWindowFlags),
ui(new Ui::ConfirmPasswordDialog)
ui(new Ui::ConfirmPassphraseDialog)
{
ui->setupUi(this);
}

ConfirmPasswordDialog::~ConfirmPasswordDialog()
ConfirmPassphraseDialog::~ConfirmPassphraseDialog()
{
delete ui;
}

void ConfirmPasswordDialog::invokeOk()
void ConfirmPassphraseDialog::invokeOk()
{
if(ui->uiPassword->text() != ui->uiConfirm->text())
if(ui->uiPassphrase->text() != ui->uiConfirm->text())
{
QMessageBox::warning(
this,
tr("Set Password"),
tr("The confirmed password does not match"));
tr("Set Passphrase"),
tr("The confirmed passphrase does not match"));
return;
}

done(QDialog::Accepted);
}

QString ConfirmPasswordDialog::GetPassword() const
QString ConfirmPassphraseDialog::GetPassphrase() const
{
return ui->uiPassword->text();
return ui->uiPassphrase->text();
}
12 changes: 6 additions & 6 deletions qt_ui/confirm_password_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,24 @@
#include <QString>

namespace Ui {
class ConfirmPasswordDialog;
class ConfirmPassphraseDialog;
}

class ConfirmPasswordDialog : public QDialog
class ConfirmPassphraseDialog : public QDialog
{
Q_OBJECT

public:
explicit ConfirmPasswordDialog(QWidget *parent = 0);
~ConfirmPasswordDialog();
explicit ConfirmPassphraseDialog(QWidget *parent = 0);
~ConfirmPassphraseDialog();

public slots:
void invokeOk();
private:
Ui::ConfirmPasswordDialog *ui;
Ui::ConfirmPassphraseDialog *ui;

public:
QString GetPassword() const;
QString GetPassphrase() const;

};

Expand Down
Loading

0 comments on commit 8cbe9ff

Please sign in to comment.