Commit Graph
350 Commits
Author SHA1 Message Date
Han-Wen Nienhuys 0a4e4d451b x/crypto/ssh: return msgNewKeys for a short-circuited first kex.
If one of both sides is slow, the first kex completes implicitly. The
first kex also produces msgNewKeys, and this must be read to ensure
that the authentication code is not confused by it.

Before this fix, the problem could be reproduced by inserting a sleep
just before the requestInitialKeyChange call.

Fixes #15198

Change-Id: I602db5dd37b2d8556c88ab4cdb693ccf90147a3d
Reviewed-on: https://go-review.googlesource.com/23137
Run-TryBot: Han-Wen Nienhuys <hanwen@google.com>
Reviewed-by: Adam Langley <agl@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-05-18 15:15:28 +00:00
Sam Hug b6789ab629 x/crypto/ssh: add 3des-cbc as a non-default cipher
3des-cbc is an insecure cipher. As such, you must explictly add it to
Config in order to use it.

Change-Id: Ifd15cde46a9908eefef1c75bae7e97b05767361d
Reviewed-on: https://go-review.googlesource.com/22770
Reviewed-by: Han-Wen Nienhuys <hanwen@google.com>
Run-TryBot: Han-Wen Nienhuys <hanwen@google.com>
2016-05-15 12:48:58 +00:00
Martin Garton 1e61df8d9e x/crypto/ssh: add support for ed25519 keys
Added support for parsing the "new" openssh private key format.
(ed25519 keys only in this format for now)

Signing and verifying functions now work with ed25519 keys.

ed25519 can now be accepted by the server to authenticate a client.

ed25519 can now be accepted by a client as a server host key.

Related documentation used:
https://www.ietf.org/archive/id/draft-bjh21-ssh-ed25519-02.txt

Change-Id: I84385f24d666fea08de21f980f78623f7bff8007
Reviewed-on: https://go-review.googlesource.com/22512
Reviewed-by: Han-Wen Nienhuys <hanwen@google.com>
Run-TryBot: Han-Wen Nienhuys <hanwen@google.com>
2016-05-12 13:28:31 +00:00
Han-Wen Nienhuys b76c864ef1 x/crypto/ssh: hide msgNewKeys in the transport layer.
This ensures that extraneous key exchanges cannot confuse application
level code.

Change-Id: I1a333e2b7b46f1e484406a79db7a949294e79c6d
Reviewed-on: https://go-review.googlesource.com/22417
Reviewed-by: Han-Wen Nienhuys <hanwen@google.com>
Run-TryBot: Han-Wen Nienhuys <hanwen@google.com>
Reviewed-by: Adam Langley <agl@golang.org>
2016-05-10 17:36:43 +00:00
Martin Garton 91ab96ae98 ssh: fix compatibility with recent OpenSSH
Make x/crypto/ssh tests compatible with recent OpenSSH versions.
This means not using rsa keys shorter than 1024 bits any more, and
explicitly enabling all key types in the OpenSSH config, since some
are now disabled by default.

Tested against OpenSSH_7.2p2 and now passes.

Change-Id: I607bf15f063d4833b0876393d6845a4f507f48af
Reviewed-on: https://go-review.googlesource.com/22840
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-05-09 21:14:43 +00:00
Alex Vaghin 47ff8dfbc5 acme: format test data
A test RSA private key was missing "-" in the END delimiter.
While working fine with encoding/pem, other tools like openssl
seem to have more strict requirements.

See
https://github.com/golang/crypto/commit/1777f3ba8c1fed80fcaec3317e3aaa4f627764d2#commitcomment-17343818
for more details.

Change-Id: I5153bb9cf405755d6621f69c1329da8290695eed
Reviewed-on: https://go-review.googlesource.com/22871
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-05-06 18:11:22 +00:00
Artyom Pervukhin 019870fc9d x/crypto/openpgp/s2k: fix misleading function comment
Remove mention of panic from HashIdToString doc.

Change-Id: If606dc1ebad53ef5c1b052fff36499af2b44a806
Reviewed-on: https://go-review.googlesource.com/22760
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-05-04 14:33:35 +00:00
Han-Wen Nienhuys 2cb52d9374 x/crypto/ssh: also log data packets when debugHandshake is set
Change-Id: Ibb26269608e506e8a676c276f847d77fe7014ceb
Reviewed-on: https://go-review.googlesource.com/22514
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Han-Wen Nienhuys <hanwen@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-05-03 14:59:30 +00:00
Han-Wen Nienhuys 285fb2ed20 x/crypto/ssh: fix subsequent key exchanges.
In https://go-review.googlesource.com/#/c/21606/ , kexResult.SessionID
was erroneously not set for all but the first key exchange. The
unittests did not catch this, as server and client make the same
mistake, but OpenSSH notices corrupted data and kills the connection.

Fixes #15445.

Change-Id: If98249b37d81efaa2ebefc836df0b150feba1256
Reviewed-on: https://go-review.googlesource.com/22418
Reviewed-by: Adam Langley <agl@golang.org>
Run-TryBot: Han-Wen Nienhuys <hanwen@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-04-26 14:51:09 +00:00
Adam Langley c9aef117f5 x/crypto/ed25519: add package.
This change “graduates” the Ed25519 package from my personal GitHub
account to x/crypto. At this point, the code and algorithm seems
sufficiently mature that it warrants more general exposure. (There seem
to be about 110 packages importing it from my GitHub repo:
https://godoc.org/github.com/agl/ed25519?importers)

Two people made changes to the code while it was living in my GitHub.
Both have signed the CLA and both have confirmed that they intended
their changes to be covered by it. (Recorded internally in b/28166583.)

The significant change from GitHub to x/crypto is that the types of
public keys, private keys and signatures have been changed from pointers
to arrays into []byte and that support for crypto.Signer has been added.

Updates golang/go#8581

Change-Id: Ia8632d2153e289363b50d76fd0662d1a7fed00f6
Reviewed-on: https://go-review.googlesource.com/22030
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Martin Garton <garton@gmail.com>
Reviewed-by: Adam Langley <agl@golang.org>
Run-TryBot: Adam Langley <agl@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-04-25 23:11:06 +00:00
Peter Moody e84a34b1ee x/crypto/ssh: support more keytypes in the agent.
This allows the golang ssh-agent to support the full suite of keys
the library accepts.

Currently constraints are ignored.

Change-Id: I7d48c78e9a355582eb54788571a483a736c3d3ef
Reviewed-on: https://go-review.googlesource.com/21536
Reviewed-by: Han-Wen Nienhuys <hanwen@google.com>
Run-TryBot: Han-Wen Nienhuys <hanwen@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-04-25 17:01:51 +00:00
Han-Wen Nienhuys f98fd1f5ec x/crypto/ssh: if debugMux is set, also log global messages.
Change-Id: I685ba7f30f1d2e2bc3c078c7bddb6d383a179113
Reviewed-on: https://go-review.googlesource.com/22416
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Han-Wen Nienhuys <hanwen@google.com>
2016-04-25 15:26:28 +00:00
Scott Bell 7b428712ab x/crypto/ssh: remove misleading comment, add example
Add an example for using the PublicKeys AuthMethod.

Change-Id: I3fe02bb3c9b8ccf313d72858328c8576cbf3eb06
Reviewed-on: https://go-review.googlesource.com/22250
Reviewed-by: Han-Wen Nienhuys <hanwen@google.com>
2016-04-21 09:08:50 +00:00
Lynn Boger fbbbdbdd6f sha3: revert alignment optimization on ppc64
A previous fix to improve performance based on alignment
to sha3 was made in both ppc64le and ppc64, when it should
have only applied to ppc64le.  This changes the build tags
so it is only done for ppc64le.

Fixes golang/go#15392

Change-Id: Idf32a0370f3c76fc2b54a2897a668acbae5d43c5
Reviewed-on: https://go-review.googlesource.com/22323
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-20 21:40:36 +00:00
Mark Severson 3305186468 x/crypto/ssh/agent: Support v1 remove all message
Some ssh-agent clients expect the server to support remove all messages
for protocols 1 & 2 and error if protocol 1 support is missing.

This adds a null-op implementation of the remove all message in similar
fashion to the existing list all message support.

Fixes golang/go#15159

Change-Id: I9389885d89c9147f3e10850893bba6ed7d0a4e82
Reviewed-on: https://go-review.googlesource.com/21468
Reviewed-by: Han-Wen Nienhuys <hanwen@google.com>
Run-TryBot: Han-Wen Nienhuys <hanwen@google.com>
2016-04-20 10:42:34 +00:00
Scott Bell de15db8e4b x/crypto/ssh: omit empty fields in error message
Although the signal and msg fields are assigned together, their
values originate from the remote server and may be empty.

Fixes golang/go#14251

Change-Id: I9d9094cc69f3c14bf1648af59951f6b6c7a71e0a
Reviewed-on: https://go-review.googlesource.com/22196
Reviewed-by: Han-Wen Nienhuys <hanwen@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-20 10:39:07 +00:00
Han-Wen Nienhuys 2f6fccd33b x/crypto/ssh: debug support for msgUserAuthSuccess and msgChannelData
Change-Id: I14d59509f22edf01827610a4ef4c50b53cbc8059
Reviewed-on: https://go-review.googlesource.com/21605
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-19 12:57:35 +00:00
Alex Vaghin 1777f3ba8c acme: initial import of ACME implementation
Originated from github.com/google/goacme.

This does not include goacme command line program
github.com/google/goacme/cmd/goacme. It will probably live somewhere
else.

Change-Id: I852d55c1a3673fab208e6e2aa19d22be42b8719f
Reviewed-on: https://go-review.googlesource.com/20837
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-13 17:25:35 +00:00
Han-Wen Nienhuys d68c3ecb62 x/crypto/ssh: make sure the initial key exchange happens once.
This is done by running the key exchange and setting the session ID
under mutex. If the first exchange encounters an already set session
ID, then do nothing.

This fixes a race condition:

On setting up the connection, both sides sent a kexInit to initiate
the first (mandatory) key exchange.  If one side was faster, the
faster side might have completed the key exchange, before the slow
side had a chance to send a kexInit.  The slow side would send a
kexInit which would trigger a second key exchange. The resulting
confirmation message (msgNewKeys) would confuse the authentication
loop.

This fix removes sessionID from the transport struct.

This fix also deletes the unused interface rekeyingTransport.

Fixes #15066

Change-Id: I7f303bce5d3214c9bdd58f52d21178a185871d90
Reviewed-on: https://go-review.googlesource.com/21606
Reviewed-by: Adam Langley <agl@golang.org>
Reviewed-by: Han-Wen Nienhuys <hanwen@google.com>
2016-04-12 17:14:56 +00:00
John Schnake 3fbbcd23f1 x/crypto/ssh/terminal: ensure windows MakeRaw returns previous state
The MakeRaw method should be returning the original state so that
it can be restored.  However, the current implementation is returning
the new, "raw" state.

Fixes golang/go#15155

Change-Id: I8e0b87229b7577544e1118fa4b95664d3a9cf5da
Reviewed-on: https://go-review.googlesource.com/21612
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-08 16:30:10 +00:00
John Schnake 21e42927af x/crypto/ssh/terminal: create stubs for plan9 methods
To facilitate testing of methods in other GOOSs we need plan9 to
be able to build and run the test without a errors due to
undefined methods.

Fixes golang/go#15195

Change-Id: Ida334676f92db6fb4652af3e3a9f6bc13a96052c
Reviewed-on: https://go-review.googlesource.com/21711
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-08 15:58:03 +00:00
Maxwell Krohn b8a0f4bb40 openpgp: Allow V3 signatures in messages
Previously, only V4 signatures were allowed in PGP messages,
and attempts to digest a message with a V3 signature would
yield an `errors.StructuralError("LiteralData not followed by Signature")`.

This patch fixes this shortcoming, by trying to consume either
signature type and verifying accordingly.

Change-Id: I27c8ea781b75b0f7dfc42c01e7de40f3323e9579
Reviewed-on: https://go-review.googlesource.com/14794
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-06 04:37:51 +00:00
Han-Wen Nienhuys 9e7f5dc375 x/crypto/ssh: interpret disconnect message as error in the transport layer.
This ensures that higher level parts (e.g. the client authentication
loop) never have to deal with disconnect messages.

Fixes https://github.com/coreos/fleet/issues/565.

Change-Id: Ie164b6c4b0982c7ed9af6d3bf91697a78a911a20
Reviewed-on: https://go-review.googlesource.com/20801
Reviewed-by: Anton Khramov <anton@endocode.com>
Reviewed-by: Adam Langley <agl@golang.org>
2016-03-29 14:38:23 +00:00
Julian Kornberger c7e3b0ebdd x/crypto/ssh: Add timeout for dialing
Fixes golang/go#14941

Change-Id: I2b3a976d451d311519fab6cdabdc98a4a4752e31
Reviewed-on: https://go-review.googlesource.com/21136
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-27 21:20:01 +00:00
Lynn Boger c197bcf24c golang/x/crypto/sha3: use better alignment
Change the build tags for xor.go and xor_unaligned.go
to perform better on ppc64/ppc64le.

This improves performance for these sha3 benchmarks:

benchmark                        old MB/s     new MB/s     speedup
BenchmarkSha3_512_MTU            68.42        76.03        1.11x
BenchmarkSha3_384_MTU            91.12        105.38       1.16x
BenchmarkSha3_256_MTU            110.19       132.63       1.20x
BenchmarkSha3_224_MTU            114.46       139.12       1.22x
BenchmarkShake128_MTU            129.77       163.14       1.26x
BenchmarkShake256_MTU            125.01       151.93       1.22x
BenchmarkShake256_16x            110.60       129.44       1.17x
BenchmarkShake256_1MiB           128.51       154.23       1.20x
BenchmarkSha3_512_1MiB           74.18        82.39        1.11x

Fixes golang/go#14847

Change-Id: I59ba763b4eaf3e567399b132ad820fb2dcbbf129
Reviewed-on: https://go-review.googlesource.com/20821
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-17 20:21:02 +00:00
Jacob H. Haven 6025851c7c openpgp: ECDSA key and signature support
Add support for creating and signing with ECDSA OpenPGP keys

Change-Id: I6d530325ab801ba800187b88e8cfea079cfa41ed
Reviewed-on: https://go-review.googlesource.com/20608
Run-TryBot: Adam Langley <agl@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jacob H. Haven <jacob@jhaven.me>
Reviewed-by: Adam Langley <agl@golang.org>
2016-03-14 20:49:18 +00:00
Adam Langley de93d05161 x/crypto/ocsp: correct OID for DSA-with-SHA-256.
This was incorrect in crypto/x509 and go copied here.
See https://go-review.googlesource.com/#/c/20549 for the fix to
crypto/x509.

Fixes golang/go#14663.

Change-Id: I1fdca4b3f3edfeef1ee4ae01b1cf252ad8471163
Reviewed-on: https://go-review.googlesource.com/20550
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-10 23:43:30 +00:00
Benjamin Wester 1bae088edb openpgp/clearsign: Handle truncated messages
When parsing a truncated clearsigned message (one that includes the
opening header but no armored data), the existing implementation of
clearsign.Decode() hangs in an infinite loop. This commit changes
Decode() to detect the end of the buffer and return as if no
clearsigned message was found.

Change-Id: Ibc85b29a08d22868470f48fe300bf8fcb4749768
Reviewed-on: https://go-review.googlesource.com/17693
Reviewed-by: Adam Langley <agl@golang.org>
2016-03-10 22:05:46 +00:00
Han-Wen Nienhuys 5dc8cb4b8a x/crypto/ssh/agent: add a client example and tweak package doc.
Change-Id: I373fdbb6351d71b12fcfed31cf4b08975a443294
Reviewed-on: https://go-review.googlesource.com/19894
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Adam Langley <agl@golang.org>
Run-TryBot: Adam Langley <agl@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-26 16:32:03 +00:00
Adam Langley 1f22c01038 x/crypto/ocsp: return errors to reflect OCSP errors.
Previously, OCSP errors (like “malformed request”, not “that certificate
is revoked”) were intended to result in a Response being returned with
Status set to ServerFailed. However, since an “optional” tag was missing
in the ASN.1, a parse error was actually returned.

This CL changes that behaviour so that ParseResponse will now return an
error for these responses. That error will be a ResponseError, allowing
callers to find the exact error code.

Change-Id: I4f8ae5ba39203c2c204fb1d65471d1427bf68b25
Reviewed-on: https://go-review.googlesource.com/18944
Reviewed-by: Adam Langley <agl@golang.org>
2016-01-26 18:40:38 +00:00
Peter Moody 3760e01685 x/crypto/ssh: add function to parse known_hosts files.
Change-Id: I9258ecf2b38258e31bcb6e73ac042ad8125fd2d1
Reviewed-on: https://go-review.googlesource.com/18106
Reviewed-by: Peter Moody <peter.moody@gmail.com>
Reviewed-by: Adam Langley <agl@golang.org>
2016-01-13 19:11:26 +00:00
Sami Commerot d67eb63455 x/crypto/openpgp: add ElGamal support when writing GPG keys.
When writing keys that contain ElGamal subkeys, the openpgp
package would previously return an error.

Change-Id: I1c487f4a9cfb92b40e99e9be6aa4ed5928e36dbe
Reviewed-on: https://go-review.googlesource.com/18254
Reviewed-by: Adam Langley <agl@golang.org>
2016-01-11 18:26:45 +00:00
Adam Langley 803f01ea27 x/crypto/ssh: allow a custom Config to specify CBC mode.
Cryptographic flaws are so hard to kill it can only be a matter of time
before they start crying “brains!” and holding their arms out straight.

Fixes golang/go#13776.

Change-Id: Iee1c19dbe823eb8728e283dd11083638e41f7189
Reviewed-on: https://go-review.googlesource.com/18482
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Adam Langley <agl@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-01-10 18:39:22 +00:00
Brad Fitzpatrick f23ba3a5ee x/crypto/pkcs12: fix typo in struct tag
No test, though, because I don't know this code. Sad that it passes
with the typo, though.

Fixes golang/go#13855

Change-Id: I1170baa0f94ae4b671f5ca654cb7dcc393d1cc4d
Reviewed-on: https://go-review.googlesource.com/18363
Reviewed-by: Adam Langley <agl@golang.org>
2016-01-07 16:18:51 +00:00
Richard Barnes 552e9d568f ocsp: add support for OCSP response extensions
Some current uses of OCSP require extensions. In particular, Certificate
Transparency (RFC 6962) can use an OCSP extension to carry a Signed
Certificate Timestamp. This patch adds support for OCSP extensions (in
particular, singleExtensions), by adding Extensions and ExtraExtensions
fields with the same semantics as in x509.Certificate.

As a side-effect, trying to parse a response with a critical extension
will now return an error, just like parsing a certificate.

This change does not enable extensions in OCSP requests, just responses.

Change-Id: I5918f26ea1bb9d1ece96e85a6bb7691c7c017467
Reviewed-on: https://go-review.googlesource.com/18202
Reviewed-by: Adam Langley <agl@golang.org>
2016-01-04 21:17:08 +00:00
Mark Severson f18420efc3 x/crypto/ssh/agent: Fix keyring removing the wrong key(s)
The Remove method for the keyring sliced the internal keys list
incorrectly when removing a key. This caused the wrong key to be removed
or sometimes multiple keys were removed. Additionally, if the key to be
removed was the last key, the method never returned.

Fixes golang/go#13628

Change-Id: I0facbcb8f8b65709222067ce37ea26e3fb5ba8e8
Reviewed-on: https://go-review.googlesource.com/17870
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-15 19:15:01 +00:00
Carl Jackson 7b85b097bf x/crypto/ssh: run go fmt
Change-Id: Ibb071aa550ca7392543c2d1eba8f8a69ba1d86fa
Reviewed-on: https://go-review.googlesource.com/17270
Reviewed-by: Dave Cheney <dave@cheney.net>
2015-12-01 00:25:08 +00:00
Adam Langley beef0f4390 x/crypto/otr: reformat the libotr test harness with clang-format.
We have clang-format these days to eliminate any worries about C-code
formatting.

Change-Id: I86433d99f786ac4091c39eb4a41422c5a18d4d4a
Reviewed-on: https://go-review.googlesource.com/16937
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-11-20 20:14:19 +00:00
Adam Langley 8270119ea2 x/crypto/otr: update libotr test code for version 4.
The test for this package contains a test case (disabled by default)
that exercises the code against libotr (the reference implementation).
Since that test was written, libotr has updated to version 4 which
contains non-backwards-compatible API changes.

This change updates the test harness for version 4 of libotr.

Change-Id: Ib40c899c609cc827903ae18fd80476d179bf0a33
Reviewed-on: https://go-review.googlesource.com/16936
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-11-20 20:13:31 +00:00
Adam Langley fb90bd22f5 x/crypto/otr: make errors fatal.
Since the test against libotr (disabled by default) runs forever, any
errors should be fatal otherwise they'll never be noticed.

Change-Id: Idf07dd963260f140be1950afcbd04331b56bd627
Reviewed-on: https://go-review.googlesource.com/16935
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-11-20 20:13:25 +00:00
Adam Langley d438f321d3 x/crypto/otr: clear key slots when handshaking.
The OTR implementation had a bug where key slots would not be marked as
unused after a rehandshake. Since handshaking resets the key ids, some
key slots would be left over with much higher key ids. These key slots
would lead to an error when the code ran out of slots.

Fixes agl/xmpp-client#96.

Change-Id: I013bbc4eaf0616373ab52f14b7f7757c353983ca
Reviewed-on: https://go-review.googlesource.com/16934
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-11-20 20:11:45 +00:00
Jonathan Boulle 346896d577 crypto/ssh: fix typo in error string.
cound -> could
Also change fmt.Errorf -> errors.New for consistency.

Change-Id: I0b6900a76b70cd37ab2e8d61327868b46366ec64
Reviewed-on: https://go-review.googlesource.com/11235
Reviewed-by: Adam Langley <agl@golang.org>
2015-11-15 23:11:30 +00:00
Adam Langley b270509459 x/crypto/openpgp/packet: fix message for errors resulting from an unknown cipher.
Change-Id: Icebde4a001b220a64aa4bcddd206484feed5ad79
Reviewed-on: https://go-review.googlesource.com/15155
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-11-15 20:56:08 +00:00
Arlo Breault ccca2aa616 otr: smpFailureError processing tlvTypeSMP3 prevents sending tlvTypeSMP4
* The other side is left hanging, waiting for their chance to do the
   comparison.

Change-Id: I186933ebb53a30e190414c5572206851681e0a37
Reviewed-on: https://go-review.googlesource.com/15260
Reviewed-by: Adam Langley <agl@golang.org>
2015-11-15 17:51:08 +00:00
Cedric Staub 575fdbe86e x/crypto/pkcs12: deal with short byte array in PBKDF
A bug in the PBKDF implementation in the pkcs12 package caused certain
inputs to produce the wrong output. In step 6C, we treat Ij as a big.Int
of v bytes and compute Ij + B + 1. The resulting big.Int can have
leading zero bytes, such that Ij.Bytes() produces a byte array that is
smaller than v bytes. In this case we must zero-pad the output to make
Ijb properly sized.

Change-Id: I6e672e6f6bbbd5bea419355d318db289731bb174
Reviewed-on: https://go-review.googlesource.com/16520
Reviewed-by: Adam Langley <agl@golang.org>
2015-11-02 18:45:47 +00:00
Paul Meyer c8b9e6388e x/crypto: Add pkcs12 package for reading pkcs12 data
Package pkcs12 provides some Go implementations of PKCS#12.
This implementation is distilled from https://tools.ietf.org/html/rfc7292 and
referenced documents. It is intented for decoding P12/PFX-stored certificate+key
for use with the crypto/tls package.

Package includes @dgryski's RC2 implementation as a sub package as requested in
https://github.com/golang/go/issues/10621.

Change-Id: I78401241e39cd0099e9082a3a227cf0a3a36e6d1
Reviewed-on: https://go-review.googlesource.com/11986
Reviewed-by: Adam Langley <agl@golang.org>
Run-TryBot: Adam Langley <agl@golang.org>
2015-10-04 18:58:11 +00:00
Adam Langley 0c93e1ff9f golang.org/x/crypto/openssh: don't loop forever after a bad password.
SymmetricKeyEncrypted cached the results of decryption so, if a bad
password was given, ReadMessage would prompt forever because a later,
correct password wouldn't override the cached decryption.

The SymmetricKeyEncrypted object can't know whether a given passphrase
is correct so it should never have been a mutable object in the first
place. This change makes it so that it doesn't cache anything.

Fixes #9315

Change-Id: Ic2b75f7f60a575e2182ac7e5c5d4198597c5d0a2
Reviewed-on: https://go-review.googlesource.com/14038
Reviewed-by: Andrew Gerrand <adg@golang.org>
Reviewed-by: Adam Langley <agl@golang.org>
2015-09-30 00:38:34 +00:00
Lewin Bormann 59a4410d82 x/crypto/ssh: Add protocol version to ServerVersion
280be00 introduced custom server versions; however, at least OpenSSH
clients do not accept a server version that doesn't start with a
protocol version like "SSH-2.0-"; this is not documented in this
library, and automatically adding it in case that the user did not does
no harm.

Change-Id: Iafc23b23160a8277b10cbf29778dc64a96351bd7
Reviewed-on: https://go-review.googlesource.com/14018
Reviewed-by: Adam Langley <agl@golang.org>
2015-09-28 22:51:19 +00:00
Evan Broder e74b0352e5 crypto/ssh: Support turning a crypto.Signer into an ssh.Signer
This adds a NewSignerFromSigner to crypto/ssh which takes a
crypto.Signer and turns it into an ssh.Signer, helpful if, e.g., your
crypto.Signer is backed by some sort of hardware device.

The interfaces are very similar - the biggest differences are that a
crypto.Signer accepts hashed data, while an ssh.Signer does not, and
some differences in encoding for DSA and ECDSA signatures.

This also adjusts NewSignerFromKey to use NewSignerFromSigner where
possible, dropping the rsaPrivateKey and ecdsaPrivateKey types in
favor of wrappedSigner. (However, because *dsa.PrivateKey is not a
crypto.Signer, we still have to keep dsaPrivateKey)

Change-Id: Ia2e20ece9c9d3844b4e5a64c1a7d997178ec8781
Reviewed-on: https://go-review.googlesource.com/10953
Reviewed-by: Adam Langley <agl@golang.org>
2015-09-24 18:35:42 +00:00
Reinaldo de Souza Jr aedad9a179 otr: Fix revealing MAC keys when a DH key is rotated
The existing implementation did not save all the fields in keySlot, which not
only caused a cache miss on every calcDataKeys() but also caused the rotate keys
functions to not find the MAC keys that should be revealed.

It also stops revealing the sending MAC keys. The finite-state analysis of the
otr v2 spec[1] revealed an attack on message integrity when sending MAC keys are
revealed. The spec had been updated accordingly [2].

1 - http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.165.7945&rep=rep1&type=pdf
2 - http://sourceforge.net/p/otr/libotr/ci/58fd90cb77c836ff9fa762e91d2b2becc6d5aae8/

Change-Id: Iee36205994ebdb27d8c890ae25fd9981326401df
Reviewed-on: https://go-review.googlesource.com/12781
Reviewed-by: Adam Langley <agl@golang.org>
2015-08-30 18:06:42 +00:00