Commit graph

171 commits

Author SHA1 Message Date
Lukas Burkhalter
1136c7d026
feat: Add SHA256 fingerprint getter (#299)
* feat: Add SHA256 fingerprint getter to key
2024-09-26 12:03:48 +02:00
Aron Wussler
0d1ce13767
Add parsing and serializing interfaces for keyrings (#275)
* Add parsing and serializing interfaces for keyrings

* Make error check more compact
2024-04-08 11:38:52 +02:00
Lukas Burkhalter
453e81905b
Add support for the crypto refresh in v2 (#265)
This commit adds support for the OpenPGP crypto-refresh.
- Updates go-crypto dependency to v1.1.0-alpha.1
- Adapts the session key logic to handle PKESK/SKESK v6 packets without an algorithm attached
- Updates the min go version to 1.17 as requires by  go-crypto v1.1.0-alpha.1
- Update the cricl dependency to 1.3.7 matching go-crypto
Not supported:
- crypto-refresh intended recipients
- v6 key generation
2024-02-28 13:51:52 +01:00
Lukas Burkhalter
c6a3058e2e
Prepare release 2.7.5 with packet API (#269)
Adds the following API functions:
- API to get signature key IDs for mobile:
	func (msg *PGPMessage) GetHexSignatureKeyIDsJson() []byte

- API to get encryption key IDs for mobile:
	func (msg *PGPMessage) GetHexEncryptionKeyIDsJson() []byte

- API to get the number of key packets in a PGP message:
	func (msg *PGPSplitMessage) GetNumberOfKeyPackets() (int, error)

- API in package `helper` to encrypt a PGP message to an additional key:
	func EncryptPGPMessageToAdditionalKey(messageToModify *crypto.PGPSplitMessage, keyRing *crypto.KeyRing, additionalKey *crypto.KeyRing) error
2024-02-07 08:09:26 +01:00
Lukas Burkhalter
da4cecfea5
Update session key decryption to not allow SED packets (#255) 2023-10-27 12:10:17 +02:00
Lukas Burkhalter
ca02a218b8
Ensure DecryptSessionKey returns an error for a missing key packet (#245) 2023-06-20 14:47:57 +02:00
Dmitriy Matrenichev
158eba9411
Reset origText in verifySignature before the retry
This is partial fix for #231

Signed-off-by: Dmitriy Matrenichev <dmitry.matrenichev@siderolabs.com>
2023-04-13 10:45:56 -04:00
M. Thiercelin
97323a4c2b
Add signature context for embedded signatures 2023-04-06 12:28:12 +02:00
M. Thiercelin
c55b9d203c
Add API to sign stream with context 2023-04-06 11:45:50 +02:00
M. Thiercelin
257c381604
Add SIGNATURE_BAD_CONTEXT status to verification error.
Add a special status for verification errors that are
caused by the signature context.
2023-04-06 10:34:04 +02:00
M. Thiercelin
e9fca4d62f
Wrap the cause of signature verification errors.
Instead of swallowing the cause of verification errors,
we use error wrapping to communicate the cause to the caller.
2023-04-05 13:50:55 +02:00
M. Thiercelin
1ec90e34ea
Add API to add contexts to detached signatures.
Using the notation data packets of signatures, we add a way to
set a context to detached signatures.
We also add a way to enforce that signatures have the right context
during verification.
2023-03-13 11:48:31 +01:00
Daniel Huigens
9d05b3e9b6 Use returned signature in GetVerifiedSignatureTimestamp
Instead of parsing the signature packets manually, use the signature
packet returned by VerifyDetachedSignatureAndHash to get the
signature creation time.
2023-02-20 12:53:44 +01:00
Daniel Huigens
379e4814e0 More strictly verify detached signatures
Reject detached signatures from revoked and expired keys.
2023-02-20 12:53:44 +01:00
Aron Wussler
47534e9288 Upgrade go crypto and adapt SEIPD 2023-01-25 14:42:41 +01:00
M. Thiercelin
eccc1df619
Add streaming APIs to encrypt with compression 2023-01-24 17:44:07 +01:00
M. Thiercelin
2b9d76708a Size checks not needed in linebreaks unit tests 2022-11-18 15:33:31 +01:00
M. Thiercelin
76b77258e3 Add tests for encrypring text with non canonical line ends 2022-11-18 15:33:31 +01:00
Daniel Huigens
b189309152 Don't trim trailing spaces from non-clearsigned text messages 2022-11-18 15:33:31 +01:00
M. Thiercelin
bae54f7e83 Check signature types in unit tests 2022-11-17 17:28:55 +00:00
Daniel Huigens
b90e70daa4 Detached sign text messages with signature type text 2022-11-16 14:21:39 +01:00
M. Thiercelin
4971d78a53
Sanitize strings by default on all platforms.
Instead of sanitizing strings only on iOS, we do it on all platforms.
2022-11-03 12:32:20 +01:00
M. Thiercelin
a2fd1c6a3b
Sanitize non utf8 strings before returning them to iOS apps
In swift, strings must be strictly utf8, and when golang
returns a string with non utf8 characters, it gets translated to
an empty string for utf8.
To avoid this situation, we sanitize strings before returning them.
This behavior is only enabled when building with the "ios" build tag.
2022-11-03 12:31:05 +01:00
Aron Wussler
a065bf20b0 Update go-crypto 2022-08-19 11:20:08 +02:00
Martin
1791c07702
[codespell] Fix typos (#190) 2022-07-11 10:27:59 +02:00
M. Thiercelin
373e1ad526
Add unit tests for decryption of aead packets 2022-06-14 16:49:16 +02:00
M. Thiercelin
4cea9a0940
Decrypt AEAD encrypted data packets with a session key
Adds the support to decrypt AEAD encrypted data packets
when decrypting the data packet with a session key directly.
2022-06-14 16:10:25 +02:00
Aron Wussler
fee9ec19fd Improve golang CI 2022-05-17 17:06:18 +02:00
Aron Wussler
f5803d148d Do not return error on empty name or email key generation 2022-04-26 10:21:28 +02:00
marinthiercelin
2f59f6414f Return decrypted PGP/MIME content with wrong signatures
When the PGP/MIME decryption encounters a signature verification error, it will keep decrypting the content
and return it in the appropriate callbacks.
This allows the caller to choose to display the content with a warning rather than just returning an error.
2022-04-25 16:00:28 +02:00
M. Thiercelin
b54b5f4d6d
Fix test data for PGP/MIME tests
We update the test data for the PGP/MIME unit tests.
For a PGP/MIME signature to be valid, it must be done on the canonical text
and not the raw text.
2022-03-17 10:31:09 +01:00
M. Thiercelin
5c5666eaa1
Canonicalize PGP/MIME content before verifying signatures
Before verifying signatures of PGP/MIME messages we need to canonicalize
the content
2022-03-17 10:17:34 +01:00
wussler
53010fdee7
Update crypto/message.go 2022-03-01 09:14:38 +01:00
Daniel Huigens
e1f6ea603a Create SplitMessage() to replace SeparateKeyAndData(...int)
Keep SeparateKeyAndData(_ int, _ int) for backwards compatibility
with go-mobile bindings.
Deprecate SeparateKeyAndData in favor of SplitMessage.
2022-02-28 18:50:01 +01:00
Daniel Huigens
ff97844785 Clone data when splitting messages 2022-02-28 12:26:01 +01:00
Aron Wussler
3a65fb8dbb Fix bad MDC messages parsing 2022-02-24 19:20:15 +01:00
Aron Wussler
6799f1e8ce Fix linter 2022-02-15 11:57:30 +01:00
Daniel Huigens
7103bdf2a5 Generic implementation of splitting messages 2022-02-15 11:32:32 +01:00
Daniel Huigens
682166d9e3 Fix attachment processor error handling 2022-02-11 16:14:28 +01:00
marin thiercelin
1a2e569373
Fix parsing issue of AEAD encrypted messages.
In pgpMessage.SeparateKeyAndData(), the parsing would
ignore AEAD encrypted data packets. Which would result
in a split message with a nil data packet.
We add support for AEAD encrypted data packets.
This also affects `NewPGPSplitMessageFromArmored` and `NewPGPSplitMessage`.
2022-01-10 14:24:08 +01:00
marin thiercelin
6f86adc432
Add keyRing.GetVerifiedSignatureTimestamp()
Add a function to verify a detached signature and access
its creation time.
2021-12-21 10:02:23 +01:00
wussler
18bc6a059c
Apply suggestions from code review 2021-12-15 11:28:45 +01:00
marin thiercelin
e2f03af655
Fix verification of signature for PGP/MIME messages
We fix the verification of embedded and PGM/MIME signatures
when decrypting PGP/MIME messages.
2021-12-15 11:01:04 +01:00
Aron Wussler
130472d5a5 Release 2.3.0: Update go-crypto, add Key.IsRevoked and fix key.IsExpired 2021-11-15 15:46:42 +01:00
Aron Wussler
24a754d34a Fix linter 2021-11-11 17:03:40 +01:00
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