Commit Graph

3034 Commits

Author SHA1 Message Date
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
Maximilian Krambach
93f674d33d js: throw errors in sync functions
--

* synchronous functions should throw errors if something goes wrong,
  Promises should reject. This commit changes some error cases that
  returned Error objects instead of throwing them

  - src/Key.js: createKey() and sync Key.get() throw errors
  - src/Error.js: Exporting the list of errors to be able to test and
    compare against these strings
  - src/Keyring.js: Setting a null value in pattern is not useful, and
    now caused an error with the new changes.
  - src/Message.js: createMessage and Message.setParameter now throw
    errors
2018-08-22 12:18:55 +02:00
Maximilian Krambach
6d720137dd js: update decrypt/verify results
--

* src/gpgmejs.js: Decrypt now parses additional optional dec_info
  information, as well as any verify information, if present

* src/permittedOperations: Now decrypt also expect the new return
  object dec_inf (containing info such as is_mime and file_name)
2018-08-21 15:26:17 +02:00
Maximilian Krambach
9dd6c67cd5 js: remove outdated checklists
--

* They are heavily outdated and offer no more useful information
2018-08-21 14:37:50 +02:00
Andre Heinecke
263dadb04a
json: Add proper decrypt_result_t handling
* src/gpgme-json.c (recipient_to_json, decrypt_result_to_json):
New.
(op_decrypt, hlp_decrypt): Update.

--
The op_decrypt as one of the first operations did not yet
match the current 1 <> 1 mapping of gpgme types to json
dictonaries.

info and dec_info are bad names but used for compatibility reasons.
2018-08-21 14:36:42 +02:00
Andre Heinecke
0036b9bc49
js: Fix library name mentioned in js Makefiles
--
2018-08-21 13:58:51 +02:00
Andre Heinecke
738a8e6f95
js: Update extra_dist files
* lang/js/BrowserTestExtension/Makefile.am,
lang/js/Makefile.am (EXTRA_DIST): Update.
2018-08-21 13:58:51 +02:00
Andre Heinecke
9608996d88
Add example manifests for gpgme-json
* doc/examples/gpgme-chrome.json, doc/examples/gpgme-mozilla.json: New.
* doc/Makefile.am (EXTRA_DIST): Include them.

--
The id contained in the examples is the ID of Mailvelope.
2018-08-21 13:58:51 +02:00
Andre Heinecke
605eb8a8bf
js: Improve README
* lang/js/README: Clarify structure at the beginning.
2018-08-21 13:58:51 +02:00
Andre Heinecke
fe3de5b86b
Remove js as language from configure.ac
* configure.ac: Remove js language.

--
It does not make much sense to integrate gpgme-js into the
GPGME build system. gpgme-js will be distrbuted by it's users
as part of the web extensions / their distribution as that
is the JavaScript way.

So they can use their tools etc. to compile gpgme-js JavaScript
style, which is documented in the lang/js folder.
2018-08-21 13:58:40 +02:00
Maximilian Krambach
8b8c009dee js: set expiry of generatedKey to seconds from now
--

* src/Keyring.js: Changed key ecpiration from Date to seconds from
  creation, as in gpgme. The Date parameter used before was due to a
  misunderstanding in documentation and requests from potential users.
2018-08-21 11:42:11 +02:00
Maximilian Krambach
d77a1c887d js: add option "subkey-algo" to generateKey
--

* The option was recently added to gpgme-json; this reflects this on
  javascript side
2018-08-20 18:05:34 +02:00
Maximilian Krambach
91c2362550 js: set expiry date on generateKey
--

* on the javascript side a Date is expected, gpggme-json expects
  seconds from 'now'
2018-08-20 17:46:29 +02:00
Andre Heinecke
8103eeba80
json: Add subkey_algo and defaults to createkey
* src/gpgme-json.c (op_createkey, hlp_createkey): Add subkey_algo
handling.
(hlp_createkey): Fix documentation of expiry.
--
Due to the funny quick-gen-key interface generating a key
with an explicit algo would result in bad defaults (only an SC key),
without a subkey.

This adds handling that should probably be in GnuPG proper to fix
the semantics of createkey by adding default subkey_algo handling.
2018-08-20 16:38:36 +02:00
Maximilian Krambach
dd32daad0b js: add and apply eslint rules
--

* mainly spacing, see .eslintrc.json for details
2018-08-20 15:12:01 +02:00
Maximilian Krambach
1954d27be8 js: revert changes to class read/write restriction
--

* undoes 94ee0988d4 and
  e16a87e839.
  I do not fully understand why my approach was bad, but I am not in
  a position to argue. This revert was requested to me after a review,
  and I'm doing it in the assumption that more experienced people know
  better than me.
* unittests: Also changed some outdated tests that stopped working
  since 754e799d35 (as GPGME_Key is not
  exported, one cannot check for instanceof in the tests anymore)
2018-08-20 12:12:43 +02:00
Ben McGinnes
75bc5e6356 Python bindings examples
* import-key.py: fixed a minor typo.
* pmkey-import.py: locates and imports keys from the ProtonMail keyserver.
* pmkey-import-alt.py: the same as the previous except with setting an
  alternative $GNUPGHOME directory.
2018-08-19 14:32:30 +10:00
Ben McGinnes
03b899dbe1 Python bindings setup file
* Moved the build import back up where it belongs.
* Included comments indicating how to build and install for multiple
  Python versions beyond the first 2 on the same system.
2018-08-19 00:21:47 +10:00
Ben McGinnes
5facba45c8 Python bindings tests: Near PEP8 compliance
* PEP8 compliance for the vast majoeity of the tests.
2018-08-18 20:29:14 +10:00
Ben McGinnes
b5fbe90676 Python bindings examples: PEP8 conpliance
* Appears to be complete compliance.
2018-08-18 18:46:47 +10:00
Ben McGinnes
fc55caccfc Python bindings setup: Near PEP8 compliance
* lang/python/version.py.in: Fixed most things, but there's still an
  issue near the build portion with the existing Python bugs referenced.
* lang/python/setup.py.in: Now PEP8 compliant.
2018-08-18 18:19:16 +10:00
Ben McGinnes
8a6a73b9c4 Python bindings constants: PEP8 compliance (almost)
* PEP8 compliance for all constants except the globals in
  src/constants/__init__.py depending on whether the import sequence
  affects the globals themselves.
2018-08-18 15:36:23 +10:00
Ben McGinnes
7962cde13c Python bindings src: PEP8 compliance
* import namespace clearance for src/*.py.
* Fixed a handful of is/is not None checks as well.
2018-08-18 15:05:34 +10:00
Maximilian Krambach
74684f24c6 js: decode arriving gpg message strings
--

* Arriving strings (i.e. user id names, error messages) are not
  always in javascript encoding. This is an attempt to go through
  the whole gpgme answer (with the exception of payload data) and
  to fix the encoding of these
2018-08-17 19:20:35 +02:00
Maximilian Krambach
3cbafb97ec js: correct decrypt result info (2)
--

* the permittedOperation from last commit ended up in the wrong place.
  sign does not return an additional 'info' object.
2018-08-17 18:25:57 +02:00
Maximilian Krambach
fff365ffc5 js: expect additional 'info' to arrive on decrypt, too
--

* src/permittedOperations.js: if decrypt includes a verification,
  this info needs to pass, too.
2018-08-17 17:55:11 +02:00
Maximilian Krambach
5b0f8230b2 js: decrypt callback is_mime fix
--

* src/gpgmejs: is_mime should report its' counterpart. Also,
  file_name is not optional in specification. We'll send null if
  there is no file_name
2018-08-17 17:44:06 +02:00
Maximilian Krambach
8e87790db3 js: don't expire new keys if no date is set
--

* src/Keyring.js A new Key without expiration is documented as
  'never expire' here, and should behave accordingly. This requires
  sending '0' here.
2018-08-17 17:20:35 +02:00
Maximilian Krambach
3fb094a9b8 js: small documentation fix
--
2018-08-17 17:14:51 +02:00
Maximilian Krambach
ad39d54d19 js: removed Key.armor property in synchronous use
--

* src/Key.js The synchronous mode for a Key does not offer an armor/
  armored property anymore. This frees up a lot of performance issues,
  also the armored expoort is expected to change quite often, so a
  cached version is not advisable.

* hasSecret/getHasSecret is now refactored, to reflect their uses.
  With get('hasSecret') there is a method that fetches the result.

* src/Key.js also some refactoring
2018-08-17 16:57:41 +02:00
Maximilian Krambach
754e799d35 js: disallow bulk set data on key from outside
--

* src/Key.js Key class is not exported anymore, as it should not be
  used directly anywhere. setKeyData is no more a method of the Key,
  (optional) data are now validated and set on Key creation and on
  updates, both from within this module, thus no longer exposing
  setKeyData to the outside.
* createKey now gained an optional parameter which allows to set Key
  data at this point.
2018-08-17 14:40:27 +02:00
Maximilian Krambach
90cb4a6842 js: importKey feedback refactor
--
* src/Keyring.js: An empty result should no longer cause an error,
  the import feedback summary has been refactored slightly
* Browsertests to reflect import feedback change
2018-08-16 17:58:11 +02:00
Maximilian Krambach
d65a392670 js: fix import feedback
--
* src/Keyring.js For Key imports without prepare_sync the import
  feedback was lacking the summary
2018-08-16 17:07:29 +02:00
Maximilian Krambach
ea43158d40 js: avoid async getters
--

* src/Key.js get armored was returning a promise on async keys.
  As getters should not do that, it returns an error in this case.
2018-08-16 14:40:53 +02:00
Maximilian Krambach
43cff51364 js: wrong object assumed in recent commit
--

* src/Keyring.js I wrongly assumed an object to be a GPGME_Key,
  it was the raw answer from nativeMessaging instead. Now it returns
  a GPGME_Key again.
2018-08-16 12:13:10 +02:00
Maximilian Krambach
715cdc0d7d js: get default key fixes
--

* src/Keyring.js: The answer was not parsed correctly, so a config was
  being ignored.

* If no config is set, we return the first non-invalid key with a
  secret, instead of the first key (which may be e.g. an expired one)
2018-08-16 12:03:30 +02:00
Maximilian Krambach
aeb065acc9 js: simplify getDefaultKey
--

* src/Keyring.js: In case no default Key is set in configuration,
  only Keys reported as having a secret part should be considered
  for default Keys, avoiding some extra requests.
2018-08-16 11:29:10 +02:00
Maximilian Krambach
622db0d1de js: consistently return uppercase fingerprint
--

* src/Key.js: the fingerprint returned by a Key is now always upper
  case hex, even if the constructor had lower case input. This is to be
  more consistent with gpgme and to be more readable and reliable in
  comparisions.
2018-08-16 11:25:50 +02:00
Ben McGinnes
279cac0ffb Symmetric example
* lang/python/examples/howto/symcrypt-file.py: *sigh*; passphrase was
  right the first time, just the error check that wasn't.
* I really should stop second guessing myself one of these days ...

Signed-off-by: Ben McGinnes <ben@adversary.org>
2018-08-14 02:55:56 +10:00
Ben McGinnes
a256d84882 Symmetric encryption example
* lang/python/examples/howto/symcrypt-file.py: Fixed the error code
  and the passphrase key word arg.
2018-08-14 02:48:38 +10:00
Ben McGinnes
ed5ef8293c Symmetric encryption example.
* lang/python/examples/howto/symcrypt-file.py: A variation on standard
  key based encryption.
2018-08-14 02:22:36 +10:00
Ben McGinnes
94bf13e78e PEP8 compliance and other code fixes
* Ran all the .py files in src/ and below through Yapf.
* Included some manual edits of core.py, this time successfully making
  two notorious sections a bit more pythonic than scheming.
* Left the module imports as is.
* This will be committed if it passes the most essential test:
  compiling, installing and running it.

Signed-off-by: Ben McGinnes <ben@adversary.org>
2018-08-10 11:25:01 +10:00
Ben McGinnes
b6d2a66b41 Link fixes
* lang/python/README: Fixed links in both versions of the README.
2018-08-10 03:42:15 +10:00
Andre Heinecke
4dd1d0abd3
json: Wipe memory in cJSON_Delete
* src/cJSON.c (cJSON_Delete): Wipe memory on deletion.
2018-08-08 14:27:24 +02:00
Andre Heinecke
fdc07b3ddc
json: Only use calloc instead of malloc
* src/cJSON.c, src/gpgme-json.c (CALLOC_ONLY): New define
to change xmalloc / xtrymalloc to use calloc.

--
Some people consider malloc dangerous as it might allow an
information leak.
2018-08-08 14:25:28 +02:00
Andre Heinecke
974a95db04
json: Add checks when skipping byte
* src/cJSON.c (parse_string, cJSON_Minify): Check for
terminating NULL byte when skipping the byte after a an escaped
quote.
2018-08-08 13:30:01 +02:00
Andre Heinecke
6e48bb0f1c
json: Don't error out if chunksize is omitted
* src/gpgme-json.c (encode_and_chunk): Don't error out
if no chunksize is provided.

--
This fixes 82e4b900a9 which
caused every call without chunksize to error out.
2018-08-08 09:49:51 +02:00