QCA не может импортировать закрытый ключ OpenPGP — он превращается в открытый ключ

Используя библиотеку QCA (libqca.so) OpenPGP, я пытаюсь прочитать закрытый ключ в объект QCA :: PGPKey, но, похоже, QCA преобразует его в открытый ключ.
Пара ключей находится в связке ключей, но QCA также не распознает ее.

Вот коды:

   #include <QCoreApplication>

int main(int argc, char *argv[])

QCoreApplication a(argc, argv);

QCA::Initializer init;
if(!QCA::isSupported("openpgp")){
throw std::exception();
}

QFile file("file.txt");
if(!file.open(QFile::WriteOnly | QFile::Text))
throw std::exception();
QTextStream stream(&file);

QFile pubkey("slclientpub.asc");
if(!pubkey.open(QFile::ReadOnly | QFile::Text))
throw std::exception();

QString pubkey_str = pubkey.readAll();
stream << "pubkey_str:\n"<< pubkey_str;

pubkey.flush();
pubkey.close();

QFile prikey("slclientsecret.asc");
if(!prikey.open(QFile::ReadOnly | QFile::Text))
throw std::exception();

QString prikey_str = prikey.readAll();
stream << "prikey_str:\n"<< prikey_str;

prikey.flush();
prikey.close();

QCA::ConvertResult cr1, cr2;
QCA::PGPKey public_key_1 = QCA::PGPKey::fromString(pubkey_str,&cr1);
QCA::PGPKey private_key_2 = QCA::PGPKey::fromString(pubkey_str,&cr2);
QCA::PGPKey public_key_3("slclientpub.asc");
QCA::PGPKey private_key_4("slclientsecret.asc");if((cr1 != QCA::ConvertGood) || (cr2 != QCA::ConvertGood)){
throw std::exception();
}

stream<<"public_key_1 data:\n"<<"Secret: " << public_key_1.isSecret()
<<"\nIn Keyring: " << public_key_1.inKeyring()
<<"\n Data: \n"<<public_key_1.toString();

stream<<"private_key_2 data:\n"<<"Secret: " << private_key_2.isSecret()
<<"\nIn Keyring: " << private_key_2.inKeyring()
<<"\n Data: \n"<<private_key_2.toString();

stream<<"public_key_3 data:\n"<<"Secret: " << public_key_3.isSecret()
<<"\nIn Keyring: " << public_key_3.inKeyring()
<<"\n Data: \n"<<public_key_3.toString();

stream<<"private_key_4 data:\n"<<"Secret: " << private_key_4.isSecret()
<<"\nIn Keyring: " << private_key_4.inKeyring()
<<"\n Data: \n"<<private_key_4.toString();

stream.flush();
file.flush();
file.close();

return a.exec();
}

file.txt (ВЫХОД):

pubkey_str:
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.4.11 (GNU/Linux)

mQENBFMaIpgBCAC9alX6wbA3vcEIJSfsXaPBf/kOrNd2JFPcJbk+oXICIOU+ZEhD
4g1ejJ/bej52aq8tvrxGQoZBVVCUdFpIO1Cerk1xMdjAzKzy4K2mi+vlTYIm9VaM
xIFgFFoXSVvlRwGWzhQppXPHqbxsWQtnPdAA83ioHJH4WxLWcf/1jai2FdvZdPVl
S9bPl3SDZ9pFxtx46u7pIqXyQ3XhFR6F82T1TxrrkeLZY08QsmCdXAaXFh3DmY4J
9EN3+87U9JCwqcUUkgHi68yzswacY7sWnPnsZ60uQk7dA107bNrjilUtzW9oXfeM
NCpmgfmpwfPSEnbPbDQxeZvWRV84IiaT/5fXABEBAAG0HFNsQ2xpZW50IDxzbGNs
aUBmdWNrLmNvbS56YT6JAT4EEwECACgFAlMaIpgCGy8FCQPC9kgGCwkIBwMCBhUI
AgkKCwQWAgMBAh4BAheAAAoJEOsdWacrjyQGE10H/2Q1Zk6RcQr7WeiTI3H+tomQ
SCs8+CFLUgo2SAUd/nkG4scpZj1tfh/DrYCY0ZoJB0CxkE00lMo/raIH4IhZsLtT
gayFPhIihetFxyESswFhWrBYk+fI9+okZbVmSoZXkqJJU1AzBp4Bzq4P88CDbZJD
XCMZCTpScJUhQLgmyersH/t8N3imoglH1suIGPlv3SvM9adU3//TBgB9h6gmeH/D
UJao0yFppEOJ5CefBUVhfqzLDL3h+jpf1rcEDg7KIPEUDR7Y+oBVB55Y2U1YfVC0
EDiZo2FRDpZzHMibXcTDyJmNxFdQmvE9YH8sMoA4fFrcA27RnHeEOoprP+jnJRs=
=EKsG
-----END PGP PUBLIC KEY BLOCK-----
prikey_str:
-----BEGIN PGP PRIVATE KEY BLOCK-----
Version: GnuPG v1.4.11 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4Bzq4P88CDbZJD
XCMZCTpScJUhQLgmyersH/t8N3imoglH1suIGPlv3SvM9adU3//TBgB9h6gmeH/D
UJao0yFppEOJ5CefBUVhfqzLDL3h+jpf1rcEDg7KIPEUDR7Y+oBVB55Y2U1YfVC0
EDiZo2FRDpZzHMibXcTDyJmNxFdQmvE9YH8sMoA4fFrcA27RnHeEOoprP+jnJRs=
=EKsG
-----END PGP PUBLIC KEY BLOCK-----

0

Решение

Задача ещё не решена.

Другие решения

Других решений пока нет …

По вопросам рекламы [email protected]