Commit graph

126 commits

Author SHA1 Message Date
Aron Wussler
1db1b41588 Fix unlocking and locking keys 2021-11-11 16:36:44 +01:00
Carlos Quintana
2118a0e776
Lint fixes 2021-10-19 09:06:09 +02:00
Carlos Quintana
c406b182bb
Replace Mutex with RWMutex 2021-10-19 08:09:59 +02:00
Carlos Quintana
9f25490f61
Lock global gopenpgp fields 2021-10-18 11:40:58 +02:00
marin thiercelin
5558d4a177
Fix: use verifyTime in the config time instead of Now()
When decrypting message, we have to use verifyTime in the config
otherwise signatures not valid at verifyTime but valid at Now()
will be seen as valid.
2021-09-23 17:14:19 +02:00
Aron Wussler
dcd95f3e5b Fix linter 2021-09-21 11:34:17 +02:00
Aron Wussler
64c051f0d9 Generate keys with compression & release 2.2.3 2021-09-21 11:20:36 +02:00
Aron Wussler
e0531b779c Add NewKeyFromEntity 2021-08-04 12:04:20 +02:00
Aron Wussler
26dd18cf42 Add documentation for messages 2021-08-03 20:55:03 +02:00
wussler
abf7e6f86a
Merge branch 'master' into master 2021-07-30 14:39:28 +02:00
Aron Wussler
5904ff3d70 Add static malformed key test 2021-07-30 13:01:23 +02:00
Aron Wussler
b50a051c7e Deprecate Key#Check() 2021-07-30 11:20:38 +02:00
Hendrik 'T4cC0re' Meyer
c5a8b1f2f7 Disregard GNU dummy subkeys when checking (un)locked state and unlocking a crypto.Key
Because a GNU dummy key has a `PrivateKey` property, the existing check will
count it as a key to be decrypted. However, a `Decrypt` call on such key will
then yield an error, as it is a dummy key.

This commit addresses this behaviour by summing all valid decrpytable private
keys and returning on their count.
Further, it adapts `Unlock` to ignore any dummy subkey.

Fixes #138
2021-07-18 22:45:18 +02:00
marin thiercelin
77df8cba3d
Fix signature status when verifying unsigned message
Return `SIGNATURE_NOT_SIGNED` instead of `SIGNATURE_NO_VERIFIER` when
verifying a messages with no embedded signatures.
2021-07-16 12:17:18 +02:00
larabr
cd4adae9f2
Update error messages in passwordDecrypt (#124) 2021-07-05 10:42:18 +02:00
marinthiercelin
c46ed8ed9e
Add a streaming api to KeyRing and SessionKey (#131)
* barebone streaming functionality

* encryption needs to return a writecloser

* added eof check

* workaround for reader problem with copies

* separate mobile wrappers from main api

* add a clone in the read result to avoid memory corruption

* refactor to reuse code, and fix verification

* have to give the verify key at the start of the decryption

* enfore readAll before signature verification

* streaming api for SessionKey

* add split message stream apis

* name interface params

* fix streaming api so it's supported by go-mobile

* hide internal writeCloser

* fix nil access

* added detached sigs methods

* started unit testing

* unit testing and fixed a bug where key and data packets where inverted

* remove unecessary error wrapping

* figured out closing order and error handling

* add GC calls to mobile writer and reader

* remove debugging values and arrays

* writer with builtin sha256

* unit testing the mobile helpers

* comments and linting

* Typo in error

Co-authored-by: wussler <aron@wussler.it>

* Add GetKeyPacket doc

Co-authored-by: wussler <aron@wussler.it>

* Add rfc reference in comments

Co-authored-by: wussler <aron@wussler.it>

* small improvements

* add compatibility tests with normal methods

* remove unecessary copies in the tests

* update go-crypto to the merged changes commit

* update comments of core internal functions

* remove unused nolint comment

* group message metadata in a struct

* fix comments

* change default values for metadata

* change the mobile reader wrapper to fit the behavior of java

* remove gc calls in the wrappers to avoid performance penalties

* bring back the former Go2MobileReader to be used for ios

* Update crypto/keyring_streaming.go

Co-authored-by: wussler <aron@wussler.it>

* return an error when verifying an embedded sig with no keyring

* Update crypto/sessionkey_streaming.go

Co-authored-by: wussler <aron@wussler.it>

* linter error

* update changelog

* update changelog

Co-authored-by: wussler <aron@wussler.it>
2021-06-30 16:49:30 +02:00
wussler
7380f7391f
Refactor internals of client time (#134) 2021-06-16 17:24:25 +02:00
wussler
039f757e93
Remove monotonic clock (#133) 2021-06-16 14:06:07 +02:00
Daniel Huigens
9126511a96
Update go-crypto (#129)
* Update go-crypto

* Edit changelog

Co-authored-by: Aron Wussler <aron@wussler.it>
2021-04-28 18:33:14 +02:00
wussler
c19faed5da
Add methods for embedded signatures using session keys (#128)
* Add methods to sign when using session keys

* Add mobile helpers for explicit decryption

* Add functions to CHANGELOG

* Fix linter
2021-04-27 17:38:25 +02:00
Aditya Wasan
3dd1711707
Add methods to get key capabilities (#125)
* Add methods to get key capabilities

Signed-off-by: Aditya Wasan <adityawasan55@gmail.com>

* Use correct indetity to check for flags

Signed-off-by: Aditya Wasan <adityawasan55@gmail.com>

* Fix lint

Signed-off-by: Aditya Wasan <adityawasan55@gmail.com>

* Remove CanCertify and update CanSign to use SigningKey

Signed-off-by: GitHub <noreply@github.com>

* keyring: implement CanSign and CanEncrypt

Signed-off-by: GitHub <noreply@github.com>

* key/keyring: add tests for key capabilities

Signed-off-by: GitHub <noreply@github.com>

* Apply suggestions from code review

Renames CanSign to CanVerify and adds an extended test for public-only keys to confirm CanVerify is true for them.

Co-authored-by: wussler <aron@wussler.it>

Co-authored-by: Harsh Shandilya <me@msfjarvis.dev>
Co-authored-by: wussler <aron@wussler.it>
2021-04-09 12:32:10 +02:00
marinthiercelin
973856d299
Add new attachment processor that uses pre-allocated buffer (#120) 2021-03-29 20:46:47 +02:00
wussler
ff54225384
Fix various keys issues (#117)
* Fix armouring headers for public keys
* Fix error for session key decryption failure
2021-03-09 19:06:35 +01:00
wussler
27efcb4627
WIP: Add tests for attachments (#116)
* Add tests for attachments

* Fix CI

* Use go 1.15 for mobile
2021-03-08 17:59:03 +01:00
marinthiercelin
cea3d0da4d
Removed the cloning of the final data in the attachment processor (#114)
* removed the cloning of the final data in the attachment processor

* fix linter
2021-02-19 14:54:31 +01:00
marinthiercelin
e0deea82a3
add signcryption methods to the keyrings (#109)
* add signcryption methods to the keyrings

* added signing and verifying keyrings

* added nil checks

* added unit test for signcrypt

* updated changelog

* switched the keyrings in the api

* update the error messages

* changed the names of the keyRing variable
2020-12-17 12:58:25 +01:00
Daniel Huigens
d0daa53ca6
Update x/crypto fork to github.com/ProtonMail/go-crypto (#106) 2020-12-08 18:34:39 +01:00
wussler
6105a3bcc0
Improve attachment memory allocation (#105)
* Improve attachment memory allocation

* added explicit garbage collection

* redundant GC

* added GCs in attachment processor and a FreeOSMemory helper

* added changelog

* linting

* Remove commented call to debug.FreeOSMemory

Co-authored-by: marin thiercelin <marin.thiercelin@pm.me>
Co-authored-by: marinthiercelin <marin.thiercelin@epfl.ch>
2020-12-08 17:52:50 +01:00
wussler
75f27fd1df
Add key generation offset (#104)
* Add key generation offset

* Bump version to 2.1.2
2020-12-01 19:44:49 +01:00
wussler
385e6d21d2
Drop regex for canonicalization (#102)
* Drop regex for canonicalization

* Fix CI
2020-12-01 18:09:25 +01:00
wussler
4166d25a63
Allow multiple keypackets in session key decryption (#99)
* Fix session key decryption

* Break on all data packets

Co-authored-by: Daniel Huigens <d.huigens@protonmail.com>
2020-11-13 14:13:11 +01:00
wussler
371d429001
WIP: Add compression to API (#91)
* Add compression to API

* Add docs

* Use defaults for a simpler interface

* Update x/crypto

* Fix ecdsa key types for lib update
2020-11-04 17:40:45 +01:00
wussler
53a85837e0
Improve error handling, fix linter (#92)
* Improve error handling, fix linter
2020-10-29 12:42:32 +01:00
wussler
d53bd4a351
Move getters to file excluded from android build (#88) 2020-10-14 18:28:12 +02:00
wussler
ac353fcbef
Make Time and Filename public (#87) 2020-10-13 13:14:09 +02:00
wussler
ce607e0fa8
Canonicalize line endings for text messages (#86)
* Canonicalize line endings for text messages

* Improve cleartext messages
2020-10-12 21:24:33 +02:00
wussler
a4d89bce32
Add filename and time properties to message (#85)
* Add filename and time properties to message

* Message time defaults to current time
2020-10-12 18:45:57 +02:00
wussler
7de8833ff6
Fix binary format for session key encryption (#84) 2020-10-12 12:17:10 +02:00
marinthiercelin
55c4bd994d
Additional helpers for iOS drive (#78)
* add tests

Co-authored-by: wussler <aron@wussler.it>
Co-authored-by: marin thiercelin <marin.thiercelin@pm.me>
2020-09-11 15:35:22 +02:00
wussler
64b3b45404
Fix mixed symmetric/asymmetric decryption (#77) 2020-09-01 11:07:30 +02:00
wussler
2f89b9fa0e
Add KeyIDs public API functionality (#76)
* Add public KeyIDs functions

* Add signature keyIDs functions

* Lint code
2020-09-01 10:02:13 +02:00
Ilya Chesnokov
1f4d966115
use aes256 for password encryption (#75) 2020-08-31 13:42:06 +03:00
Ilya Chesnokov
af371097e0
break for cycle in getEncryptionKeyIDs (#74)
break cycle on literal/aead/encrypted/compressed packets
2020-08-26 19:05:06 +03:00
wussler
979fdb3f4b
Add ToPublic method to get a public key object from a private key (#65) 2020-07-22 17:13:23 +02:00
dimitar10
48f05401ce
Prevent server time from going backwards in UpdateTime (#64) 2020-07-21 13:42:41 +02:00
wussler
8c04ff64a5
Add session key size check (#62)
* Add session key size check

Co-authored-by: Daniel Huigens <d.huigens@protonmail.com>
2020-07-20 11:43:36 +02:00
Ilya Chesnokov
88da5d44b1
Throw error EncryptSessionKey (#60)
* throw error EncryptSessionKey

throw error if one of the keys in keyring does not have valid encryption
key

* add key id to error description
2020-07-15 16:17:49 +07:00
Ilya Chesnokov
b38f993c25
Encrypt session key to multiple keys in keyring. (#59)
`EncryptSessionKey` now creates encrypted key packet for each valid key
in keyring.

Co-authored-by: Aron Wussler <aron@wussler.it>
2020-07-10 00:31:57 +07:00
Ilya Chesnokov
8d42a53775
Add getEntity and getEcryptionKeyIDs functions to key and message types respectively (#55)
* add getEntity function to key struct

* add getEncryptionKeyIDs

* add chengelog + bool return in getEncryptionKeyIDs

* fix description
2020-07-02 15:55:11 +07:00
Daniel Huigens
608bedaaf1
Reject signatures using insecure hash algorithms (#52) 2020-06-25 13:45:59 +02:00