From: Enar Vaikene Date: Wed, 20 Jul 2011 13:01:10 +0000 (+0300) Subject: Added PswGen application. X-Git-Url: https://vaikene.ee/gitweb/gitweb.cgi?a=commitdiff_plain;h=473db85d79d6d89b7b8fe617346efa3e94c66cd9;p=evaf Added PswGen application. This application generates strong passwords using cryptographic hashes. The initial version uses MD5 checksums. --- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 79123e7..e1508b4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,3 +1,4 @@ add_subdirectory(libs) add_subdirectory(main) add_subdirectory(plugins) +add_subdirectory(apps) diff --git a/src/apps/CMakeLists.txt b/src/apps/CMakeLists.txt new file mode 100644 index 0000000..e6cf7f0 --- /dev/null +++ b/src/apps/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(PswGen) diff --git a/src/apps/PswGen/CMakeLists.txt b/src/apps/PswGen/CMakeLists.txt new file mode 100644 index 0000000..64a26c5 --- /dev/null +++ b/src/apps/PswGen/CMakeLists.txt @@ -0,0 +1,5 @@ +set(eVaf_INCLUDE ${eVaf_INCLUDE} ${CMAKE_SOURCE_DIR}/src/apps/PswGen) + +add_subdirectory(GUI) +add_subdirectory(Generator) +#add_subdirectory(Storage) diff --git a/src/apps/PswGen/GUI/CMakeLists.txt b/src/apps/PswGen/GUI/CMakeLists.txt new file mode 100644 index 0000000..fceaa2e --- /dev/null +++ b/src/apps/PswGen/GUI/CMakeLists.txt @@ -0,0 +1,37 @@ +# Name of the target +set(TARGET PswGui) + +# Qt modules +include(${QT_USE_FILE}) + +# Needed for exporting/importing symbols +add_definitions(-DPSWGEN_GUI_LIBRARY) + +# Include files +include_directories(${eVaf_INCLUDE}) + +# Required eVaf libraries +set(eVaf_LIBRARIES CommonLib PluginsLib SdiWindow PswGen) + +# Source files +set(SRCS + gui.cpp +) + +# Header files for the meta-object compiler +set(MOC_HDRS + gui.h +) + +# Version info resource file for Windows builds +if(WIN32) + set(SRCS ${SRCS} version.rc) +endif(WIN32) + +qt4_wrap_cpp(MOC_SRCS ${MOC_HDRS}) + +add_library(${TARGET} SHARED ${SRCS} ${MOC_SRCS}) + +target_link_libraries(${TARGET} ${QT_LIBRARIES} ${eVaf_LIBRARIES}) + +install(TARGETS ${TARGET} DESTINATION bin) diff --git a/src/apps/PswGen/GUI/gui.cpp b/src/apps/PswGen/GUI/gui.cpp new file mode 100644 index 0000000..34bd2f0 --- /dev/null +++ b/src/apps/PswGen/GUI/gui.cpp @@ -0,0 +1,174 @@ +/** + * @file PswGen/GUI/gui.cpp + * @brief GUI for the PswGen application + * @author Enar Vaikene + * + * Copyright (c) 2011 Enar Vaikene + * + * This file is part of the eVaf C++ cross-platform application development framework. + * + * This file can be used under the terms of the GNU General Public License + * version 3.0 as published by the Free Software Foundation and appearing in + * the file LICENSE included in the packaging of this file. Please review the + * the following information to ensure the GNU General Public License version + * 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html. + * + * Alternatively, this file may be used in accordance with the Commercial License + * Agreement provided with the Software. + */ + +#include "gui.h" +#include "version.h" + +#include "Generator/iGenerator" + +#include +#include +#include +#include + +#include + + +using namespace eVaf; + +VER_EXPORT_VERSION_INFO() +Q_EXPORT_PLUGIN2(VER_MODULE_NAME_STR, PswGen::GUI::Module) + + +//------------------------------------------------------------------- + +using namespace eVaf::PswGen::GUI; + +Module::Module() + : Plugins::iPlugin() + , mReady(false) + , mGenerator(0) +{ + setObjectName(QString("%1.%2").arg(VER_MODULE_NAME_STR).arg(__FUNCTION__)); + + EVAF_INFO("%s created", qPrintable(objectName())); +} + +Module::~Module() +{ + EVAF_INFO("%s destroyed", qPrintable(objectName())); +} + +bool Module::init(QString const & args) +{ + Q_UNUSED(args); + + // Get the iGenerator interface + EVAF_TEST_X((mGenerator = evafQueryInterface("iGenerator")), "No iGenerator interface"); + + // Get the main window interface and fill it with the widgets + SdiWindow::iSdiWindow * win = evafQueryInterface("iSdiWindow"); + EVAF_TEST_X(win, "No iSdiWindow interface"); + + QVBoxLayout * v = new QVBoxLayout; + win->widget()->setLayout(v); + + QGridLayout * g = new QGridLayout; + v->addLayout(g); + g->setColumnStretch(2, 2); + + QLabel * l = new QLabel(tr("Web site or application &name:", VER_MODULE_NAME_STR)); + l->setAlignment(Qt::AlignRight); + g->addWidget(l, 0, 0); + + wName = new QLineEdit; + l->setBuddy(wName); + connect(wName, SIGNAL(textChanged(QString)), this, SLOT(textChanged(QString))); + g->addWidget(wName, 0, 1, 1, 2); + win->widget()->setFocusProxy(wName); + + l = new QLabel(tr("Master &password:", VER_MODULE_NAME_STR)); + l->setAlignment(Qt::AlignRight); + g->addWidget(l, 1, 0); + + wMasterPassword = new QLineEdit; + l->setBuddy(wMasterPassword); + connect(wMasterPassword, SIGNAL(textChanged(QString)), this, SLOT(textChanged(QString))); + wMasterPassword->setEchoMode(QLineEdit::Password); + g->addWidget(wMasterPassword, 1, 1, 1, 2); + + l = new QLabel(tr("&Length of the password:", VER_MODULE_NAME_STR)); + l->setAlignment(Qt::AlignRight); + g->addWidget(l, 2, 0); + + wLength = new QSpinBox; + l->setBuddy(wLength); + wLength->setRange(0, mGenerator->maxLength()); + wLength->setValue(PswGen::iGenerator::DEFAULT_LENGTH); + wLength->setSpecialValueText(tr("Maximum", VER_MODULE_NAME_STR)); + g->addWidget(wLength, 2, 1); + + l = new QLabel(tr("Password:")); + l->setAlignment(Qt::AlignRight); + g->addWidget(l, 3, 0); + + wPassword = new QLineEdit; + wPassword->setReadOnly(true); + g->addWidget(wPassword, 3, 1, 1, 2); + + v->addStretch(); + + QHBoxLayout * h = new QHBoxLayout; + h->addStretch(); + v->addLayout(h); + + wGenerate = new QPushButton(tr("&Generate", VER_MODULE_NAME_STR)); + wGenerate->setDisabled(true); + wGenerate->setDefault(true); + connect(wGenerate, SIGNAL(clicked()), this, SLOT(generateClicked())); + h->addWidget(wGenerate); + + wCopy = new QPushButton(tr("&Copy to Clipboard", VER_MODULE_NAME_STR)); + wCopy->setDisabled(true); + connect(wCopy, SIGNAL(clicked()), this, SLOT(copyClicked())); + h->addWidget(wCopy); + + QAction * a = new QAction(win->widget()); + a->setShortcut(Qt::Key_Return); + connect(a, SIGNAL(triggered()), this, SLOT(generateClicked())); + win->widget()->addAction(a); + + a = new QAction(win->widget()); + a->setShortcut(Qt::Key_Escape); + connect(a, SIGNAL(triggered()), qApp, SLOT(quit())); + win->widget()->addAction(a); + + mReady = true; + + EVAF_INFO("%s initialized", qPrintable(objectName())); + + return true; +} + +void Module::done() +{ + mReady = false; + + EVAF_INFO("%s finalized", qPrintable(objectName())); +} + +void Module::textChanged(QString const &) +{ + wGenerate->setDisabled(wMasterPassword->text().isEmpty() || wName->text().isEmpty()); +} + +void Module::generateClicked() +{ + if (wMasterPassword->text().isEmpty() || wName->text().isEmpty()) + return; + wPassword->setText(mGenerator->generatePassword(wName->text().toLatin1().constData(), wMasterPassword->text().toLatin1().constData(), wLength->value())); + wCopy->setEnabled(true); +} + +void Module::copyClicked() +{ + QClipboard * clipboard = QApplication::clipboard(); + if (clipboard) + clipboard->setText(wPassword->text()); +} diff --git a/src/apps/PswGen/GUI/gui.h b/src/apps/PswGen/GUI/gui.h new file mode 100644 index 0000000..e9607e4 --- /dev/null +++ b/src/apps/PswGen/GUI/gui.h @@ -0,0 +1,93 @@ +/** + * @file PswGen/GUI/gui.h + * @brief GUI for the PswGen application + * @author Enar Vaikene + * + * Copyright (c) 2011 Enar Vaikene + * + * This file is part of the eVaf C++ cross-platform application development framework. + * + * This file can be used under the terms of the GNU General Public License + * version 3.0 as published by the Free Software Foundation and appearing in + * the file LICENSE included in the packaging of this file. Please review the + * the following information to ensure the GNU General Public License version + * 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html. + * + * Alternatively, this file may be used in accordance with the Commercial License + * Agreement provided with the Software. + */ + +#ifndef __PSWGEN_GUI_GUI_H +#define __PSWGEN_GUI_GUI_H + +#include + +#include +#include + +class QLineEdit; +class QSpinBox; +class QPushButton; + +namespace eVaf { +namespace PswGen { + class iGenerator; +namespace GUI { + +/** + * Graphical User Interface for the PswGen application. + * + * This module adds a GUI window to the pswGen application using the SdiWindow module. + */ +class Module : public Plugins::iPlugin +{ + Q_OBJECT + +public: + + Module(); + + virtual ~Module(); + + virtual bool init(const QString & args); + + virtual void done(); + + virtual bool isReady() const { return mReady; } + + +private slots: + + /// Master password or name changed + void textChanged(QString const &); + + /// 'Generate' button clicked + void generateClicked(); + + /// 'Copy' button clicked + void copyClicked(); + + +private: // Members + + /// Flag indicating that the module is ready + bool mReady; + + /// The iGenerator interface + eVaf::PswGen::iGenerator * mGenerator; + + /// Widgets on the screen + QLineEdit * wName; + QLineEdit * wMasterPassword; + QSpinBox * wLength; + QLineEdit * wPassword; + QPushButton * wGenerate; + QPushButton * wCopy; + +}; + +} // namespace eVaf::PswGen::GUI +} // namespace eVaf::PswGen +} // namespace eVaf + +#endif // gui.h diff --git a/src/apps/PswGen/GUI/lib.h b/src/apps/PswGen/GUI/lib.h new file mode 100644 index 0000000..8a3fdfb --- /dev/null +++ b/src/apps/PswGen/GUI/lib.h @@ -0,0 +1,30 @@ +/** + * @file PswGen/GUI/lib.h + * @author Enar Vaikene + * + * Copyright (c) 2011 Enar Vaikene + * + * This file is part of the eVaf C++ cross-platform application development framework. + * + * This file can be used under the terms of the GNU General Public License + * version 3.0 as published by the Free Software Foundation and appearing in + * the file LICENSE included in the packaging of this file. Please review the + * the following information to ensure the GNU General Public License version + * 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html. + * + * Alternatively, this file may be used in accordance with the Commercial License + * Agreement provided with the Software. + */ + +#ifndef __PSWGEN_GUI_LIB_H +# define __PSWGEN_GUI_LIB_H + +#include + +#if defined(PSWGEN_GUI_LIBRARY) +# define PSWGEN_GUI_EXPORT Q_DECL_EXPORT +#else +# define PSWGEN_GUI_EXPORT Q_DECL_IMPORT +#endif + +#endif // lib.h diff --git a/src/apps/PswGen/GUI/version.h b/src/apps/PswGen/GUI/version.h new file mode 100644 index 0000000..690db50 --- /dev/null +++ b/src/apps/PswGen/GUI/version.h @@ -0,0 +1,60 @@ +/** + * @file PswGen/GUI/version.h + * @brief Version information for eVaf modules + * @author Enar Vaikene + * + * Copyright (c) 2011 Enar Vaikene + * + * This file is part of the eVaf C++ cross-platform application development framework. + * + * This file can be used under the terms of the GNU General Public License + * version 3.0 as published by the Free Software Foundation and appearing in + * the file LICENSE included in the packaging of this file. Please review the + * the following information to ensure the GNU General Public License version + * 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html. + * + * Alternatively, this file may be used in accordance with the Commercial License + * Agreement provided with the Software. + */ + +#ifndef __PSWGEN_GUI_VERSION_H +#define __PSWGEN_GUI_VERSION_H + +#include + +/** + * Module/library version number in the form major,minor,release,build + */ +#define VER_FILE_VERSION 0,1,1,1 + +/** + * Module/library version number in the string format (shall end with \0) + */ +#define VER_FILE_VERSION_STR "0.1.1.1\0" + +/** + * Module/library name (shall end with \0) + */ +#define VER_MODULE_NAME_STR "pswGui\0" + +/** + * Module type (see version_rc.h for all the types) + */ +#define VER_MODULE_TYPE MT_GENERIC + +/** + * Module type in the string format (see version_rc for all the types) + */ +#define VER_MODULE_TYPE_STR MT_GENERIC + +/** + * Original file name for windows (shall end with \0) + */ +#define VER_ORIGINAL_FILE_NAME_STR "pswGui.dll\0" + +/** + * Description of the module/library (shall end with \0) + */ +#define VER_FILE_DESCRIPTION_STR "User interface for the PswGen application.\0" + +#endif // version.h diff --git a/src/apps/PswGen/GUI/version.rc b/src/apps/PswGen/GUI/version.rc new file mode 100644 index 0000000..b80e70f --- /dev/null +++ b/src/apps/PswGen/GUI/version.rc @@ -0,0 +1,54 @@ +/** + * @file PswGen/GUI/version.rc + * @brief Windows resource file with module/library version information. + * @author Enar Vaikene + * + * Copyright (c) 2011 Enar Vaikene + * + * This file is part of the eVaf C++ cross-platform application development framework. + * + * This file can be used under the terms of the GNU General Public License + * version 3.0 as published by the Free Software Foundation and appearing in + * the file LICENSE included in the packaging of this file. Please review the + * the following information to ensure the GNU General Public License version + * 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html. + * + * Alternatively, this file may be used in accordance with the Commercial License + * Agreement provided with the Software. + */ + +#include "version.h" +#include +#include + + +VS_VERSION_INFO VERSIONINFO + FILEVERSION VER_FILE_VERSION + PRODUCTVERSION VER_PRODUCT_VERSION + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS VS_FF_DEBUG +#else + FILEFLAGS 0x0L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE 0x0L + BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904B0" + BEGIN + VALUE "CompanyName", VER_COMPANY_NAME_STR + VALUE "FileDescription", VER_FILE_DESCRIPTION_STR + VALUE "FileVersion", VER_FILE_VERSION_STR + VALUE "LegalCopyright", VER_LEGAL_COPYRIGHT_STR + VALUE "OriginalFilename", VER_ORIGINAL_FILE_NAME_STR + VALUE "ProductName", VER_PRODUCT_NAME_STR + VALUE "ProductVersion", VER_PRODUCT_VERSION_STR + VALUE "Build Date", VER_PRODUCT_DATE_STR + VALUE "Module Name", VER_MODULE_NAME_STR + VALUE "Module Type", VER_MODULE_TYPE_STR + END + END + END diff --git a/src/apps/PswGen/Generator/CMakeLists.txt b/src/apps/PswGen/Generator/CMakeLists.txt new file mode 100644 index 0000000..ffaba79 --- /dev/null +++ b/src/apps/PswGen/Generator/CMakeLists.txt @@ -0,0 +1,39 @@ +# Name of the target +set(TARGET PswGen) + +# Qt modules +set(QT_DONT_USE_QTGUI TRUE) +include(${QT_USE_FILE}) + +# Needed for exporting/importing symbols +add_definitions(-DPSWGEN_GENERATOR_LIBRARY) + +# Include files +include_directories(${eVaf_INCLUDE}) + +# Required eVaf libraries +set(eVaf_LIBRARIES CommonLib PluginsLib) + +# Source files +set(SRCS + generator.cpp +) + +# Header files for the meta-object compiler +set(MOC_HDRS + igenerator.h + generator.h +) + +# Version info resource file for Windows builds +if(WIN32) + set(SRCS ${SRCS} version.rc) +endif(WIN32) + +qt4_wrap_cpp(MOC_SRCS ${MOC_HDRS}) + +add_library(${TARGET} SHARED ${SRCS} ${MOC_SRCS}) + +target_link_libraries(${TARGET} ${QT_LIBRARIES} ${eVaf_LIBRARIES}) + +install(TARGETS ${TARGET} DESTINATION bin) diff --git a/src/apps/PswGen/Generator/generator.cpp b/src/apps/PswGen/Generator/generator.cpp new file mode 100644 index 0000000..dddc845 --- /dev/null +++ b/src/apps/PswGen/Generator/generator.cpp @@ -0,0 +1,123 @@ +/** + * @file PswGen/Generator/generator.cpp + * @brief Implementation of the iGenerator interface + * @author Enar Vaikene + * + * Copyright (c) 2011 Enar Vaikene + * + * This file is part of the eVaf C++ cross-platform application development framework. + * + * This file can be used under the terms of the GNU General Public License + * version 3.0 as published by the Free Software Foundation and appearing in + * the file LICENSE included in the packaging of this file. Please review the + * the following information to ensure the GNU General Public License version + * 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html. + * + * Alternatively, this file may be used in accordance with the Commercial License + * Agreement provided with the Software. + */ + +#include "generator.h" +#include "version.h" + +#include +#include + +#include + +using namespace eVaf; +using namespace evaf::PswGen; +using namespace eVaf::PswGen::Generator; + +//------------------------------------------------------------------- + +Generator::Generator() + : Plugins::iPlugin() + , mReady(false) +{ + setObjectName(QString("%1.%2").arg(VER_MODULE_NAME_STR).arg(__FUNCTION__)); + + mGenerator = new Internal::GeneratorImpl; + + EVAF_INFO("%s created", qPrintable(objectName())); +} + +Generator::~Generator() +{ + delete mGenerator; + + EVAF_INFO("%s destroyed", qPrintable(objectName())); +} + +bool Generator::init(const QString & args) +{ + Q_UNUSED(args); + + if (!mGenerator->init()) + return false; + + mReady = true; + + EVAF_INFO("%s initialized", qPrintable(objectName())); + + return true; +} + +void Generator::done() +{ + mReady = false; + + mGenerator->done(); + + EVAF_INFO("%s finalized", qPrintable(objectName())); +} + + +//------------------------------------------------------------------- + +using namespace eVaf::PswGen::Generator::Internal; + +GeneratorImpl::GeneratorImpl() + : iGenerator() +{ + setObjectName(QString("%1.iGenerator").arg(VER_MODULE_NAME_STR)); + + Common::iRegistry::instance()->registerInterface("iGenerator", this); + + EVAF_INFO("%s created", qPrintable(objectName())); +} + +GeneratorImpl::~GeneratorImpl() +{ + EVAF_INFO("%s destroyed", qPrintable(objectName())); +} + +bool GeneratorImpl::init() +{ + EVAF_INFO("%s initialized", qPrintable(objectName())); + + return true; +} + +void GeneratorImpl::done() +{ + EVAF_INFO("%s finalized", qPrintable(objectName())); +} + +QString GeneratorImpl::generatePassword(char const * const name, char const * const masterPassword, int length, uint flags) +{ + QByteArray inputString = QString("%1%2").arg(name).arg(masterPassword).toLatin1(); + QCryptographicHash hash(QCryptographicHash::Md5); + hash.addData(inputString); + QByteArray result = hash.result().toBase64(); + if (length > 0) + return result.left(length); + else + return result; +} + + +//------------------------------------------------------------------- + +VER_EXPORT_VERSION_INFO() +Q_EXPORT_PLUGIN2(VER_MODULE_NAME_STR, Generator) diff --git a/src/apps/PswGen/Generator/generator.h b/src/apps/PswGen/Generator/generator.h new file mode 100644 index 0000000..77513be --- /dev/null +++ b/src/apps/PswGen/Generator/generator.h @@ -0,0 +1,101 @@ +/** + * @file PswGen/Generator/generator.h + * @brief Implementation of the iGenerator interface + * @author Enar Vaikene + * + * Copyright (c) 2011 Enar Vaikene + * + * This file is part of the eVaf C++ cross-platform application development framework. + * + * This file can be used under the terms of the GNU General Public License + * version 3.0 as published by the Free Software Foundation and appearing in + * the file LICENSE included in the packaging of this file. Please review the + * the following information to ensure the GNU General Public License version + * 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html. + * + * Alternatively, this file may be used in accordance with the Commercial License + * Agreement provided with the Software. + */ + +#ifndef __PSWGEN_GENERATOR_GENERATOR_H +# define __PSWGEN_GENERATOR_GENERATOR_H + +#include "igenerator.h" + +#include + +#include + +namespace eVaf { +namespace PswGen { + +/// Module that generates strong passwords using cryptographic methods +namespace Generator { + +/// Internal implementation of the Generator module +namespace Internal { + +/** + * iGenerator interface implementation. + * + * Implements the iGenerator interface using MD5 cryptographic hashes. + */ + +class GeneratorImpl : public iGenerator +{ + Q_OBJECT + +public: + + GeneratorImpl(); + + virtual ~GeneratorImpl(); + + bool init(); + + void done(); + + virtual QString generatePassword(char const * const name, char const * const masterPassword, int length = iGenerator::DEFAULT_LENGTH, uint flags = 0); + + virtual int maxLength() const { return 24; } + +}; + +} // namespace eVaf::PswGen::Generator::Internal + +/** + * Module implementing the iGenerator interface. + */ +class Generator : public Plugins::iPlugin +{ + Q_OBJECT + +public: + + Generator(); + + virtual ~Generator(); + + virtual bool init(const QString & args); + + virtual void done(); + + virtual bool isReady() const { return mReady; } + + +private: // Members + + /// Flag indicating that the module is ready + bool mReady; + + /// iGenerator interface instance + Internal::GeneratorImpl * mGenerator; + +}; + + +} // namespace eVaf::PswGen::Generator +} // namespace eVaf::PswGen +} // namespace eVaf + +#endif // generator.h diff --git a/src/apps/PswGen/Generator/iGenerator b/src/apps/PswGen/Generator/iGenerator new file mode 100644 index 0000000..6475f7f --- /dev/null +++ b/src/apps/PswGen/Generator/iGenerator @@ -0,0 +1 @@ +#include "igenerator.h" diff --git a/src/apps/PswGen/Generator/igenerator.h b/src/apps/PswGen/Generator/igenerator.h new file mode 100644 index 0000000..d5122f2 --- /dev/null +++ b/src/apps/PswGen/Generator/igenerator.h @@ -0,0 +1,94 @@ +/** + * @file PswGen/Generator/igenerator.h + * @brief Interface for password generator modules + * @author Enar Vaikene + * + * Copyright (c) 2011 Enar Vaikene + * + * This file is part of the eVaf C++ cross-platform application development framework. + * + * This file can be used under the terms of the GNU General Public License + * version 3.0 as published by the Free Software Foundation and appearing in + * the file LICENSE included in the packaging of this file. Please review the + * the following information to ensure the GNU General Public License version + * 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html. + * + * Alternatively, this file may be used in accordance with the Commercial License + * Agreement provided with the Software. + */ + +#ifndef __PSWGEN_GENERATOR_IGENERATOR_H +# define __PSWGEN_GENERATOR_IGENERATOR_H + +#include "lib.h" + +#include + +namespace eVaf { +namespace PswGen { + +/** + * Password generator interface. + * + * This interface is used to generate strong passwords. + */ +class PSWGEN_GENERATOR_EXPORT iGenerator : public QObject +{ + Q_OBJECT + +public: + + /// Interface constructor + iGenerator() {} + + /// Empty virtual destructor + virtual ~iGenerator() {} + + /** + * Flags for the password generator. + */ + enum { + ALPHANUMERIC = 0x01 ///< Generated password contains only alphanumeric characters + }; + + /** + * Default length of the generated password + */ + enum { + DEFAULT_LENGTH = 16 + }; + + /** + * Generates a strong password + * @param name Name of the password + * @param masterPassword Master password + * @param length Length of the password + * @param flags Flags for the generator + * @return Generated password + * + * This function generates a strong password using the name and the master password string + * as inputs. Calling this function with the same input always returns the same generated + * password. + * + * The length of the password is specified with the length argument. However, the generated password + * is never longer than possible with the particular cryptographic method. + * + * Optional flags can be used to fine-tune the generator. + */ + virtual QString generatePassword(char const * const name, char const * const masterPassword, int length = DEFAULT_LENGTH, uint flags = 0) = 0; + + /** + * Returns the maximum length of generated passwords + * @return Maximum length + * + * This function returns the maximum length of generated passwords that is possible with the cryptographic method + * used by the module implementing this interface. + */ + virtual int maxLength() const = 0; + +}; + +} // namespace eVaf::PswGen +} // namespace eVaf + +#endif // igenerator.h diff --git a/src/apps/PswGen/Generator/lib.h b/src/apps/PswGen/Generator/lib.h new file mode 100644 index 0000000..b50afe3 --- /dev/null +++ b/src/apps/PswGen/Generator/lib.h @@ -0,0 +1,30 @@ +/** + * @file PswGen/Generator/lib.h + * @author Enar Vaikene + * + * Copyright (c) 2011 Enar Vaikene + * + * This file is part of the eVaf C++ cross-platform application development framework. + * + * This file can be used under the terms of the GNU General Public License + * version 3.0 as published by the Free Software Foundation and appearing in + * the file LICENSE included in the packaging of this file. Please review the + * the following information to ensure the GNU General Public License version + * 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html. + * + * Alternatively, this file may be used in accordance with the Commercial License + * Agreement provided with the Software. + */ + +#ifndef __PSWGEN_GENERATOR_LIB_H +# define __PSWGEN_GENERATOR_LIB_H + +#include + +#if defined(PSWGEN_GENERATOR_LIBRARY) +# define PSWGEN_GENERATOR_EXPORT Q_DECL_EXPORT +#else +# define PSWGEN_GENERATOR_EXPORT Q_DECL_IMPORT +#endif + +#endif // libgen.h diff --git a/src/apps/PswGen/Generator/version.h b/src/apps/PswGen/Generator/version.h new file mode 100644 index 0000000..b118cdc --- /dev/null +++ b/src/apps/PswGen/Generator/version.h @@ -0,0 +1,60 @@ +/** + * @file PswGen/Generator/version.h + * @brief Version information for eVaf modules + * @author Enar Vaikene + * + * Copyright (c) 2011 Enar Vaikene + * + * This file is part of the eVaf C++ cross-platform application development framework. + * + * This file can be used under the terms of the GNU General Public License + * version 3.0 as published by the Free Software Foundation and appearing in + * the file LICENSE included in the packaging of this file. Please review the + * the following information to ensure the GNU General Public License version + * 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html. + * + * Alternatively, this file may be used in accordance with the Commercial License + * Agreement provided with the Software. + */ + +#ifndef __PSWGEN_GENERATOR_VERSION_H +#define __PSWGEN_GENERATOR_VERSION_H + +#include + +/** + * Module/library version number in the form major,minor,release,build + */ +#define VER_FILE_VERSION 0,1,1,1 + +/** + * Module/library version number in the string format (shall end with \0) + */ +#define VER_FILE_VERSION_STR "0.1.1.1\0" + +/** + * Module/library name (shall end with \0) + */ +#define VER_MODULE_NAME_STR "PswGen\0" + +/** + * Module type (see version_rc.h for all the types) + */ +#define VER_MODULE_TYPE MT_GENERIC + +/** + * Module type in the string format (see version_rc for all the types) + */ +#define VER_MODULE_TYPE_STR MT_GENERIC + +/** + * Original file name for windows (shall end with \0) + */ +#define VER_ORIGINAL_FILE_NAME_STR "PswGen.dll\0" + +/** + * Description of the module/library (shall end with \0) + */ +#define VER_FILE_DESCRIPTION_STR "Module that generates strong passwords using MD5 hashes.\0" + +#endif // version.h diff --git a/src/apps/PswGen/Generator/version.rc b/src/apps/PswGen/Generator/version.rc new file mode 100644 index 0000000..33672fb --- /dev/null +++ b/src/apps/PswGen/Generator/version.rc @@ -0,0 +1,54 @@ +/** + * @file PswGen/Generator/version.rc + * @brief Windows resource file with module/library version information. + * @author Enar Vaikene + * + * Copyright (c) 2011 Enar Vaikene + * + * This file is part of the eVaf C++ cross-platform application development framework. + * + * This file can be used under the terms of the GNU General Public License + * version 3.0 as published by the Free Software Foundation and appearing in + * the file LICENSE included in the packaging of this file. Please review the + * the following information to ensure the GNU General Public License version + * 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html. + * + * Alternatively, this file may be used in accordance with the Commercial License + * Agreement provided with the Software. + */ + +#include "version.h" +#include +#include + + +VS_VERSION_INFO VERSIONINFO + FILEVERSION VER_FILE_VERSION + PRODUCTVERSION VER_PRODUCT_VERSION + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS VS_FF_DEBUG +#else + FILEFLAGS 0x0L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE 0x0L + BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904B0" + BEGIN + VALUE "CompanyName", VER_COMPANY_NAME_STR + VALUE "FileDescription", VER_FILE_DESCRIPTION_STR + VALUE "FileVersion", VER_FILE_VERSION_STR + VALUE "LegalCopyright", VER_LEGAL_COPYRIGHT_STR + VALUE "OriginalFilename", VER_ORIGINAL_FILE_NAME_STR + VALUE "ProductName", VER_PRODUCT_NAME_STR + VALUE "ProductVersion", VER_PRODUCT_VERSION_STR + VALUE "Build Date", VER_PRODUCT_DATE_STR + VALUE "Module Name", VER_MODULE_NAME_STR + VALUE "Module Type", VER_MODULE_TYPE_STR + END + END + END diff --git a/src/apps/PswGen/README b/src/apps/PswGen/README new file mode 100644 index 0000000..c01de99 --- /dev/null +++ b/src/apps/PswGen/README @@ -0,0 +1,12 @@ +A sample eVaf application that generates strong passwords. +Copyright © 2011 Enar Väikene + +This application generates and optionally stores passwords. The application consists +of 3 modules: +1) The GUI module - allows the user to generate and store passwords. +2) The GENERATOR module - generates strong passwords in such a way that given the same input, + the generated password is always the same. +3) The STORAGE module - stores generated passwords in a secure way. + +The application is split into modules to make it easier to replace them with ones having stronger security. +