Commit Graph

2880 Commits

Author SHA1 Message Date
Ben McGinnes
4e8a92ed14 Python bindings: examples
* lang/python/examples/howto/export-secret-keys.py and groups.py:
  Updated the backwards compatibility adjustments to account for
  unicode differences between python 2 and 3.
2018-09-16 03:34:36 +10:00
Ben McGinnes
864ef9b40f Python examples: backwards compatibility
* lang/python/examples/howto/groups.py: subprocess update
* lang/python/examples/howto/export-secret-keys.py: subprocess update

  Both of these try the nice and easy method of getting the subprocess
  output available in Python 3, but will fall back to the older Popen
  method if it doesn't work.  Essentially this is to be a little nicer
  to Python 2.7.15 (even though the examples are filled with warnings
  that py2 support is not guaranteed with the examples).
2018-09-15 12:10:05 +10:00
Thomas Oberndörfer
dd7d37ca21
js: Fix errorDetails of GPGME_Signature
* lang/js/src/Signature.js (GPGME_Signature.errorDetails):
Access properties from the summary object.
2018-09-10 13:11:48 +02:00
Ben McGinnes
2375959180 estreams revised
* Egon Spengler was right, crossing the streams is bad.
* Restored both src/gpgme.def and src/libgpgme.vers to use the
  estreams symbols without the leading underscore.
* The new_from_estream() function added to lang/python/src/core.py and
  set to alias the new_from_stream() function remains.
* Opted for the solution favouring Linux onthree main grounds:
  1. Andre reported major problems with Windows as well, so the number
     of potentially affected systems would vastly increase.
  2. All the BSDs and OS X have spent far more time and development
     work in order to accommodate the eccentricities of both Microsoft
     and the GNU Project (ref. GCC), so they're more likely to be able
     to cope with doing so again than the other way around.
  3. If I really have to I can write a custom installer for OS X to
     try this and, if it fails, to then patch the two symbol entries and
     recompile from scratch.  That said, I may not have to since it
     actually behaved during the most recent tests for this
     commit; into ten separate CPython installations and all five
     supported versions (standard source installs and OS X Framework
     installs for each version).

Tested-by: Ben McGinnes <ben@adversary.org>
Signed-off-by: Ben McGinnes <ben@adversary.org>
2018-09-08 14:45:37 +10:00
Maximilian Krambach
53d69af014 js: add new documentation file to extra_dist
--
* jsdoc_index.md is the documentation's 'main page' to offer a better
  intro than only the parser-generated API confusion.
2018-09-06 11:27:39 +02:00
Maximilian Krambach
6463b1cd3b js: fix error in toKeyIdArray
--
* src/Helpers.js: GPGME_Keys were not parsed as valid, as their
  fingerprint getter is not a fingerprint 'property'.

* BrowserTestExtension: fixed a dsplay typo in counting of tests.
2018-09-06 10:11:10 +02:00
Maximilian Krambach
1c618166fc js: documentation cleanup
--
2018-09-05 18:46:28 +02:00
Ben McGinnes
879cc1f84f estreams symbols for python bindings
* It turns out that even though some platforms detect differing
  symbols for estreams, the two types do not appear to be in
  conflict.  At least they don't from the BSD/OS X side of things.
  As a consequence both versions are now included.

Tested-by: Ben McGinnes <ben@adversary.org>
Signed-off-by: Ben McGinnes <ben@adversary.org>
2018-09-02 19:07:18 +10:00
Maximilian Krambach
dacb119715 js: key deletion after test
--

* Yet again some wrong syntax in Browsertests
2018-08-31 15:24:38 +02:00
Maximilian Krambach
346dfac0de js: cleanup after key import test
--

* one of the public Keys imported was not removed afterwards.
2018-08-31 10:36:54 +02:00
Ben McGinnes
55991aa916 docs: python bindings
* minor typographic update.

Signed-off-by: Ben McGinnes <ben@adversary.org>
2018-08-31 17:36:45 +10:00
Maximilian Krambach
87bbe728fa js: tests for file name encoding
--

* BrowsertestExtension/tests/decryptTest.js: There were cases in which
  file names returned in a wrong encoding from decryption. The test
  cases here are a  'Hello World' in a text file with different names,
  then being encrypted with cli gnupg.
2018-08-30 16:16:13 +02:00
Maximilian Krambach
5d6039f6bf js: decoding of information
--

* src/Helpers.js: This additional escape should 'repair' special
  characters like spaces in filenames. In the strange world of
  encoding there is little hope that this captures all cases, or
  that it will never fail to return some value, let alone meaningful.
  In my test cases it worked.
2018-08-30 15:37:37 +02:00
Maximilian Krambach
3201ded91f js: add tests
--

* BrowserTestExtension/tests:

  - decryptTest.js: Check Decryption and return values of binary data
  - encryptTest.js: Return data type of armored/non-armored encryption
  - added a small encoded input png for testing

* DemoExtension/maindemo.js: Fixed unexpected usage of the Demo encrypt
  (non-armored)
2018-08-30 15:00:19 +02:00
Maximilian Krambach
44691995b7 js: add encoding parameter for encrypt return
--

* src/gpgme.js: In case the encryption was done unarmored, the result
  is binary data. Added an option to either return the binary data as
  base64-encoded string or as Uint8Array, similar to return values of
  decrypt
2018-08-30 14:46:54 +02:00
Maximilian Krambach
a9863717b1 js: separate gpgme answer by type of data
--

* src/Connection.js; src/permittedOperations.js: To avoid further
  encoding problems, data sent by gpgme is now sorted  as either
  'payload' or 'info'. Payload data may come in any encoding, and here
  the 'expected' and 'format' options are used, 'info' data may
  contain text created by gnupg which may need re-encoding, but this
  should not be affected by 'expected' and 'format'
2018-08-30 12:09:26 +02:00
Ben McGinnes
1d00fb987b python bindings: estreams fix
* lang/python/src/core.py: Adjusted new_from_estream function to alias
  new_from_stream instead of fd.
* fixed the _gpgme import errors introduced in commit
  08cd34afb7 by changing the exported
  functions/types to match the inner module where all the work is
  done, rather than the outer one(s).

Tested-by: Ben McGinnes <ben@adversary.org>
Signed-off-by: Ben McGinnes <ben@adversary.org>
2018-08-30 15:41:31 +10:00
Maximilian Krambach
61ac70cfb5 js: return base64 after encrypt with armor=false
--

* src/gpgmejs.js/encrypt: the encrypted data were converted back to a
  (incorrect) string, whereas they should be data with no encoding
  specified. Returning base64 data is the expected way.
* DemoExtension: caught yet another usage of old syntax.
2018-08-29 17:45:55 +02:00
Ben McGinnes
18ea838671 python bindings: core
* lang/python/src/core.py: expanded gpgme_error check lists.
2018-08-30 01:01:23 +10:00
Ben McGinnes
dcedddecb6 python bindings: core
* lang/python/src/core.py: added gpgme_data_set_flag to the errorcheck
  funtion.
2018-08-30 01:01:23 +10:00
Ben McGinnes
6078b53033 python bindings: core
* lang/python/src/core.py: added new function new_from_estream to wrap
  new_from_fd just like new_from_stream does and for the same reason.
2018-08-30 01:01:23 +10:00
Andre Heinecke
1420c3bd68
json: Fix detached verify
* src/gpgme-json.c (op_verify): Only create output and
use it for clearsigned and opaque signed.

--
Just passing output to gpgme_op_verify changes the behavior to
no longer do a verify of the signature.
2018-08-29 14:32:36 +02:00
Ben McGinnes
f7e5ae7f16 docs: python bindings - protonmail examples
* lang/python/docs/GPGMEpythonHOWTOen.org: Updated links to the
  ProtonMail keyserver import scripts and added a warning regarding
  being unable to update third party keys.
* lang/python/examples/howto/pmkey-import-alt.py: added usage.
* lang/python/examples/howto/pmkey-import.py: added usage.
2018-08-29 20:30:57 +10:00
Ben McGinnes
16e566f319 Merge branch 'master' of ssh+git://playfair.gnupg.org/git/gpgme 2018-08-29 04:16:37 +10:00
Ben McGinnes
02d0b97bfe docs: python bindings HOWTO
* Finished CFFI vs SWIG bit in known issues.
* tidied up some of the structure.
* Fixed some minor errors and links.
2018-08-29 04:14:24 +10:00
Ben McGinnes
a8a983c5bc docs: python bindings
* Added section on why no CFFI.
2018-08-29 03:42:46 +10:00
Ben McGinnes
c2831e2377 docs: python howto
* Added another key import example using ProtonMail's new keyserver.
2018-08-28 18:45:37 +10:00
Andre Heinecke
3bdf8be6d2
json: Delete primary key if subkey gen fails
* src/gpgme-json.c (op_delete): Delete primary key on
subkey gen error.

--
This can happen for example if the user cancels the
pinentry to unlock the primary key when adding the
subkey.  To avoid an artifact of a pimary key without
an encryption capable subkey we delete the created
key and treat the whole operation as failed.
2018-08-28 08:35:06 +02:00
Andre Heinecke
7d3c13df26
json: Allow NULL request in encode and chunk
* src/gpgme-json.c (encode_and_chunk): Don't error on NULL
request.

--
This fixes the error that is passed when parthing the json
object failed and request would be NULL.
Instead of the JSON parser error it would otherwise report
that encode and chunk failed.
2018-08-28 08:05:46 +02:00
Ben McGinnes
1c261b9fa3 docs: python bindings
* Added details on installation troubleshooting.
2018-08-28 06:42:27 +10:00
Maximilian Krambach
8aa61fd3a2 js: small documentation update
--
2018-08-27 13:25:58 +02:00
Maximilian Krambach
28086252f1 js: make non-payload data more encoding-tolerant
--

* src/Helpers.js: As non-payload data might come in different
  encodings, a conversion has been introduced that worked in most
  cases. Data like the userid might come in different encodings,
  which we don't know of. For now, a try..catch returns the data
  as they are if the utf-8 decoding fails. Sometimes this yields the
  correct result, sometimes it may not work, but it won't stop the
  whole operation anymore.
2018-08-27 13:00:50 +02:00
Maximilian Krambach
766d42c248 js: typecheck destructured parameters
--

* destructuring just takes the input argument and treats it as object.
  In cases like in src/Keyring/generateKey, where I forgot to change
  the old syntax, the fingerprint as string was destructured into an
  object without "pattern", which caused all Keys to be retrieved.
  So, methods with a destructuring now check if the first argument is
  an object and get a default empty object if no parameter is
  submitted. This allows the further use of destructured parameters,
  while still ensuring nothing vastly incorrect is used.
* src/Kering.js, unittsets.js: fixed old syntax in method usage
2018-08-27 12:38:32 +02:00
Werner Koch
53c5b9a265
json: Do not put FILE_NAME into the verify result.
* src/gpgme-json.c (verify_result_to_json): Remove "file_name".
--

Having the file name in the verify result may lead developers to
assume that the file name is covered by the signature.  This is not
the case and can easily be checked by hex-editing a signed message.
We better don't output it at all.

The same is true for the is_mime flag but that is anyway only an
advisory and I can't see damage from a faulty one.

Note that we keep file_name in gpgme's output for ABI stability and
because some tools want to display meta information even if they are
subject to tampering.  This is similar to the non-encrypted subject in
mails.

Signed-off-by: Werner Koch <wk@gnupg.org>
2018-08-27 11:43:02 +02:00
Werner Koch
702566b36c
doc: Add warning that FILE_NAME is not part of the signed data.
--
2018-08-27 11:43:02 +02:00
Maximilian Krambach
4f28fbddd3 js: extend information on decoding in decrypt
--

* src/Connection.js: resulting data, if not pure ascii, is base64
  encoded in the result message. A further decoding attempt into
  javascript 'string' will be attempted by default, unless specified
  at the decrypt() method. The return value 'format' now shows which
  of the possibilities has been applied. The old boolean 'base64'
  now turns into format:'base64' if the returned payload is a base64
  string after decryption.
2018-08-27 11:50:09 +02:00
Maximilian Krambach
557fec6002 js: fix file_name return on decrypt
--
* src/gpgmejs: Line 228 checked the wrong variable. To avoid further
  confusion, _result was renamed to returnValue in the whole file
2018-08-27 11:21:02 +02:00
Jasper Spaans
08cd34afb7
core: Export gpgme_data_new_from_estream function.
Signed-off-by: Werner Koch <wk@gnupg.org>
2018-08-27 09:06:20 +02:00
Maximilian Krambach
138e1dde02 js: add new options to permittedOperations
--

* reflecting the new optional strings accepted by the backend.
  'file_name' and 'sender' can be  used via the 'additional'
  parameter in encrypt operations
2018-08-24 10:33:42 +02:00
Andre Heinecke
a5f8dac77d
json: Add sender and file name to encrypt
* src/gpgme-json.c (hlp_encrypt, op_encrypt): Support sender
and file_name.
2018-08-23 20:50:18 +02:00
Maximilian Krambach
f62dd4bb27 js: fix syntax inside Keyring methods
--

* recent changes in parameter calling led to a forgotten internal call
  in getDefaultKey using old syntax (and failing in case a default key
  is configured)
2018-08-23 17:58:22 +02:00
Maximilian Krambach
352c53040d js: offer an always-trust parameter on encrypt
--

* src/gpgmejs.js: Setting the default to 'always trust' assumes that
  most api users will already have made their internal checks, but may
  not have the gnupg web-of-trust model implemented, thus trusting the
  key themselves, without gnupg having full or even any information.
  Still it should stay an option to have gnupg decide.
2018-08-23 12:30:49 +02:00
Maximilian Krambach
3fd6837fce js: use destructured option parameters
--
* Adds to f0409bbdaf and makes use of
  destructuring, allowing for defaults, and cleaning up the
  validation.
2018-08-23 12:15:59 +02:00
Maximilian Krambach
60dc499abd js: update getDefaultKey to more precise logic
--

* src/Keyring.js: Adapted Keyring.getDefaultKey() to my current
  understanding  of a default signing key: either the default key set
  in the gpg config, or 'the first usable private key' - usability
  meaning  'not invalid, expired, revoked, and can be used for
  signing'. It should be the same key used as in command line when
  doing a --sign operation.
  In case the user has a smartcard plugged in, we currently
  won't know of this here, so our choice may differ. But as we do all
  javascript-binding sign operations with the key  fingerprint
  explicitly set, this should not be a real problem. This method is
  seen more as a convenience to tell using librarys which key
  represents the main user.
2018-08-23 11:28:18 +02:00
Maximilian Krambach
24a0005865 js: add decrypt result options
--

* As a decrypt result cannot be known beforehand, the decrypt operation
  may add an 'expect' property, taking either 'uint8' or 'base64',
  which will return the decrypted data in the appropiate formats.
  the return property 'format' will give a feedback on which option
  was taken.
  A test was added to reflect these changes.
2018-08-22 19:07:05 +02:00
Maximilian Krambach
f0409bbdaf js: make method parameters objects
--

* As requested by using parties, the options to be passed into the
  methods are now objects, with the objects' properties better
  describing what they do, and to avoid the need to type several nulls
  in a method call if one wants the last parameter.
  - src/Keyring.js, src/gpgme.js: Changed parameters and their
    validations
  - BrowserTest/*.js Had to adapt quite some calls to the new format
2018-08-22 18:37:46 +02:00
Maximilian Krambach
129fa919b9 js: improve decryption performance
--
* src/Connection.js, src/Helpers.js: performance of decoding incoming
  base64 data was improved to about 4 times the speed by introducing
  two more efficient functions (thanks to rrenkert@intevation.de for
  finding and testing them)

* src/gpgmejs.js: Decrypted data will now return as Uint8Array, if the
  caller does not wish for a decoding. Decoding binary data will return
  invalid data, and a Uint8Array may be desired. This can be indicated
  by using the (new) 'binary' option in decrypt.

* src/Errors.js A new error in case this decoding fails

* src/Message.js, src/Connection.js: expected is change from base64
  to binary, to avoid confusion later on.
2018-08-22 16:32:31 +02:00
Maximilian Krambach
94a0ed361e js: Return error if signature has no fingerprint
--

* src/Signature.js/get fingerprint: A signature with no fingerprint
  should not happen, but if it does, we should throw an error here,
  as the method is a getter.
2018-08-22 14:49:11 +02:00
Andre Heinecke
59ed27bae1
Merge branch 'javascript-binding'
This adds a new language binding "gpgme.js" to GPGME. It
serves as a bridge between the native-messaging service "gpgme-json"
and JavaScript Applications.

The first user of this binding will be Mailvelope which will
see GnuPG integration in the near future.

GnuPG-Bug-Id: T4107
2018-08-22 13:15:35 +02:00
Maximilian Krambach
d8fd4aad8a js: changed verify signature result infos
--

* the resulting information of verify now are as documented,
  and the same as in a decrypt callback
2018-08-22 12:44:05 +02:00