Commit Graph
35 Commits
Author SHA1 Message Date
David Leon Gil 632d287f9f crypto/openpgp: support public keys generated by End-to-End
packet/packet.go: add ECDSA to the algorithms in CanSign()
packet/signature.go: add support for the features subpacket (which is
used to signal support for the MDC packet)
openpgp/read_test.go: add a key generated by End-to-End as a testcase
(End-to-End's keys are unusual: they set critical bits)

Change-Id: Ifaf3922cd35ea27cf1276d7a8238dd50536eb4ed
Reviewed-on: https://go-review.googlesource.com/2058
Reviewed-by: Adam Langley <agl@golang.org>
2015-01-06 19:53:31 +00:00
David Symonds 1fbbd62cfe crypto: add import comments.
Change-Id: I33240faf1b8620d0cd600de661928d8e422ebdbc
Reviewed-on: https://go-review.googlesource.com/1235
Reviewed-by: Andrew Gerrand <adg@golang.org>
2014-12-09 23:26:36 +00:00
Adam Langley f59690be3f go.crypto/openpgp: fix nil Config case.
This is a followup to https://golang.org/cl/176080043/. That
change didn't handle the case of a *Config being nil.

CC=golang-codereviews
https://golang.org/cl/179200043
2014-11-21 14:11:46 -08:00
Brian Gitonga Marete ca455997ca go.crypto/openpgp: Allow config. of s2k count for symmetric encrypt.
This patch allows the user to choose the strength of the
passphrase mangling during the process in which the key is
produced from the passphrase. It only affects symmetric
encryption.

Unmodified code that calls openpgp.SymmetricallyEncrypt() will
continue to get the now-default count of 65536. Otherwise, a
count in the range [1024, 65011712] may be configured. Illegal
values in and outside this range will silently be rounded up
to legal values within the said range.

The test to s2k.Serialize() has been modified to test a
variety of non-default counts with all the valid hashes and
ensure that the decoding component of s2k can parse and
decrypt the result.

Additional testing has been done with GPG to ensure that the
latter can parse and decrypt files encrypted/encoded with
various counts.

LGTM=agl
R=golang-codereviews, agl
CC=golang-codereviews
https://golang.org/cl/176080043
2014-11-21 14:04:52 -08:00
Andrew Gerrand a73c6bbfc5 go.crypto: use golang.org/x/... import paths
LGTM=bradfitz
R=rsc, bradfitz
CC=golang-codereviews
https://golang.org/cl/167190043
2014-11-10 08:50:25 +11:00
Brian Gitonga Marete c24604da51 go.crypto/openpgp: Allow configuration of s2k hash during encryption.
This patch/CL allows the user to configure the hash function
used in the s2k key-stretching transformation during
encryption. It fixes the current limitation in which SHA1 is
hard-coded for that task.

With this change, packet.Config.DefaultHash is used by default
for the mode 3 s2k key-stretching that is currently used for
encryption, but the user may choose any other valid openpgp
hash by passing a new (possibly nil) pointer argument to
s2k.Serialize().

Note that this change introduces an API change to
s2k.Serialize() in the form of an additional
argument. However, the s2k package is a low-level facility
that (as far as I could tell) is used directly by
go.crypto/openpgp only.

The CL comes with an modified test to check the use and
decoding of all the valid hash functions with regard to
s2k.Serialize().

This patch should be followed by one that allows the user to
configure the iteration count in mode 3 s2k, and it is a
prerequisite for that forthcoming change.

R=golang-codereviews, agl
CC=agl, golang-codereviews
https://golang.org/cl/160110045
2014-10-29 18:30:24 -07:00
Adam Langley 3e2271302c go.crypto/openpgp: don't corrupt encrypted private key when decryption fails.
Since the decryption was done in place, if an incorrect key was given,
the encrypted data would be corrupted.

Fixes golang/go#8439.

R=bradfitz
CC=golang-codereviews
https://golang.org/cl/115550043
2014-10-25 11:19:44 -07:00
Adam Langley 18c283559e go.crypto/openpgp: fix clearsigned parsing of messages with leading blank lines.
Fixes golang/go#8508.

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/128920043
2014-08-28 10:37:22 -07:00
Adam Langley 3092f0d93b go.crypto/openpgp: return signature error rather than unknown issuer.
In the event that a detached signature fails to verify, the code would
continue trying to find other keys with the same key ID and eventually
conclude that the signature was issued by someone unknown
(ErrUnknownIssuer).

With this change, the signature verification error would be returned
instead. (Technically the last error if several keys had a matching key
id and neither verified.)

Fixes golang/go#8509.

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/125030043
2014-08-11 15:41:56 -07:00
Adam Langley aeb0262c11 go.crypto/openpgp: fix hash presence checks.
At some point in the distant past, crypto.Hash.New() changed from
returning nil when a hash function wasn't provided, to panicing. Some
of the code in openpgp predates this and was still using the nil check.

LGTM=bradfitz
R=sburford, bradfitz
CC=golang-codereviews
https://golang.org/cl/104850045
2014-06-04 11:40:03 -07:00
Adam Langley 84ca184138 go.crypto/openpgp: fix user id signing.
Entity.SignIdentity used the wrong signature function and produced invalid
certification signatures. Fixed.

VerifyUserIdSignature was used for checking the self-signature on an identity,
but didn't support anything but a self-signature. This change alters the
low-level API so that checking cross-signatures is possible.

Fixes golang/go#7371.

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/96240043
2014-05-12 11:23:48 -07:00
Adam Langley aa3adaf1aa go.crypto/openpgp: check for revoked keys.
R=agl
CC=golang-codereviews
https://golang.org/cl/95050043
2014-05-05 11:41:50 -07:00
Adam Langley 7bb6c099c0 go.crypto/openpgp: support v3 detached signatures.
Although the package doesn't attempt to fully support ancient, version
3 messages, supporting v3 detached signatures is fairly easy and some
projects (in this case, Ubuntu) are using them for unknown reasons.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/14590043
2013-10-09 17:24:09 -04:00
Casey Marshall 58b09dec0e openpgp/packet: Compact UserAttribute subpacket lengths, fixes signatures.
Necessary to reproduce the same hash for verifying a UserAttribute signature.
Reuse and fix defect in serializeSubpacketLength, RFC 4880, Section 4.2.2.2.

R=agl
CC=golang-dev
https://golang.org/cl/13464044
2013-09-04 10:21:45 -04:00
Casey Marshall 964142eb52 openpgp/packet: Add support for V3 public keys and signatures.
My goal here is to allow read-only access to legacy key material without allowing new V3 keys or signatures.

R=agl
CC=golang-dev
https://golang.org/cl/12746046
2013-09-03 10:36:04 -04:00
Adam Langley 488d045bc0 go.crypto/openpgp/packet: use minimal interface for SerializeSignaturePrefix.
Only an io.Writer is needed in this case.

Fixes golang/go#6035.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13277044
2013-08-30 10:38:22 -04:00
Casey Marshall da934910d6 openpgp/packet: Parse and serialize ECC key material (RFC 6637).
Support ECDSA signature verification.

R=agl
CC=golang-dev
https://golang.org/cl/13141044
2013-08-29 17:10:08 -04:00
Casey Marshall 3780a70b7b go.crypto/openpgp/packet: Add user attribute packet support.
Supports JPEG images as well as free-form arbitrary subpacket data in
user attributes (RFC 4880, Section 5.12)

R=agl
CC=golang-dev
https://golang.org/cl/12966045
2013-08-28 11:02:21 -04:00
Brian Gitonga Marete 690e22b80a openpgp: Implement compressed data packets & add support for compressing data during symmetric encryption.
This patch implements the facilities needed to compress data before
encryption as allowed (and recommended) by RFC 4880. The new
functionality is then used to add support for compressing data during
symmetric encryption (openpgp.SymmetricallyEncrypt()).

For now, compression defaults to off. Also, only the ZIP and ZLIB
compression schemes are supported by this patch.

Resulting output tested/verified using GPG.

https://gist.github.com/marete/6189760 is a small program that can be
used to test that the output of various compression/encryption settings
can be read by GPG or other RFC 4880 programs.

Upon review, I will follow this patch with 2 others: a) Add support for 	compression during public key encryption (openpgp.Encrypt()) b) Enable
compression by default (subject to the restrictions of the "Compression 	Preferences" section in RFC 4880).

R=golang-dev, agl
CC=golang-dev
https://golang.org/cl/12685044
2013-08-15 12:04:10 -04:00
Adam Langley f23aef828f go.crypto/openpgp: test that hashes are compiled in before using them.
Previously, if Encrypt decided to use a hash function that wasn't
compiled in then it would panic.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12055043
2013-08-05 14:22:57 -04:00
Adam Langley eb19e229bd go.crypto/openpgp: don't select expired keys.
When selecting keys for encryption, don't select keys that have
expired.

Fixes golang/go#5808.

R=bradfitz
CC=golang-dev
https://golang.org/cl/10847043
2013-07-22 18:23:28 -04:00
Drew Hintz 0982ebf089 crypto: Correct s2k type constants. They are 0,1,3 according to both the RFC: http://tools.ietf.org/html/rfc4880#section-3.7
And according to the gpg implementation: http://git.gnupg.org/cgi-bin/gitweb.cgi?p=gnupg.git&a=search&h=refs%2Fheads%2FSTABLE-BRANCH-2-0&st=grep&s=s2kmode

R=agl
CC=evn, golang-dev
https://golang.org/cl/11355046
2013-07-16 17:39:57 -04:00
Brian Gitonga Marete d43a35d821 openpgp: Add support for BZIP2-compressed data packets.
Tested using a variety of files encrypted with gpg and the
"--compress-algo BZIP2" gpg option.

R=golang-dev, bradfitz, agl
CC=golang-dev
https://golang.org/cl/10801043
2013-07-03 11:31:17 -04:00
Adam Langley aa0f5b4081 go.crypto: revert 7f5a59ff6b43.
This change reverts https://golang.org/cl/10113043/ because
some folks are stuck on 1.0 till 1.1.1 comes out.

R=golang-dev
CC=golang-dev
https://golang.org/cl/10151043
2013-06-10 10:57:00 -04:00
Adam Langley eca6c1626e go.crypto: remove unreachable code.
I ran go vet over all of go.crypto and removed lots of panic("unreachable") that are no longer needed.

R=golang-dev, r, dgryski
CC=golang-dev
https://golang.org/cl/10113043
2013-06-07 16:05:15 -04:00
Casey Marshall 50ff460fe1 openpgp: remove TeeReader from packet.Read
This is a followup to issue 6927044. I *really* don't want to
break streaming for large encrypted data packets.

Removing the automatic re-parsing. OpaqueReader can be
used for recovering useful information from mangled/unsupported packets.

R=agl
CC=golang-dev
https://golang.org/cl/6944056
2012-12-18 17:57:21 -05:00
Casey Marshall 2da167fbbe openpgp: improve parser resilience & flexibility, add PublicKey.BitLength()
These are improvements I've made as necessary to develop Hockeypuck,
an OpenPGP keyserver (https://launchpad.net/hockeypuck).

The max armor line length was increased to 96 because some keyservers (SKS)
will output armor with lines greater than 64 (the prior max).

I've exposed packet.ReadEntity to support stream-parsing, useful for
large SKS dump files.

ReadKeyRing attempts to recover in the event of malformed data.

Because many packet types are not yet supported, I added OpaquePacket to
capture unsupported types for offline storage and later reparsing.

R=agl
CC=golang-dev
https://golang.org/cl/6927044
2012-12-15 14:30:05 -05:00
Mikio Hara eeef66c528 go.crypto: gofmt -w -s
R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/6948057
2012-12-15 14:19:17 +09:00
Adam Langley be3c8d448b openpgp: support 3DES encrypted private keys.
It appears that CentOS (and so I presume Fedora/RHEL too) default to
encrypting private keys with 3DES so it looks like we need to support
that.

Fixes golang/go#3940.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6446121
2012-08-12 17:36:49 -04:00
Adam Langley 63736bd2bf openpgp: fix error strings and typos.
Fixes golang/go#2841.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5688054
2012-02-21 09:52:37 -05:00
Adam Langley 54eafe1dea openpgp: eliminate implicit rand.Reader and time.Now
Fixes golang/go#2501.

R=rsc, bradfitz
CC=golang-dev
https://golang.org/cl/5653067
2012-02-20 10:48:21 -05:00
Andrew Gerrand 1e43631a6e go.crypto/openpgp/armor: update for NewBufferSize signature change
Fixes the go.crypto build.

R=r
CC=golang-dev
https://golang.org/cl/5641049
2012-02-08 14:15:21 +11:00
Adam Langley 303976f059 crypto/openpgp: add clear-signing support.
Clear signed messages are often seen in email and are formatted so
that the plaintext of the signed message is readable without any
special tools.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5604043
2012-02-03 16:46:11 -05:00
Adam Langley a1e605a210 openpgp/packet: move OCFB code here.
The code has been moved from crypto/cipher in CL 5629044.

R=rsc
CC=golang-dev
https://golang.org/cl/5627045
2012-02-03 15:08:12 -05:00
Russ Cox 470549d502 go.crypto: initial code
Manual edits to README.
Moved from main Go repository, deleted Makefiles, ran gofix -r go1rename.

Tested with: go test code.google.com/p/go.crypto/...

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5564059
2012-01-25 15:31:12 -05:00