GNOME Bugzilla – Bug 641848
possible to collapse GMimeGpgContext with GMimePkcs7Context ?
Last modified: 2017-03-11 22:29:24 UTC
GMime 2.4 has GMimeGpgContext. GMime 2.5 also introduces GMimePkcs7Context. Both are implementations of GMimeCryptoContext, and both appear (from the documentation) to use GnuPG under the hood. It sounds to me like it is going to be up to the caller to decide which cryptocontext to use based on whether a given GMimePart uses PGP/MIME or S/MIME. Is this correct? If so, this determination seems possible to do within GMime itself, and it might be possible to collapse these two contexts into the same object. This would simplify things for the caller, particularly when verifying or decrypting. For signing/encrypting, it might make sense to allow the user to set a flag on the context object itself to indicate what form of signing/encrypting they want to do. If these really must be different classes of context for whatever reason, it seems like they should be re-named to make it clearer which is which (e.g. if they both use GnuPG, then neither or both of them should have "Gpg" in the name, but not just one) and the documentation should be improved to indicate when to use one or the other. What happens if you use a GMimeGpgContext to decrypt/verify an S/MIME message? What happens if you use a GMimePkcs7Context to decrypt/verify a PGP/MIME message?
This is in progress... I still want to keep the 2 different contexts, but I am working toward making them share as much code as possible. I've already made it such that MultipartSigned.Verify() chooses the correct context for you so you don't have to pass one in. MultipartEncrypted.Decrypt() does the same and the new ApplicationPkcs7Mime class does as well. It's now only necessary to choose the context when doing MultipartEncrypted.Encrypt() and MultipartSigned.Sign().
This is now fixed.