#7 new
Gary.Wzl

Using HMAC-SHA1 in qOAuth on Symbian

Reported by Gary.Wzl | April 17th, 2010 @ 12:28 PM

Hi,ayoy,long time no see,I hope this can be useful for me to make qOauth support Symbian
I am very lazy,So I copy main point of this blog I post(http://garywang77.blogspot.com/2010/04/using-hmac-sha1-in-qoauth-on...)
There is a easy way,Look this.
How to generate oauth signature using HMAC-SHA1 in Symbian C++
(http://wiki.forum.nokia.com/index.php/How_to_generate_oauth_signatu...) Follow These Tips .
we just need to do little stuff
1.add macro Q_OS_SYMBIAN to remove anything about QCA from .cpp or .h in qOAuth when Precompiled
2.generating your own random number method to replace the following codes
QCA::InitializationVector iv( 16 );
QByteArray nonce = iv.toByteArray().toHex();
3.add these lines in function:createSignature

ifdnef Q_OS_SYMBIAN

..... ..... .....

else

CSHA1 sha=CSHA1::NewL();
TBuf8<100> keyVal;
keyVal.Copy(_L8(QByteArray(consumerSecret + "&" + tokenSecret).constData()));
CHMAC
hmac=CHMAC::NewL(keyVal,sha);
TBuf8<1024> baseString;
TPtrC8 hashedSig(hmac->Hash(baseString));
TImCodecB64 b64enc;
b64enc.Initialise();
HBufC8* buf = HBufC8::NewL(hashedSig.Length() * 2);
buf->Des().Copy(hashedSig);
TBuf8<512> result;
b64enc.Encode(buf->Des(),result);
result.Copy(result.Left(result.Length()));
if(hmac)
{

delete hmac;
hmac=NULL;

} digest = QByteArray::fromRawData((char*)result.Ptr(),result.Length());

endif

That's all ;-)

Comments and changes to this ticket

  • ayoy

    ayoy June 16th, 2010 @ 09:59 PM

    • Assigned user set to “ayoy”

    Aaaaaah! Sorry for the delay :| I'm too busy for anything the last few months :/

    Many thanks for your input :) Would you be so kind and create a patch? Or even a commit, so that I could pick it and apply to the tree? I'd be extremely grateful!

    Cheers,
    Dominik

  • gardiol

    gardiol September 24th, 2010 @ 10:35 AM

    • Milestone order changed from “0” to “0”

    Guys, this patch is COMPLETELY BROKEN in several places.
    This code works (see in action on code.google.com/p/qtfreetrack):

        CSHA1* sha=CSHA1::NewL();
        TBuf8<100> keyVal;
        keyVal.Copy(_L8(QByteArray(consumerSecret.toPercentEncoding() + "&" +
                                   tokenSecret.toPercentEncoding()).constData()));
    
        CHMAC* hmac=CHMAC::NewL(keyVal,sha);
        TBuf8<1024> baseString;
        baseString.Copy(_L8(signatureBaseString.constData() ) );
        TPtrC8 hashedSig(hmac->Hash(baseString));
    
        TImCodecB64 b64enc;
        b64enc.Initialise();
        HBufC8* buf = HBufC8::NewL(hashedSig.Length() * 2);
        buf->Des().Copy(hashedSig);
        TBuf8<512> result;
        // encode your signature into base64 or encoding scheme required
        b64enc.Encode(  buf->Des(),result);
        result.Copy(result.Left(result.Length()));
        if(hmac)
        {
            delete hmac;
            hmac=NULL;
         }
        digest = QByteArray::fromRawData((char*)result.Ptr(),result.Length());
    

    this works.

  • Gary.Wzl

    Gary.Wzl September 24th, 2010 @ 12:15 PM

    long time no see,ayoy
    haha........
    gardiol is right.
    It seems to be necessary to port qOAuth to Symbian.
    awesome

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

QOAuth is a Qt-based C++ library providing means for communicating with services supporting OAuth authorization scheme.

Shared Ticket Bins

People watching this ticket

Pages