gpgme.git
16 months agojs: import result feedback
Maximilian Krambach [Thu, 14 Jun 2018 12:50:25 +0000 (14:50 +0200)]
js: import result feedback

--

* src/Keyring.js: Changed and documented the import result feedback
  towards the javascript side

16 months agojs: add verify and signature parsing
Maximilian Krambach [Thu, 14 Jun 2018 10:15:51 +0000 (12:15 +0200)]
js: add verify and signature parsing

--

* src/gpgmejs.js:
  - Added verify method
  - Added verification results in decrypt (if signatures are present
    in the message)
  - Added a base64 option to decrypt

* src/Signature.js: Convenience class for verification results. Used
   for e.g. converting timestamps to javascript time, quick overall
   validity checks

* src/Keyring.js: removed debug code

* src/Errors.js add two new Signature errors

16 months agojs: getDefaultKey and verify fix
Maximilian Krambach [Wed, 13 Jun 2018 13:22:03 +0000 (15:22 +0200)]
js: getDefaultKey and verify fix

--

* DemoExtension/maindemo.js - added a Demo for retrieving the default
  signing key

* src/Errors.js - add a new Error if no default key can be determined

* src/Key.js added documentation and a TODO marker for hasSecret.

* src/Keyring.js implemented getDefaultKey

* src/permittedOperations.js: Added missing entry for verify,
    added config_opt

16 months agojs: less confusing icons for test/Demo extension
Maximilian Krambach [Wed, 13 Jun 2018 09:49:37 +0000 (11:49 +0200)]
js: less confusing icons for test/Demo extension

--
* The current test icon was just a generic pin. Changed that by the
  gnupg lock symbol with 'Demo'/'Tests' written on it. Original taken
  from gnupg artwork/icons/lock-wing.svg.

16 months agojs: removed config
Maximilian Krambach [Mon, 11 Jun 2018 13:10:43 +0000 (15:10 +0200)]
js: removed config

--

* There is no use for a configuration at the moment, and it seems
  improbable that this use will arise.

16 months agojs: Add key creation to Keyring
Maximilian Krambach [Mon, 11 Jun 2018 10:08:50 +0000 (12:08 +0200)]
js: Add key creation to Keyring

--

* src/Keyring.js: Added method generateKey for new Keys
  Still TODO: Key length and some further testing. Automated testing
  does not work in this case, and gpgmejs will not be able to delete
  test keys again.
* src/permittedOperations.js Added new method's definitions according
  to gpgme-json

16 months agojs: change chunksize handling and decoding
Maximilian Krambach [Fri, 8 Jun 2018 15:54:58 +0000 (17:54 +0200)]
js: change chunksize handling and decoding

--

* the nativeApp now sends all data in one base64-encoded string, which
  needs reassembly, but in a much easier way now.

* there are some new performance problems now, especially with
  decrypting data

16 months agojs: change Keyinfo timestamps into javascript date
Maximilian Krambach [Wed, 6 Jun 2018 13:29:21 +0000 (15:29 +0200)]
js: change Keyinfo timestamps into javascript date

--
* src/Key.js

16 months agojs: code cleanup (eslint)
Maximilian Krambach [Wed, 6 Jun 2018 11:05:53 +0000 (13:05 +0200)]
js: code cleanup (eslint)

--
* trying to stick to eslint from now on for readability

* As some attribution was lost in previous git confusions, I added my
  name into some of the licence headers

16 months agojs: implement import/delete Key, some fixes
Maximilian Krambach [Wed, 6 Jun 2018 09:57:41 +0000 (11:57 +0200)]
js: implement import/delete Key, some fixes

--

* Keyring.js
   - implemented importKey: importing one or more armored public key
     blocks.
   - implemented deleteKey: deleting a public Key from gpg.

* Key.js renamed property Key.armor to Key.armored

* Helpers.js: toKeyIDArray does not complain anymore if there are no
  keys. Not having Keys in e.g. signing keys in encrypt is legitimate
  and common, the complaints were getting spammy

* Errors.js: gpgme_errors now always pass an optional additional
  message, for easier debugging in minified code

* Connection.js: Fix in gpgme-json responses containing objects

* eslintrc.json: Start using eslint. A cleanup to conform to it is not
  done yet

* Added further tests for the new functionality

16 months agojs: more Keyring/Key handling
Maximilian Krambach [Wed, 30 May 2018 15:05:54 +0000 (17:05 +0200)]
js: more Keyring/Key handling

--

* src/Keys.js
  - made setKeyData more consistent with other methods
  - added convenience methods (Key.armored, Key.hasSecret)
  - Added a Key delete function

* src/Keyring.js:
  - added a getkeysArmored which allows for bulk export of public Keys

gpgmejs:
  - removed deleteKey. It is now a method of the Key itself
  - Encrypt: Added some common options as parameter, and the
    possibility to set all allowed flags via an additional Object

16 months agojs: Keyring listing keys
Maximilian Krambach [Mon, 28 May 2018 15:26:56 +0000 (17:26 +0200)]
js: Keyring listing keys

--

* implementing Keyring methods:

  - Keyring.getKeys: has an additional option that retrieves the armor
    and secret state once at the beginning. This is power hungry, but
    allows for Keys to be used directly (without querying gpgme-json
    each call)
  * permittedOperations.js: reflect recent changes in the native
    counterpart, adding more options
  * Key: adding two methods for retrieving the armored Key block and
    for finding out if the Key includes a secret subkey.

16 months agojs: Treat a connection as a gpgme Context
Maximilian Krambach [Mon, 28 May 2018 14:52:50 +0000 (16:52 +0200)]
js: Treat a  connection as a gpgme Context

--

* After an operation a connection should be disconnected again.
  The "end of operation" is now assumed to be either an error as
  answer, or a message not including a "more"

* GPGME, GPGME_Key, GPGME_Keyring don't require a connection
  anymore
* Message.js: The Message.post() method will open a connection as
  required

16 months agojs: implement Key handling (1)
Maximilian Krambach [Fri, 25 May 2018 17:02:18 +0000 (19:02 +0200)]
js: implement Key handling (1)

--

* Keys can now be queried for information. Onne version queries gnug
  directly (asynchronous Promise in javascript terms), the cached
  version refreshes on demand.

* Small fixes:
  src/Connection.js joins answers that stay json properly now

16 months agojs: use version operation for connection checks
Maximilian Krambach [Fri, 25 May 2018 09:53:24 +0000 (11:53 +0200)]
js: use version operation for connection checks

--

* src/Connection.js: isConnected was renamed to checkConnection, that
  returns a promise with either version information or Boolean
* Connection checks have been adapted to reflect that checkConnection
  returns a Promise
* BrowsertestExtension: tests/signTest.js was missing from my last
  commit

16 months agojs: adding sign method
Maximilian Krambach [Thu, 24 May 2018 13:16:18 +0000 (15:16 +0200)]
js: adding sign method

--

  * src/gpgmejs.js: method, update in src/permittedOperations
  * basic testing in BrowsertestExtension

16 months agoMerge branch 'master' into javascript-binding
Maximilian Krambach [Thu, 24 May 2018 12:03:09 +0000 (14:03 +0200)]
Merge branch 'master' into javascript-binding

16 months agojson: Put signature info before data output
Andre Heinecke [Thu, 24 May 2018 11:36:31 +0000 (13:36 +0200)]
json: Put signature info before data output

* src/gpgme-json.c (op_decrypt): Move info before data.

--
This should enable it to first parse signatures before
handling very large chunks of data.

16 months agojson: Add sign to help
Andre Heinecke [Thu, 24 May 2018 11:31:15 +0000 (13:31 +0200)]
json: Add sign to help

* src/gpgme-json.c (hlp_help): Add sign.

16 months agojson: Add op_sign
Andre Heinecke [Thu, 24 May 2018 11:24:02 +0000 (13:24 +0200)]
json: Add op_sign

* src/gpgme-json.c (op_sign): New.

16 months agojson: Fix invalid function call
Andre Heinecke [Thu, 24 May 2018 11:16:55 +0000 (13:16 +0200)]
json: Fix invalid function call

* src/gpgme-json.c (add_signatures_to_object): Fix call to
xjson_CreateArray.

--
That is what happens if you edit code while reviewing changes,
without testing it again,..

16 months agojson: Print signatures for decrypt/verify
Andre Heinecke [Thu, 24 May 2018 10:34:31 +0000 (12:34 +0200)]
json: Print signatures for decrypt/verify

* gpgme-json.c (xJSON_CreateArray),
(add_summary_to_object, validity_to_string): New helpers.
(add_signature_to_object, add_signatures_to_object)
(add_signatures_object): New.
(op_decrypt): Handle verify_result.
(hlp_help): Mention decrypt.

16 months agojson: Minor typo fixes
Andre Heinecke [Thu, 24 May 2018 08:26:41 +0000 (10:26 +0200)]
json: Minor typo fixes

* src/gpgme-json.c: Minor typo fixes.

16 months agojs: remove openpgp mode
Maximilian Krambach [Wed, 23 May 2018 10:56:23 +0000 (12:56 +0200)]
js: remove openpgp mode

--

* After discussion, that mode is not required, and can result in
  being quite misleading and a maintenance hassle later on.

16 months agodocs and examples: python howto
Ben McGinnes [Wed, 23 May 2018 04:43:06 +0000 (14:43 +1000)]
docs and examples: python howto

* Updated the decryption example code in the HOWTO and the
  corresponding decrypt-file.py script to gracefully handle a
  decryption failure.  This error will always be triggered when GPGME
  is used to try to decrypt an old, MDC-less encrypted message or
  file.

16 months agojs: transfer encoding changes
Maximilian Krambach [Tue, 22 May 2018 12:24:16 +0000 (14:24 +0200)]
js: transfer encoding changes

--

* Uint8Arrays are not supported for now there are unsolved issues in
  conversion, and they are lower priority

* encrypt gains a new option to indicate that input values are base64
  encoded
* as decrypted values are always base64 encoded, the option base64 will
  not try to decode the result into utf, but leave it as it is

16 months agocpp: Expose sessionKey and symkeyAlgo
Andre Heinecke [Tue, 22 May 2018 10:08:01 +0000 (12:08 +0200)]
cpp: Expose sessionKey and symkeyAlgo

* lang/cpp/decryptionresult.cpp, lang/cpp/decryptionresult.h
(DecryptionResult::symkeyAlgo, DecryptionResult::sessionKey): New.

17 months agocore, w32: Add w64 handling for regkeys
Andre Heinecke [Thu, 17 May 2018 15:41:53 +0000 (17:41 +0200)]
core, w32: Add w64 handling for regkeys

* src/w32-util.c (_gpgme_get_gpg_path): Use new defines.
(GNUPG_REGKEY_2): x64 aware regkey as used by GnuPG in Gpg4win 2.x
(GNUPG_REGKEY_3): x64 aware regkey as used by GnuPG in Gpg4win 3.x
(_gpgme_get_gpgconf_path): Use new regkeys. Add another fallback.

--
This should fix more "unsupported protocol" issues if Gpg4win /
GnuPG is installed in a non standard path on 64bit systems.

The regkey handling is similar to that of gpgex and gpgol.

GnuPG-Bug-Id: T3988

17 months agocore: Always fail if an OpenPG message is not integrity protected.
Werner Koch [Thu, 17 May 2018 07:14:40 +0000 (09:14 +0200)]
core: Always fail if an OpenPG message is not integrity protected.

* src/decrypt.c (struct op_data_t): Add field not_integrity_protected.
(parse_decryption_info): Set this.  Also rename mode to aead_algo for
clarity.
(_gpgme_decrypt_status_handler): Force failure in case of a missing
MDC.
--

This extra check makes sure that a missing or stripped MDC in
 - gpg < 2.1
 - or gpg 2.2 with an old cipher algorithm
will lead to a decryption failure.  gpg 2.3 will always fail in this
case.  Implementing this check here and not backporting the 2.3 change
to 2.2 has the benefit that all GPGME using applications are protected
but scripts relying on rfc2440 (i.e. without MDC) will only break when
migrating to 2.3.

Note that S/MIME has no integrity protection mechanism but gpgsm
neither emits a DECRYPTION_INFO status line, so an error will not be
triggered.  If in the future gpgsm supports authenticated encryption
it may issue a DECRYPTION_INFO line to force a failure here but it
will in that case also emit a DECRYPTION_FAILED anyway.

GnuPG-bug-id: 3981
Signed-off-by: Werner Koch <wk@gnupg.org>
17 months agojs: Testing lare messages
Maximilian Krambach [Mon, 14 May 2018 17:02:49 +0000 (19:02 +0200)]
js: Testing lare messages

--

* Some assumption on messages were wrong. Now the tests use more
  reasonable sizes.
* bigString now uses the full utf8-extent, with the exception of
  U+0000. This code gets dropped during the encryption-decryption
  process.

17 months agojs: remove non-browser tests
Maximilian Krambach [Mon, 14 May 2018 14:36:05 +0000 (16:36 +0200)]
js: remove non-browser tests

--

* The majority of tests needs to be run in a nativeMessaging context.
  Offering the few tests that don't need this context at two places
  introduces issues with maintainability. All tests now removed can be
  found in ./unittests.js

17 months agojs: Tests and improvements for openpgp mode
Maximilian Krambach [Mon, 14 May 2018 14:23:24 +0000 (16:23 +0200)]
js: Tests and improvements for openpgp mode

--

* Added openpgp - Mode tests to the browsertest Extension. These tests
  require openpgp, which should not be a hard dependency for the main
  project. Packing openpgpjs into the extension is still TODO

* Fixes:
  - openpgp mode API now correctly handles parameters as an object,
    similar to openpgpjs
  - proper check and parsing of openpgpjs Message Objects

17 months agojs: more testing of nativeMessaging connection
Maximilian Krambach [Wed, 9 May 2018 17:40:57 +0000 (19:40 +0200)]
js: more testing of nativeMessaging connection

--

* There were some inconsistencies between utf-8, transfer and browsers'
  utf16, which broke characters that were split between individual
  messages. src/Connection now contains a workaround that reassembles
  javascripts' format from passed base64 strings. This needs someone
  more experienced looking.
* Added several new tests which were failing during initial debugging
  of this issue
* reorganized BrowsertestExtension to avoid cluttering.

17 months agoMerge branch 'master' into javascript-binding
Maximilian Krambach [Wed, 9 May 2018 14:55:50 +0000 (16:55 +0200)]
Merge branch 'master' into javascript-binding

17 months agojson: Improve auto-base64 encoding to not split UTF-8 chars.
Werner Koch [Wed, 9 May 2018 14:41:05 +0000 (16:41 +0200)]
json: Improve auto-base64 encoding to not split UTF-8 chars.

* src/gpgme-json.c (make_data_object): Switch to Base64 also for UTF-8
characters.

Signed-off-by: Werner Koch <wk@gnupg.org>
17 months agocore: Make the status-fd monitor work for all gpgsm commands.
Werner Koch [Wed, 9 May 2018 14:39:30 +0000 (16:39 +0200)]
core: Make the status-fd monitor work for all gpgsm commands.

* src/engine-gpgsm.c (status_handler): Call the status monitor also
here.

Signed-off-by: Werner Koch <wk@gnupg.org>
17 months agojs: more testing
Maximilian Krambach [Tue, 8 May 2018 16:33:41 +0000 (18:33 +0200)]
js: more testing

--

* Tests: Under certain circumstances, some data change during
  encrypt-decrypt. Committing the current state so the problem can be
  discussed.

* Fixes:
  - disconnecting the test ports after tests are complete
  - fixed passing of the error message from gpgme-json

17 months agojs: fixing errors found by testing: encrypt/decrypt
Maximilian Krambach [Mon, 7 May 2018 16:27:25 +0000 (18:27 +0200)]
js: fixing errors found by testing: encrypt/decrypt

--

* Key.js: Error code for wrong parameter in createKey should be
  "PARAM_WRONG"
* Helpers.js: The property openpgpjs-like Objects were checked for in
  toKeyIdArray was not defined.
* src/permittedOperations.js: updated more expectations and assumptions
  for the native API

* new Problems:
  - There seems to be a message size limit of about 21 MB for
    nativeMessaging, much lower than the documented 4GB.
  - Some bytes are lost with random data in an encrypt-decrypt
    roundtrip. The culprit is unclear.

17 months agopython: key expiration datetime stamp tests
Ben McGinnes [Sat, 5 May 2018 02:27:17 +0000 (12:27 +1000)]
python: key expiration datetime stamp tests

* Changed the expiration date for the generated test key to NYE this
  century, rather than the NYE this millennium as originally suggested
  in job #3815.
* This covers the lifetimes of current users (except, maybe, some very
  healthy millennials) as well as the 32-bit clock end date in 2038;
  without falling foul of OpenPGP's 2106 expiration.

17 months agojs: fixing errors found by testing
Maximilian Krambach [Fri, 4 May 2018 10:56:59 +0000 (12:56 +0200)]
js: fixing errors found by testing

--

* Key.js: Error code for wrong parameter in createKey should be
  "PARAM_WRONG"

* Helpers.js: The property openpgpjs-like Objects were checked for in
  toKeyIdArray was not defined.

* src/permittedOperations.js: updated more expectations and assumptions
  for the native API

17 months agoqt: Respect --disable-gpg-test for tests
Andre Heinecke [Fri, 4 May 2018 08:03:42 +0000 (10:03 +0200)]
qt: Respect --disable-gpg-test for tests

* lang/qt/Makefile.am: Respect --disable-gpg-test

--
This is similar to the core switch to disable the tests.

17 months agojs: Added browser testing for unit tests
Maximilian Krambach [Thu, 3 May 2018 16:03:22 +0000 (18:03 +0200)]
js: Added browser testing for unit tests

--

* Added unittests to be run inside a Browser. To be able to access
  the non-exposed functions and classes, a testing bundle will be
  created, containing the tests (unittests.js) and the items to be
  tested.
* src/Helpelpers, src/Key, src/Keyring: fixed some errors found
  during testing.

17 months agojs: changed Key class stub
Maximilian Krambach [Thu, 3 May 2018 12:12:10 +0000 (14:12 +0200)]
js: changed Key class stub

--

* src/Key.js:
  A Key object cannot offer more than basic functionality outside a
  connection, so it now requires a connection to be present.

17 months agojs: more testing
Maximilian Krambach [Fri, 27 Apr 2018 18:03:09 +0000 (20:03 +0200)]
js: more testing

--

* Tests: initialization of the two modes, encryption

* gpgme.js: reintroduced message check before calling
  Connection.post()

* gpgmejs_openpgp.js: Fixed openpgp mode not passing keys

* index.js: fixed some confusion in parseconfig()

* Inserted some TODO stubs for missing error handling

17 months agojs: fixed empty operation setter in Message
Maximilian Krambach [Fri, 27 Apr 2018 08:21:13 +0000 (10:21 +0200)]
js: fixed empty operation setter in Message

--

* src/Message.js Messages failed because they were not assigned
  operations

17 months agojs: fixed wrong paths in DemoExtension
Maximilian Krambach [Thu, 26 Apr 2018 15:59:40 +0000 (17:59 +0200)]
js: fixed wrong paths in DemoExtension

--

* Some forgotten internal links after the move to a subdir and cleaning

17 months agojs: created TestExtension and smaller fixes
Maximilian Krambach [Thu, 26 Apr 2018 15:13:34 +0000 (17:13 +0200)]
js: created TestExtension and smaller fixes

--

* Extensions:

  - Moved testapplication to Demoextension
  - Created BrowserTestExtension.
    Includes mocha and chai. For running tests that cannot be run
    outside a WebExtension

  Both Extensions can be found zipped in build/extensions after
  running build_extensions.sh

* Code changes:
  - src/Config: Place for the configuration
  - small fixes raised during testing in Keyring.js, Message.js,
  - src/gpgmejs_openpgpjs.js don't offer direct GpgME object to the
    outside, as it only causes confusion
  - index.js init() now checks the config for validity

* Tests:
  - Reordered tests in test/.
  - Input values are now in a separate file which may be of use for
    bulk testing

* moved the build directory from dist to build

17 months agoqt: Fix filename handling in cryptoconfig
Andre Heinecke [Thu, 26 Apr 2018 12:11:19 +0000 (14:11 +0200)]
qt: Fix filename handling in cryptoconfig

* src/qgpgmenewcryptoconfig.cpp (QGpgMENewCryptoConfigEntry::urlValue):
Build url from local file.
(QGpgMENewCryptoConfigEntry::setURLValue): Set native seperated
path.

--
This fixes setting files through cryptoconfig on Windows.
GnuPG-Bug-Id: T3939

17 months agojs: First testing and improvements
Maximilian Krambach [Wed, 25 Apr 2018 17:45:39 +0000 (19:45 +0200)]
js: First testing and improvements

--

* Introduced Mocha/chai as testsuite. After development build
  'npm test' should run the unit tests. Functionality exclusive to
  Browsers/WebExtensions cannot be run this way, so some other testing
  is still needed.

  - package.json: Added required development packages
  - .babelrc indirect configuration for mocha. ES6 transpiling
    needs some babel configuration, but mocha has no setting for it.
  - test/mocha.opts Vonfiguration for mocha runs

* Fixed errors:
  - Helpers.js toKeyIdArray; isLongId is now exported
  - Key.js Key constructor failed
  - Message.js will not throw an Error during construction, a new
    message is now created with createMessage, which can return an
    Error or a GPGME_Message object

* Tests:
  - test/Helpers: exports from Helpers.js, GPGME_Error handling
  - test/Message: first init test with bad parameters

17 months agojs: Configuration and Error handling
Maximilian Krambach [Wed, 25 Apr 2018 13:59:36 +0000 (15:59 +0200)]
js: Configuration and Error handling

--

* gpgmejs_openpgpjs
  - unsuported values with no negative consequences can now reject,
    warn or be ignored, according to config.unconsidered_params
  - cleanup of unsupported/supported parameters and TODOS

* A src/index.js init() now accepts a configuration object

* Errors will now be derived from Error, offering more info and a
  stacktrace.

* Fixed Connection.post() timeout triggering on wrong cases

* Added comments in permittedOperations.js, which gpgme interactions
  are still unimplemented and should be added next

17 months agojs: reactivate timeout on connection
Maximilian Krambach [Wed, 25 Apr 2018 09:32:21 +0000 (11:32 +0200)]
js: reactivate timeout on connection

--
* A timeout of 5 seconds is activated for functions that do not require
  a pinentry. This definition is written to src/permittedOperations.js
* testapplication.js now alerts the proper error codes and messages.
* src/Errors.js fixed two typos in error handling

17 months agojs: change in Error behaviour
Maximilian Krambach [Wed, 25 Apr 2018 08:54:24 +0000 (10:54 +0200)]
js: change in Error behaviour

--

* Error objects will now return the error code if defined as error type
  in src/Errors.js, or do a console.log if it is a warning. Errors from
  the native gpgme-json will be marked as GNUPG_ERROR.

17 months agojs: allow openpgp-like Message objects as Data
Maximilian Krambach [Tue, 24 Apr 2018 17:47:48 +0000 (19:47 +0200)]
js: allow openpgp-like Message objects as Data

--

* src/gpgmejs.js: If a message offers a getText, consider it as the
  message's content

17 months agojs: Key object adjustments after discussion
Maximilian Krambach [Tue, 24 Apr 2018 17:29:32 +0000 (19:29 +0200)]
js: Key object adjustments after discussion

--

* src/aKey.js changed fingerprint to setter (to avoid overwrites)
* src/gpgmejs_openpgpjs.js
  - Added a class GPGME_Key_openpgpmode, which allows for renaming and
    deviation from GPGME.
  - renamed classes *_openPGPCompatibility to *_openpgpmode. They are
    not fully compatible, but only offer a subset of properties. Also,
    the name seems less clunky

17 months agojs: change in initialization ancd connection handling
Maximilian Krambach [Tue, 24 Apr 2018 16:44:30 +0000 (18:44 +0200)]
js: change in initialization ancd connection handling

--

* The Connection will now be started before an object is created, to
  better account for failures.
* index.js: now exposes an init(), which returns a Promise of
  configurable <GpgME | gpgmeGpgME_openPGPCompatibility> with an
  established connection.
* TODO: There is currently no way to recover from a "connection lost"
* Connection.js offers Connection.isConnected, which toggles on port
  closing.

17 months agojs: don't allow message operation changes
Maximilian Krambach [Mon, 23 Apr 2018 17:15:40 +0000 (19:15 +0200)]
js: don't allow message operation changes

--

Once an operation is changed, their set of allowed/required parameters
will change. So we shouldn't set/change the operation later.

17 months agojs: Key handling stubs, Error handling, refactoring
Maximilian Krambach [Mon, 23 Apr 2018 15:18:46 +0000 (17:18 +0200)]
js: Key handling stubs, Error handling, refactoring

--

* Error handling: introduced GPGMEJS_Error class that handles errors
  at a more centralized and consistent position
* src/Connection.js:
  The nativeMessaging port now opens per session instead of per
  message. Some methods were added that reflect this change
  - added methods disconnect() and reconnect()
  - added connection status query
* src/gpgmejs.js
  - stub for key deletion
  - error handling
  - high level API for changing connection status
* src/gpgmejs_openpgpjs.js
  - added stubs for Key/Keyring handling according to current
    state of discussion. It is still subject to change
* src/Helpers.js
  - toKeyIdArray creates an array of KeyIds, now accepting
    fingerprints, GPGMEJS_Key objects and openpgp Key objects.
* Key objects (src/Key.js) Querying information about a key
  directly from gnupg. Currently a stub, only the Key.fingerprint is
  functional.
* Keyring queries (src/Keyring.js): Listing and searching keys.
  Currently a stub.

17 months agojs: encrypt improvement and decrypt method
Maximilian Krambach [Wed, 18 Apr 2018 14:38:06 +0000 (16:38 +0200)]
js: encrypt improvement and decrypt method

* Compatibility class gpgme_openpgpjs offers an API that should accept
  openpgpjs syntax, throwing errors if a parameter is unexpected/not
  implemented
* tried to be more generic in methods
* waiting for multiple answers if 'more' is in the answer
* more consistency checking on sending and receiving
* updated the example extension
--

17 months agoMerge branch 'master' into javascript-binding
Maximilian Krambach [Fri, 20 Apr 2018 13:23:57 +0000 (15:23 +0200)]
Merge branch 'master' into javascript-binding

17 months agocore: Do not modify args for ignored failures
Andre Heinecke [Fri, 20 Apr 2018 12:30:53 +0000 (14:30 +0200)]
core: Do not modify args for ignored failures

* src/op-support.c (_gpgme_parse_failure): Ignore gpg-exit failures
before modifying args.

--
For op_decrypt_verify the status handler for both decrypt and
verify would parse the failure when the first parser ignored
the failure. This resulted in an ERR_INV_ENGINE as the first
call to parse_failure modified the args.

GnuPG-Bug-Id: T3919

17 months agoPost release updates
Werner Koch [Fri, 20 Apr 2018 08:41:38 +0000 (10:41 +0200)]
Post release updates

--

17 months agoRelease 1.11.1 gpgme-1.11.1
Werner Koch [Fri, 20 Apr 2018 08:22:12 +0000 (10:22 +0200)]
Release 1.11.1

* configure.ac: Bump LT version to C31/A20/R1.  For cpp to C13/A7/R0.
For qt to: C10/A3/R2.

Signed-off-by: Werner Koch <wk@gnupg.org>
17 months agocore: Remove another debug output leftover.
Werner Koch [Fri, 20 Apr 2018 08:32:37 +0000 (10:32 +0200)]
core: Remove another debug output leftover.

* src/decrypt.c (_gpgme_decrypt_status_handler): Remove log debug.

Signed-off-by: Werner Koch <wk@gnupg.org>
17 months agobuild: More release creation automation.
Werner Koch [Fri, 20 Apr 2018 08:13:25 +0000 (10:13 +0200)]
build: More release creation automation.

* Makefile.am: Add release and sign-release targets.

Signed-off-by: Werner Koch <wk@gnupg.org>
17 months agodoc: Suggest the use of strconcat for recipient strings.
Werner Koch [Fri, 20 Apr 2018 06:56:01 +0000 (08:56 +0200)]
doc: Suggest the use of strconcat for recipient strings.

--
GnuPG-bug-id: 3775

Signed-off-by: Werner Koch <wk@gnupg.org>
17 months agojson: Remove the -noinstall flag used during development.
Werner Koch [Thu, 19 Apr 2018 14:19:47 +0000 (16:19 +0200)]
json: Remove the -noinstall flag used during development.

* src/Makefile.am (gpgme-json_LDFLAGS): Remove.
--

Reported-by: Alon Bar-Lev <alon.barlev@gmail.com>
Signed-off-by: Werner Koch <wk@gnupg.org>
17 months agocpp: Add origin and last_update to UserID
Andre Heinecke [Thu, 19 Apr 2018 09:56:15 +0000 (11:56 +0200)]
cpp: Add origin and last_update to UserID

* NEWS: Mention it.
* lang/cpp/src/key.cpp, lang/cpp/src/key.h (UserID::lastUpdate),
(UserID::origin): New.
(gpgme_origin_to_pp_origin): New helper.

17 months agocpp: Add origin and last_update
Andre Heinecke [Thu, 19 Apr 2018 08:44:01 +0000 (10:44 +0200)]
cpp: Add origin and last_update

* NEWS: mention interface change.
* lang/cpp/src/key.cpp (Key::origin, Key::lastUpdate): New.
* lang/cpp/src/key.h (Key::Origin): New enum.

17 months agocore: Remove leftover debug output.
Werner Koch [Thu, 19 Apr 2018 08:34:32 +0000 (10:34 +0200)]
core: Remove leftover debug output.

* src/verify.c (_gpgme_verify_status_handler): Remove debug output.
--

Actually this is a real bug because it uses a debug function available
only in the new libgpg-error versions.  Time to call Jenkins back from
vacation; there are rumors that he has been seen in the city looking
for a new Ryzen tail coat.

Signed-off-by: Werner Koch <wk@gnupg.org>
17 months agotests: Fix t-verify test for GnuPG < 2.2.7.
Werner Koch [Thu, 19 Apr 2018 08:29:30 +0000 (10:29 +0200)]
tests: Fix t-verify test for GnuPG < 2.2.7.

* tests/gpg/t-verify.c (check_result): Tweak for gnupg < 2.2.7.
--

The not yet releases 2.2.7-beta may print a full fingerprint in the
ERRSIG status.  This is compliant with the dscription but the new
t-verify test case did not took in account that older GnuPG versions
print only a keyid.

Fixes-commit: b99502274ae5efdf6df0d967900ec3d1e64373d7
GnUPG-bug-id: 3920
Signed-off-by: Werner Koch <wk@gnupg.org>
17 months agoPost release updates
Werner Koch [Wed, 18 Apr 2018 18:27:14 +0000 (20:27 +0200)]
Post release updates

--

17 months agoRelease 1.11.0 gpgme-1.11.0
Werner Koch [Wed, 18 Apr 2018 17:41:45 +0000 (19:41 +0200)]
Release 1.11.0

* configure.ac: Bump LT version to C31/A20/R0.  For cpp to C12/A6/R0.
For qt to: C10/A3/R1.

Signed-off-by: Werner Koch <wk@gnupg.org>
17 months agojson: Add stpcpy replacement.
Werner Koch [Wed, 18 Apr 2018 18:11:27 +0000 (20:11 +0200)]
json: Add stpcpy replacement.

* src/gpgme-json.c [!HAVE_STPCPY](_my_stpcpy): New.

Signed-off-by: Werner Koch <wk@gnupg.org>
17 months agodoc: Update copyright years and change two URLs.
Werner Koch [Wed, 18 Apr 2018 17:30:50 +0000 (19:30 +0200)]
doc: Update copyright years and change two URLs.

--

Signed-off-by: Werner Koch <wk@gnupg.org>
17 months agodoc: Unify comment style in gpgme.h
Werner Koch [Wed, 18 Apr 2018 17:28:51 +0000 (19:28 +0200)]
doc: Unify comment style in gpgme.h

--

Signed-off-by: Werner Koch <wk@gnupg.org>
17 months agocore: New convenience constant GPGME_KEYLIST_MODE_LOCATE.
Werner Koch [Wed, 18 Apr 2018 15:59:29 +0000 (17:59 +0200)]
core: New convenience constant GPGME_KEYLIST_MODE_LOCATE.

* src/gpgme.h.in (GPGME_KEYLIST_MODE_LOCATE): New.

Signed-off-by: Werner Koch <wk@gnupg.org>
17 months agojson: Add command "decrypt" to gpgme-json.
Werner Koch [Wed, 18 Apr 2018 13:24:42 +0000 (15:24 +0200)]
json: Add command "decrypt" to gpgme-json.

* src/gpgme-json.c (make_data_object): Enable auto-detection of
base-64.
(op_encrypt): Support a 'mime' flag.
(op_decrypt): New.
(process_request): Add command "encrypt".

Signed-off-by: Werner Koch <wk@gnupg.org>
17 months agocore: Add 'is_mime' flags to the verify and decrypt results.
Werner Koch [Wed, 18 Apr 2018 13:20:35 +0000 (15:20 +0200)]
core: Add 'is_mime' flags to the verify and decrypt results.

* src/op-support.c (_gpgme_parse_plaintext): Add arg r_mime.
* src/decrypt.c (_gpgme_decrypt_status_handler): Ser mime flag.
* src/verify.c (_gpgme_verify_status_handler): Ditto.
* src/gpgme.h.in (gpgme_op_verify_result_t): Append fields 'is_mime'
and '_unused'.
(gpgme_op_decrypt_result_t): New field 'is_mime'.  Shrink '_unused'.

* tests/run-decrypt.c (print_result): Print MIME flag.
* tests/run-verify.c (print_result): Ditto.
--

Note that this flag (Liternal Data packet's 'm' mode) is only
specified in RFC-4880bis.  To use it you currently need to add
"rfc4880bis" to the the gpg.conf.

Signed-off-by: Werner Koch <wk@gnupg.org>
17 months agocore: Fix possible compliance mode detection error.
Werner Koch [Wed, 18 Apr 2018 12:41:50 +0000 (14:41 +0200)]
core: Fix possible compliance mode detection error.

* src/verify.c (_gpgme_verify_status_handler): Insert missing break.
--

Before the insertion of the compliance status checking the break in
the default clause was used by the STATUS_PLAINTEXT code.  That got
lost.  I don't see any actual harm due to different values currently
in use for the compliance status.

Fixes-commit: 05fa2a9c7764b28fdac35eb72631439df948ca0e
Signed-off-by: Werner Koch <wk@gnupg.org>
17 months agojson: Improve help meta command in gpgme-json.
Werner Koch [Wed, 18 Apr 2018 09:34:16 +0000 (11:34 +0200)]
json: Improve help meta command in gpgme-json.

* src/gpgme-json.c (process_meta_commands): Add ",help CMD".

Signed-off-by: Werner Koch <wk@gnupg.org>
17 months agojson: Add command "getmore" to gpgme-json.
Werner Koch [Wed, 18 Apr 2018 09:12:46 +0000 (11:12 +0200)]
json: Add command "getmore" to gpgme-json.

* src/gpgme-json.c (MIN_REPLY_CHUNK_SIZE): New const.
(DEF_REPLY_CHUNK_SIZE): New const.
(MAX_REPLY_CHUNK_SIZE): New const.
(pending_data): New var.
(add_base64_to_object): Chnage to take a plain data pointer.
(get_chunksize): New.
(make_data_object): New.
(op_encrypt): Get chunksize and use make_data_object.
(op_getmore): New.
(process_request): Release pending data for all commands but "getmore"
and "help".
--

Native messaging has a limit on the data it may receive in one
request.  Thus the caller needs to watch for the "more" flag and
request the remaining data using "getmore" in a loop.

Signed-off-by: Werner Koch <wk@gnupg.org>
17 months agojson: Add meta command ,read to gpgme-json.
Werner Koch [Wed, 18 Apr 2018 07:26:33 +0000 (09:26 +0200)]
json: Add meta command ,read to gpgme-json.

* src/gpgme-json.c: Include stat.h.
(get_file): New.
(process_meta_commands): Implement ",read".

Signed-off-by: Werner Koch <wk@gnupg.org>
18 months agocore: Extend decryption result with symkey_algo.
Werner Koch [Tue, 17 Apr 2018 11:48:56 +0000 (13:48 +0200)]
core: Extend decryption result with symkey_algo.

* src/gpgme.h.in (gpgme_op_decrypt_result_t): Add field 'symkey_algo'.
* src/decrypt.c (release_op_data): Free SYMKEY_ALGO.
(gpgme_op_decrypt_result): Make sure SYMKEY_ALGO is not NULL.
(parse_decryption_info): New.
(_gpgme_decrypt_status_handler): Parse DECRYPTION_INFO status.
* src/conversion.c (_gpgme_cipher_algo_name): New.
(_gpgme_cipher_mode_name): New.

* tests/run-decrypt.c (print_result): Print SYMKEY_ALGO

* src/util.h (_gpgme_map_gnupg_error): Remove obsolete prototype.
--

Signed-off-by: Werner Koch <wk@gnupg.org>
18 months agocore: New keyword --file for OpenPGP recpstring.
Werner Koch [Tue, 17 Apr 2018 10:40:30 +0000 (12:40 +0200)]
core: New keyword --file for OpenPGP recpstring.

* src/engine-gpg.c (append_args_from_recipients_string): Add new
flags.
--

Now you can use gpgme to encrypt without first importing a key.

Signed-off-by: Werner Koch <wk@gnupg.org>
18 months agocore: For OpenPGP let offline mode disable dirmngr.
Werner Koch [Tue, 17 Apr 2018 09:06:27 +0000 (11:06 +0200)]
core: For OpenPGP let offline mode disable dirmngr.

* src/engine-gpg.c (struct engine_gpg): New flag.offline.
(gpg_set_engine_flags): Set it.  Also fix setting of no_symkey_cache.
(build_argv): Pass --disable-dirmngr in offline mode.
--

GnuPG-bug-id: 3831
Signed-off-by: Werner Koch <wk@gnupg.org>
18 months agopython: Fix crash by leaving struct members intact
Tobias Mueller [Tue, 20 Feb 2018 16:34:14 +0000 (17:34 +0100)]
python: Fix crash by leaving struct members intact

* lang/python/setup.py.in: Copy gpgme.h instead of parsing it.
--
The python bindings tried to parse deprecated functions
out of gpgme.h. This fails for the current gpgme.h in
that it removes an entire field in the key sig struct (_obsolete_class).
Hence, the fields were off by an int and the bindings accessed struct
members via the wrong offset. That caused python program to crash.
At least on 32bit platforms, the crash can be easily triggered by
accessing key.uids[0].signatures. On 64bit platforms the compiler
probably aligns the struct so that the missing 4 bytes are not noticed.

With this change, the python bindings will expose all functions
that gpgme exposes, including the deprecated ones.

Credits go to Justus Winter for debugging and identying the issue.

Signed-off-by: Tobias Mueller <muelli@cryptobitch.de>
GnuPG-bug-id: 3892

18 months agocore: Allow for --hidden keyword in OpenPGP recpstrings.
Werner Koch [Tue, 17 Apr 2018 08:04:20 +0000 (10:04 +0200)]
core: Allow for --hidden keyword in OpenPGP recpstrings.

* src/engine-gpg.c (append_args_from_recipients_string): Add special
keywords.
--

GnuPG-bug-id: 3775
Signed-off-by: Werner Koch <wk@gnupg.org>
18 months agocore: New encryption flag GPGME_ENCRYPT_WANT_ADDRESS.
Werner Koch [Tue, 17 Apr 2018 07:40:27 +0000 (09:40 +0200)]
core: New encryption flag GPGME_ENCRYPT_WANT_ADDRESS.

* src/gpgme.h.in (GPGME_ENCRYPT_WANT_ADDRESS): New flag.
* src/engine-gpg.c (add_arg_recipient): New.
(add_arg_recipient_string): New.
(append_args_from_recipients): Call new helper function.
(append_args_from_recipients_string): Ditto.
* src/gpgme-json.c (op_encrypt): Add flag "want-address".
--

Signed-off-by: Werner Koch <wk@gnupg.org>
18 months agocore: Add extended versions of the encrypt functions.
Werner Koch [Tue, 17 Apr 2018 06:33:44 +0000 (08:33 +0200)]
core: Add extended versions of the encrypt functions.

* src/gpgme.h.in (gpgme_op_encrypt_ext_start) New.
(gpgme_op_encrypt_ext): New.
(gpgme_op_encrypt_sign_ext_start): New.
(gpgme_op_encrypt_sign_ext): New.
* src/libgpgme.vers, tests/run-encrypt.c: Add them.

* src/encrypt.c (encrypt_start): Add arg recpstring.
(gpgme_op_encrypt): Factor code out to ...
(gpgme_op_encrypt_ext): new function with new arg recpstring.
(gpgme_op_encrypt_start): Factor code out to ...
(gpgme_op_encrypt_ext_start): new function with new arg recpstring.
* src/encrypt-sign.c (encrypt_sign_start): Add arg recpstring.
(gpgme_op_encrypt_sign): Factor code out to ...
(gpgme_op_encrypt_sign_ext): new function with new arg recpstring.
(gpgme_op_encrypt_sign_start): Factor code out to ...
(gpgme_op_encrypt_sign_ext_start): new function with new arg
recpstring.

* src/engine-backend.h (struct engine_ops): Change fields encrypt and
encrypt_sign.
* src/engine.c (_gpgme_engine_op_encrypt): Add arg recpstring and pass
to engine.
(_gpgme_engine_op_encrypt_sign): Ditto.
* src/engine-gpg.c (append_args_from_recipients_string): New.
(gpg_encrypt): Add arg recpstring and call new function as needed.
(gpg_encrypt_sign): Ditto.
* src/engine-gpgsm.c (set_recipients_from_string): New.
(gpgsm_encrypt): Add arg recpstring and call new function as needed.
* src/engine-uiserver.c (set_recipients_from_string): New.
(uiserver_encrypt): Add arg recpstring and call new function as
needed.

* tests/run-encrypt.c (xstrdup): New.
(main): Add option --keystring.

* src/gpgme-json.c (get_keys): Simplify.
(op_encrypt): Modify to make use of the extended encrypt function.

--

This new feature can be used to avoid the need for a key lookup and
thus several extra calls to the backend.

Note that run-test uses a semicolon as delimiter because that make
testing the feature on the command line much easier.

Signed-off-by: Werner Koch <wk@gnupg.org>
18 months agocore: Tweak STATUS_FAILURE handling.
Werner Koch [Thu, 12 Apr 2018 18:36:30 +0000 (20:36 +0200)]
core: Tweak STATUS_FAILURE handling.

* src/op-support.c (_gpgme_parse_failure): Ignore failures with
location "gpg-exit".
* tests/gpg/t-verify.c (main): Adjust for the now working checking of
the second key.

Signed-off-by: Werner Koch <wk@gnupg.org>
18 months agocore: For a failed verification return the sig's fingerprint.
Werner Koch [Thu, 12 Apr 2018 18:26:00 +0000 (20:26 +0200)]
core: For a failed verification return the sig's fingerprint.

* src/verify.c (parse_new_sig): Parse the new ERRSIG fpr.
--

This works only when the signatures features an ISSUER_FPR sub-packet
and with GnuPG >= 2.2.7.  If that is not the case the keyid is kept in
the FPR field.

Signed-off-by: Werner Koch <wk@gnupg.org>
18 months agotests: Avoid segv in run-verify due to Policy URLs
Werner Koch [Thu, 12 Apr 2018 13:59:22 +0000 (15:59 +0200)]
tests: Avoid segv in run-verify due to Policy URLs

* tests/run-verify.c (print_result): Take care of Policy URLs.

Signed-off-by: Werner Koch <wk@gnupg.org>
18 months agotests: Add another check to gpg/t-verify.
Werner Koch [Thu, 12 Apr 2018 13:39:20 +0000 (15:39 +0200)]
tests: Add another check to gpg/t-verify.

* tests/gpg/t-verify.c (PGM): New.  Use it instead of __FILE__.
(test_sig1_plus_unknown_key): New test signature.
(check_result): Allow checking of several signatures.
(main): Check a signature with a know and an unknown key.

Signed-off-by: Werner Koch <wk@gnupg.org>
18 months agocore: Add new context flag "no-symkey-cache".
Werner Koch [Thu, 12 Apr 2018 07:17:27 +0000 (09:17 +0200)]
core: Add new context flag "no-symkey-cache".

* src/gpgme.c (gpgme_set_ctx_flag): Set flag.
(gpgme_get_ctx_flag): Get flag.
* src/context.h (struct gpgme_context): Add field no_symkey_cache.
* src/engine-gpg.c (struct engine_gpg): Ditto.
(gpg_set_engine_flags): Set flag.
(build_argv): Pass option --no-symkey-cache to gpg.

* tests/run-decrypt.c (print_result): Fix segv for symmetric messages.
(main): New option --no-symkey-cache.
* tests/run-encrypt.c (main): New option --no-symkey-cache.

Signed-off-by: Werner Koch <wk@gnupg.org>
18 months agojs: Initial commit for JavaScript Native Messaging API
raimund.renkert@intevation.de [Tue, 10 Apr 2018 09:33:14 +0000 (11:33 +0200)]
js: Initial commit for JavaScript Native Messaging API

--

Note this code misses all the legal boilerplate; please add this as
soon as possible and provide a DCO so we can merge it into master.

I also removed the dist/ directory because that was not source code.

18 months agoqt: Add test for resetting config value
Andre Heinecke [Wed, 4 Apr 2018 09:21:53 +0000 (11:21 +0200)]
qt: Add test for resetting config value

* lang/qt/tests/t-config.cpp (CryptoConfigTest::testDefault): New.

--
There is a bug around here somewhere. This test does not show
it :-(

18 months agoMerge branch 'master' of ssh+git://playfair.gnupg.org/git/gpgme
Ben McGinnes [Thu, 29 Mar 2018 23:38:31 +0000 (10:38 +1100)]
Merge branch 'master' of ssh+git://playfair.gnupg.org/git/gpgme

* Also fixed a small grammatical error highlighted by a merge conflict
  (in the python bindings howto).

18 months agojson: Build only a dummy if libgpg-error is < 1.28
Werner Koch [Thu, 29 Mar 2018 13:06:47 +0000 (15:06 +0200)]
json: Build only a dummy if libgpg-error is < 1.28

Signed-off-by: Werner Koch <wk@gnupg.org>
18 months agoMerge branch 'ben/howto-update-02' of ssh+git://playfair.gnupg.org/git/gpgme
Ben McGinnes [Wed, 28 Mar 2018 23:27:41 +0000 (10:27 +1100)]
Merge branch 'ben/howto-update-02' of ssh+git://playfair.gnupg.org/git/gpgme

18 months agoexample: revoke UID ben/howto-update-02
Ben McGinnes [Wed, 28 Mar 2018 23:21:52 +0000 (10:21 +1100)]
example: revoke UID

* Script to revoke a UID on an existing key.