×

Discussion Board

Results 1 to 10 of 10
  1. #1
    Registered User
    Join Date
    Sep 2008
    Posts
    5

    How can I use RSA classes of cryptography api?

    Hi All,

    how can I use RSA classes of cryptography api?

    I try to use function DecryptL() of class CRSAPKCS1v15Decryptor.

    But the function is not available.
    Compilation OK.
    At debug following hint is given:
    dec -> DecryptL(cipherText,plainText);
    dec -> DecryptL = identifier is not a valid struct/union/class member

    CRSAPKCS1v15Decryptor* dec = CRSAPKCS1v15Decryptor::NewL((CRSAPrivateKey&)privKey);

    Thanks,
    Andree

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,674

    Re: How can I use RSA classes of cryptography api?

    CRSAPKCS1v15Decryptor::DecryptL is properly declared in cryptoasymmetric.h, re-check what you are doing (for example make sure that "dec" is accessible in the given scope).
    Last edited by ltomuta; 2008-09-16 at 17:56. Reason: Removed unintended smilies

  3. #3
    Registered User
    Join Date
    Sep 2008
    Posts
    5

    Re: How can I use RSA classes of cryptography api?

    Quote Originally Posted by wizard_hu_ View Post
    CRSAPKCS1v15Decryptor:ecryptL is properly declared in cryptoasymmetric.h, re-check what you are doing (for example make sure that "dec" is accessible in the given scope).
    I'm sure "dec" is accessible in the given scope.

    Enclosed the given function.

    Code:
    void CDecryptView::decryptData() {
    
         _LIT8(aD,"12345678");
         _LIT8(aN,"123456789");
         
         //Prepare Key & Decryptor
        RInteger iN = RInteger::NewL(aN);
        RInteger iD = RInteger::NewL(aD);
        
        const CRSAPrivateKeyStandard* privKey = CRSAPrivateKeyStandard::NewLC(iN, iD);
        CRSAPKCS1v15Decryptor* dec = CRSAPKCS1v15Decryptor::NewL((CRSAPrivateKey&)privKey);
        
        //Prepare filesessionserver
        RFs fsSession;
        fsSession.Connect();
        RFile inFile, outFile;
        
        //Open, Read, Flush and Close inputFile
        inFile.Open(fsSession,_L("C:\\shared\\test_0_cipher.txt"),EFileRead);
        TBuf8<1024> cipherText;
        TInt size;
        inFile.Size(size);
        inFile.Read(cipherText,size);
        inFile.Flush();
        inFile.Close();
        
        //Decrypt
        TBuf8<1024> plainText;
        TInt maxInputLength;
        TInt maxOutputLength;
        maxInputLength = dec->MaxInputLength(); // no error
        maxOutputLength = dec->MaxOutputLength(); // no error
    
        dec->DecryptL(cipherText,plainText); // ERROR
        
        //Open, Write, Flush and Close outputFile
        TInt err = outFile.Open(fsSession,_L("c:\\shared\\test_0_cipher_out.txt"),EFileWrite);
        if (err==KErrNotFound) // 
        outFile.Create(fsSession,_L("c:\\shared\\test_0_cipher_out.txt"),EFileStreamText|EFileWrite|EFileShareAny);
    
        outFile.Write(plainText,size);
        outFile.Flush();
        outFile.Close();
        
        RFileLogger::WriteFormat(fileDir, fileName, EFileLoggingModeAppend,
                      Exception, 10000);
    
    }
    Any other idea?


    Thanks,

    Andree

  4. #4
    Super Contributor
    Join Date
    Nov 2004
    Location
    Wiltshire, UK
    Posts
    3,644

    Re: How can I use RSA classes of cryptography api?

    This looks like you have not #included cryptoasymetric.h
    Download Symbian OS now! [url]http://developer.symbian.org[/url]

  5. #5
    Registered User
    Join Date
    Sep 2008
    Posts
    5

    Re: How can I use RSA classes of cryptography api?

    Quote Originally Posted by Paul.Todd View Post
    This looks like you have not #included cryptoasymetric.h
    In this case previous lines must also faulty. Or not?

    The line is available.

  6. #6
    Super Contributor
    Join Date
    Nov 2004
    Location
    Wiltshire, UK
    Posts
    3,644

    Re: How can I use RSA classes of cryptography api?

    No, because you can forward declare the class asits a pointer
    Download Symbian OS now! [url]http://developer.symbian.org[/url]

  7. #7
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,674

    Re: How can I use RSA classes of cryptography api?

    The strange thing is that the NewL seems to be accepted just a few lines above. Though it might happen that the error messages are not ordered by lines, and the NewL also has its error somewhere else.

    EDIT: oops, I was trying to reply #4...

  8. #8
    Super Contributor
    Join Date
    Nov 2004
    Location
    Wiltshire, UK
    Posts
    3,644

    Re: How can I use RSA classes of cryptography api?

    Well it works for us
    CRSAPKCS1v15Encryptor * encryptor = CRSAPKCS1v15Encryptor::NewLC(aPublic);
    CRSAPKCS1v15Decryptor * decryptor = CRSAPKCS1v15Decryptor::NewLC(aPrivate);

    ....

    encryptor->EncryptL(raw, encrypted);
    decryptor->DecryptL(encrypted, decrypted);
    test(decrypted.Compare(raw) == 0);
    CleanupStack::PopAndDestroy(2, encryptor);

    In the original example there was a space between the -> and Decrypt is that the case.

    Can you also post the actual error from carbide or the output build log
    Download Symbian OS now! [url]http://developer.symbian.org[/url]

  9. #9
    Registered User
    Join Date
    Sep 2008
    Posts
    5

    Re: How can I use RSA classes of cryptography api?

    Quote Originally Posted by Paul.Todd View Post
    In the original example there was a space between the -> and Decrypt is that the case.
    Orignal example? What do you think?
    I cleared the spaces.

    Quote Originally Posted by Paul.Todd View Post
    Can you also post the actual error from carbide or the output build log
    Please patient. I must restart my computer.

  10. #10
    Registered User
    Join Date
    Sep 2008
    Posts
    5

    Re: How can I use RSA classes of cryptography api?

    I replace the Sourceline with

    Code:
    TRAPD(err3, dec->DecryptL(cipherText,plainText));
    After execution err3 is -5 (= KErrNotSupported = The operation requested is not supported).

    Has anybody an validated example?
    Ideally as Carbide.c++ 1.3 project.

    Thanks,
    Andree

Similar Threads

  1. Is there a C++ API for the video player
    By avbrozhko in forum Symbian
    Replies: 9
    Last Post: 2008-06-06, 14:34
  2. If the JSR-179 API is included in a mobile phone...
    By Summerman in forum Mobile Java Networking & Messaging & Security
    Replies: 5
    Last Post: 2006-10-05, 00:52
  3. public key cryptography (RSA)
    By Alex Mizrahi in forum Symbian
    Replies: 2
    Last Post: 2006-08-09, 18:40
  4. ICE Technology released iPush J2ME Package for MIDP 2.0 API
    By rockw99 in forum News and Announcements
    Replies: 0
    Last Post: 2006-06-22, 10:21
  5. User Comments and Examples into API Docs
    By jyrkiettila in forum Feedback - Nokia Developer Services & Infrastructure
    Replies: 4
    Last Post: 2006-04-21, 11:04

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×