From 4ddb2f716fa5501271bfb2d270a56562ddb5051d Mon Sep 17 00:00:00 2001 From: Thorsten Behrens Date: Wed, 21 Jun 2017 16:54:52 +0200 Subject: gpg4libre: some code improvements, add metadata for OpenPGP keys Change-Id: I1beb692b9a9a34b5f0cf743ba9e4a145ac582184 --- xmlsecurity/source/gpg/CertificateImpl.cxx | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'xmlsecurity/source/gpg/CertificateImpl.cxx') diff --git a/xmlsecurity/source/gpg/CertificateImpl.cxx b/xmlsecurity/source/gpg/CertificateImpl.cxx index c0f48e309c7c..e40f59323a04 100644 --- a/xmlsecurity/source/gpg/CertificateImpl.cxx +++ b/xmlsecurity/source/gpg/CertificateImpl.cxx @@ -24,13 +24,12 @@ using namespace css::security; using namespace css::util; CertificateImpl::CertificateImpl() : - m_pKey(nullptr) + m_pKey() { } CertificateImpl::~CertificateImpl() { - // TODO: cleanup key } //Methods from XCertificateImpl @@ -214,17 +213,16 @@ void CertificateImpl::setCertificate(GpgME::Context* ctx, const GpgME::Key& key) GpgME::Data data_out; ctx->exportPublicKeys(key.keyID(), data_out); - // TODO: needs some error handling - data_out.seek(0,SEEK_SET); + assert(data_out.seek(0,SEEK_SET) == 0); int len=0, curr=0; char buf; while( (curr=data_out.read(&buf, 1)) ) len += curr; // write bits to sequence of bytes m_aBits.realloc(len); - data_out.seek(0,SEEK_SET); + assert(data_out.seek(0,SEEK_SET) == 0); if( data_out.read(m_aBits.getArray(), len) != len ) - throw RuntimeException("The GpgME library failed to initialize for the OpenPGP protocol."); + throw RuntimeException("The GpgME library failed to read the key"); } const GpgME::Key* CertificateImpl::getCertificate() const -- cgit v1.2.3