diff --git a/src/s3access.cpp b/src/s3access.cpp index a1ffb9d..3df6dc3 100644 --- a/src/s3access.cpp +++ b/src/s3access.cpp @@ -4,8 +4,11 @@ extern "C" { #include +// Needed for performOp #include "s3access.h" +#include + S3Result::S3Result(QNetworkReply *reply, QObject *parent) : QObject(parent) , m_reply(reply) { @@ -130,7 +133,7 @@ S3ListResult *S3Access::list(QString const &prefix) QNetworkReply *S3Access::performOp(Method method, QString const &url, QIODevice *in, const char *content_md5, const char *content_type, QString signDataKey) { QNetworkRequest request; - char *digest; + unsigned char digest[EVP_MAX_MD_SIZE]; QString methodStr; QString date = QDateTime::currentDateTimeUtc().toString(Qt::RFC2822Date); QNetworkReply *reply; @@ -157,10 +160,10 @@ QNetworkReply *S3Access::performOp(Method method, QString const &url, QIODevice signData+=signDataKey; request.setUrl(QUrl(QString(url))); - digest = s3_hmac_sign(m_secret.toLatin1().data(), signData.toLatin1().data(), signData.toLatin1().size()); + HMAC(EVP_sha1(), m_secret.toLatin1().data(), m_secret.toLatin1().size(), (unsigned char*)signData.toLatin1().data(), signData.toLatin1().size(), digest, (unsigned int*)EVP_MAX_MD_SIZE); request.setRawHeader("Date", date.toLocal8Bit()); - request.setRawHeader("Authorization", QString(QStringLiteral("AWS %1:%2")).arg(m_id).arg(digest).toLocal8Bit()); + request.setRawHeader("Authorization", QString(QStringLiteral("AWS %1:%2")).arg(m_id).arg((char*)digest).toLocal8Bit()); request.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true); qDebug() << "Request to: " << url; @@ -188,7 +191,6 @@ QNetworkReply *S3Access::performOp(Method method, QString const &url, QIODevice break; } - free(digest); return reply; }