Initial import
commit
dbc765a8f2
@ -0,0 +1,16 @@
|
|||||||
|
TQCA TLS Plugin v1.0
|
||||||
|
-------------------
|
||||||
|
Author: Justin Karneges <justin@affinix.com>
|
||||||
|
Date: September 15th, 2003
|
||||||
|
|
||||||
|
This is a plugin to provide SSL/TLS capability to programs that
|
||||||
|
utilize the TQt Cryptographic Architecture (TQCA).
|
||||||
|
|
||||||
|
Requirements:
|
||||||
|
OpenSSL Library (http://www.openssl.org/)
|
||||||
|
|
||||||
|
Installation procedure:
|
||||||
|
./configure
|
||||||
|
make
|
||||||
|
su -c "make install"
|
||||||
|
|
@ -0,0 +1,590 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
show_usage() {
|
||||||
|
cat <<EOT
|
||||||
|
Usage: ./configure [OPTION]...
|
||||||
|
|
||||||
|
This script creates necessary configuration files to build/install.
|
||||||
|
|
||||||
|
Main options:
|
||||||
|
--qtdir=[path] Directory where Qt is installed.
|
||||||
|
--help This help text.
|
||||||
|
|
||||||
|
Dependency options:
|
||||||
|
--with-openssl-inc=[path] Path to OpenSSL include files
|
||||||
|
--with-openssl-lib=[path] Path to OpenSSL library files
|
||||||
|
|
||||||
|
EOT
|
||||||
|
}
|
||||||
|
|
||||||
|
while [ $# -gt 0 ]; do
|
||||||
|
case "$1" in
|
||||||
|
--qtdir=*)
|
||||||
|
QTDIR=`expr "${1}" : "--qtdir=\(.*\)"`
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
|
||||||
|
--with-openssl-inc=*)
|
||||||
|
QC_WITH_OPENSSL_INC=`expr "${1}" : "--with-openssl-inc=\(.*\)"`
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
|
||||||
|
--with-openssl-lib=*)
|
||||||
|
QC_WITH_OPENSSL_LIB=`expr "${1}" : "--with-openssl-lib=\(.*\)"`
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
|
||||||
|
--debug)
|
||||||
|
QC_DEBUG="Y"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
--help) show_usage; exit ;;
|
||||||
|
*) show_usage; exit ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
echo "Configuring qca-tls ..."
|
||||||
|
|
||||||
|
if [ "$QC_DEBUG" = "Y" ]; then
|
||||||
|
echo
|
||||||
|
echo QTDIR=$QTDIR
|
||||||
|
echo QC_WITH_OPENSSL_INC=$QC_WITH_OPENSSL_INC
|
||||||
|
echo QC_WITH_OPENSSL_LIB=$QC_WITH_OPENSSL_LIB
|
||||||
|
echo
|
||||||
|
fi
|
||||||
|
|
||||||
|
printf "Verifying TQt 3.x Multithreaded (MT) build environment ... "
|
||||||
|
|
||||||
|
if [ -z "$QTDIR" ]; then
|
||||||
|
if [ "$QC_DEBUG" = "Y" ]; then
|
||||||
|
echo \$QTDIR not set... trying to find Qt manually
|
||||||
|
fi
|
||||||
|
for p in /usr/lib/tqt /usr/share/tqt /usr/share/tqt3 /usr/local/lib/tqt /usr/local/share/tqt /usr/lib/tqt3 /usr/local/lib/tqt3 /usr/lib/qt /usr/share/qt /usr/share/qt3 /usr/local/lib/qt /usr/local/share/qt /usr/lib/qt3 /usr/local/lib/qt3 /usr/X11R6/share/qt /usr/qt/3 ; do
|
||||||
|
if [ -d "$p/mkspecs" ]; then
|
||||||
|
QTDIR=$p
|
||||||
|
break;
|
||||||
|
fi;
|
||||||
|
done
|
||||||
|
if [ -z "$QTDIR" ]; then
|
||||||
|
echo fail
|
||||||
|
echo
|
||||||
|
echo Unable to find Qt 'mkspecs'. Please set QTDIR
|
||||||
|
echo manually. Perhaps you need to install Qt 3
|
||||||
|
echo development utilities. You may download them either
|
||||||
|
echo from the vendor of your operating system or from
|
||||||
|
echo www.trolltech.com
|
||||||
|
echo
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -x "$QTDIR/bin/qmake" ]; then
|
||||||
|
if [ "$QC_DEBUG" = "Y" ]; then
|
||||||
|
echo Warning: qmake not in \$QTDIR/bin/qmake
|
||||||
|
echo trying to find it in \$PATH
|
||||||
|
fi
|
||||||
|
qm=`type -p qmake`
|
||||||
|
if [ -x "$qm" ]; then
|
||||||
|
if [ "$QC_DEBUG" = "Y" ]; then
|
||||||
|
echo qmake found in $qm
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo fail
|
||||||
|
echo
|
||||||
|
echo Sorry, you seem to have a very unusual setup,
|
||||||
|
echo or I missdetected \$QTDIR=$QTDIR
|
||||||
|
echo
|
||||||
|
echo Please set \$QTDIR manually and make sure that
|
||||||
|
echo \$QTDIR/bin/qmake exists.
|
||||||
|
echo
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
qm=$QTDIR/bin/qmake
|
||||||
|
fi
|
||||||
|
|
||||||
|
gen_files() {
|
||||||
|
cat >$1/modules.cpp <<EOT
|
||||||
|
/*
|
||||||
|
-----BEGIN QCMOD-----
|
||||||
|
name: OpenSSL
|
||||||
|
arg: with-openssl-inc=[path],Path to OpenSSL include files
|
||||||
|
arg: with-openssl-lib=[path],Path to OpenSSL library files
|
||||||
|
-----END QCMOD-----
|
||||||
|
*/
|
||||||
|
class qc_openssl : public ConfObj
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
qc_openssl(Conf *c) : ConfObj(c) {}
|
||||||
|
TQString name() const { return "OpenSSL"; }
|
||||||
|
TQString shortname() const { return "openssl"; }
|
||||||
|
bool exec()
|
||||||
|
{
|
||||||
|
TQString inc, lib;
|
||||||
|
TQString s;
|
||||||
|
bool kb = false;
|
||||||
|
TQString kbdir = "/usr/kerberos/include";
|
||||||
|
|
||||||
|
// Redhat 9?
|
||||||
|
if(TQFileInfo(kbdir).exists())
|
||||||
|
kb = true;
|
||||||
|
|
||||||
|
s = conf->getenv("QC_WITH_OPENSSL_INC");
|
||||||
|
if(!s.isEmpty()) {
|
||||||
|
if(!conf->checkHeader(s, "openssl/ssl.h"))
|
||||||
|
return false;
|
||||||
|
inc = s;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(!conf->findHeader("openssl/ssl.h", TQStringList(), &s))
|
||||||
|
return false;
|
||||||
|
inc = s;
|
||||||
|
}
|
||||||
|
|
||||||
|
s = conf->getenv("QC_WITH_OPENSSL_LIB");
|
||||||
|
if(!s.isEmpty()) {
|
||||||
|
if(!conf->checkLibrary(s, "ssl"))
|
||||||
|
return false;
|
||||||
|
lib = s;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(!conf->findLibrary("ssl", &s))
|
||||||
|
return false;
|
||||||
|
lib = s;
|
||||||
|
}
|
||||||
|
|
||||||
|
// is it at least openssl 0.9.7?
|
||||||
|
TQString str =
|
||||||
|
"#include<openssl/opensslv.h>\n"
|
||||||
|
"int main()\n"
|
||||||
|
"{\n"
|
||||||
|
" unsigned long x = OPENSSL_VERSION_NUMBER;\n"
|
||||||
|
" if(x >= 0x00907000) return 0; else return 1;\n"
|
||||||
|
"}\n";
|
||||||
|
TQString ext;
|
||||||
|
if(!inc.isEmpty())
|
||||||
|
ext += TQString("-I") + inc + ' ';
|
||||||
|
if(kb)
|
||||||
|
ext += TQString("-I") + kbdir + ' ';
|
||||||
|
if(!lib.isEmpty())
|
||||||
|
ext += TQString("-L") + lib + " -lssl -lcrypto ";
|
||||||
|
int ret;
|
||||||
|
if(!conf->doCompileAndLink(str, ext, &ret))
|
||||||
|
return false;
|
||||||
|
if(ret == 0)
|
||||||
|
conf->addDefine("OSSL_097");
|
||||||
|
|
||||||
|
if(!inc.isEmpty())
|
||||||
|
conf->addIncludePath(inc);
|
||||||
|
if(kb)
|
||||||
|
conf->addIncludePath(kbdir);
|
||||||
|
if(!lib.isEmpty())
|
||||||
|
conf->addLib(TQString("-L") + s);
|
||||||
|
conf->addLib("-lssl -lcrypto");
|
||||||
|
|
||||||
|
// Make sure tqtinterface can be found
|
||||||
|
conf->addIncludePath("/usr/include/tqt");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
EOT
|
||||||
|
cat >$1/modules_new.cpp <<EOT
|
||||||
|
o = new qc_openssl(conf);
|
||||||
|
o->required = true;
|
||||||
|
o->disabled = false;
|
||||||
|
|
||||||
|
EOT
|
||||||
|
cat >$1/conf.cpp <<EOT
|
||||||
|
#include<stdio.h>
|
||||||
|
#include<stdlib.h>
|
||||||
|
#include<qstring.h>
|
||||||
|
#include<qdict.h>
|
||||||
|
#include<qptrlist.h>
|
||||||
|
#include<qfileinfo.h>
|
||||||
|
#include<qfile.h>
|
||||||
|
#include<qdir.h>
|
||||||
|
#include<qstringlist.h>
|
||||||
|
|
||||||
|
class Conf;
|
||||||
|
|
||||||
|
class ConfObj
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ConfObj(Conf *c);
|
||||||
|
virtual ~ConfObj();
|
||||||
|
|
||||||
|
virtual TQString name() const=0;
|
||||||
|
virtual TQString shortname() const=0;
|
||||||
|
virtual bool exec()=0;
|
||||||
|
|
||||||
|
Conf *conf;
|
||||||
|
bool required;
|
||||||
|
bool disabled;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef TQPtrList<ConfObj> ConfObjList;
|
||||||
|
typedef TQPtrListIterator<ConfObj> ConfObjListIt;
|
||||||
|
|
||||||
|
class Conf
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Conf() : vars(17)
|
||||||
|
{
|
||||||
|
list.setAutoDelete(true);
|
||||||
|
vars.setAutoDelete(true);
|
||||||
|
|
||||||
|
vars.insert("QMAKE_INCDIR_X11", new TQString(X11_INC));
|
||||||
|
vars.insert("QMAKE_LIBDIR_X11", new TQString(X11_LIBDIR));
|
||||||
|
vars.insert("QMAKE_LIBS_X11", new TQString(X11_LIB));
|
||||||
|
vars.insert("QMAKE_CC", new TQString(CC));
|
||||||
|
}
|
||||||
|
|
||||||
|
~Conf()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void added(ConfObj *o)
|
||||||
|
{
|
||||||
|
list.append(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
TQString getenv(const TQString &var)
|
||||||
|
{
|
||||||
|
char *p = ::getenv(var.latin1());
|
||||||
|
if(!p)
|
||||||
|
return TQString::null;
|
||||||
|
return TQString(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool exec()
|
||||||
|
{
|
||||||
|
ConfObjListIt it(list);
|
||||||
|
for(ConfObj *o; (o = it.current()); ++it) {
|
||||||
|
// if this was a disabled-by-default option, check if it was enabled
|
||||||
|
if(o->disabled) {
|
||||||
|
TQString v = TQString("QC_ENABLE_") + o->shortname();
|
||||||
|
if(getenv(v) != "Y")
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// and the opposite?
|
||||||
|
else {
|
||||||
|
TQString v = TQString("QC_DISABLE_") + o->shortname();
|
||||||
|
if(getenv(v) == "Y")
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("Checking for %s ...", o->name().latin1());
|
||||||
|
fflush(stdout);
|
||||||
|
bool ok = o->exec();
|
||||||
|
if(ok)
|
||||||
|
printf(" yes\n");
|
||||||
|
else
|
||||||
|
printf(" no\n");
|
||||||
|
if(!ok && o->required) {
|
||||||
|
printf("\nError: need %s!\n", o->name().latin1());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const TQString & qvar(const TQString &s)
|
||||||
|
{
|
||||||
|
TQString *p = vars.find(s);
|
||||||
|
if(p)
|
||||||
|
return *p;
|
||||||
|
else
|
||||||
|
return blank;
|
||||||
|
}
|
||||||
|
|
||||||
|
TQString expandIncludes(const TQString &inc)
|
||||||
|
{
|
||||||
|
return TQString("-I") + inc;
|
||||||
|
}
|
||||||
|
|
||||||
|
TQString expandLibs(const TQString &lib)
|
||||||
|
{
|
||||||
|
return TQString("-L") + lib;
|
||||||
|
}
|
||||||
|
|
||||||
|
int doCommand(const TQString &s)
|
||||||
|
{
|
||||||
|
//printf("[%s]\n", s.latin1());
|
||||||
|
int r = system((s + " 1>/dev/null 2>/dev/null").latin1());
|
||||||
|
//printf("returned: %d\n", r);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool doCompileAndLink(const TQString &filedata, const TQString &flags, int *retcode=0)
|
||||||
|
{
|
||||||
|
TQDir dir(".");
|
||||||
|
TQString fname = "atest.c";
|
||||||
|
TQString out = "atest";
|
||||||
|
TQFile f(fname);
|
||||||
|
TQCString cs = filedata.latin1();
|
||||||
|
if(!f.open(IO_WriteOnly | IO_Truncate))
|
||||||
|
return false;
|
||||||
|
f.writeBlock(cs.data(), cs.length());
|
||||||
|
f.close();
|
||||||
|
|
||||||
|
TQString str = qvar("QMAKE_CC") + ' ' + fname + " -o " + out + ' ' + flags;
|
||||||
|
int r = doCommand(str);
|
||||||
|
if(r == 0 && retcode)
|
||||||
|
*retcode = doCommand(TQString("./") + out);
|
||||||
|
dir.remove(fname);
|
||||||
|
dir.remove(out);
|
||||||
|
if(r != 0)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool checkHeader(const TQString &path, const TQString &h)
|
||||||
|
{
|
||||||
|
TQFileInfo fi(path + '/' + h);
|
||||||
|
if(fi.exists())
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool findHeader(const TQString &h, const TQStringList &ext, TQString *inc)
|
||||||
|
{
|
||||||
|
if(checkHeader("/usr/include", h)) {
|
||||||
|
*inc = "";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
TQStringList dirs;
|
||||||
|
dirs += "/usr/local/include";
|
||||||
|
dirs += ext;
|
||||||
|
for(TQStringList::ConstIterator it = dirs.begin(); it != dirs.end(); ++it) {
|
||||||
|
if(checkHeader(*it, h)) {
|
||||||
|
*inc = *it;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool checkLibrary(const TQString &path, const TQString &name)
|
||||||
|
{
|
||||||
|
TQString str =
|
||||||
|
"int main()\n"
|
||||||
|
"{\n"
|
||||||
|
" return 0;\n"
|
||||||
|
"}\n";
|
||||||
|
|
||||||
|
TQString extra;
|
||||||
|
if(!path.isEmpty())
|
||||||
|
extra += TQString("-L") + path + ' ';
|
||||||
|
extra += TQString("-l") + name;
|
||||||
|
if(!doCompileAndLink(str, extra))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool findLibrary(const TQString &name, TQString *lib)
|
||||||
|
{
|
||||||
|
if(checkLibrary("", name)) {
|
||||||
|
*lib = "";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if(checkLibrary("/usr/local/lib", name)) {
|
||||||
|
*lib = "/usr/local/lib";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void addDefine(const TQString &str)
|
||||||
|
{
|
||||||
|
if(DEFINES.isEmpty())
|
||||||
|
DEFINES = str;
|
||||||
|
else
|
||||||
|
DEFINES += TQString(" ") + str;
|
||||||
|
}
|
||||||
|
|
||||||
|
void addLib(const TQString &str)
|
||||||
|
{
|
||||||
|
if(LIBS.isEmpty())
|
||||||
|
LIBS = str;
|
||||||
|
else
|
||||||
|
LIBS += TQString(" ") + str;
|
||||||
|
}
|
||||||
|
|
||||||
|
void addIncludePath(const TQString &str)
|
||||||
|
{
|
||||||
|
if(INCLUDEPATH.isEmpty())
|
||||||
|
INCLUDEPATH = str;
|
||||||
|
else
|
||||||
|
INCLUDEPATH += TQString(" ") + str;
|
||||||
|
}
|
||||||
|
|
||||||
|
void addExtra(const TQString &str)
|
||||||
|
{
|
||||||
|
extra += str + '\n';
|
||||||
|
}
|
||||||
|
|
||||||
|
TQString DEFINES;
|
||||||
|
TQString INCLUDEPATH;
|
||||||
|
TQString LIBS;
|
||||||
|
TQString extra;
|
||||||
|
|
||||||
|
private:
|
||||||
|
ConfObjList list;
|
||||||
|
TQDict<TQString> vars;
|
||||||
|
TQString blank;
|
||||||
|
};
|
||||||
|
|
||||||
|
ConfObj::ConfObj(Conf *c)
|
||||||
|
{
|
||||||
|
conf = c;
|
||||||
|
conf->added(this);
|
||||||
|
required = false;
|
||||||
|
disabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ConfObj::~ConfObj()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
#include"modules.cpp"
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
// main
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
Conf *conf = new Conf;
|
||||||
|
ConfObj *o;
|
||||||
|
o = 0;
|
||||||
|
#include"modules_new.cpp"
|
||||||
|
|
||||||
|
printf("ok\n");
|
||||||
|
bool success = false;
|
||||||
|
if(conf->exec()) {
|
||||||
|
TQFile f("conf.pri");
|
||||||
|
if(!f.open(IO_WriteOnly | IO_Truncate)) {
|
||||||
|
printf("Error writing %s\n", f.name().latin1());
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
TQString str;
|
||||||
|
str += "# qconf\n";
|
||||||
|
str += "QT_PATH_PLUGINS = " + TQString(qInstallPathPlugins()) + '\n';
|
||||||
|
if(!conf->DEFINES.isEmpty())
|
||||||
|
str += "DEFINES += " + conf->DEFINES + '\n';
|
||||||
|
if(!conf->INCLUDEPATH.isEmpty())
|
||||||
|
str += "INCLUDEPATH += " + conf->INCLUDEPATH + '\n';
|
||||||
|
if(!conf->LIBS.isEmpty())
|
||||||
|
str += "LIBS += " + conf->LIBS + '\n';
|
||||||
|
if(!conf->extra.isEmpty())
|
||||||
|
str += conf->extra;
|
||||||
|
str += '\n';
|
||||||
|
|
||||||
|
char *p = getenv("BINDIR");
|
||||||
|
if(p) {
|
||||||
|
str += TQString("target.path = ") + p + '\n';
|
||||||
|
str += "INSTALLS += target\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
TQCString cs = str.latin1();
|
||||||
|
f.writeBlock(cs.data(), cs.length());
|
||||||
|
f.close();
|
||||||
|
success = true;
|
||||||
|
}
|
||||||
|
delete conf;
|
||||||
|
|
||||||
|
if(success)
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
EOT
|
||||||
|
cat >$1/conf.pro <<EOT
|
||||||
|
TEMPLATE = app
|
||||||
|
CONFIG += qt x11 thread console
|
||||||
|
TARGET = conf
|
||||||
|
|
||||||
|
DEFINES += X11_INC='"\$\$QMAKE_INCDIR_X11"'
|
||||||
|
DEFINES += X11_LIBDIR='"\$\$QMAKE_LIBDIR_X11"'
|
||||||
|
DEFINES += X11_LIB='"\$\$QMAKE_LIBS_X11"'
|
||||||
|
DEFINES += CC='"\$\$QMAKE_CC"'
|
||||||
|
|
||||||
|
SOURCES += conf.cpp
|
||||||
|
|
||||||
|
EOT
|
||||||
|
}
|
||||||
|
|
||||||
|
export QTDIR
|
||||||
|
export QC_WITH_OPENSSL_INC
|
||||||
|
export QC_WITH_OPENSSL_LIB
|
||||||
|
rm -rf .qconftemp
|
||||||
|
(
|
||||||
|
mkdir .qconftemp
|
||||||
|
gen_files .qconftemp
|
||||||
|
cd .qconftemp
|
||||||
|
$qm conf.pro >/dev/null
|
||||||
|
QTDIR=$QTDIR make clean >/dev/null 2>&1
|
||||||
|
QTDIR=$QTDIR make >../conf.log 2>&1
|
||||||
|
)
|
||||||
|
|
||||||
|
if [ "$?" != "0" ]; then
|
||||||
|
rm -rf .qconftemp
|
||||||
|
echo fail
|
||||||
|
echo
|
||||||
|
echo "There was an error compiling 'conf'. Be sure you have a proper"
|
||||||
|
echo "TQt 3.x Multithreaded (MT) build environment set up."
|
||||||
|
if [ ! -f "$QTDIR/lib/libtqt-mt.so.3" ]; then
|
||||||
|
echo
|
||||||
|
echo "One possible reason is that you don't have"
|
||||||
|
echo "libtqt-mt.so.3 installed in $QTDIR/lib/."
|
||||||
|
fi
|
||||||
|
echo
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
.qconftemp/conf
|
||||||
|
ret="$?"
|
||||||
|
if [ "$ret" = "1" ]; then
|
||||||
|
rm -rf .qconftemp
|
||||||
|
echo
|
||||||
|
exit 1;
|
||||||
|
else
|
||||||
|
if [ "$ret" != "0" ]; then
|
||||||
|
rm -rf .qconftemp
|
||||||
|
echo fail
|
||||||
|
echo
|
||||||
|
echo Unexpected error launching 'conf'
|
||||||
|
echo
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
rm -rf .qconftemp
|
||||||
|
|
||||||
|
if [ -x "./qcextra" ]; then
|
||||||
|
./qcextra
|
||||||
|
fi
|
||||||
|
# run qmake
|
||||||
|
if expr match "$DEB_BUILD_OPTIONS" ".*nostrip"; then
|
||||||
|
$qm QMAKE_STRIP=true qca-tls.pro
|
||||||
|
else
|
||||||
|
$qm qca-tls.pro
|
||||||
|
fi
|
||||||
|
if [ "$?" != "0" ]; then
|
||||||
|
echo
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
cat >Makefile.tmp <<EOT
|
||||||
|
export QTDIR = $QTDIR
|
||||||
|
EOT
|
||||||
|
cat Makefile >> Makefile.tmp
|
||||||
|
rm -f Makefile
|
||||||
|
cp -f Makefile.tmp Makefile
|
||||||
|
rm -f Makefile.tmp
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo Good, your configure finished. Now run \'make\'.
|
||||||
|
echo
|
@ -0,0 +1,80 @@
|
|||||||
|
/*
|
||||||
|
-----BEGIN QCMOD-----
|
||||||
|
name: OpenSSL
|
||||||
|
arg: with-openssl-inc=[path],Path to OpenSSL include files
|
||||||
|
arg: with-openssl-lib=[path],Path to OpenSSL library files
|
||||||
|
-----END QCMOD-----
|
||||||
|
*/
|
||||||
|
class qc_openssl : public ConfObj
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
qc_openssl(Conf *c) : ConfObj(c) {}
|
||||||
|
QString name() const { return "OpenSSL"; }
|
||||||
|
QString shortname() const { return "openssl"; }
|
||||||
|
bool exec()
|
||||||
|
{
|
||||||
|
QString inc, lib;
|
||||||
|
QString s;
|
||||||
|
bool kb = false;
|
||||||
|
QString kbdir = "/usr/kerberos/include";
|
||||||
|
|
||||||
|
// Redhat 9?
|
||||||
|
if(QFileInfo(kbdir).exists())
|
||||||
|
kb = true;
|
||||||
|
|
||||||
|
s = conf->getenv("QC_WITH_OPENSSL_INC");
|
||||||
|
if(!s.isEmpty()) {
|
||||||
|
if(!conf->checkHeader(s, "openssl/ssl.h"))
|
||||||
|
return false;
|
||||||
|
inc = s;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(!conf->findHeader("openssl/ssl.h", QStringList(), &s))
|
||||||
|
return false;
|
||||||
|
inc = s;
|
||||||
|
}
|
||||||
|
|
||||||
|
s = conf->getenv("QC_WITH_OPENSSL_LIB");
|
||||||
|
if(!s.isEmpty()) {
|
||||||
|
if(!conf->checkLibrary(s, "ssl"))
|
||||||
|
return false;
|
||||||
|
lib = s;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(!conf->findLibrary("ssl", &s))
|
||||||
|
return false;
|
||||||
|
lib = s;
|
||||||
|
}
|
||||||
|
|
||||||
|
// is it at least openssl 0.9.7?
|
||||||
|
QString str =
|
||||||
|
"#include<openssl/opensslv.h>\n"
|
||||||
|
"int main()\n"
|
||||||
|
"{\n"
|
||||||
|
" unsigned long x = OPENSSL_VERSION_NUMBER;\n"
|
||||||
|
" if(x >= 0x00907000) return 0; else return 1;\n"
|
||||||
|
"}\n";
|
||||||
|
QString ext;
|
||||||
|
if(!inc.isEmpty())
|
||||||
|
ext += QString("-I") + inc + ' ';
|
||||||
|
if(kb)
|
||||||
|
ext += QString("-I") + kbdir + ' ';
|
||||||
|
if(!lib.isEmpty())
|
||||||
|
ext += QString("-L") + lib + " -lssl -lcrypto ";
|
||||||
|
int ret;
|
||||||
|
if(!conf->doCompileAndLink(str, ext, &ret))
|
||||||
|
return false;
|
||||||
|
if(ret == 0)
|
||||||
|
conf->addDefine("OSSL_097");
|
||||||
|
|
||||||
|
if(!inc.isEmpty())
|
||||||
|
conf->addIncludePath(inc);
|
||||||
|
if(kb)
|
||||||
|
conf->addIncludePath(kbdir);
|
||||||
|
if(!lib.isEmpty())
|
||||||
|
conf->addLib(QString("-L") + s);
|
||||||
|
conf->addLib("-lssl -lcrypto");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
cp ../../src/qca.h .
|
||||||
|
cp ../../src/qcaprovider.h .
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* qca-tls.h - TLS plugin for TQCA
|
||||||
|
* Copyright (C) 2003 Justin Karneges
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef TQCA_TLS_H
|
||||||
|
#define TQCA_TLS_H
|
||||||
|
|
||||||
|
#include"qcaprovider.h"
|
||||||
|
|
||||||
|
#ifdef TQCA_PLUGIN
|
||||||
|
TQCA_PLUGIN_EXPORT TQCAProvider *createProvider();
|
||||||
|
#else
|
||||||
|
TQCAProvider *createProviderTLS();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,26 @@
|
|||||||
|
# qca-tls qmake profile
|
||||||
|
|
||||||
|
TEMPLATE = lib
|
||||||
|
CONFIG += qt thread release plugin
|
||||||
|
TARGET = qca-tls
|
||||||
|
|
||||||
|
!exists(qcaprovider.h) {
|
||||||
|
Q_PREFIX = ../../src
|
||||||
|
INCLUDEPATH += $$Q_PREFIX
|
||||||
|
}
|
||||||
|
HEADERS += ($$Q_PREFIX)qcaprovider.h
|
||||||
|
|
||||||
|
HEADERS = qca-tls.h
|
||||||
|
SOURCES = qca-tls.cpp
|
||||||
|
|
||||||
|
DEFINES += QCA_PLUGIN
|
||||||
|
win32:{
|
||||||
|
DEFINES += QCA_PLUGIN_DLL OSSL_097
|
||||||
|
INCLUDEPATH += c:\local\include
|
||||||
|
LIBS += c:\local\lib\libeay32.lib c:\local\lib\ssleay32.lib
|
||||||
|
}
|
||||||
|
|
||||||
|
include(conf.pri)
|
||||||
|
include(extra.pri)
|
||||||
|
|
||||||
|
QMAKE_PROJECT_DEPTH=0
|
@ -0,0 +1,9 @@
|
|||||||
|
<qconf>
|
||||||
|
<name>qca-tls</name>
|
||||||
|
<profile>qca-tls.pro</profile>
|
||||||
|
<noprefix/>
|
||||||
|
<dep type='openssl'>
|
||||||
|
<required/>
|
||||||
|
</dep>
|
||||||
|
<moddir>.</moddir>
|
||||||
|
</qconf>
|
@ -0,0 +1,468 @@
|
|||||||
|
/*
|
||||||
|
* qca.h - TQt Cryptographic Architecture
|
||||||
|
* Copyright (C) 2003 Justin Karneges
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef TQCA_H
|
||||||
|
#define TQCA_H
|
||||||
|
|
||||||
|
#include<tqstring.h>
|
||||||
|
#include<tqcstring.h>
|
||||||
|
#include<tqdatetime.h>
|
||||||
|
#include<tqmap.h>
|
||||||
|
#include<tqptrlist.h>
|
||||||
|
#include<tqobject.h>
|
||||||
|
|
||||||
|
#ifdef Q_OS_WIN32
|
||||||
|
# ifndef TQCA_STATIC
|
||||||
|
# ifdef TQCA_MAKEDLL
|
||||||
|
# define TQCA_EXPORT __declspec(dllexport)
|
||||||
|
# else
|
||||||
|
# define TQCA_EXPORT __declspec(dllimport)
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#ifndef TQCA_EXPORT
|
||||||
|
#define TQCA_EXPORT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef Q_OS_WIN32
|
||||||
|
# ifdef TQCA_PLUGIN_DLL
|
||||||
|
# define TQCA_PLUGIN_EXPORT extern "C" __declspec(dllexport)
|
||||||
|
# else
|
||||||
|
# define TQCA_PLUGIN_EXPORT extern "C" __declspec(dllimport)
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#ifndef TQCA_PLUGIN_EXPORT
|
||||||
|
#define TQCA_PLUGIN_EXPORT extern "C"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class TQHostAddress;
|
||||||
|
class TQStringList;
|
||||||
|
|
||||||
|
class TQCAProvider;
|
||||||
|
class TQCA_HashContext;
|
||||||
|
class TQCA_CipherContext;
|
||||||
|
class TQCA_CertContext;
|
||||||
|
|
||||||
|
namespace TQCA
|
||||||
|
{
|
||||||
|
enum {
|
||||||
|
CAP_SHA1 = 0x0001,
|
||||||
|
CAP_SHA256 = 0x0002,
|
||||||
|
CAP_MD5 = 0x0004,
|
||||||
|
CAP_BlowFish = 0x0008,
|
||||||
|
CAP_TripleDES = 0x0010,
|
||||||
|
CAP_AES128 = 0x0020,
|
||||||
|
CAP_AES256 = 0x0040,
|
||||||
|
CAP_RSA = 0x0080,
|
||||||
|
CAP_X509 = 0x0100,
|
||||||
|
CAP_TLS = 0x0200,
|
||||||
|
CAP_SASL = 0x0400
|
||||||
|
};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
CBC = 0x0001,
|
||||||
|
CFB = 0x0002
|
||||||
|
};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
Encrypt = 0x0001,
|
||||||
|
Decrypt = 0x0002
|
||||||
|
};
|
||||||
|
|
||||||
|
TQCA_EXPORT void init();
|
||||||
|
TQCA_EXPORT bool isSupported(int capabilities);
|
||||||
|
TQCA_EXPORT void insertProvider(TQCAProvider *);
|
||||||
|
TQCA_EXPORT void unloadAllPlugins();
|
||||||
|
|
||||||
|
TQCA_EXPORT TQString arrayToHex(const TQByteArray &);
|
||||||
|
TQCA_EXPORT TQByteArray hexToArray(const TQString &);
|
||||||
|
|
||||||
|
class TQCA_EXPORT Hash
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Hash(const Hash &);
|
||||||
|
Hash & operator=(const Hash &);
|
||||||
|
~Hash();
|
||||||
|
|
||||||
|
void clear();
|
||||||
|
void update(const TQByteArray &a);
|
||||||
|
TQByteArray final();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
Hash(TQCA_HashContext *);
|
||||||
|
|
||||||
|
private:
|
||||||
|
class Private;
|
||||||
|
Private *d;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
class TQCA_EXPORT HashStatic
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
HashStatic<T>() {}
|
||||||
|
|
||||||
|
static TQByteArray hash(const TQByteArray &a)
|
||||||
|
{
|
||||||
|
T obj;
|
||||||
|
obj.update(a);
|
||||||
|
return obj.final();
|
||||||
|
}
|
||||||
|
|
||||||
|
static TQByteArray hash(const TQCString &cs)
|
||||||
|
{
|
||||||
|
TQByteArray a(cs.length());
|
||||||
|
memcpy(a.data(), cs.data(), a.size());
|
||||||
|
return hash(a);
|
||||||
|
}
|
||||||
|
|
||||||
|
static TQString hashToString(const TQByteArray &a)
|
||||||
|
{
|
||||||
|
return arrayToHex(hash(a));
|
||||||
|
}
|
||||||
|
|
||||||
|
static TQString hashToString(const TQCString &cs)
|
||||||
|
{
|
||||||
|
return arrayToHex(hash(cs));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class TQCA_EXPORT Cipher
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Cipher(const Cipher &);
|
||||||
|
Cipher & operator=(const Cipher &);
|
||||||
|
~Cipher();
|
||||||
|
|
||||||
|
TQByteArray dyn_generateKey(int size=-1) const;
|
||||||
|
TQByteArray dyn_generateIV() const;
|
||||||
|
void reset(int dir, int mode, const TQByteArray &key, const TQByteArray &iv, bool pad=true);
|
||||||
|
bool update(const TQByteArray &a);
|
||||||
|
TQByteArray final(bool *ok=0);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
Cipher(TQCA_CipherContext *, int dir, int mode, const TQByteArray &key, const TQByteArray &iv, bool pad);
|
||||||
|
|
||||||
|
private:
|
||||||
|
class Private;
|
||||||
|
Private *d;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
class TQCA_EXPORT CipherStatic
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CipherStatic<T>() {}
|
||||||
|
|
||||||
|
static TQByteArray generateKey(int size=-1)
|
||||||
|
{
|
||||||
|
T obj;
|
||||||
|
return obj.dyn_generateKey(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
static TQByteArray generateIV()
|
||||||
|
{
|
||||||
|
T obj;
|
||||||
|
return obj.dyn_generateIV();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class TQCA_EXPORT SHA1 : public Hash, public HashStatic<SHA1>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SHA1();
|
||||||
|
};
|
||||||
|
|
||||||
|
class TQCA_EXPORT SHA256 : public Hash, public HashStatic<SHA256>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SHA256();
|
||||||
|
};
|
||||||
|
|
||||||
|
class TQCA_EXPORT MD5 : public Hash, public HashStatic<MD5>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MD5();
|
||||||
|
};
|
||||||
|
|
||||||
|
class TQCA_EXPORT BlowFish : public Cipher, public CipherStatic<BlowFish>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
BlowFish(int dir=Encrypt, int mode=CBC, const TQByteArray &key=TQByteArray(), const TQByteArray &iv=TQByteArray(), bool pad=true);
|
||||||
|
};
|
||||||
|
|
||||||
|
class TQCA_EXPORT TripleDES : public Cipher, public CipherStatic<TripleDES>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TripleDES(int dir=Encrypt, int mode=CBC, const TQByteArray &key=TQByteArray(), const TQByteArray &iv=TQByteArray(), bool pad=true);
|
||||||
|
};
|
||||||
|
|
||||||
|
class TQCA_EXPORT AES128 : public Cipher, public CipherStatic<AES128>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AES128(int dir=Encrypt, int mode=CBC, const TQByteArray &key=TQByteArray(), const TQByteArray &iv=TQByteArray(), bool pad=true);
|
||||||
|
};
|
||||||
|
|
||||||
|
class TQCA_EXPORT AES256 : public Cipher, public CipherStatic<AES256>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AES256(int dir=Encrypt, int mode=CBC, const TQByteArray &key=TQByteArray(), const TQByteArray &iv=TQByteArray(), bool pad=true);
|
||||||
|
};
|
||||||
|
|
||||||
|
class RSA;
|
||||||
|
class TQCA_EXPORT RSAKey
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
RSAKey();
|
||||||
|
RSAKey(const RSAKey &from);
|
||||||
|
RSAKey & operator=(const RSAKey &from);
|
||||||
|
~RSAKey();
|
||||||
|
|
||||||
|
bool isNull() const;
|
||||||
|
bool havePublic() const;
|
||||||
|
bool havePrivate() const;
|
||||||
|
|
||||||
|
TQByteArray toDER(bool publicOnly=false) const;
|
||||||
|
bool fromDER(const TQByteArray &a);
|
||||||
|
|
||||||
|
TQString toPEM(bool publicOnly=false) const;
|
||||||
|
bool fromPEM(const TQString &);
|
||||||
|
|
||||||
|
// only call if you know what you are doing
|
||||||
|
bool fromNative(void *);
|
||||||
|
|
||||||
|
private:
|
||||||
|
class Private;
|
||||||
|
Private *d;
|
||||||
|
|
||||||
|
friend class RSA;
|
||||||
|
friend class TLS;
|
||||||
|
bool encrypt(const TQByteArray &a, TQByteArray *out, bool oaep) const;
|
||||||
|
bool decrypt(const TQByteArray &a, TQByteArray *out, bool oaep) const;
|
||||||
|
bool generate(unsigned int bits);
|
||||||
|
};
|
||||||
|
|
||||||
|
class TQCA_EXPORT RSA
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
RSA();
|
||||||
|
~RSA();
|
||||||
|
|
||||||
|
RSAKey key() const;
|
||||||
|
void setKey(const RSAKey &);
|
||||||
|
|
||||||
|
bool encrypt(const TQByteArray &a, TQByteArray *out, bool oaep=false) const;
|
||||||
|
bool decrypt(const TQByteArray &a, TQByteArray *out, bool oaep=false) const;
|
||||||
|
|
||||||
|
static RSAKey generateKey(unsigned int bits);
|
||||||
|
|
||||||
|
private:
|
||||||
|
RSAKey v_key;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef TQMap<TQString, TQString> CertProperties;
|
||||||
|
class TQCA_EXPORT Cert
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Cert();
|
||||||
|
Cert(const Cert &);
|
||||||
|
Cert & operator=(const Cert &);
|
||||||
|
~Cert();
|
||||||
|
|
||||||
|
bool isNull() const;
|
||||||
|
|
||||||
|
TQString commonName() const;
|
||||||
|
TQString serialNumber() const;
|
||||||
|
TQString subjectString() const;
|
||||||
|
TQString issuerString() const;
|
||||||
|
CertProperties subject() const;
|
||||||
|
CertProperties issuer() const;
|
||||||
|
TQDateTime notBefore() const;
|
||||||
|
TQDateTime notAfter() const;
|
||||||
|
|
||||||
|
TQByteArray toDER() const;
|
||||||
|
bool fromDER(const TQByteArray &a);
|
||||||
|
|
||||||
|
TQString toPEM() const;
|
||||||
|
bool fromPEM(const TQString &);
|
||||||
|
|
||||||
|
private:
|
||||||
|
class Private;
|
||||||
|
Private *d;
|
||||||
|
|
||||||
|
friend class TLS;
|
||||||
|
void fromContext(TQCA_CertContext *);
|
||||||
|
};
|
||||||
|
|
||||||
|
class TQCA_EXPORT TLS : public TQObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
TQ_OBJECT
|
||||||
|
public:
|
||||||
|
enum Validity {
|
||||||
|
NoCert,
|
||||||
|
Valid,
|
||||||
|
HostMismatch,
|
||||||
|
Rejected,
|
||||||
|
Untrusted,
|
||||||
|
SignatureFailed,
|
||||||
|
InvalidCA,
|
||||||
|
InvalidPurpose,
|
||||||
|
SelfSigned,
|
||||||
|
Revoked,
|
||||||
|
PathLengthExceeded,
|
||||||
|
Expired,
|
||||||
|
Unknown
|
||||||
|
};
|
||||||
|
enum Error { ErrHandshake, ErrCrypt };
|
||||||
|
|
||||||
|
TLS(TQObject *parent=0);
|
||||||
|
~TLS();
|
||||||
|
|
||||||
|
void setCertificate(const Cert &cert, const RSAKey &key);
|
||||||
|
void setCertificateStore(const TQPtrList<Cert> &store); // note: store must persist
|
||||||
|
|
||||||
|
void reset();
|
||||||
|
bool startClient(const TQString &host="");
|
||||||
|
bool startServer();
|
||||||
|
void close();
|
||||||
|
bool isHandshaken() const;
|
||||||
|
|
||||||
|
// plain (application side)
|
||||||
|
void write(const TQByteArray &a);
|
||||||
|
TQByteArray read();
|
||||||
|
|
||||||
|
// encoded (socket side)
|
||||||
|
void writeIncoming(const TQByteArray &a);
|
||||||
|
TQByteArray readOutgoing();
|
||||||
|
TQByteArray readUnprocessed();
|
||||||
|
|
||||||
|
// cert related
|
||||||
|
const Cert & peerCertificate() const;
|
||||||
|
int certificateValidityResult() const;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void handshaken();
|
||||||
|
void readyRead();
|
||||||
|
void readyReadOutgoing(int plainBytes);
|
||||||
|
void closed();
|
||||||
|
void error(int);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void update();
|
||||||
|
|
||||||
|
private:
|
||||||
|
class Private;
|
||||||
|
Private *d;
|
||||||
|
};
|
||||||
|
|
||||||
|
class TQCA_EXPORT SASL : public TQObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
TQ_OBJECT
|
||||||
|
public:
|
||||||
|
enum Error { ErrAuth, ErrCrypt };
|
||||||
|
enum ErrorCond {
|
||||||
|
NoMech,
|
||||||
|
BadProto,
|
||||||
|
BadServ,
|
||||||
|
BadAuth,
|
||||||
|
NoAuthzid,
|
||||||
|
TooWeak,
|
||||||
|
NeedEncrypt,
|
||||||
|
Expired,
|
||||||
|
Disabled,
|
||||||
|
NoUser,
|
||||||
|
RemoteUnavail
|
||||||
|
};
|
||||||
|
SASL(TQObject *parent=0);
|
||||||
|
~SASL();
|
||||||
|
|
||||||
|
static void setAppName(const TQString &name);
|
||||||
|
|
||||||
|
void reset();
|
||||||
|
int errorCondition() const;
|
||||||
|
|
||||||
|
// options
|
||||||
|
void setAllowPlain(bool);
|
||||||
|
void setAllowAnonymous(bool);
|
||||||
|
void setAllowActiveVulnerable(bool);
|
||||||
|
void setAllowDictionaryVulnerable(bool);
|
||||||
|
void setRequireForwardSecrecy(bool);
|
||||||
|
void setRequirePassCredentials(bool);
|
||||||
|
void setRequireMutualAuth(bool);
|
||||||
|
|
||||||
|
void setMinimumSSF(int);
|
||||||
|
void setMaximumSSF(int);
|
||||||
|
void setExternalAuthID(const TQString &authid);
|
||||||
|
void setExternalSSF(int);
|
||||||
|
|
||||||
|
void setLocalAddr(const TQHostAddress &addr, TQ_UINT16 port);
|
||||||
|
void setRemoteAddr(const TQHostAddress &addr, TQ_UINT16 port);
|
||||||
|
|
||||||
|
// initialize
|
||||||
|
bool startClient(const TQString &service, const TQString &host, const TQStringList &mechlist, bool allowClientSendFirst=true);
|
||||||
|
bool startServer(const TQString &service, const TQString &host, const TQString &realm, TQStringList *mechlist);
|
||||||
|
|
||||||
|
// authentication
|
||||||
|
void putStep(const TQByteArray &stepData);
|
||||||
|
void putServerFirstStep(const TQString &mech);
|
||||||
|
void putServerFirstStep(const TQString &mech, const TQByteArray &clientInit);
|
||||||
|
void setUsername(const TQString &user);
|
||||||
|
void setAuthzid(const TQString &auth);
|
||||||
|
void setPassword(const TQString &pass);
|
||||||
|
void setRealm(const TQString &realm);
|
||||||
|
void continueAfterParams();
|
||||||
|
void continueAfterAuthCheck();
|
||||||
|
|
||||||
|
// security layer
|
||||||
|
int ssf() const;
|
||||||
|
void write(const TQByteArray &a);
|
||||||
|
TQByteArray read();
|
||||||
|
void writeIncoming(const TQByteArray &a);
|
||||||
|
TQByteArray readOutgoing();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
// for authentication
|
||||||
|
void clientFirstStep(const TQString &mech, const TQByteArray *clientInit);
|
||||||
|
void nextStep(const TQByteArray &stepData);
|
||||||
|
void needParams(bool user, bool authzid, bool pass, bool realm);
|
||||||
|
void authCheck(const TQString &user, const TQString &authzid);
|
||||||
|
void authenticated();
|
||||||
|
|
||||||
|
// for security layer
|
||||||
|
void readyRead();
|
||||||
|
void readyReadOutgoing(int plainBytes);
|
||||||
|
|
||||||
|
// error
|
||||||
|
void error(int);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void tryAgain();
|
||||||
|
|
||||||
|
private:
|
||||||
|
class Private;
|
||||||
|
Private *d;
|
||||||
|
|
||||||
|
void handleServerFirstStep(int r);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,191 @@
|
|||||||
|
/*
|
||||||
|
* qcaprovider.h - TQCA Plugin API
|
||||||
|
* Copyright (C) 2003 Justin Karneges
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef TQCAPROVIDER_H
|
||||||
|
#define TQCAPROVIDER_H
|
||||||
|
|
||||||
|
#include<tqglobal.h>
|
||||||
|
#include<tqstring.h>
|
||||||
|
#include<tqdatetime.h>
|
||||||
|
#include<tqobject.h>
|
||||||
|
#include<tqhostaddress.h>
|
||||||
|
#include"qca.h"
|
||||||
|
|
||||||
|
#define TQCA_PLUGIN_VERSION 1
|
||||||
|
|
||||||
|
class TQCAProvider
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TQCAProvider() {}
|
||||||
|
virtual ~TQCAProvider() {}
|
||||||
|
|
||||||
|
virtual void init()=0;
|
||||||
|
virtual int qcaVersion() const=0;
|
||||||
|
virtual int capabilities() const=0;
|
||||||
|
virtual void *context(int cap)=0;
|
||||||
|
};
|
||||||
|
|
||||||
|
class TQCA_HashContext
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~TQCA_HashContext() {}
|
||||||
|
|
||||||
|
virtual TQCA_HashContext *clone()=0;
|
||||||
|
virtual void reset()=0;
|
||||||
|
virtual void update(const char *in, unsigned int len)=0;
|
||||||
|
virtual void final(TQByteArray *out)=0;
|
||||||
|
};
|
||||||
|
|
||||||
|
class TQCA_CipherContext
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~TQCA_CipherContext() {}
|
||||||
|
|
||||||
|
virtual TQCA_CipherContext *clone()=0;
|
||||||
|
virtual int keySize()=0;
|
||||||
|
virtual int blockSize()=0;
|
||||||
|
virtual bool generateKey(char *out, int keysize=-1)=0;
|
||||||
|
virtual bool generateIV(char *out)=0;
|
||||||
|
|
||||||
|
virtual bool setup(int dir, int mode, const char *key, int keysize, const char *iv, bool pad)=0;
|
||||||
|
virtual bool update(const char *in, unsigned int len)=0;
|
||||||
|
virtual bool final(TQByteArray *out)=0;
|
||||||
|
};
|
||||||
|
|
||||||
|
class TQCA_RSAKeyContext
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~TQCA_RSAKeyContext() {}
|
||||||
|
|
||||||
|
virtual TQCA_RSAKeyContext *clone() const=0;
|
||||||
|
virtual bool isNull() const=0;
|
||||||
|
virtual bool havePublic() const=0;
|
||||||
|
virtual bool havePrivate() const=0;
|
||||||
|
virtual bool createFromDER(const char *in, unsigned int len)=0;
|
||||||
|
virtual bool createFromPEM(const char *in, unsigned int len)=0;
|
||||||
|
virtual bool createFromNative(void *in)=0;
|
||||||
|
virtual bool generate(unsigned int bits)=0;
|
||||||
|
virtual bool toDER(TQByteArray *out, bool publicOnly)=0;
|
||||||
|
virtual bool toPEM(TQByteArray *out, bool publicOnly)=0;
|
||||||
|
|
||||||
|
virtual bool encrypt(const TQByteArray &in, TQByteArray *out, bool oaep)=0;
|
||||||
|
virtual bool decrypt(const TQByteArray &in, TQByteArray *out, bool oaep)=0;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct TQCA_CertProperty
|
||||||
|
{
|
||||||
|
TQString var;
|
||||||
|
TQString val;
|
||||||
|
};
|
||||||
|
|
||||||
|
class TQCA_CertContext
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~TQCA_CertContext() {}
|
||||||
|
|
||||||
|
virtual TQCA_CertContext *clone() const=0;
|
||||||
|
virtual bool isNull() const=0;
|
||||||
|
virtual bool createFromDER(const char *in, unsigned int len)=0;
|
||||||
|
virtual bool createFromPEM(const char *in, unsigned int len)=0;
|
||||||
|
virtual bool toDER(TQByteArray *out)=0;
|
||||||
|
virtual bool toPEM(TQByteArray *out)=0;
|
||||||
|
|
||||||
|
virtual TQString serialNumber() const=0;
|
||||||
|
virtual TQString subjectString() const=0;
|
||||||
|
virtual TQString issuerString() const=0;
|
||||||
|
virtual TQValueList<TQCA_CertProperty> subject() const=0;
|
||||||
|
virtual TQValueList<TQCA_CertProperty> issuer() const=0;
|
||||||
|
virtual TQDateTime notBefore() const=0;
|
||||||
|
virtual TQDateTime notAfter() const=0;
|
||||||
|
virtual bool matchesAddress(const TQString &realHost) const=0;
|
||||||
|
};
|
||||||
|
|
||||||
|
class TQCA_TLSContext
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum Result { Success, Error, Continue };
|
||||||
|
virtual ~TQCA_TLSContext() {}
|
||||||
|
|
||||||
|
virtual void reset()=0;
|
||||||
|
virtual bool startClient(const TQPtrList<TQCA_CertContext> &store, const TQCA_CertContext &cert, const TQCA_RSAKeyContext &key)=0;
|
||||||
|
virtual bool startServer(const TQPtrList<TQCA_CertContext> &store, const TQCA_CertContext &cert, const TQCA_RSAKeyContext &key)=0;
|
||||||
|
|
||||||
|
virtual int handshake(const TQByteArray &in, TQByteArray *out)=0;
|
||||||
|
virtual int shutdown(const TQByteArray &in, TQByteArray *out)=0;
|
||||||
|
virtual bool encode(const TQByteArray &plain, TQByteArray *to_net, int *encoded)=0;
|
||||||
|
virtual bool decode(const TQByteArray &from_net, TQByteArray *plain, TQByteArray *to_net)=0;
|
||||||
|
virtual bool eof() const=0;
|
||||||
|
virtual TQByteArray unprocessed()=0;
|
||||||
|
|
||||||
|
virtual TQCA_CertContext *peerCertificate() const=0;
|
||||||
|
virtual int validityResult() const=0;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct TQCA_SASLHostPort
|
||||||
|
{
|
||||||
|
TQHostAddress addr;
|
||||||
|
TQ_UINT16 port;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct TQCA_SASLNeedParams
|
||||||
|
{
|
||||||
|
bool user, authzid, pass, realm;
|
||||||
|
};
|
||||||
|
|
||||||
|
class TQCA_SASLContext
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum Result { Success, Error, NeedParams, AuthCheck, Continue };
|
||||||
|
virtual ~TQCA_SASLContext() {}
|
||||||
|
|
||||||
|
// common
|
||||||
|
virtual void reset()=0;
|
||||||
|
virtual void setCoreProps(const TQString &service, const TQString &host, TQCA_SASLHostPort *local, TQCA_SASLHostPort *remote)=0;
|
||||||
|
virtual void setSecurityProps(bool noPlain, bool noActive, bool noDict, bool noAnon, bool reqForward, bool reqCreds, bool reqMutual, int ssfMin, int ssfMax, const TQString &_ext_authid, int _ext_ssf)=0;
|
||||||
|
virtual int security() const=0;
|
||||||
|
virtual int errorCond() const=0;
|
||||||
|
|
||||||
|
// init / first step
|
||||||
|
virtual bool clientStart(const TQStringList &mechlist)=0;
|
||||||
|
virtual int clientFirstStep(bool allowClientSendFirst)=0;
|
||||||
|
virtual bool serverStart(const TQString &realm, TQStringList *mechlist, const TQString &name)=0;
|
||||||
|
virtual int serverFirstStep(const TQString &mech, const TQByteArray *in)=0;
|
||||||
|
|
||||||
|
// get / set params
|
||||||
|
virtual TQCA_SASLNeedParams clientParamsNeeded() const=0;
|
||||||
|
virtual void setClientParams(const TQString *user, const TQString *authzid, const TQString *pass, const TQString *realm)=0;
|
||||||
|
virtual TQString username() const=0;
|
||||||
|
virtual TQString authzid() const=0;
|
||||||
|
|
||||||
|
// continue steps
|
||||||
|
virtual int nextStep(const TQByteArray &in)=0;
|
||||||
|
virtual int tryAgain()=0;
|
||||||
|
|
||||||
|
// results
|
||||||
|
virtual TQString mech() const=0;
|
||||||
|
virtual const TQByteArray *clientInit() const=0;
|
||||||
|
virtual TQByteArray result() const=0;
|
||||||
|
|
||||||
|
// security layer
|
||||||
|
virtual bool encode(const TQByteArray &in, TQByteArray *out)=0;
|
||||||
|
virtual bool decode(const TQByteArray &in, TQByteArray *out)=0;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue