4
0
mirror of https://github.com/QuasarApp/qca.git synced 2025-05-14 19:39:33 +00:00
Brad Hards 791977a0b6 The first V2 plugin!
This has OpenSSL support, and implements hashes (SHA1, SHA0, MD2, MD4,
MD5, RIPEMD160) and HMAC (with SHA1, MD5 and RIPEMD160).

CCMAIL: delta-affinix.com@lists.affinix.com

svn path=/trunk/kdesupport/qca/; revision=361137
2004-11-07 10:08:07 +00:00

81 lines
1.7 KiB
Plaintext

/*
-----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;
}
};