diff --git a/data/js/tomahawk.js b/data/js/tomahawk.js index b0ba05eeb..7f32ca1b5 100644 --- a/data/js/tomahawk.js +++ b/data/js/tomahawk.js @@ -312,6 +312,11 @@ Tomahawk.asyncRequest = function (url, callback, extraHeaders, options) { }; Tomahawk.sha256 = Tomahawk.sha256 || CryptoJS.SHA256; +Tomahawk.md5 = Tomahawk.md5 || CryptoJS.MD5; +// Return a HMAC (md5) signature of the input text with the desired key +Tomahawk.hmac = function (key, message) { + return CryptoJS.HmacMD5(message, key); +}; // some aliases Tomahawk.setTimeout = Tomahawk.setTimeout || window.setTimeout; diff --git a/src/libtomahawk/resolvers/JSResolverHelper.cpp b/src/libtomahawk/resolvers/JSResolverHelper.cpp index 067451a1d..07045ae01 100644 --- a/src/libtomahawk/resolvers/JSResolverHelper.cpp +++ b/src/libtomahawk/resolvers/JSResolverHelper.cpp @@ -40,7 +40,6 @@ #include "UrlHandler.h" #include -#include #include #include #include @@ -416,39 +415,6 @@ JSResolverHelper::setResolverConfig( const QVariantMap& config ) } -QString -JSResolverHelper::hmac( const QByteArray& key, const QByteArray &input ) -{ -#ifdef QCA2_FOUND - if ( !QCA::isSupported( "hmac(md5)" ) ) - { - tLog() << "HMAC(md5) not supported with qca-ossl plugin, or qca-ossl plugin is not installed! Unable to generate signature!"; - return QByteArray(); - } - - QCA::MessageAuthenticationCode md5hmac1( "hmac(md5)", QCA::SecureArray() ); - QCA::SymmetricKey keyObject( key ); - md5hmac1.setup( keyObject ); - - md5hmac1.update( QCA::SecureArray( input ) ); - QCA::SecureArray resultArray = md5hmac1.final(); - - QString result = QCA::arrayToHex( resultArray.toByteArray() ); - return result.toUtf8(); -#else - tLog() << "Tomahawk compiled without QCA support, cannot generate HMAC signature"; - return QString(); -#endif -} - - -QString -JSResolverHelper::md5( const QByteArray& input ) -{ - QByteArray const digest = QCryptographicHash::hash( input, QCryptographicHash::Md5 ); - return QString::fromLatin1( digest.toHex() ); -} - void JSResolverHelper::addCustomUrlHandler( const QString& protocol, const QString& callbackFuncName, diff --git a/src/libtomahawk/resolvers/JSResolverHelper.h b/src/libtomahawk/resolvers/JSResolverHelper.h index be52b31f5..2b632f81c 100644 --- a/src/libtomahawk/resolvers/JSResolverHelper.h +++ b/src/libtomahawk/resolvers/JSResolverHelper.h @@ -42,10 +42,6 @@ public: JSResolverHelper( const QString& scriptPath, JSResolver* parent ); void setResolverConfig( const QVariantMap& config ); - // Return a HMAC (md5) signature of the input text with the desired key - Q_INVOKABLE QString hmac( const QByteArray& key, const QByteArray& input ); - Q_INVOKABLE QString md5( const QByteArray& input ); - Q_INVOKABLE void addCustomUrlHandler( const QString& protocol, const QString& callbackFuncName, const QString& isAsynchronous = "false" ); Q_INVOKABLE void reportStreamUrl( const QString& qid, const QString& streamUrl ); Q_INVOKABLE void reportStreamUrl( const QString& qid, const QString& streamUrl, const QVariantMap& headers );