summaryrefslogtreecommitdiff
path: root/xmlsecurity/source/gpg/CertificateImpl.cxx
diff options
context:
space:
mode:
authorThorsten Behrens <Thorsten.Behrens@CIB.de>2017-07-17 02:17:16 +0200
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2017-07-17 02:40:31 +0200
commit40f181207574827827d2bf1b4ad72d46fc8ff1fb (patch)
tree5516dd96136bafbd1b54b148ea09f8fc5bee941f /xmlsecurity/source/gpg/CertificateImpl.cxx
parentc1bd6f9bb41859911e59aefaf238b8da80284a8f (diff)
gpg4libre: use full SHA1 hash for key identification
Read and write full 20 bytes/40 hex chars of SHA1 key hash, instead of some abridged versions. See also https://lists.debian.org/debian-devel/2016/08/msg00215.html Change-Id: I741afc94ac7cf559880fe55ff02420723e13310d Reviewed-on: https://gerrit.libreoffice.org/40027 Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de> Tested-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'xmlsecurity/source/gpg/CertificateImpl.cxx')
-rw-r--r--xmlsecurity/source/gpg/CertificateImpl.cxx24
1 files changed, 12 insertions, 12 deletions
diff --git a/xmlsecurity/source/gpg/CertificateImpl.cxx b/xmlsecurity/source/gpg/CertificateImpl.cxx
index 03fa49cdef68..49674f877956 100644
--- a/xmlsecurity/source/gpg/CertificateImpl.cxx
+++ b/xmlsecurity/source/gpg/CertificateImpl.cxx
@@ -40,10 +40,9 @@ sal_Int16 SAL_CALL CertificateImpl::getVersion()
Sequence< sal_Int8 > SAL_CALL CertificateImpl::getSerialNumber()
{
- // This is mapped to the fingerprint for gpg
- const char* keyId = m_pKey.primaryFingerprint();
- return comphelper::arrayToSequence<sal_Int8>(
- keyId, strlen(keyId));
+ // TODO: perhaps map to subkey's cardSerialNumber - if you have
+ // one to test
+ return Sequence< sal_Int8 >();
}
OUString SAL_CALL CertificateImpl::getIssuerName()
@@ -153,24 +152,25 @@ OUString SAL_CALL CertificateImpl::getSignatureAlgorithm()
Sequence< sal_Int8 > SAL_CALL CertificateImpl::getSHA1Thumbprint()
{
- // This is mapped to the short keyID for gpg
- const char* keyId = m_pKey.shortKeyID();
+ // This is mapped to the fingerprint for gpg
+ const char* keyId = m_pKey.primaryFingerprint();
return comphelper::arrayToSequence<sal_Int8>(
keyId, strlen(keyId));
}
-uno::Sequence<sal_Int8> CertificateImpl::getSHA256Thumbprint()
+Sequence<sal_Int8> CertificateImpl::getSHA256Thumbprint()
{
- // This is mapped to the long keyID for gpg
- const char* keyId = m_pKey.keyID();
+ // This is mapped to the fingerprint for gpg (though that's only
+ // SHA1 actually)
+ const char* keyId = m_pKey.primaryFingerprint();
return comphelper::arrayToSequence<sal_Int8>(
keyId, strlen(keyId));
}
Sequence< sal_Int8 > SAL_CALL CertificateImpl::getMD5Thumbprint()
{
- // This is mapped to the short keyID for gpg
- const char* keyId = m_pKey.shortKeyID();
+ // This is mapped to the shorter keyID for gpg
+ const char* keyId = m_pKey.keyID();
return comphelper::arrayToSequence<sal_Int8>(
keyId, strlen(keyId));
}
@@ -212,7 +212,7 @@ void CertificateImpl::setCertificate(GpgME::Context* ctx, const GpgME::Key& key)
// extract key data, store into m_aBits
GpgME::Data data_out;
ctx->setArmor(false); // caller will base64-encode anyway
- GpgME::Error err = ctx->exportPublicKeys(key.keyID(), data_out);
+ GpgME::Error err = ctx->exportPublicKeys(key.primaryFingerprint(), data_out);
if (err)
throw RuntimeException("The GpgME library failed to retrieve the public key");