Enable QT_NO_CAST_FROM_ASCII

This commit is contained in:
Albert Astals Cid 2020-02-13 00:59:09 +01:00
parent 197b49677d
commit ad1b9e1b07
38 changed files with 326 additions and 323 deletions

View File

@ -104,6 +104,7 @@ if (CMAKE_COMPILER_IS_GNUCXX)
endif (CMAKE_COMPILER_IS_GNUCXX)
add_definitions(-DQT_NO_CAST_TO_ASCII
-DQT_NO_CAST_FROM_ASCII
-DQT_NO_URL_CAST_FROM_STRING
-DQT_NO_CAST_FROM_BYTEARRAY
-DQT_NO_SIGNALS_SLOTS_KEYWORDS

View File

@ -273,10 +273,10 @@ int main(int argc, char **argv)
// set the MAC to use the key
cmacObject.setup(key);
QCA::SecureArray message = QCA::hexToArray("6bc1bee22e409f96e93d7e117393172a"
QCA::SecureArray message = QCA::hexToArray(QStringLiteral("6bc1bee22e409f96e93d7e117393172a"
"ae2d8a571e03ac9c9eb76fac45af8e51"
"30c81c46a35ce411e5fbc1191a0a52ef"
"f69f2445df4f9b17ad2b417be66c3710");
"f69f2445df4f9b17ad2b417be66c3710"));
QCA::SecureArray message1(message);
message1.resize(0);
qDebug();

View File

@ -24,6 +24,7 @@
#include <QtCrypto>
#include <QCoreApplication>
#include <QFile>
#include <iostream>
@ -108,7 +109,7 @@ int main(int argc, char** argv)
QCA::ConvertResult importResult;
// This imports all the PEM encoded certificates from the file specified as the argument
// Note that you pass in a pointer to the result argument.
filecerts = QCA::CertificateCollection::fromFlatTextFile( argv[1], &importResult );
filecerts = QCA::CertificateCollection::fromFlatTextFile( QFile::decodeName(argv[1]), &importResult );
if ( QCA::ConvertGood == importResult) {
std::cout << "Import succeeded" << std::endl;
// this turns the CertificateCollection into a QList of Certificate objects

View File

@ -23,6 +23,7 @@
#include <QtCrypto>
#include <QCoreApplication>
#include <QFile>
#include <QTimer>
#include <cstdio>
@ -109,7 +110,7 @@ int main(int argc, char **argv)
PassphraseHandler passphraseHandler;
App app;
app.str = argv[1];
app.str = QFile::decodeName(argv[1]);
QObject::connect(&app, &App::quit, &qapp, QCoreApplication::quit);
QTimer::singleShot(0, &app, &App::start);
qapp.exec();

View File

@ -146,9 +146,9 @@ QString qca_md5crypt( const QCA::SecureArray &password, const QCA::SecureArray &
// Salt is part of the encoded password ($1$<string>$)
QString encodedString;
encodedString.append ( magic_string.toByteArray() );
encodedString.append ( salt.toByteArray() );
encodedString.append ( "$" );
encodedString.append ( QString::fromLatin1( magic_string.toByteArray() ) );
encodedString.append ( QString::fromLatin1( salt.toByteArray() ) );
encodedString.append ( QStringLiteral("$") );
long l;

View File

@ -39,8 +39,8 @@ static QString prompt(const QString &s)
fflush(stdout);
char line[256];
fgets(line, 255, stdin);
QString result = line;
if(result[result.length()-1] == '\n')
QString result = QString::fromLatin1(line);
if(result[result.length()-1] == QLatin1Char('\n'))
result.truncate(result.length()-1);
return result;
}
@ -236,7 +236,7 @@ private Q_SLOTS:
{
if(sock->canReadLine())
{
QString line = sock->readLine();
QString line = QString::fromLatin1(sock->readLine());
line.truncate(line.length() - 1); // chop the newline
handleLine(line);
}
@ -249,7 +249,7 @@ private Q_SLOTS:
QString line = sasl->mechanism();
if(clientInit)
{
line += ' ';
line += QLatin1Char(' ');
line += arrayToString(clientInitData);
}
sendLine(line);
@ -260,7 +260,7 @@ private Q_SLOTS:
QString line = QStringLiteral("C");
if(!stepData.isEmpty())
{
line += ',';
line += QLatin1Char(',');
line += arrayToString(stepData);
}
sendLine(line);
@ -388,7 +388,7 @@ private:
void sendLine(const QString &line)
{
printf("Writing: {%s}\n", qPrintable(line));
QString s = line + '\n';
QString s = line + QLatin1Char('\n');
QByteArray a = s.toUtf8();
if(mode == 2) // app mode
sasl->write(a); // write to sasl
@ -418,14 +418,14 @@ private:
if(mode == 0)
{
// first line is the method list
QStringList mechlist = line.split(' ');
QStringList mechlist = line.split(QLatin1Char(' '));
mode = 1; // switch to sasl negotiation mode
sasl->startClient(proto, host, mechlist);
}
else if(mode == 1)
{
QString type, rest;
int n = line.indexOf(',');
int n = line.indexOf(QLatin1Char(','));
if(n != -1)
{
type = line.mid(0, n);
@ -494,7 +494,7 @@ int main(int argc, char **argv)
QString opt = args[n].mid(2);
QString var, val;
int at = opt.indexOf('=');
int at = opt.indexOf(QLatin1Char('='));
if(at != -1)
{
var = opt.mid(0, at);
@ -543,7 +543,7 @@ int main(int argc, char **argv)
if(args.count() >= 3)
pass = args[2];
int at = hostinput.indexOf(':');
int at = hostinput.indexOf(QLatin1Char(':'));
if(at != -1)
{
host = hostinput.mid(0, at);

View File

@ -213,7 +213,7 @@ private Q_SLOTS:
{
if(sock->canReadLine())
{
QString line = sock->readLine();
QString line = QString::fromLatin1(sock->readLine());
line.truncate(line.length() - 1); // chop the newline
handleLine(line);
}
@ -237,7 +237,7 @@ private Q_SLOTS:
QString line = QStringLiteral("C");
if(!stepData.isEmpty())
{
line += ',';
line += QLatin1Char(',');
line += arrayToString(stepData);
}
sendLine(line);
@ -317,11 +317,11 @@ private:
printf("%d: Reading: [%s]\n", id, qPrintable(line));
if(mode == 0)
{
int n = line.indexOf(' ');
int n = line.indexOf(QLatin1Char(' '));
if(n != -1)
{
QString mech = line.mid(0, n);
QString rest = line.mid(n + 1).toUtf8();
QString rest = QString::fromLatin1(line.mid(n + 1).toUtf8());
sasl->putServerFirstStep(mech, stringToArray(rest));
}
else
@ -331,7 +331,7 @@ private:
else if(mode == 1)
{
QString type, rest;
int n = line.indexOf(',');
int n = line.indexOf(QLatin1Char(','));
if(n != -1)
{
type = line.mid(0, n);
@ -371,7 +371,7 @@ private:
void sendLine(const QString &line)
{
printf("%d: Writing: {%s}\n", id, qPrintable(line));
QString s = line + '\n';
QString s = line + QLatin1Char('\n');
QByteArray a = s.toUtf8();
if(mode == 2) // app mode
{
@ -456,7 +456,7 @@ int main(int argc, char **argv)
QString opt = args[n].mid(2);
QString var, val;
int at = opt.indexOf('=');
int at = opt.indexOf(QLatin1Char('='));
if(at != -1)
{
var = opt.mid(0, at);
@ -488,7 +488,7 @@ int main(int argc, char **argv)
if(args.count() >= 2)
str = args[1];
int at = hostinput.indexOf(':');
int at = hostinput.indexOf(QLatin1Char(':'));
if(at != -1)
{
host = hostinput.mid(0, at);

View File

@ -88,8 +88,8 @@ public:
connect(ssl, &QCA::TLS::closed, this, &SecureServer::ssl_closed);
connect(ssl, &QCA::TLS::error, this, &SecureServer::ssl_error);
cert = QCA::Certificate::fromPEM(pemdata_cert);
privkey = QCA::PrivateKey::fromPEM(pemdata_privkey);
cert = QCA::Certificate::fromPEM(QString::fromLatin1(pemdata_cert));
privkey = QCA::PrivateKey::fromPEM(QString::fromLatin1(pemdata_privkey));
mode = Idle;
}
@ -255,7 +255,7 @@ int main(int argc, char **argv)
QCA::Initializer init;
QCoreApplication app(argc, argv);
int port = argc > 1 ? QString(argv[1]).toInt() : 8000;
int port = argc > 1 ? QString::fromLatin1(argv[1]).toInt() : 8000;
if(!QCA::isSupported("tls")) {
qDebug() << "TLS not supported!";

View File

@ -132,7 +132,7 @@ public:
void start(const QString &_host)
{
int n = _host.indexOf(':');
int n = _host.indexOf(QLatin1Char(':'));
int port;
if(n != -1)
{
@ -164,7 +164,7 @@ private Q_SLOTS:
// We add this one to show how, and to make it work with
// the server example.
rootCerts.addCertificate(QCA::Certificate::fromPEM(exampleCA_cert));
rootCerts.addCertificate(QCA::Certificate::fromPEM(QString::fromLatin1(exampleCA_cert)));
if(!QCA::haveSystemStore())
printf("Warning: no root certs\n");
@ -236,7 +236,7 @@ private Q_SLOTS:
ssl->continueAfterStep();
printf("Let's try a GET request now.\n");
QString req = "GET / HTTP/1.0\nHost: " + host + "\n\n";
QString req = QStringLiteral("GET / HTTP/1.0\nHost: ") + host + QStringLiteral("\n\n");
ssl->write(req.toLatin1());
}
@ -316,7 +316,7 @@ int main(int argc, char **argv)
QCA::Initializer init;
QCoreApplication app(argc, argv);
QString host = argc > 1 ? argv[1] : QStringLiteral("andbit.net");
QString host = argc > 1 ? QString::fromLocal8Bit(argv[1]) : QStringLiteral("andbit.net");
if(!QCA::isSupported("tls"))
{

View File

@ -204,7 +204,7 @@ static QByteArray makeByteArray(const void *in, unsigned int len)
static QString addrString(const SASLContext::HostPort &hp)
{
return (hp.addr + ';' + QString::number(hp.port));
return (hp.addr + QLatin1Char(';') + QString::number(hp.port));
}
//----------------------------------------------------------------------------
@ -365,8 +365,8 @@ private:
static int scb_checkauth(sasl_conn_t *, void *context, const char *requested_user, unsigned, const char *auth_identity, unsigned, const char *, unsigned, struct propctx *)
{
saslContext *that = (saslContext *)context;
that->sc_username = auth_identity; // yeah yeah, it looks
that->sc_authzid = requested_user; // backwards, but it is right
that->sc_username = QString::fromLatin1(auth_identity); // yeah yeah, it looks
that->sc_authzid = QString::fromLatin1(requested_user); // backwards, but it is right
that->ca_flag = true;
return SASL_OK;
}
@ -395,7 +395,7 @@ private:
params.applyInteract(need);
if(params.missingAny()) {
out_mech = m;
out_mech = QString::fromLatin1(m);
result_result = Params;
return;
}
@ -406,7 +406,7 @@ private:
return;
}
out_mech = m;
out_mech = QString::fromLatin1(m);
if(in_sendFirst && clientout) {
out_buf = makeByteArray(clientout, clientoutlen);
result_haveClientInit = true;
@ -713,7 +713,7 @@ public:
r = sasl_listmech(con, nullptr, nullptr, " ", nullptr, &ml, nullptr, nullptr);
if(r != SASL_OK)
return;
result_mechlist = QString::fromUtf8(ml).split(' ');
result_mechlist = QString::fromUtf8(ml).split(QLatin1Char(' '));
servermode = true;
step = 0;

View File

@ -32,7 +32,7 @@ static QDateTime getTimestamp(const QString &s)
if(s.isEmpty())
return QDateTime();
if(s.contains('T'))
if(s.contains(QLatin1Char('T')))
{
return QDateTime::fromString(s, Qt::ISODate);
}
@ -90,7 +90,7 @@ static QByteArray getCString(const QByteArray &a)
static bool stringToKeyList(const QString &outstr, GpgOp::KeyList *_keylist, QString *_keyring)
{
GpgOp::KeyList keyList;
QStringList lines = outstr.split('\n');
const QStringList lines = outstr.split(QLatin1Char('\n'));
if(lines.count() < 1)
return false;
@ -103,7 +103,7 @@ static bool stringToKeyList(const QString &outstr, GpgOp::KeyList *_keylist, QSt
// if the second line isn't a divider, we are dealing
// with a new version of gnupg that doesn't give us
// the keyring file on gpg --list-keys --with-colons
if(it == lines.constEnd() || (*it).isEmpty() || (*it).at(0) != '-')
if(it == lines.constEnd() || (*it).isEmpty() || (*it).at(0) != QLatin1Char('-'))
{
// first line wasn't the keyring name...
keyring.clear();
@ -118,7 +118,7 @@ static bool stringToKeyList(const QString &outstr, GpgOp::KeyList *_keylist, QSt
for(; it != lines.constEnd(); ++it)
{
QStringList f = (*it).split(':');
const QStringList f = (*it).split(QLatin1Char(':'));
if(f.count() < 1)
continue;
QString type = f[0];
@ -175,13 +175,13 @@ static bool stringToKeyList(const QString &outstr, GpgOp::KeyList *_keylist, QSt
item.id = f[4];
item.creationDate = getTimestamp(f[5]);
item.expirationDate = getTimestamp(f[6]);
if(caps.contains('e'))
if(caps.contains(QLatin1Char('e')))
item.caps |= GpgOp::KeyItem::Encrypt;
if(caps.contains('s'))
if(caps.contains(QLatin1Char('s')))
item.caps |= GpgOp::KeyItem::Sign;
if(caps.contains('c'))
if(caps.contains(QLatin1Char('c')))
item.caps |= GpgOp::KeyItem::Certify;
if(caps.contains('a'))
if(caps.contains(QLatin1Char('a')))
item.caps |= GpgOp::KeyItem::Auth;
keyList.last().keyItems += item;
@ -208,7 +208,7 @@ static bool stringToKeyList(const QString &outstr, GpgOp::KeyList *_keylist, QSt
static bool findKeyringFilename(const QString &outstr, QString *_keyring)
{
QStringList lines = outstr.split('\n');
const QStringList lines = outstr.split(QLatin1Char('\n'));
if(lines.count() < 1)
return false;
@ -605,7 +605,7 @@ void GpgAction::submitCommand(const QByteArray &a)
// since str is taken as a value, it is ok to use the same variable for 'rest'
QString GpgAction::nextArg(QString str, QString *rest)
{
int n = str.indexOf(' ');
int n = str.indexOf(QLatin1Char(' '));
if(n == -1)
{
if(rest)
@ -622,7 +622,7 @@ QString GpgAction::nextArg(QString str, QString *rest)
void GpgAction::processStatusLine(const QString &line)
{
appendDiagnosticText("{" + line + "}");
appendDiagnosticText(QStringLiteral("{") + line + QStringLiteral("}"));
ensureDTextEmit();
if(!proc.isActive())
@ -748,14 +748,14 @@ void GpgAction::processStatusLine(const QString &line)
else if(s == QLatin1String("ERRSIG"))
{
output.wasSigned = true;
QStringList list = rest.split(' ', QString::SkipEmptyParts);
const QStringList list = rest.split(QLatin1Char(' '), QString::SkipEmptyParts);
output.signerId = list[0];
output.timestamp = getTimestamp(list[4]);
output.verifyResult = GpgOp::VerifyNoKey;
}
else if(s == QLatin1String("VALIDSIG"))
{
QStringList list = rest.split(' ', QString::SkipEmptyParts);
const QStringList list = rest.split(QLatin1Char(' '), QString::SkipEmptyParts);
output.timestamp = getTimestamp(list[2]);
}
}
@ -809,7 +809,7 @@ void GpgAction::processResult(int code)
if (!str.startsWith(QLatin1String("Home: ")))
continue;
output.homeDir = str.section(' ', 1);
output.homeDir = str.section(QLatin1Char(' '), 1);
break;
}
output.success = true;
@ -939,7 +939,7 @@ void GpgAction::proc_bytesWrittenCommand(int)
void GpgAction::proc_debug(const QString &str)
{
appendDiagnosticText("GPGProc: " + str);
appendDiagnosticText(QStringLiteral("GPGProc: ") + str);
ensureDTextEmit();
}

View File

@ -195,13 +195,13 @@ void GpgOp::Private::act_finished()
if(output.wasSigned)
{
const char *s;
QString s;
if(output.verifyResult == GpgOp::VerifyGood)
s = "VerifyGood";
s = QStringLiteral("VerifyGood");
else if(output.verifyResult == GpgOp::VerifyBad)
s = "VerifyBad";
s = QStringLiteral("VerifyBad");
else
s = "VerifyNoKey";
s = QStringLiteral("VerifyNoKey");
diagnosticText += QStringLiteral("wasSigned: verifyResult: %1\n").arg(s);
}

View File

@ -196,7 +196,7 @@ void GPGProc::Private::setupArguments()
}
QString fullcmd = fullargs.join(QStringLiteral(" "));
emit q->debug(QStringLiteral("Running: [") + bin + ' ' + fullcmd + ']');
emit q->debug(QStringLiteral("Running: [") + bin + QLatin1Char(' ') + fullcmd + QLatin1Char(']'));
args = fullargs;
}

View File

@ -154,7 +154,7 @@ KeyStoreEntryContext *MyKeyStoreList::entryPassive(const QString &serialized)
{
QMutexLocker locker(&ringMutex);
QStringList parts = serialized.split(':');
const QStringList parts = serialized.split(QLatin1Char(':'));
if(parts.count() < 2)
return nullptr;
if(unescape_string(parts[0]) != QLatin1String("qca-gnupg-1"))
@ -375,7 +375,7 @@ void MyKeyStoreList::gpg_finished()
if(secring.isEmpty())
{
secring = homeDir + "/secring.gpg";
secring = homeDir + QStringLiteral("/secring.gpg");
}
ringWatch.add(secring);
@ -389,7 +389,7 @@ void MyKeyStoreList::gpg_finished()
pubring = QFileInfo(gpg.keyringFile()).canonicalFilePath();
if(pubring.isEmpty())
{
pubring = homeDir + "/pubring.gpg";
pubring = homeDir + QStringLiteral("/pubring.gpg");
}
ringWatch.add(pubring);

View File

@ -212,7 +212,7 @@ void MyPGPKeyContext::set(const GpgOp::Key &i, bool isSecret, bool inKeyring, bo
void MyPGPKeyContext::cleanup_temp_keyring(const QString &name)
{
QFile::remove(name);
QFile::remove(name + '~'); // remove possible backup file
QFile::remove(name + QLatin1Char('~')); // remove possible backup file
}
} // end namespace gpgQCAPlugin

View File

@ -156,7 +156,7 @@ void RingWatch::handleChanged()
for(int n = 0; n < files.count(); ++n)
{
FileItem &i = files[n];
QString filePath = dir + '/' + i.fileName;
QString filePath = dir + QLatin1Char('/') + i.fileName;
QFileInfo fi(filePath);
// if the file didn't exist, and still doesn't, skip

View File

@ -123,9 +123,9 @@ QString find_bin()
// Prefer bundled gpg
foreach (const QString &bin, bins)
{
if (check_bin(QCoreApplication::applicationDirPath() + "/" + bin))
if (check_bin(QCoreApplication::applicationDirPath() + QLatin1Char('/') + bin))
{
return QCoreApplication::applicationDirPath() + "/" + bin;
return QCoreApplication::applicationDirPath() + QLatin1Char('/') + bin;
}
}
@ -159,9 +159,9 @@ QString find_bin()
{
foreach (const QString &bin, bins)
{
if (check_bin(path + "/" + bin))
if (check_bin(path + QLatin1Char('/') + bin))
{
return path + "/" + bin;
return path + QLatin1Char('/') + bin;
}
}
}
@ -175,9 +175,9 @@ QString escape_string(const QString &in)
QString out;
for(const QChar &c : in)
{
if(c == '\\')
if(c == QLatin1Char('\\'))
out += QStringLiteral("\\\\");
else if(c == ':')
else if(c == QLatin1Char(':'))
out += QStringLiteral("\\c");
else
out += c;
@ -190,14 +190,14 @@ QString unescape_string(const QString &in)
QString out;
for(int n = 0; n < in.length(); ++n)
{
if(in[n] == '\\')
if(in[n] == QLatin1Char('\\'))
{
if(n + 1 < in.length())
{
if(in[n + 1] == '\\')
out += '\\';
else if(in[n + 1] == 'c')
out += ':';
if(in[n + 1] == QLatin1Char('\\'))
out += QLatin1Char('\\');
else if(in[n + 1] == QLatin1Char('c'))
out += QLatin1Char(':');
++n;
}
}

View File

@ -156,9 +156,9 @@ public:
defaultConfig () const override {
QVariantMap mytemplate;
mytemplate[QStringLiteral("formtype")] = "http://affinix.com/qca/forms/qca-logger#1.0";
mytemplate[QStringLiteral("formtype")] = QStringLiteral("http://affinix.com/qca/forms/qca-logger#1.0");
mytemplate[QStringLiteral("enabled")] = false;
mytemplate[QStringLiteral("file")] = "";
mytemplate[QStringLiteral("file")] = QLatin1String("");
mytemplate[QStringLiteral("level")] = (int)Logger::Quiet;
return mytemplate;

View File

@ -1607,18 +1607,18 @@ static const int JCE_768_COUNTER = 263;
static const char* JCE_1024_SEED = "8D515589 4229D5E6 89EE01E6 018A237E 2CAE64CD";
static const int JCE_1024_COUNTER = 92;
static QByteArray dehex(const QString &hex)
static QByteArray dehex(const QByteArray &hex)
{
QString str;
for(const QChar &c : hex)
for(const char c : hex)
{
if(c != ' ')
str += c;
str += QLatin1Char(c);
}
return hexToArray(str);
}
static BigInteger decode(const QString &prime)
static BigInteger decode(const QByteArray &prime)
{
QByteArray a(1, 0); // 1 byte of zero padding
a.append(dehex(prime));
@ -1626,7 +1626,7 @@ static BigInteger decode(const QString &prime)
}
#ifndef OPENSSL_FIPS
static QByteArray decode_seed(const QString &hex_seed)
static QByteArray decode_seed(const QByteArray &hex_seed)
{
return dehex(hex_seed);
}
@ -3620,7 +3620,7 @@ public:
if(ai)
{
char *rep = i2s_ASN1_INTEGER(nullptr, ai);
QString str = rep;
QString str = QString::fromLatin1(rep);
OPENSSL_free(rep);
p.serial.fromString(str);
}
@ -7251,7 +7251,7 @@ public:
QString credit() const override
{
return QString(
return QStringLiteral(
"This product includes cryptographic software "
"written by Eric Young (eay@cryptsoft.com)");
}

View File

@ -381,7 +381,7 @@ public:
QString
message () const {
return _msg + QStringLiteral(" ") + pkcs11h_getMessage (_rv);
return _msg + QStringLiteral(" ") + QString::fromLatin1(pkcs11h_getMessage (_rv));
}
};
@ -1649,7 +1649,7 @@ pkcs11KeyStoreListContext::name (int id) const {
);
if (_storesById.contains (id)) {
ret = _storesById[id]->tokenId ()->label;
ret = QString::fromLatin1(_storesById[id]->tokenId ()->label);
}
QCA_logTextMessage (
@ -1966,7 +1966,7 @@ pkcs11KeyStoreListContext::_tokenPrompt (
else {
_registerTokenId (token_id);
storeId = _tokenId2storeId (token_id);
storeName = token_id->label;
storeName = QString::fromLatin1(token_id->label);
}
TokenAsker asker;
@ -2023,7 +2023,7 @@ pkcs11KeyStoreListContext::_pinPrompt (
else {
_registerTokenId (token_id);
storeId = _tokenId2storeId (token_id);
storeName = token_id->label;
storeName = QString::fromLatin1(token_id->label);
}
PasswordAsker asker;
@ -2210,7 +2210,7 @@ pkcs11KeyStoreListContext::_keyStoreEntryByCertificateId (
QString description = _description;
const Certificate &cert = chain.primary ();
if (description.isEmpty ()) {
description = cert.subjectInfoOrdered ().toString () + " by " + cert.issuerInfo ().value (CommonName, QStringLiteral("Unknown"));
description = cert.subjectInfoOrdered ().toString () + QStringLiteral(" by ") + cert.issuerInfo ().value (CommonName, QStringLiteral("Unknown"));
}
if (has_private) {
@ -2235,7 +2235,7 @@ pkcs11KeyStoreListContext::_keyStoreEntryByCertificateId (
key,
_tokenId2storeId (certificate_id->token_id),
serialized,
certificate_id->token_id->label,
QString::fromLatin1(certificate_id->token_id->label),
description,
provider ()
);
@ -2245,7 +2245,7 @@ pkcs11KeyStoreListContext::_keyStoreEntryByCertificateId (
cert,
_tokenId2storeId (certificate_id->token_id),
serialized,
certificate_id->token_id->label,
QString::fromLatin1(certificate_id->token_id->label),
description,
provider()
);
@ -2302,7 +2302,7 @@ pkcs11KeyStoreListContext::_tokenId2storeId (
buf.resize ((int)len);
storeId = "qca-pkcs11/" + _escapeString (QString::fromUtf8 (buf));
storeId = QStringLiteral("qca-pkcs11/") + _escapeString (QString::fromUtf8 (buf));
QCA_logTextMessage (
QString::asprintf (
@ -2490,7 +2490,7 @@ pkcs11KeyStoreListContext::_escapeString (
QString to;
foreach (QChar c, from) {
if (c == '/' || c == '\\') {
if (c == QLatin1Char('/') || c == QLatin1Char('\\')) {
to += QString::asprintf ("\\x%04x", c.unicode ());
}
else {
@ -2510,7 +2510,7 @@ pkcs11KeyStoreListContext::_unescapeString (
for (int i=0;i<from.size ();i++) {
QChar c = from[i];
if (c == '\\') {
if (c == QLatin1Char('\\')) {
to += QChar ((ushort)from.midRef (i+2, 4).toInt (nullptr, 16));
i+=5;
}
@ -2759,19 +2759,19 @@ pkcs11Provider::defaultConfig () const {
Logger::Debug
);
mytemplate[QStringLiteral("formtype")] = "http://affinix.com/qca/forms/qca-pkcs11#1.0";
mytemplate[QStringLiteral("formtype")] = QStringLiteral("http://affinix.com/qca/forms/qca-pkcs11#1.0");
mytemplate[QStringLiteral("allow_load_rootca")] = false;
mytemplate[QStringLiteral("allow_protected_authentication")] = true;
mytemplate[QStringLiteral("pin_cache")] = PKCS11H_PIN_CACHE_INFINITE;
mytemplate[QStringLiteral("log_level")] = 0;
for (int i=0;i<_CONFIG_MAX_PROVIDERS;i++) {
mytemplate[QString::asprintf ("provider_%02d_enabled", i)] = false;
mytemplate[QString::asprintf ("provider_%02d_name", i)] = "";
mytemplate[QString::asprintf ("provider_%02d_library", i)] = "";
mytemplate[QString::asprintf ("provider_%02d_name", i)] = QLatin1String("");
mytemplate[QString::asprintf ("provider_%02d_library", i)] = QLatin1String("");
mytemplate[QString::asprintf ("provider_%02d_allow_protected_authentication", i)] = true;
mytemplate[QString::asprintf ("provider_%02d_cert_private", i)] = false;
mytemplate[QString::asprintf ("provider_%02d_private_mask", i)] = PKCS11H_PRIVATEMODE_MASK_AUTO;
mytemplate[QString::asprintf ("provider_%02d_slotevent_method", i)] = "auto";
mytemplate[QString::asprintf ("provider_%02d_slotevent_method", i)] = QStringLiteral("auto");
mytemplate[QString::asprintf ("provider_%02d_slotevent_timeout", i)] = 0;
}
@ -2968,7 +2968,7 @@ pkcs11Provider::_logHook (
char buffer[2048];
qvsnprintf (buffer, sizeof (buffer)-1, format, args);
buffer[sizeof (buffer)-1] = '\x0';
QCA_logTextMessage (buffer, severity);
QCA_logTextMessage (QString::fromLatin1(buffer), severity);
//@END-WORKAROUND
}

View File

@ -1285,7 +1285,7 @@ private:
QString to;
foreach (const QChar &c, from) {
if (c == '/' || c == '\\') {
if (c == QLatin1Char('/') || c == QLatin1Char('\\')) {
to += QString::asprintf ("\\x%04x", c.unicode ());
}
else {
@ -1305,7 +1305,7 @@ private:
for (int i=0;i<from.size ();i++) {
QChar c = from[i];
if (c == '\\') {
if (c == QLatin1Char('\\')) {
to += QChar ((ushort)from.midRef (i+2, 4).toInt (nullptr, 16));
i+=5;
}
@ -1406,14 +1406,14 @@ public:
Logger::Debug
);
mytemplate[QStringLiteral("formtype")] = "http://affinix.com/qca/forms/qca-softstore#1.0";
mytemplate[QStringLiteral("formtype")] = QStringLiteral("http://affinix.com/qca/forms/qca-softstore#1.0");
for (int i=0;i<_CONFIG_MAX_ENTRIES;i++) {
mytemplate[QString::asprintf ("entry_%02d_enabled", i)] = false;
mytemplate[QString::asprintf ("entry_%02d_name", i)] = "";
mytemplate[QString::asprintf ("entry_%02d_public_type", i)] = "";
mytemplate[QString::asprintf ("entry_%02d_private_type", i)] = "";
mytemplate[QString::asprintf ("entry_%02d_public", i)] = "";
mytemplate[QString::asprintf ("entry_%02d_private", i)] = "";
mytemplate[QString::asprintf ("entry_%02d_name", i)] = QLatin1String("");
mytemplate[QString::asprintf ("entry_%02d_public_type", i)] = QLatin1String("");
mytemplate[QString::asprintf ("entry_%02d_private_type", i)] = QLatin1String("");
mytemplate[QString::asprintf ("entry_%02d_public", i)] = QLatin1String("");
mytemplate[QString::asprintf ("entry_%02d_private", i)] = QLatin1String("");
mytemplate[QString::asprintf ("entry_%02d_unlock_timeout", i)] = -1;
mytemplate[QString::asprintf ("entry_%02d_no_passphrase", i)] = false;
}

View File

@ -447,7 +447,7 @@ QString Cipher::withAlgorithms(const QString &cipherType, Mode modeType, Padding
else
pad = QStringLiteral("pkcs7");
QString result = cipherType + '-' + mode;
QString result = cipherType + QLatin1Char('-') + mode;
if(!pad.isEmpty())
result += QStringLiteral("-") + pad;
@ -588,14 +588,14 @@ SymmetricKey KeyDerivationFunction::makeKey(const SecureArray &secret,
QString KeyDerivationFunction::withAlgorithm(const QString &kdfType, const QString &algType)
{
return (kdfType + '(' + algType + ')');
return (kdfType + QLatin1Char('(') + algType + QLatin1Char(')'));
}
//----------------------------------------------------------------------------
// HKDF
//----------------------------------------------------------------------------
HKDF::HKDF(const QString &algorithm, const QString &provider)
: Algorithm(QStringLiteral("hkdf(") + algorithm + ')', provider)
: Algorithm(QStringLiteral("hkdf(") + algorithm + QLatin1Char(')'), provider)
{
}

View File

@ -221,40 +221,40 @@ static QString knownToId(CertificateInfoTypeKnown k)
Q_ASSERT(out);
if(!out)
abort();
return QString(out);
return QString::fromLatin1(out);
}
static int idToKnown(const QString &id)
{
if(id == CommonName_id)
if(id == QLatin1String(CommonName_id))
return CommonName;
else if(id == Email_id)
else if(id == QLatin1String(Email_id))
return Email;
else if(id == EmailLegacy_id)
else if(id == QLatin1String(EmailLegacy_id))
return EmailLegacy;
else if(id == Organization_id)
else if(id == QLatin1String(Organization_id))
return Organization;
else if(id == OrganizationalUnit_id)
else if(id == QLatin1String(OrganizationalUnit_id))
return OrganizationalUnit;
else if(id == Locality_id)
else if(id == QLatin1String(Locality_id))
return Locality;
else if(id == IncorporationLocality_id)
else if(id == QLatin1String(IncorporationLocality_id))
return IncorporationLocality;
else if(id == State_id)
else if(id == QLatin1String(State_id))
return State;
else if(id == IncorporationState_id)
else if(id == QLatin1String(IncorporationState_id))
return IncorporationState;
else if(id == Country_id)
else if(id == QLatin1String(Country_id))
return Country;
else if(id == IncorporationCountry_id)
else if(id == QLatin1String(IncorporationCountry_id))
return IncorporationCountry;
else if(id == URI_id)
else if(id == QLatin1String(URI_id))
return URI;
else if(id == DNS_id)
else if(id == QLatin1String(DNS_id))
return DNS;
else if(id == IPAddress_id)
else if(id == QLatin1String(IPAddress_id))
return IPAddress;
else if(id == XMPP_id)
else if(id == QLatin1String(XMPP_id))
return XMPP;
else
return -1;
@ -324,46 +324,46 @@ static QString constraintKnownToId(ConstraintTypeKnown k)
Q_ASSERT(out);
if(!out)
abort();
return QString(out);
return QString::fromLatin1(out);
}
static int constraintIdToKnown(const QString &id)
{
if(id == DigitalSignature_id)
if(id == QLatin1String(DigitalSignature_id))
return DigitalSignature;
else if(id == NonRepudiation_id)
else if(id == QLatin1String(NonRepudiation_id))
return NonRepudiation;
else if(id == KeyEncipherment_id)
else if(id == QLatin1String(KeyEncipherment_id))
return KeyEncipherment;
else if(id == DataEncipherment_id)
else if(id == QLatin1String(DataEncipherment_id))
return DataEncipherment;
else if(id == KeyAgreement_id)
else if(id == QLatin1String(KeyAgreement_id))
return KeyAgreement;
else if(id == KeyCertificateSign_id)
else if(id == QLatin1String(KeyCertificateSign_id))
return KeyCertificateSign;
else if(id == CRLSign_id)
else if(id == QLatin1String(CRLSign_id))
return CRLSign;
else if(id == EncipherOnly_id)
else if(id == QLatin1String(EncipherOnly_id))
return EncipherOnly;
else if(id == DecipherOnly_id)
else if(id == QLatin1String(DecipherOnly_id))
return DecipherOnly;
else if(id == ServerAuth_id)
else if(id == QLatin1String(ServerAuth_id))
return ServerAuth;
else if(id == ClientAuth_id)
else if(id == QLatin1String(ClientAuth_id))
return ClientAuth;
else if(id == CodeSigning_id)
else if(id == QLatin1String(CodeSigning_id))
return CodeSigning;
else if(id == EmailProtection_id)
else if(id == QLatin1String(EmailProtection_id))
return EmailProtection;
else if(id == IPSecEndSystem_id)
else if(id == QLatin1String(IPSecEndSystem_id))
return IPSecEndSystem;
else if(id == IPSecTunnel_id)
else if(id == QLatin1String(IPSecTunnel_id))
return IPSecTunnel;
else if(id == IPSecUser_id)
else if(id == QLatin1String(IPSecUser_id))
return IPSecUser;
else if(id == TimeStamping_id)
else if(id == QLatin1String(TimeStamping_id))
return TimeStamping;
else if(id == OCSPSigning_id)
else if(id == QLatin1String(OCSPSigning_id))
return OCSPSigning;
else
return -1;
@ -393,7 +393,7 @@ static QString dnLabel(const CertificateInfoType &type)
{
const char *str = knownToShortName(type.known());
if(str)
return str;
return QString::fromLatin1(str);
QString id = type.id();
// is it an oid?
@ -412,7 +412,7 @@ QString orderedToDNString(const CertificateInfoOrdered &in)
continue;
QString name = dnLabel(i.type());
parts += name + '=' + i.value();
parts += name + QLatin1Char('=') + i.value();
}
return parts.join(QStringLiteral(", "));
}
@ -551,7 +551,7 @@ static QString uniqueConstraintValue(const ConstraintType &type, const QList<int
}
if(!found)
return QString(constraintToString(type));
return QString::fromLatin1(constraintToString(type));
}
return QString();
@ -581,7 +581,7 @@ static QString makeUniqueName(const QList<int> &items, const QStringList &list,
str = uniqueSubjectValue(Email, items, certs, i);
if(!str.isEmpty())
{
name = list[items[i]] + QStringLiteral(" <") + str + '>';
name = list[items[i]] + QStringLiteral(" <") + str + QLatin1Char('>');
goto end;
}
@ -589,7 +589,7 @@ static QString makeUniqueName(const QList<int> &items, const QStringList &list,
str = uniqueSubjectValue(XMPP, items, certs, i);
if(!str.isEmpty())
{
name = list[items[i]] + QStringLiteral(" <xmpp:") + str + '>';
name = list[items[i]] + QStringLiteral(" <xmpp:") + str + QLatin1Char('>');
goto end;
}
@ -1199,9 +1199,9 @@ void CertificateOptions::setValidityPeriod(const QDateTime &start, const QDateTi
static QByteArray ipaddr_str2bin(const QString &str)
{
// ipv6
if(str.contains(':'))
if(str.contains(QLatin1Char(':')))
{
QStringList parts = str.split(':', QString::KeepEmptyParts);
QStringList parts = str.split(QLatin1Char(':'), QString::KeepEmptyParts);
if(parts.count() < 3 || parts.count() > 8)
return QByteArray();
@ -1242,7 +1242,7 @@ static QByteArray ipaddr_str2bin(const QString &str)
}
else
{
if(parts[n].indexOf('.') == -1)
if(parts[n].indexOf(QLatin1Char('.')) == -1)
{
bool ok;
int x = parts[n].toInt(&ok, 16);
@ -1271,9 +1271,9 @@ static QByteArray ipaddr_str2bin(const QString &str)
return ipv6;
}
else if(str.contains('.'))
else if(str.contains(QLatin1Char('.')))
{
QStringList parts = str.split('.', QString::KeepEmptyParts);
QStringList parts = str.split(QLatin1Char('.'), QString::KeepEmptyParts);
if(parts.count() != 4)
return QByteArray();
@ -1301,7 +1301,7 @@ static bool cert_match_domain(const QString &certname, const QString &acedomain)
// KSSL strips trailing dot, even though the dot is probably not
// legal anyway. (compat)
if(name.length() > 0 && name[name.length()-1] == '.')
if(name.length() > 0 && name[name.length()-1] == QLatin1Char('.'))
name.truncate(name.length()-1);
// after our compatibility modifications, make sure the name isn't
@ -1313,23 +1313,23 @@ static bool cert_match_domain(const QString &certname, const QString &acedomain)
name = name.toLower();
// ensure the cert field contains valid characters only
if(QRegExp("[^a-z0-9\\.\\*\\-]").indexIn(name) >= 0)
if(QRegExp(QLatin1String("[^a-z0-9\\.\\*\\-]")).indexIn(name) >= 0)
return false;
// hack into parts, and require at least 1 part
QStringList parts_name = name.split('.', QString::KeepEmptyParts);
const QStringList parts_name = name.split(QLatin1Char('.'), QString::KeepEmptyParts);
if(parts_name.isEmpty())
return false;
// KSSL checks to make sure the last two parts don't contain
// wildcards. I don't know where it is written that this
// should be done, but for compat sake we'll do it.
if(parts_name[parts_name.count()-1].contains('*'))
if(parts_name[parts_name.count()-1].contains(QLatin1Char('*')))
return false;
if(parts_name.count() >= 2 && parts_name[parts_name.count()-2].contains('*'))
if(parts_name.count() >= 2 && parts_name[parts_name.count()-2].contains(QLatin1Char('*')))
return false;
QStringList parts_compare = acedomain.split('.', QString::KeepEmptyParts);
QStringList parts_compare = acedomain.split(QLatin1Char('.'), QString::KeepEmptyParts);
if(parts_compare.isEmpty())
return false;
@ -1382,7 +1382,7 @@ static bool cert_match_ipaddress(const QString &certname, const QByteArray &ipad
// KSSL accepts IPv6 in brackets, which is usually done for URIs, but
// IMO sounds very strange for a certificate. We'll follow this
// behavior anyway. (compat)
if(name.length() >= 2 && name[0] == '[' && name[name.length()-1] == ']')
if(name.length() >= 2 && name[0] == QLatin1Char('[') && name[name.length()-1] == QLatin1Char(']'))
name = name.mid(1, name.length() - 2); // chop off brackets
// after our compatibility modifications, make sure the name isn't
@ -1668,11 +1668,11 @@ bool Certificate::matchesHostName(const QString &host) const
name = QString::fromLatin1(QUrl::toAce(name));
// don't allow wildcards in the comparison host
if(name.contains('*'))
if(name.contains(QLatin1Char('*')))
return false;
// strip out trailing dot
if(name.length() > 0 && name[name.length()-1] == '.')
if(name.length() > 0 && name[name.length()-1] == QLatin1Char('.'))
name.truncate(name.length()-1);
// make sure the name is not empty after our modifications
@ -2278,20 +2278,20 @@ static QString readNextPem(QTextStream *ts, bool *isCRL)
if(line.contains(QLatin1String("CERTIFICATE")))
{
found = true;
pem += line + '\n';
pem += line + QLatin1Char('\n');
crl = false;
}
else if(line.contains(QLatin1String("CRL")))
{
found = true;
pem += line + '\n';
pem += line + QLatin1Char('\n');
crl = true;
}
}
}
else
{
pem += line + '\n';
pem += line + QLatin1Char('\n');
if(line.startsWith(QLatin1String("-----END ")))
{
done = true;

View File

@ -365,7 +365,7 @@ bool isSupported(const QStringList &features, const QString &provider)
bool isSupported(const char *features, const QString &provider)
{
return isSupported(QString(features).split(',', QString::SkipEmptyParts), provider);
return isSupported(QString::fromLatin1(features).split(QLatin1Char(','), QString::SkipEmptyParts), provider);
}
QStringList supportedFeatures()
@ -458,17 +458,17 @@ QStringList pluginPaths()
{
QStringList paths;
#ifndef DEVELOPER_MODE
const QString qcaPluginPath = qgetenv("QCA_PLUGIN_PATH");
const QByteArray qcaPluginPath = qgetenv("QCA_PLUGIN_PATH");
if (!qcaPluginPath.isEmpty())
{
#ifdef Q_OS_WIN
QLatin1Char pathSep(';');
char pathSep(';');
#else
QLatin1Char pathSep(':');
char pathSep(':');
#endif
foreach (const QString &path, qcaPluginPath.split(pathSep))
foreach (const QByteArray &path, qcaPluginPath.split(pathSep))
{
QString canonicalPath = QDir(path).canonicalPath();
QString canonicalPath = QDir(QFile::decodeName(path)).canonicalPath();
if (!canonicalPath.isEmpty())
paths << canonicalPath;
}

View File

@ -779,13 +779,13 @@ static QString escape_string(const QString &in)
QString out;
for(const QChar &c : in)
{
if(c == '\\')
if(c == QLatin1Char('\\'))
out += QLatin1String("\\\\");
else if(c == ':')
else if(c == QLatin1Char(':'))
out += QLatin1String("\\c");
else if(c == ',')
else if(c == QLatin1Char(','))
out += QLatin1String("\\o");
else if(c == '\n')
else if(c == QLatin1Char('\n'))
out += QLatin1String("\\n");
else
out += c;
@ -798,19 +798,19 @@ static bool unescape_string(const QString &in, QString *_out)
QString out;
for(int n = 0; n < in.length(); ++n)
{
if(in[n] == '\\')
if(in[n] == QLatin1Char('\\'))
{
if(n + 1 >= in.length())
return false;
if(in[n + 1] == '\\')
out += '\\';
else if(in[n + 1] == 'c')
out += ':';
else if(in[n + 1] == 'o')
out += ',';
else if(in[n + 1] == 'n')
out += '\n';
if(in[n + 1] == QLatin1Char('\\'))
out += QLatin1Char('\\');
else if(in[n + 1] == QLatin1Char('c'))
out += QLatin1Char(':');
else if(in[n + 1] == QLatin1Char('o'))
out += QLatin1Char(',');
else if(in[n + 1] == QLatin1Char('n'))
out += QLatin1Char('\n');
else
return false;
++n;
@ -833,7 +833,7 @@ static QString escape_stringlist(const QStringList &in)
static bool unescape_stringlist(const QString &in, QStringList *_out)
{
QStringList out;
QStringList list = in.split(':');
const QStringList list = in.split(QLatin1Char(':'));
for(int n = 0; n < list.count(); ++n)
{
QString str;
@ -1171,7 +1171,7 @@ public:
static bool unescape_config_stringlist(const QString &in, QStringList *_out)
{
QStringList out;
QStringList list = in.split(',');
const QStringList list = in.split(QLatin1Char(','));
for(int n = 0; n < list.count(); ++n)
{
QString str;
@ -1240,7 +1240,7 @@ public:
QVariantMap defaultConfig() const override
{
QVariantMap config;
config[QStringLiteral("formtype")] = "http://affinix.com/qca/forms/default#1.0";
config[QStringLiteral("formtype")] = QStringLiteral("http://affinix.com/qca/forms/default#1.0");
config[QStringLiteral("use_system")] = true;
config[QStringLiteral("roots_file")] = QString();
config[QStringLiteral("skip_plugins")] = QString();
@ -1270,7 +1270,7 @@ public:
QString &s = plugin_priorities[n];
// make sure the entry ends with ":number"
int x = s.indexOf(':');
int x = s.indexOf(QLatin1Char(':'));
bool ok = false;
if(x != -1)
s.midRef(x + 1).toInt(&ok);

View File

@ -58,9 +58,9 @@ QString truncate_log(const QString &in, int size)
// if the previous char is a newline, then this is a perfect cut.
// otherwise, we need to skip to after the next newline.
if(in[at - 1] != '\n')
if(in[at - 1] != QLatin1Char('\n'))
{
while(at < in.length() && in[at] != '\n')
while(at < in.length() && in[at] != QLatin1Char('\n'))
{
++at;
}
@ -68,7 +68,7 @@ QString truncate_log(const QString &in, int size)
// at this point we either reached a newline, or end of
// the entire buffer
if(in[at] == '\n')
if(in[at] == QLatin1Char('\n'))
++at;
}
@ -80,7 +80,7 @@ static ProviderManager *g_pluginman = nullptr;
static void logDebug(const QString &str)
{
if(g_pluginman)
g_pluginman->appendDiagnosticText(str + '\n');
g_pluginman->appendDiagnosticText(str + QLatin1Char('\n'));
}
static bool validVersion(int ver)
@ -801,7 +801,7 @@ int ProviderManager::get_default_priority(const QString &name) const
foreach(const QString &s, list)
{
// qca_default already sanity checks the strings
int n = s.indexOf(':');
int n = s.indexOf(QLatin1Char(':'));
QString sname = s.mid(0, n);
int spriority = s.midRef(n + 1).toInt();
if(sname == name)

View File

@ -805,7 +805,7 @@ BigInteger::BigInteger(int i)
BigInteger::BigInteger(const char *c)
{
d = new Private;
fromString(QString(c));
fromString(QString::fromLatin1(c));
}
BigInteger::BigInteger(const QString &s)
@ -967,7 +967,7 @@ QString BigInteger::toString() const
QString str;
if(d->n.is_negative())
str += '-';
str += QLatin1Char('-');
str += QString::fromLatin1(cs);
return str;
}
@ -979,7 +979,7 @@ bool BigInteger::fromString(const QString &s)
QByteArray cs = s.toLatin1();
bool neg = false;
if(s[0] == '-')
if(s[0] == QLatin1Char('-'))
neg = true;
try

View File

@ -826,7 +826,7 @@ public:
}
if(!charMode)
writeString(promptStr + ": ");
writeString(promptStr + QStringLiteral(": "));
return true;
}
@ -847,14 +847,14 @@ public:
return false;
}
if(c == '\r' || c == '\n')
if(c == QLatin1Char('\r') || c == QLatin1Char('\n'))
{
writeString(QStringLiteral("\n"));
done = true;
return false;
}
if(c == '\b' || c.unicode() == 0x7f)
if(c == QLatin1Char('\b') || c.unicode() == 0x7f)
{
if(at > 0)
{

View File

@ -38,14 +38,14 @@ int main(int argc, char **argv)
return 0;
}
QFile infile(argv[1]);
QFile infile(QString::fromLocal8Bit(argv[1]));
if(!infile.open(QFile::ReadOnly))
{
fprintf(stderr, "Error opening input file\n");
return 1;
}
QFile outfile(argv[2]);
QFile outfile(QString::fromLocal8Bit(argv[2]));
if(!outfile.open(QFile::WriteOnly | QFile::Truncate))
{
fprintf(stderr, "Error opening output file\n");
@ -58,13 +58,13 @@ int main(int argc, char **argv)
while(!ts.atEnd())
{
QString line = ts.readLine();
if(QRegExp("^#").indexIn(line) != -1)
if(QRegExp(QLatin1String("^#")).indexIn(line) != -1)
continue;
if(QRegExp("^\\s*$").indexIn(line) != -1)
if(QRegExp(QLatin1String("^\\s*$")).indexIn(line) != -1)
continue;
line = line.trimmed();
if(QRegExp("CKA_LABEL").indexIn(line) != -1)
if(QRegExp(QLatin1String("CKA_LABEL")).indexIn(line) != -1)
{
QStringList list = splitWithQuotes(line, ' ');
if(list.count() != 3)
@ -78,16 +78,16 @@ int main(int argc, char **argv)
// .replace(QRegExp(","), "_") + ".pem";
continue;
}
else if(QRegExp("CKA_VALUE MULTILINE_OCTAL").indexIn(line) != -1)
else if(QRegExp(QLatin1String("CKA_VALUE MULTILINE_OCTAL")).indexIn(line) != -1)
{
QByteArray buf;
while(!ts.atEnd())
{
line = ts.readLine();
if(QRegExp("^END").indexIn(line) != -1)
if(QRegExp(QLatin1String("^END")).indexIn(line) != -1)
break;
line = line.trimmed();
QRegExp rx("\\\\([0-3][0-7][0-7])");
QRegExp rx(QLatin1String("\\\\([0-3][0-7][0-7])"));
int pos = 0;
while((pos = rx.indexIn(line, pos)) != -1)
{
@ -120,7 +120,7 @@ int find_notchar(const QString &str, char c, int offset)
{
for(int n = offset; n < str.length(); ++n)
{
if(str[n] != c)
if(str[n] != QLatin1Char(c))
return n;
}
return -1;
@ -130,23 +130,23 @@ QStringList splitWithQuotes(const QString &in, char c)
{
QStringList result;
int at = 0;
if(in[at] == c)
if(in[at] == QLatin1Char(c))
at = find_notchar(in, c, at);
while(at != -1)
{
bool quote = false;
int end;
QString str;
if(in[at] == '\"')
if(in[at] == QLatin1Char('\"'))
{
quote = true;
++at;
end = in.indexOf('\"', at);
end = in.indexOf(QLatin1Char('\"'), at);
if(end == -1)
break;
}
else
end = in.indexOf(c, at);
end = in.indexOf(QLatin1Char(c), at);
if(end != -1)
str = in.mid(at, end - at);
@ -157,7 +157,7 @@ QStringList splitWithQuotes(const QString &in, char c)
result += str;
if(quote)
end = in.indexOf(c, end);
end = in.indexOf(QLatin1Char(c), end);
if(end != -1)
at = find_notchar(in, c, end);

View File

@ -136,9 +136,9 @@ static void output_plugin_diagnostic_text()
{
QString str = QCA::pluginDiagnosticText();
QCA::clearPluginDiagnosticText();
if(str[str.length()-1] == '\n')
if(str[str.length()-1] == QLatin1Char('\n'))
str.truncate(str.length()-1);
QStringList lines = str.split('\n', QString::KeepEmptyParts);
QStringList lines = str.split(QLatin1Char('\n'), QString::KeepEmptyParts);
for(int n = 0; n < lines.count(); ++n)
fprintf(stderr, "plugin: %s\n", qPrintable(lines[n]));
}
@ -147,9 +147,9 @@ static void output_keystore_diagnostic_text()
{
QString str = QCA::KeyStoreManager::diagnosticText();
QCA::KeyStoreManager::clearDiagnosticText();
if(str[str.length()-1] == '\n')
if(str[str.length()-1] == QLatin1Char('\n'))
str.truncate(str.length()-1);
QStringList lines = str.split('\n', QString::KeepEmptyParts);
QStringList lines = str.split(QLatin1Char('\n'), QString::KeepEmptyParts);
for(int n = 0; n < lines.count(); ++n)
fprintf(stderr, "keystore: %s\n", qPrintable(lines[n]));
}
@ -157,9 +157,9 @@ static void output_keystore_diagnostic_text()
static void output_message_diagnostic_text(QCA::SecureMessage *msg)
{
QString str = msg->diagnosticText();
if(str[str.length()-1] == '\n')
if(str[str.length()-1] == QLatin1Char('\n'))
str.truncate(str.length()-1);
QStringList lines = str.split('\n', QString::KeepEmptyParts);
QStringList lines = str.split(QLatin1Char('\n'), QString::KeepEmptyParts);
for(int n = 0; n < lines.count(); ++n)
fprintf(stderr, "message: %s\n", qPrintable(lines[n]));
}
@ -325,7 +325,7 @@ private Q_SLOTS:
void prompt_finished()
{
QChar c = prompt->resultChar();
if(c == 'q' || c == 'Q')
if(c == QLatin1Char('q') || c == QLatin1Char('Q'))
{
eventLoop->exit();
return;
@ -447,7 +447,7 @@ private Q_SLOTS:
else
{
if(e.keyStoreInfo().type() == QCA::KeyStore::SmartCard)
name = QStringLiteral("the '") + e.keyStoreInfo().name() + "' token";
name = QStringLiteral("the '") + e.keyStoreInfo().name() + QStringLiteral("' token");
else
name = e.keyStoreInfo().name();
}
@ -532,11 +532,11 @@ private Q_SLOTS:
QString name;
if(!entry.isNull())
{
name = QStringLiteral("Please make ") + entry.name() + " (of " + entry.storeName() + ") available";
name = QStringLiteral("Please make ") + entry.name() + QStringLiteral(" (of ") + entry.storeName() + QStringLiteral(") available");
}
else
{
name = QStringLiteral("Please insert the '") + e.keyStoreInfo().name() + "' token";
name = QStringLiteral("Please insert the '") + e.keyStoreInfo().name() + QStringLiteral("' token");
}
QString str = QStringLiteral("%1 and press Enter (or 'q' to cancel) ...").arg(name);
@ -579,9 +579,9 @@ private Q_SLOTS:
else
{
QChar c = prompt->resultChar();
if(c == '\r' || c == '\n')
if(c == QLatin1Char('\r') || c == QLatin1Char('\n'))
handler.tokenOkay(prompt_id);
else if(c == 'q' || c == 'Q')
else if(c == QLatin1Char('q') || c == QLatin1Char('Q'))
handler.reject(prompt_id);
else
{
@ -742,9 +742,9 @@ static QString line_encode(const QString &in)
QString out;
for(const QChar &c : in)
{
if(c == '\\')
if(c == QLatin1Char('\\'))
out += QStringLiteral("\\\\");
else if(c == '\n')
else if(c == QLatin1Char('\n'))
out += QStringLiteral("\\n");
else
out += c;
@ -757,14 +757,14 @@ static QString line_decode(const QString &in)
QString out;
for(int n = 0; n < in.length(); ++n)
{
if(in[n] == '\\')
if(in[n] == QLatin1Char('\\'))
{
if(n + 1 < in.length())
{
if(in[n + 1] == '\\')
out += '\\';
else if(in[n + 1] == 'n')
out += '\n';
if(in[n + 1] == QLatin1Char('\\'))
out += QLatin1Char('\\');
else if(in[n + 1] == QLatin1Char('n'))
out += QLatin1Char('\n');
++n;
}
}
@ -778,7 +778,7 @@ static QString make_ksentry_string(const QString &id)
{
QString out;
out += QStringLiteral("QCATOOL_KEYSTOREENTRY_1\n");
out += line_encode(id) + '\n';
out += line_encode(id) + QLatin1Char('\n');
return out;
}
@ -946,7 +946,7 @@ static bool validOid(const QString &in)
{
for(const QChar &c : in)
{
if(!c.isDigit() && c != '.')
if(!c.isDigit() && c != QLatin1Char('.'))
return false;
}
return true;
@ -1272,9 +1272,9 @@ static QCA::CertificateOptions promptForCertAttributes(bool advanced, bool req)
if(parts.count() == 1)
out = parts[0];
else if(parts.count() == 2)
out = parts[0] + " and " + parts[1];
out = parts[0] + QStringLiteral(" and ") + parts[1];
else if(parts.count() == 3)
out = parts[0] + ", " + parts[1] + ", and " + parts[2];
out = parts[0] + QStringLiteral(", ") + parts[1] + QStringLiteral(", and ") + parts[2];
printf("Certificate will be valid for %s.\n", qPrintable(out));
break;
}
@ -1510,7 +1510,7 @@ public:
QVariantMap out = orig_config;
// form type
out[QStringLiteral("formtype")] = "http://affinix.com/qca/forms/qca-pkcs11#1.0";
out[QStringLiteral("formtype")] = QLatin1String("http://affinix.com/qca/forms/qca-pkcs11#1.0");
// base settings
out[QStringLiteral("allow_load_rootca")] = allow_load_rootca;
@ -1541,7 +1541,7 @@ public:
bool fromVariantMap(const QVariantMap &in)
{
if(in[QStringLiteral("formtype")] != "http://affinix.com/qca/forms/qca-pkcs11#1.0")
if(in[QStringLiteral("formtype")] != QLatin1String("http://affinix.com/qca/forms/qca-pkcs11#1.0"))
return false;
allow_load_rootca = in[QStringLiteral("allow_load_rootca")].toBool();
@ -1835,7 +1835,7 @@ static QVariantMap provider_config_edit_pkcs11(const QVariantMap &in)
static QVariantMap provider_config_edit(const QVariantMap &in)
{
// see if we have a configurator for a known form type
if(in[QStringLiteral("formtype")] == "http://affinix.com/qca/forms/qca-pkcs11#1.0")
if(in[QStringLiteral("formtype")] == QLatin1String("http://affinix.com/qca/forms/qca-pkcs11#1.0"))
return provider_config_edit_pkcs11(in);
// otherwise, use the generic configurator
@ -1849,7 +1849,7 @@ static QString get_fingerprint(const QCA::Certificate &cert, const QString &hash
for(int n = 0; n < hex.count(); ++n)
{
if(n != 0 && n % 2 == 0)
out += ':';
out += QLatin1Char(':');
out += hex[n];
}
return out;
@ -2106,7 +2106,7 @@ static QString format_pgp_fingerprint(const QString &in)
for(int n = 0; n + 3 < in.length(); n += 4)
{
if(!first)
out += ' ';
out += QLatin1Char(' ');
else
first = false;
out += in.mid(n, 4).toUpper();
@ -2279,12 +2279,12 @@ static QString add_cr(const QString &in)
int at = 0;
while(true)
{
at = out.indexOf('\n', at);
at = out.indexOf(QLatin1Char('\n'), at);
if(at == -1)
break;
if(at - 1 >= 0 && out[at - 1] != '\r')
if(at - 1 >= 0 && out[at - 1] != QLatin1Char('\r'))
{
out.insert(at, '\r');
out.insert(at, QLatin1Char('\r'));
++at;
}
++at;
@ -2303,9 +2303,9 @@ static int indexOf_newline(const QString &in, int offset = 0)
{
for(int n = offset; n < in.length(); ++n)
{
if(n + 1 < in.length() && in[n] == '\r' && in[n + 1] == '\n')
if(n + 1 < in.length() && in[n] == QLatin1Char('\r') && in[n + 1] == QLatin1Char('\n'))
return n;
if(in[n] == '\n')
if(in[n] == QLatin1Char('\n'))
return n;
}
return -1;
@ -2327,7 +2327,7 @@ static int indexOf_doublenewline(const QString &in, int offset = 0)
}
at = n;
if(in[n] == '\n')
if(in[n] == QLatin1Char('\n'))
offset = n + 1;
else
offset = n + 2;
@ -2338,7 +2338,7 @@ static int indexOf_doublenewline(const QString &in, int offset = 0)
// this is so gross
static int newline_len(const QString &in, int offset = 0)
{
if(in[offset] == '\r')
if(in[offset] == QLatin1Char('\r'))
return 2;
else
return 1;
@ -2364,15 +2364,15 @@ static bool open_mime_data_sig(const QString &in, QString *data, QString *sig)
return false;
QString boundary;
QString bregion = in.mid(n, i - n);
n = bregion.indexOf(';');
n = bregion.indexOf(QLatin1Char(';'));
if(n != -1)
boundary = bregion.mid(0, n);
else
boundary = bregion;
if(boundary[0] == '\"')
if(boundary[0] == QLatin1Char('\"'))
boundary.remove(0, 1);
if(boundary[boundary.length() - 1] == '\"')
if(boundary[boundary.length() - 1] == QLatin1Char('\"'))
boundary.remove(boundary.length() - 1, 1);
//printf("boundary: [%s]\n", qPrintable(boundary));
QString boundary_end = QStringLiteral("--") + boundary;
@ -2526,7 +2526,7 @@ static QCA::KeyStoreEntry get_E(const QString &name, bool nopassiveerror = false
QCA::KeyStoreManager::start();
int n = name.indexOf(':');
int n = name.indexOf(QLatin1Char(':'));
if(n != -1)
{
ksm_start_and_wait();
@ -2570,7 +2570,7 @@ static QCA::PrivateKey get_K(const QString &name)
{
QCA::PrivateKey key;
int n = name.indexOf(':');
int n = name.indexOf(QLatin1Char(':'));
if(n != -1)
{
fprintf(stderr, "Error: cannot use store:obj notation for raw private keys.\n");
@ -2792,7 +2792,7 @@ int main(int argc, char **argv)
continue;
QString var;
QString val;
int x = s.indexOf('=');
int x = s.indexOf(QLatin1Char('='));
if(x != -1)
{
var = s.mid(2, x - 2);
@ -3484,7 +3484,7 @@ int main(int argc, char **argv)
}
QFileInfo fi(args[2]);
QString newFileName = fi.baseName() + "_new.p12";
QString newFileName = fi.baseName() + QStringLiteral("_new.p12");
if(key.toFile(newFileName, newpass))
printf("Keybundle saved to %s\n", qPrintable(newFileName));
@ -3922,7 +3922,7 @@ int main(int argc, char **argv)
if(!pgp)
{
QString text = add_cr(QString::fromUtf8(plain));
plain = QString(mime_signpart).arg(text).toUtf8();
plain = QString::fromLatin1(mime_signpart).arg(text).toUtf8();
}
QCA::SecureMessage *msg = new QCA::SecureMessage(sms);
@ -3970,7 +3970,7 @@ int main(int argc, char **argv)
enc.setLineBreaksEnabled(true);
enc.setLineBreaksColumn(76);
QString sigtext = add_cr(enc.arrayToString(output));
QString str = QString(mime_signed).arg(hashName, QString::fromUtf8(plain), sigtext);
QString str = QString::fromLatin1(mime_signed).arg(hashName, QString::fromUtf8(plain), sigtext);
output = str.toUtf8();
}
@ -4073,7 +4073,7 @@ int main(int argc, char **argv)
enc.setLineBreaksEnabled(true);
enc.setLineBreaksColumn(76);
QString enctext = add_cr(enc.arrayToString(output));
QString str = QString(mime_enveloped).arg(enctext);
QString str = QString::fromLatin1(mime_enveloped).arg(enctext);
output = str.toUtf8();
}

View File

@ -77,7 +77,7 @@ void CertUnitTest::nullCert()
foreach(const QString provider, providersToTest) {
if( !QCA::isSupported( "cert", provider ) )
QWARN( QString( "Certificate handling not supported for "+provider).toLocal8Bit().constData() );
QWARN( (QStringLiteral( "Certificate handling not supported for ")+provider).toLocal8Bit().constData() );
else {
QCA::Certificate nullCert;
QVERIFY(nullCert.isNull());
@ -96,7 +96,7 @@ void CertUnitTest::noSuchFile()
foreach(const QString provider, providersToTest) {
if( !QCA::isSupported( "cert", provider ) )
QWARN( QString( "Certificate handling not supported for "+provider).toLocal8Bit().constData() );
QWARN( (QStringLiteral( "Certificate handling not supported for ")+provider).toLocal8Bit().constData() );
else {
QCA::ConvertResult resultNoFile;
QCA::Certificate cert = QCA::Certificate::fromPEMFile( QStringLiteral("thisIsJustaFileNameThatWeDontHave"), &resultNoFile, provider);
@ -114,7 +114,7 @@ void CertUnitTest::CAcertstest()
foreach(const QString provider, providersToTest) {
if( !QCA::isSupported( "cert", provider ) )
QWARN( QString( "Certificate handling not supported for "+provider).toLocal8Bit().constData() );
QWARN( (QStringLiteral( "Certificate handling not supported for ")+provider).toLocal8Bit().constData() );
else {
QCA::ConvertResult resultca1;
QCA::Certificate ca1 = QCA::Certificate::fromPEMFile( QStringLiteral("certs/RootCAcert.pem"), &resultca1, provider);
@ -165,7 +165,7 @@ void CertUnitTest::qualitysslcatest()
foreach(const QString provider, providersToTest) {
if( !QCA::isSupported( "cert", provider ) )
QWARN( QString( "Certificate handling not supported for "+provider).toLocal8Bit().constData() );
QWARN( (QStringLiteral( "Certificate handling not supported for ")+provider).toLocal8Bit().constData() );
else {
QCA::ConvertResult resultca1;
QCA::Certificate ca1 = QCA::Certificate::fromPEMFile( QStringLiteral("certs/QualitySSLIntermediateCA.crt"), &resultca1, provider);
@ -217,7 +217,7 @@ void CertUnitTest::checkExpiredClientCerts()
foreach(const QString provider, providersToTest) {
if( !QCA::isSupported( "cert", provider ) )
QWARN( QString( "Certificate handling not supported for "+provider).toLocal8Bit().constData() );
QWARN( (QStringLiteral( "Certificate handling not supported for ")+provider).toLocal8Bit().constData() );
else {
QCA::ConvertResult resultClient1;
QCA::Certificate client1 = QCA::Certificate::fromPEMFile( QStringLiteral("certs/User.pem"), &resultClient1, provider);
@ -325,7 +325,7 @@ void CertUnitTest::checkClientCerts()
foreach(const QString provider, providersToTest) {
if( !QCA::isSupported( "cert", provider ) )
QWARN( QString( "Certificate handling not supported for "+provider).toLocal8Bit().constData() );
QWARN( (QStringLiteral( "Certificate handling not supported for ")+provider).toLocal8Bit().constData() );
else {
QCA::ConvertResult resultClient2;
QCA::Certificate client2 = QCA::Certificate::fromPEMFile( QStringLiteral("certs/QcaTestClientCert.pem"), &resultClient2, provider);
@ -434,7 +434,7 @@ void CertUnitTest::derCAcertstest()
foreach(const QString provider, providersToTest) {
if( !QCA::isSupported( "cert", provider ) )
QWARN( QString( "Certificate handling not supported for "+provider).toLocal8Bit().constData() );
QWARN( (QStringLiteral( "Certificate handling not supported for ")+provider).toLocal8Bit().constData() );
else {
QFile f(QStringLiteral("certs/ov-root-ca-cert.crt"));
QVERIFY(f.open(QFile::ReadOnly));
@ -508,7 +508,7 @@ void CertUnitTest::altName()
foreach(const QString provider, providersToTest) {
if( !QCA::isSupported( "cert", provider ) )
QWARN( QString( "Certificate handling not supported for "+provider).toLocal8Bit().constData() );
QWARN( (QStringLiteral( "Certificate handling not supported for ")+provider).toLocal8Bit().constData() );
else {
QCA::ConvertResult resultClient1;
QCA::Certificate client1 = QCA::Certificate::fromPEMFile( QStringLiteral("certs/altname.pem"), &resultClient1, provider);
@ -584,7 +584,7 @@ void CertUnitTest::extXMPP()
foreach(const QString provider, providersToTest) {
if( !QCA::isSupported( "cert", provider ) )
QWARN( QString( "Certificate handling not supported for "+provider).toLocal8Bit().constData() );
QWARN( (QStringLiteral( "Certificate handling not supported for ")+provider).toLocal8Bit().constData() );
else {
QCA::ConvertResult resultClient1;
QCA::Certificate client1 = QCA::Certificate::fromPEMFile( QStringLiteral("certs/xmppcert.pem"), &resultClient1, provider);
@ -626,7 +626,7 @@ void CertUnitTest::altNames76()
foreach(const QString provider, providersToTest) {
if( !QCA::isSupported( "cert", provider ) )
QWARN( QString( "Certificate handling not supported for "+provider).toLocal8Bit().constData() );
QWARN( (QStringLiteral( "Certificate handling not supported for ")+provider).toLocal8Bit().constData() );
else {
QCA::ConvertResult resultClient1;
QCA::Certificate client1 = QCA::Certificate::fromPEMFile( QStringLiteral("certs/76.pem"), &resultClient1, provider);
@ -721,7 +721,7 @@ void CertUnitTest::sha256cert()
foreach(const QString provider, providersToTest) {
if( !QCA::isSupported( "cert", provider ) )
QWARN( QString( "Certificate handling not supported for "+provider).toLocal8Bit().constData() );
QWARN( (QStringLiteral( "Certificate handling not supported for ")+provider).toLocal8Bit().constData() );
else {
QFile f(QStringLiteral("certs/RAIZ2007_CERTIFICATE_AND_CRL_SIGNING_SHA256.crt"));
QVERIFY(f.open(QFile::ReadOnly));
@ -760,7 +760,7 @@ void CertUnitTest::checkExpiredServerCerts()
foreach(const QString provider, providersToTest) {
if( !QCA::isSupported( "cert", provider ) )
QWARN( QString( "Certificate handling not supported for "+provider).toLocal8Bit().constData() );
QWARN( (QStringLiteral( "Certificate handling not supported for ")+provider).toLocal8Bit().constData() );
else {
QCA::ConvertResult resultServer1;
QCA::Certificate server1 = QCA::Certificate::fromPEMFile( QStringLiteral("certs/Server.pem"), &resultServer1, provider);
@ -863,7 +863,7 @@ void CertUnitTest::checkServerCerts()
foreach(const QString provider, providersToTest) {
if( !QCA::isSupported( "cert", provider ) )
QWARN( QString( "Certificate handling not supported for "+provider).toLocal8Bit().constData() );
QWARN( (QStringLiteral( "Certificate handling not supported for ")+provider).toLocal8Bit().constData() );
else {
QCA::ConvertResult resultServer1;
QCA::Certificate server1 = QCA::Certificate::fromPEMFile( QStringLiteral("certs/QcaTestServerCert.pem"), &resultServer1, provider);
@ -982,7 +982,7 @@ void CertUnitTest::crl()
foreach(const QString provider, providersToTest) {
if( !QCA::isSupported( "crl", provider ) )
QWARN( QString( "Certificate revocation not supported for "+provider).toLocal8Bit().constData() );
QWARN( (QStringLiteral( "Certificate revocation not supported for ")+provider).toLocal8Bit().constData() );
else {
QCA::CRL emptyCRL;
QVERIFY( emptyCRL.isNull() );
@ -1043,7 +1043,7 @@ void CertUnitTest::crl2()
foreach(const QString provider, providersToTest) {
if( !QCA::isSupported( "crl", provider ) )
QWARN( QString( "Certificate revocation not supported for "+provider).toLocal8Bit().constData() );
QWARN( (QStringLiteral( "Certificate revocation not supported for ")+provider).toLocal8Bit().constData() );
else {
QCA::ConvertResult resultCrl;
QCA::CRL crl1 = QCA::CRL::fromPEMFile( QStringLiteral("certs/GoodCACRL.pem"), &resultCrl, provider);
@ -1110,7 +1110,7 @@ void CertUnitTest::csr()
foreach(const QString provider, providersToTest) {
if( !QCA::isSupported( "csr", provider ) )
QWARN( QString( "Certificate signing requests not supported for "+provider).toLocal8Bit().constData() );
QWARN( (QStringLiteral( "Certificate signing requests not supported for ")+provider).toLocal8Bit().constData() );
else {
QCA::CertificateRequest nullCSR;
QVERIFY( nullCSR.isNull() );
@ -1154,7 +1154,7 @@ void CertUnitTest::csr2()
foreach(const QString provider, providersToTest) {
if( !QCA::isSupported( "csr", provider ) )
QWARN( QString( "Certificate signing requests not supported for "+provider).toLocal8Bit().constData() );
QWARN( (QStringLiteral( "Certificate signing requests not supported for ")+provider).toLocal8Bit().constData() );
else {
QCA::ConvertResult resultCsr;
QCA::CertificateRequest csr1 = QCA::CertificateRequest::fromPEMFile( QStringLiteral("certs/newreq.pem"), &resultCsr, provider);

View File

@ -79,9 +79,9 @@ void CMSut::xcrypt()
foreach(const QString provider, providersToTest) {
if( !QCA::isSupported( "cert", provider ) )
QWARN( QString( "Certificate not supported for "+provider).toLocal8Bit().constData() );
QWARN( (QStringLiteral( "Certificate not supported for ")+provider).toLocal8Bit().constData() );
else if( !QCA::isSupported( "cms", provider ) )
QWARN( QString( "CMS not supported for "+provider).toLocal8Bit().constData() );
QWARN( (QStringLiteral( "CMS not supported for ")+provider).toLocal8Bit().constData() );
else {
QCA::Certificate pubCert = QCA::Certificate::fromPEMFile( QStringLiteral("QcaTestClientCert.pem"),nullptr, provider );
QCOMPARE( pubCert.isNull(), false );
@ -178,9 +178,9 @@ void CMSut::signverify()
foreach(const QString provider, providersToTest) {
if( !QCA::isSupported( "cert", provider ) )
QWARN( QString( "Certificate not supported for "+provider).toLocal8Bit().constData() );
QWARN( (QStringLiteral( "Certificate not supported for ")+provider).toLocal8Bit().constData() );
else if( !QCA::isSupported( "cms", provider ) )
QWARN( QString( "CMS not supported for "+provider).toLocal8Bit().constData() );
QWARN( (QStringLiteral( "CMS not supported for ")+provider).toLocal8Bit().constData() );
else {
QCA::ConvertResult res;
QCA::SecureArray passPhrase = "start";
@ -310,9 +310,9 @@ void CMSut::signverify_message()
foreach(const QString provider, providersToTest) {
if( !QCA::isSupported( "cert", provider ) )
QWARN( QString( "Certificate not supported for "+provider).toLocal8Bit().constData() );
QWARN( (QStringLiteral( "Certificate not supported for ")+provider).toLocal8Bit().constData() );
else if( !QCA::isSupported( "cms", provider ) )
QWARN( QString( "CMS not supported for "+provider).toLocal8Bit().constData() );
QWARN( (QStringLiteral( "CMS not supported for ")+provider).toLocal8Bit().constData() );
else {
QCA::ConvertResult res;
QCA::SecureArray passPhrase = "start";
@ -428,9 +428,9 @@ void CMSut::signverify_message_invalid()
foreach(const QString provider, providersToTest) {
if( !QCA::isSupported( "cert", provider ) )
QWARN( QString( "Certificate not supported for "+provider).toLocal8Bit().constData() );
QWARN( (QStringLiteral( "Certificate not supported for ")+provider).toLocal8Bit().constData() );
else if( !QCA::isSupported( "cms", provider ) )
QWARN( QString( "CMS not supported for "+provider).toLocal8Bit().constData() );
QWARN( (QStringLiteral( "CMS not supported for ")+provider).toLocal8Bit().constData() );
else {
QCA::ConvertResult res;
QCA::SecureArray passPhrase = "start";

View File

@ -219,7 +219,7 @@ void HashUnitTest::md5filetest()
{
foreach(QString provider, providersToTest) {
if(!QCA::isSupported("md5", provider)) {
QFile f1( TEST_DATA_DIR "/data/empty" );
QFile f1( QStringLiteral(TEST_DATA_DIR "/data/empty") );
QVERIFY( f1.open( QIODevice::ReadOnly ) );
{
QCA::Hash hashObj(QStringLiteral("md5"), provider);
@ -228,7 +228,7 @@ void HashUnitTest::md5filetest()
QStringLiteral( "d41d8cd98f00b204e9800998ecf8427e" ) );
}
QFile f2( TEST_DATA_DIR "/data/twobytes" );
QFile f2( QStringLiteral(TEST_DATA_DIR "/data/twobytes") );
QVERIFY( f2.open( QIODevice::ReadOnly ) );
{
QCA::Hash hashObj(QStringLiteral("md5"), provider);
@ -238,7 +238,7 @@ void HashUnitTest::md5filetest()
}
QFile f3( TEST_DATA_DIR "/data/twohundredbytes" );
QFile f3( QStringLiteral(TEST_DATA_DIR "/data/twohundredbytes") );
QVERIFY( f3.open( QIODevice::ReadOnly ) );
{
QCA::Hash hashObj(QStringLiteral("md5"), provider);
@ -368,7 +368,7 @@ void HashUnitTest::sha1longtest()
QCOMPARE( QString(QCA::arrayToHex(shaHash.final().toByteArray())),
QStringLiteral("34aa973cd4c4daa4f61eeb2bdbad27316534016f") );
QFile f1( TEST_DATA_DIR "/data/empty" );
QFile f1( QStringLiteral(TEST_DATA_DIR "/data/empty") );
QVERIFY( f1.open( QIODevice::ReadOnly ) );
{
QCA::Hash hashObj(QStringLiteral("sha1"), provider);
@ -377,7 +377,7 @@ void HashUnitTest::sha1longtest()
QStringLiteral( "da39a3ee5e6b4b0d3255bfef95601890afd80709" ) );
}
QFile f2( TEST_DATA_DIR "/data/twobytes" );
QFile f2( QStringLiteral(TEST_DATA_DIR "/data/twobytes") );
QVERIFY( f2.open( QIODevice::ReadOnly ) );
{
QCA::Hash hashObj(QStringLiteral("sha1"), provider);
@ -386,7 +386,7 @@ void HashUnitTest::sha1longtest()
QStringLiteral( "efbd6de3c51ca16094391e837bf52f7452593e5c" ) );
}
QFile f3( TEST_DATA_DIR "/data/twohundredbytes" );
QFile f3( QStringLiteral(TEST_DATA_DIR "/data/twohundredbytes") );
QVERIFY( f3.open( QIODevice::ReadOnly ) );
{
QCA::Hash hashObj(QStringLiteral("sha1"), provider);

View File

@ -64,7 +64,7 @@ void HexUnitTest::testHexString_data()
QTest::newRow("ABCD") << QStringLiteral("ABCD") << QStringLiteral("41424344");
QTest::newRow("empty") << QString(QLatin1String("")) << QString(QLatin1String(""));
QTest::newRow("abcddef") << QStringLiteral("abcddef") << QStringLiteral("61626364646566");
QTest::newRow("empty too") << QString("\0") << QString(""); // Empty QString. clazy:exclude=qstring-allocations
QTest::newRow("empty too") << QString::fromLatin1("\0") << QString::fromLatin1(""); // Empty QString. clazy:exclude=qstring-allocations
QTest::newRow("BEL") << QStringLiteral("\a") << QStringLiteral("07"); // BEL
QTest::newRow("BS") << QStringLiteral("\b") << QStringLiteral("08"); // BS
QTest::newRow("HT") << QStringLiteral("\t") << QStringLiteral("09"); // HT

View File

@ -462,7 +462,7 @@ void PgpUnitTest::testClearsign()
if(msg2.success()) {
// The trimmed() call is needed because clearsigning
// trashes whitespace
QCOMPARE( QString(msg2.read()).trimmed(), QString(plain).trimmed() );
QCOMPARE( msg2.read().trimmed(), plain.trimmed() );
} else {
qDebug() << "Failure:" << msg2.errorCode();
QFAIL("Failed to verify clearsigned message");
@ -673,7 +673,7 @@ void PgpUnitTest::testSignaturesWithExpiredSubkeys()
QByteArray signedResult = msg1.read();
QVERIFY(msg1.verifySuccess());
QCOMPARE(QString(signedResult).trimmed(), QString(validMessage).trimmed());
QCOMPARE(signedResult.trimmed(), validMessage.trimmed());
// Test signature made by the expired subkey
QByteArray expiredKeySignature("-----BEGIN PGP SIGNED MESSAGE-----\n"

View File

@ -112,7 +112,7 @@ void Pkits::pkits4_1_1()
foreach(const QString provider, providersToTest) {
if( !QCA::isSupported( "cert", provider ) )
QWARN( QString( "Certificate handling not supported for "+provider).toLocal8Bit().constData() );
QWARN( (QStringLiteral( "Certificate handling not supported for ")+provider).toLocal8Bit().constData() );
else {
QCA::Certificate cert = certFromDERFile(QStringLiteral("certs/ValidCertificatePathTest1EE.crt"), provider);
QCOMPARE( cert.isNull(), false );
@ -149,7 +149,7 @@ void Pkits::pkits4_1_2()
foreach(const QString provider, providersToTest) {
if( !QCA::isSupported( "cert", provider ) )
QWARN( QString( "Certificate handling not supported for "+provider).toLocal8Bit().constData() );
QWARN( (QStringLiteral( "Certificate handling not supported for ")+provider).toLocal8Bit().constData() );
else {
QCA::Certificate cert = certFromDERFile(QStringLiteral("certs/InvalidCASignatureTest2EE.crt"), provider);
QCOMPARE( cert.isNull(), false );
@ -186,7 +186,7 @@ void Pkits::pkits4_1_3()
foreach(const QString provider, providersToTest) {
if( !QCA::isSupported( "cert", provider ) )
QWARN( QString( "Certificate handling not supported for "+provider).toLocal8Bit().constData() );
QWARN( (QStringLiteral( "Certificate handling not supported for ")+provider).toLocal8Bit().constData() );
else {
QCA::Certificate cert = certFromDERFile(QStringLiteral("certs/InvalidEESignatureTest3EE.crt"), provider);
QCOMPARE( cert.isNull(), false );
@ -223,7 +223,7 @@ void Pkits::pkits4_1_4()
foreach(const QString provider, providersToTest) {
if( !QCA::isSupported( "cert", provider ) )
QWARN( QString( "Certificate handling not supported for "+provider).toLocal8Bit().constData() );
QWARN( (QStringLiteral( "Certificate handling not supported for ")+provider).toLocal8Bit().constData() );
else {
QCA::Certificate cert = certFromDERFile(QStringLiteral("certs/ValidDSASignaturesTest4EE.crt"), provider);
QCOMPARE( cert.isNull(), false );
@ -260,7 +260,7 @@ void Pkits::pkits4_1_5()
foreach(const QString provider, providersToTest) {
if( !QCA::isSupported( "cert", provider ) )
QWARN( QString( "Certificate handling not supported for "+provider).toLocal8Bit().constData() );
QWARN( (QStringLiteral( "Certificate handling not supported for ")+provider).toLocal8Bit().constData() );
else {
QCA::Certificate cert = certFromDERFile(QStringLiteral("certs/ValidDSAParameterInheritanceTest5EE.crt"), provider);
QCOMPARE( cert.isNull(), false );
@ -304,7 +304,7 @@ void Pkits::pkits4_1_6()
foreach(const QString provider, providersToTest) {
if( !QCA::isSupported( "cert", provider ) )
QWARN( QString( "Certificate handling not supported for "+provider).toLocal8Bit().constData() );
QWARN( (QStringLiteral( "Certificate handling not supported for ")+provider).toLocal8Bit().constData() );
else {
QCA::Certificate cert = certFromDERFile(QStringLiteral("certs/InvalidDSASignatureTest6EE.crt"), provider);
QCOMPARE( cert.isNull(), false );
@ -339,7 +339,7 @@ void Pkits::pkits4_2_1()
foreach(const QString provider, providersToTest) {
if( !QCA::isSupported( "cert", provider ) )
QWARN( QString( "Certificate handling not supported for "+provider).toLocal8Bit().constData() );
QWARN( (QStringLiteral( "Certificate handling not supported for ")+provider).toLocal8Bit().constData() );
else {
QCA::Certificate cert = certFromDERFile(QStringLiteral("certs/InvalidCAnotBeforeDateTest1EE.crt"), provider);
QCOMPARE( cert.isNull(), false );
@ -374,7 +374,7 @@ void Pkits::pkits4_2_2()
foreach(const QString provider, providersToTest) {
if( !QCA::isSupported( "cert", provider ) )
QWARN( QString( "Certificate handling not supported for "+provider).toLocal8Bit().constData() );
QWARN( (QStringLiteral( "Certificate handling not supported for ")+provider).toLocal8Bit().constData() );
else {
QCA::Certificate cert = certFromDERFile(QStringLiteral("certs/InvalidEEnotBeforeDateTest2EE.crt"), provider);
QCOMPARE( cert.isNull(), false );
@ -409,7 +409,7 @@ void Pkits::pkits4_2_3()
foreach(const QString provider, providersToTest) {
if( !QCA::isSupported( "cert", provider ) )
QWARN( QString( "Certificate handling not supported for "+provider).toLocal8Bit().constData() );
QWARN( (QStringLiteral( "Certificate handling not supported for ")+provider).toLocal8Bit().constData() );
else {
QCA::Certificate cert = certFromDERFile(QStringLiteral("certs/Validpre2000UTCnotBeforeDateTest3EE.crt"), provider);
QCOMPARE( cert.isNull(), false );
@ -444,7 +444,7 @@ void Pkits::pkits4_2_4()
foreach(const QString provider, providersToTest) {
if( !QCA::isSupported( "cert", provider ) )
QWARN( QString( "Certificate handling not supported for "+provider).toLocal8Bit().constData() );
QWARN( (QStringLiteral( "Certificate handling not supported for ")+provider).toLocal8Bit().constData() );
else {
QCA::Certificate cert = certFromDERFile(QStringLiteral("certs/ValidGeneralizedTimenotBeforeDateTest4EE.crt"), provider);
QCOMPARE( cert.isNull(), false );
@ -480,7 +480,7 @@ void Pkits::pkits4_2_5()
foreach(const QString provider, providersToTest) {
if( !QCA::isSupported( "cert", provider ) )
QWARN( QString( "Certificate handling not supported for "+provider).toLocal8Bit().constData() );
QWARN( (QStringLiteral( "Certificate handling not supported for ")+provider).toLocal8Bit().constData() );
else {
QCA::Certificate cert = certFromDERFile(QStringLiteral("certs/InvalidCAnotAfterDateTest5EE.crt"), provider);
QCOMPARE( cert.isNull(), false );
@ -515,7 +515,7 @@ void Pkits::pkits4_2_6()
foreach(const QString provider, providersToTest) {
if( !QCA::isSupported( "cert", provider ) )
QWARN( QString( "Certificate handling not supported for "+provider).toLocal8Bit().constData() );
QWARN( (QStringLiteral( "Certificate handling not supported for ")+provider).toLocal8Bit().constData() );
else {
QCA::Certificate cert = certFromDERFile(QStringLiteral("certs/InvalidEEnotAfterDateTest6EE.crt"), provider);
QCOMPARE( cert.isNull(), false );
@ -550,7 +550,7 @@ void Pkits::pkits4_2_7()
foreach(const QString provider, providersToTest) {
if( !QCA::isSupported( "cert", provider ) )
QWARN( QString( "Certificate handling not supported for "+provider).toLocal8Bit().constData() );
QWARN( (QStringLiteral( "Certificate handling not supported for ")+provider).toLocal8Bit().constData() );
else {
QCA::Certificate cert = certFromDERFile(QStringLiteral("certs/Invalidpre2000UTCEEnotAfterDateTest7EE.crt"), provider);
QCOMPARE( cert.isNull(), false );
@ -585,7 +585,7 @@ void Pkits::pkits4_2_8()
foreach(const QString provider, providersToTest) {
if( !QCA::isSupported( "cert", provider ) )
QWARN( QString( "Certificate handling not supported for "+provider).toLocal8Bit().constData() );
QWARN( (QStringLiteral( "Certificate handling not supported for ")+provider).toLocal8Bit().constData() );
else {
QCA::Certificate cert = certFromDERFile(QStringLiteral("certs/ValidGeneralizedTimenotAfterDateTest8EE.crt"), provider);
QCOMPARE( cert.isNull(), false );
@ -620,7 +620,7 @@ void Pkits::pkits4_3_1()
foreach(const QString provider, providersToTest) {
if( !QCA::isSupported( "cert", provider ) )
QWARN( QString( "Certificate handling not supported for "+provider).toLocal8Bit().constData() );
QWARN( (QStringLiteral( "Certificate handling not supported for ")+provider).toLocal8Bit().constData() );
else {
QCA::Certificate cert = certFromDERFile(QStringLiteral("certs/InvalidNameChainingTest1EE.crt"), provider);
QCOMPARE( cert.isNull(), false );
@ -655,7 +655,7 @@ void Pkits::pkits4_3_2()
foreach(const QString provider, providersToTest) {
if( !QCA::isSupported( "cert", provider ) )
QWARN( QString( "Certificate handling not supported for "+provider).toLocal8Bit().constData() );
QWARN( (QStringLiteral( "Certificate handling not supported for ")+provider).toLocal8Bit().constData() );
else {
QCA::Certificate cert = certFromDERFile(QStringLiteral("certs/InvalidNameChainingOrderTest2EE.crt"), provider);
QCOMPARE( cert.isNull(), false );
@ -690,7 +690,7 @@ void Pkits::pkits4_3_3()
foreach(const QString provider, providersToTest) {
if( !QCA::isSupported( "cert", provider ) )
QWARN( QString( "Certificate handling not supported for "+provider).toLocal8Bit().constData() );
QWARN( (QStringLiteral( "Certificate handling not supported for ")+provider).toLocal8Bit().constData() );
else {
QCA::Certificate cert = certFromDERFile(QStringLiteral("certs/ValidNameChainingWhitespaceTest3EE.crt"), provider);
QCOMPARE( cert.isNull(), false );
@ -726,7 +726,7 @@ void Pkits::pkits4_3_4()
foreach(const QString provider, providersToTest) {
if( !QCA::isSupported( "cert", provider ) )
QWARN( QString( "Certificate handling not supported for "+provider).toLocal8Bit().constData() );
QWARN( (QStringLiteral( "Certificate handling not supported for ")+provider).toLocal8Bit().constData() );
else {
QCA::Certificate cert = certFromDERFile(QStringLiteral("certs/ValidNameChainingWhitespaceTest4EE.crt"), provider);
QCOMPARE( cert.isNull(), false );
@ -761,7 +761,7 @@ void Pkits::pkits4_3_5()
foreach(const QString provider, providersToTest) {
if( !QCA::isSupported( "cert", provider ) )
QWARN( QString( "Certificate handling not supported for "+provider).toLocal8Bit().constData() );
QWARN( (QStringLiteral( "Certificate handling not supported for ")+provider).toLocal8Bit().constData() );
else {
QCA::Certificate cert = certFromDERFile(QStringLiteral("certs/ValidNameChainingCapitalizationTest5EE.crt"), provider);
QCOMPARE( cert.isNull(), false );
@ -796,7 +796,7 @@ void Pkits::pkits4_3_6()
foreach(const QString provider, providersToTest) {
if( !QCA::isSupported( "cert", provider ) )
QWARN( QString( "Certificate handling not supported for "+provider).toLocal8Bit().constData() );
QWARN( (QStringLiteral( "Certificate handling not supported for ")+provider).toLocal8Bit().constData() );
else {
QCA::Certificate cert = certFromDERFile(QStringLiteral("certs/ValidNameUIDsTest6EE.crt"), provider);
QCOMPARE( cert.isNull(), false );
@ -832,7 +832,7 @@ void Pkits::pkits4_3_7()
foreach(const QString provider, providersToTest) {
if( !QCA::isSupported( "cert", provider ) )
QWARN( QString( "Certificate handling not supported for "+provider).toLocal8Bit().constData() );
QWARN( (QStringLiteral( "Certificate handling not supported for ")+provider).toLocal8Bit().constData() );
else {
QCA::Certificate cert = certFromDERFile(QStringLiteral("certs/ValidRFC3280MandatoryAttributeTypesTest7EE.crt"), provider);
QCOMPARE( cert.isNull(), false );
@ -869,7 +869,7 @@ void Pkits::pkits4_3_8()
foreach(const QString provider, providersToTest) {
if( !QCA::isSupported( "cert", provider ) )
QWARN( QString( "Certificate handling not supported for "+provider).toLocal8Bit().constData() );
QWARN( (QStringLiteral( "Certificate handling not supported for ")+provider).toLocal8Bit().constData() );
else {
QCA::Certificate cert = certFromDERFile(QStringLiteral("certs/ValidRFC3280OptionalAttributeTypesTest8EE.crt"), provider);
QCOMPARE( cert.isNull(), false );
@ -905,7 +905,7 @@ void Pkits::pkits4_3_9()
foreach(const QString provider, providersToTest) {
if( !QCA::isSupported( "cert", provider ) )
QWARN( QString( "Certificate handling not supported for "+provider).toLocal8Bit().constData() );
QWARN( (QStringLiteral( "Certificate handling not supported for ")+provider).toLocal8Bit().constData() );
else {
QCA::Certificate cert = certFromDERFile(QStringLiteral("certs/ValidUTF8StringEncodedNamesTest9EE.crt"), provider);
QCOMPARE( cert.isNull(), false );
@ -941,7 +941,7 @@ void Pkits::pkits4_3_10()
foreach(const QString provider, providersToTest) {
if( !QCA::isSupported( "cert", provider ) )
QWARN( QString( "Certificate handling not supported for "+provider).toLocal8Bit().constData() );
QWARN( (QStringLiteral( "Certificate handling not supported for ")+provider).toLocal8Bit().constData() );
else {
QCA::Certificate cert = certFromDERFile(QStringLiteral("certs/ValidRolloverfromPrintableStringtoUTF8StringTest10EE.crt"), provider);
QCOMPARE( cert.isNull(), false );
@ -978,7 +978,7 @@ void Pkits::pkits4_3_11()
foreach(const QString provider, providersToTest) {
if( !QCA::isSupported( "cert", provider ) )
QWARN( QString( "Certificate handling not supported for "+provider).toLocal8Bit().constData() );
QWARN( (QStringLiteral( "Certificate handling not supported for ")+provider).toLocal8Bit().constData() );
else {
QCA::Certificate cert = certFromDERFile(QStringLiteral("certs/ValidUTF8StringCaseInsensitiveMatchTest11EE.crt"), provider);
QCOMPARE( cert.isNull(), false );
@ -1017,7 +1017,7 @@ void Pkits::pkits4_4_1()
foreach(const QString provider, providersToTest) {
if( !QCA::isSupported( "cert", provider ) )
QWARN( QString( "Certificate handling not supported for "+provider).toLocal8Bit().constData() );
QWARN( (QStringLiteral( "Certificate handling not supported for ")+provider).toLocal8Bit().constData() );
else {
QCA::Certificate cert = certFromDERFile(QStringLiteral("certs/InvalidMissingCRLTest1EE.crt"), provider);
QCOMPARE( cert.isNull(), false );
@ -1052,7 +1052,7 @@ void Pkits::pkits4_4_2()
foreach(const QString provider, providersToTest) {
if( !QCA::isSupported( "cert", provider ) )
QWARN( QString( "Certificate handling not supported for "+provider).toLocal8Bit().constData() );
QWARN( (QStringLiteral( "Certificate handling not supported for ")+provider).toLocal8Bit().constData() );
else {
QCA::Certificate cert = certFromDERFile(QStringLiteral("certs/InvalidRevokedCATest2EE.crt"), provider);
QCOMPARE( cert.isNull(), false );
@ -1097,7 +1097,7 @@ void Pkits::pkits4_4_3()
foreach(const QString provider, providersToTest) {
if( !QCA::isSupported( "cert", provider ) )
QWARN( QString( "Certificate handling not supported for "+provider).toLocal8Bit().constData() );
QWARN( (QStringLiteral( "Certificate handling not supported for ")+provider).toLocal8Bit().constData() );
else {
QCA::Certificate cert = certFromDERFile(QStringLiteral("certs/InvalidRevokedEETest3EE.crt"), provider);
QCOMPARE( cert.isNull(), false );

View File

@ -64,7 +64,7 @@ void RSAUnitTest::testrsa()
if(!QCA::isSupported("pkey", provider) ||
!QCA::PKey::supportedTypes(provider).contains(QCA::PKey::RSA) ||
!QCA::PKey::supportedIOTypes(provider).contains(QCA::PKey::RSA))
QWARN(QString("RSA not supported for "+provider).toLocal8Bit().constData());
QWARN((QStringLiteral("RSA not supported for ")+provider).toLocal8Bit().constData());
else {
QCA::KeyGenerator keygen;
QCOMPARE( keygen.isBusy(), false );

View File

@ -110,7 +110,7 @@ void SymmetricKeyUnitTest::weakKey()
QFETCH( QByteArray, keyText );
QFETCH( bool, isWeak );
QCA::SymmetricKey key( QCA::hexToArray( QByteArray( keyText ) ) );
QCA::SymmetricKey key( QCA::hexToArray( QString::fromLatin1(keyText) ) );
QCOMPARE( key.isWeakDESKey(), isWeak );
}