Results 1 to 2 of 2

Thread: qca, qca-gnupg Not able to open files

  1. #1
    Join Date
    Dec 2010
    Posts
    44
    Thanks
    9
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default qca, qca-gnupg Not able to open files

    Hi All,

    I am a total newbie. I am going crazy with a problem. I am using QCA and qca-gnupg.
    I am trying to simply import a secret key. The code is:
    Header File:
    Qt Code:
    1. #ifndef MYGPG_H
    2. #define MYGPG_H
    3.  
    4. #include <QDebug>
    5. #include <QObject>
    6. #include <QtCrypto>
    7.  
    8. class PassphraseHandler: public QObject
    9. {
    10. Q_OBJECT
    11. public:
    12. QCA::EventHandler handler;
    13. PassphraseHandler(QObject *parent = 0);
    14.  
    15. private slots:
    16. void eh_eventReady(int id, const QCA::Event &event);
    17.  
    18. };
    19. class myKeyLoader : public QObject
    20. {
    21. Q_OBJECT
    22.  
    23. public:
    24. myKeyLoader(QObject* parent = NULL);
    25. public slots:
    26. void start();
    27. };
    28.  
    29. #endif // MYGPG_H
    To copy to clipboard, switch view to plain text mode 
    Source file:
    Qt Code:
    1. #include "mygpg.h"
    2.  
    3.  
    4. PassphraseHandler::PassphraseHandler(QObject *parent) : QObject(parent)
    5. {
    6. connect(&handler, SIGNAL(eventReady(int, const QCA::Event &)),
    7. SLOT(eh_eventReady(int, const QCA::Event &)));
    8. handler.start();
    9. }
    10.  
    11.  
    12. void PassphraseHandler::eh_eventReady(int id, const QCA::Event &event)
    13. {
    14. if(event.type() == QCA::Event::Password)
    15. {
    16. QCA::SecureArray pass;
    17. QCA::ConsolePrompt prompt;
    18. prompt.getHidden("Passphrase");
    19. prompt.waitForFinished();
    20. pass = prompt.result();
    21. handler.submitPassword(id, pass);
    22. }
    23. else
    24. handler.reject(id);
    25. }
    26. myKeyLoader::myKeyLoader(QObject* parent)
    27. :QObject(parent)
    28. {
    29.  
    30. }
    31.  
    32. void myKeyLoader::start()
    33. {
    34. QCA::ConvertResult* result = new QCA::ConvertResult;
    35. QCA::PGPKey myPgpKey = QCA::PGPKey::fromFile("private_key.pkr",result,"qca-gnupg");
    36. qDebug()<<"pgp:"<<*result;
    37. qDebug()<<"can decrypt:"<<myPgpKey.inKeyring();
    38. }
    To copy to clipboard, switch view to plain text mode 
    main.cpp:
    Qt Code:
    1. #include <QtCore/QCoreApplication>
    2. #include <QDebug>
    3. #include <QFile>
    4. #include <QTimer>
    5.  
    6. #include "mygpg.h"
    7.  
    8. int main(int argc, char *argv[])
    9. {
    10. QCoreApplication a(argc, argv);
    11.  
    12. QCA::Initializer init;
    13. if(!QCA::isSupported("openpgp"))
    14. {
    15. }
    16. else
    17. {
    18. PassphraseHandler passphraseHandler;
    19. myKeyLoader* keyLoader = new myKeyLoader();
    20. QTimer::singleShot(0,keyLoader,SLOT(start()));
    21. }
    22.  
    23. return a.exec();
    24. }
    To copy to clipboard, switch view to plain text mode 

    I get the following dignostic string:

    "GPGProc: Running: [C:\Program Files\GNU\GnuPG\gpg.exe --no-tty --no-default-keyring --keyring C:\prj\qcaGnupg\qca_gnupg_tmp.JS4036.gpg --secret-keyring C:\prj\qcaGnupg\qca_gnupg_tmp.Oh4036.gpg --import]
    GPGProc: Process started
    GPGProc: Process finished: 2
    GPGProc: Done
    GPG Process Finished: exitStatus=2
    stdout: []
    stderr: [gpg: can't open `C:\prj\qcaGnupg\qca_gnupg_tmp.Oh4036.gpg'
    gpg: key 169C844F: secret key not found: file open error
    gpg: error reading `[stdin]': file open error
    gp..."

    But if I run the same command at the dos prompt it runs sucessfully, following is the output:

    C:\prj\qcaGnupg>gpg.exe --no-tty --no-default-keyring --keyring C:\prj\qcaGnupg\qca_gnupg_tmp.JS4036.gpg --secret-keyring C:\prj\qcaGnupg\qca_gnupg_tmp.Oh4036.gpg --import
    -----BEGIN PGP PRIVATE KEY BLOCK-----
    Version: BCPG v1.45

    lQIGBE0hbIABBAChhmP3pkI+XWlow0q9a3ZmwWLpPjQRs9oaNO CzMwAA5p54gNT7
    5UCBv9K5uqreily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Fk36/ELtS4y6jeOYtVe4cJ8qLXAy3Wf/qHcTUXbfX9P
    a1ZNUVMExHIFnIprOwARAQAB/gcDAlaHs7BSahNiYI921+4EMeBszeR/XkfTECz6
    OIw/grd00bQ3VOVrYRaSjmjGyEql5LiAaDQybMcQ9YND9A28EX/Og1C0E6AmRWIu
    oe6zr1tEeZ3tVOXgaT5VAhIn3Y8og5NGd638SMvLVItNDwqRxL IalRrv6zSc/iab
    4igPWO5Uiz32muJGMSYy1d7eLaA4Vae29Yk4WZ95fH0Kmy+slS y+aerLOODuS+57
    GMRPMUAfOVGYvSBL5xgWap+/Pdkv2wnA9BokkhkS/XVI/h52HqX4M15zxD5s1RuG
    CHcX9FeHMxxc/ikHB2QNrxa9Bp5baF5DrvwcXSGSNdnaIZRlOccm19QtjIaMwhp z
    LmDWElrgiDFhctwcAAx86G51lirG+qdZJUMC4rce/1lsm8nLDQ7tgwWhG9mVZAdp
    YMJGlUH0FJti7m9Ie70993w2+6ZlMGYacVR4UnANFItLhofqvU o5gDCeE+cbxGw7
    iMATu8jdef+XaV6InwQYAQIACQUCTSFsggIbDAAKCRBp8bpwFp yET0PLA/48AVUY
    oKm9p/SO7taSQSG+rsJF+yaMFRlitbY90YnmwT4tTb6d8IgaBhepk1Sb nz6fquDu
    rXfF6pxkfZ/2gHITCHfSBm3Blzf9AVBdw80cl3qvvkid3UOY1Bvyx68W5g7Q2 X9n
    3vG36efFEd/gVIDs70x6yrTpUTWI7kRgTYEpZA==
    =xcAg
    -----END PGP PRIVATE KEY BLOCK-----
    ^Z
    gpg: key 169C844F: secret key imported
    gpg: key 169C844F: public key "619d1180-e611-11df-880a-1231390a9cc1" imported
    gpg: Total number processed: 1
    gpg: imported: 1 (RSA: 1)
    gpg: secret keys read: 1
    gpg: secret keys imported: 1


    ____________

    Any kind soul, please let me know what is wrong with my code and how to solve this problem. Thank you very much.

  2. #2
    Join Date
    Dec 2010
    Posts
    44
    Thanks
    9
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: qca, qca-gnupg Not able to open files

    I got it solved for now. But the I don't think the solution will be useful to anybody. I kind of removed the "HomeDir" data from the registry entry for GnuPg. Now GnuPg uses the windows temp directory for these files. It was previously looking for HomeDir\C:\prj\qcaGnupg\qca_gnupg_tmp.JS4036.gpg.

    Sky

Similar Threads

  1. open files in different windows
    By ramaha8319 in forum Qt Tools
    Replies: 1
    Last Post: 27th April 2009, 14:27
  2. [Solved] Open files outside my program
    By Nykoo in forum Qt Programming
    Replies: 0
    Last Post: 27th January 2008, 16:13
  3. How to open IGES files in Qt Application?
    By Shuchi Agrawal in forum Newbie
    Replies: 1
    Last Post: 21st February 2007, 01:06
  4. integrating Qt files in open cascade?
    By Shuchi Agrawal in forum Qt Tools
    Replies: 5
    Last Post: 9th January 2007, 05:27
  5. integrating Qt files with open cascade??
    By Shuchi Agrawal in forum Qt Tools
    Replies: 1
    Last Post: 29th December 2006, 07:11

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.