1
0
mirror of https://github.com/golang/go synced 2024-10-04 16:21:22 -06:00
Commit Graph

260 Commits

Author SHA1 Message Date
Russ Cox
2715956f13 build: add build comments to core packages
The go/build package already recognizes
system-specific file names like

        mycode_darwin.go
        mycode_darwin_386.go
        mycode_386.s

However, it is also common to write files that
apply to multiple architectures, so a recent CL added
to go/build the ability to process comments
listing a set of conditions for building.  For example:

        // +build darwin freebsd openbsd/386

says that this file should be compiled only on
OS X, FreeBSD, or 32-bit x86 OpenBSD systems.

These conventions are not yet documented
(hence this long CL description).

This CL adds build comments to the multi-system
files in the core library, a step toward making it
possible to use go/build to build them.

With this change go/build can handle crypto/rand,
exec, net, path/filepath, os/user, and time.

os and syscall need additional adjustments.

R=golang-dev, r, gri, r, gustavo
CC=golang-dev
https://golang.org/cl/5011046
2011-09-15 16:48:57 -04:00
Adam Langley
a775fbf8a4 crypto/tls: support SSLv3
It would be nice not to have to support this since all the clients
that we care about support TLSv1 by now. However, due to buggy
implementations of SSLv3 on the Internet which can't do version
negotiation correctly, browsers will sometimes switch to SSLv3. Since
there's no good way for a browser tell a network problem from a buggy
server, this downgrade can occur even if the server in question is
actually working correctly.

So we need to support SSLv3 for robustness :(

Fixes #1703.

R=bradfitz
CC=golang-dev
https://golang.org/cl/5018045
2011-09-14 15:32:19 -04:00
Russ Cox
3b189d8f9c crypto/tls: handle non-TLS more robustly
Fixes #2253.

R=agl
CC=golang-dev
https://golang.org/cl/4960066
2011-09-12 16:52:49 -04:00
Rob Pike
7d43b84282 time: make Weekday a method.
Weekday is redundant information for a Time structure.
When parsing a time with a weekday specified, it can create an
incorrect Time value.
When parsing a time without a weekday specified, people
expect the weekday to be set.
Fix all three problems by computing the weekday on demand.

This is hard to gofix, since we must change the type of the node.
Since uses are rare and existing code will be caught by the compiler,
there is no gofix module here.

Fixes #2245.

R=golang-dev, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/4974077
2011-09-12 11:47:55 -07:00
Robert Griesemer
61650b21d6 cleanup: gofmt -s -w src misc
R=r
CC=golang-dev
https://golang.org/cl/4984052
2011-09-06 16:04:55 -07:00
Mike Rosset
8ddd66145e build: clear execute bit from Go files
R=golang-dev, rsc
CC=golang-dev, mike.rosset
https://golang.org/cl/4950062
2011-09-05 07:48:42 -04:00
Joel Sing
8c46e47b61 crypto, exec, path, time: add support for OpenBSD
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/4837048
2011-08-12 14:44:16 +10:00
Kyle Consalus
476150f4bf crypto/x509, go/scanner, index/suffixarray: Removed []interface{}/vector uses.
Changed some []interface{} uses to slices of the concrete types; removed use of IntVector.

R=gri, rsc
CC=golang-dev
https://golang.org/cl/4810085
2011-08-08 14:32:37 -07:00
John Asmuth
2f4632febc container/vector: removed some uses of container/vector in other pkgs
R=gri
CC=golang-dev
https://golang.org/cl/4823054
2011-07-27 15:23:42 -07:00
Robert Griesemer
90564a9256 go/printer: changed max. number of newlines from 3 to 2
manual changes in src/pkg/go/printer, src/cmd/gofix/signal_test.go
(cd src/cmd/gofix/testdata; gofmt -w *.in *.out)
(cd src/pkg/go/printer; gotest -update)
gofmt -w misc src

runs all tests

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4715041
2011-07-14 14:39:40 -07:00
Adam Langley
d1d466f620 crypto/x509: prevent chain cycles in Verify
It's possible to include a self-signed root certificate as an
intermediate and push Verify into a loop.

I already had a test for this so I thought that it was ok, but it
turns out that the test was void because the Verisign root certificate
doesn't contain the "IsCA" flag and so it wasn't an acceptable
intermediate certificate for that reason.

R=bradfitz
CC=golang-dev
https://golang.org/cl/4657080
2011-07-07 18:06:50 -04:00
Gideon Jan-Wessel Redelinghuys
582d6e5848 crypto/openpgp: fixed dangerous use of for loop variable
In function readSignedMessage a pointer to for loop variable 'key' was incorrectly being assigned
to md.SignedBy. Changed so that md.SignedBy is pointing to the 'more correct' memory position.

R=golang-dev, r, agl
CC=golang-dev
https://golang.org/cl/4631088
2011-07-07 10:49:03 +10:00
Adam Langley
502589e030 crypto/tls: fix generate_cert.go
Fixes #2030.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/4635092
2011-07-06 16:22:21 -04:00
Adam Langley
acc284d847 crypto/openpgp: add ability to reserialize keys.
This changes Signature so that parsed signatures can be reserialized
exactly. With this ability we can add Serialize to Entity and also the
ability to sign other public keys.

R=bradfitz
CC=golang-dev
https://golang.org/cl/4627084
2011-07-01 13:53:12 -04:00
Wei Guangjing
63b8b948d9 windows: define and use syscall.Handle
Fixes #1487.

R=rsc, alex.brainman, go.peter.90, mikioh.mikioh, mattn.jp
CC=golang-dev
https://golang.org/cl/4600042
2011-07-01 10:18:07 -04:00
Russ Cox
25733a94fd reflect: support for struct tag use by multiple packages
Each package using struct field tags assumes that
it is the only package storing data in the tag.
This CL adds support in package reflect for sharing
tags between multiple packages.  In this scheme, the
tags must be of the form

        key:"value" key2:"value2"

(raw strings help when writing that tag in Go source).

reflect.StructField's Tag field now has type StructTag
(a string type), which has method Get(key string) string
that returns the associated value.

Clients of json and xml will need to be updated.
Code that says

        type T struct {
                X int "name"
        }

should become

        type T struct {
                X int `json:"name"`  // or `xml:"name"`
        }

Use govet to identify struct tags that need to be changed
to use the new syntax.

R=r, r, dsymonds, bradfitz, kevlar, fvbommel, n13m3y3r
CC=golang-dev
https://golang.org/cl/4645069
2011-06-29 09:52:34 -04:00
Rob Pike
ebb1566a46 strings.Split: make the default to split all.
Change the signature of Split to have no count,
assuming a full split, and rename the existing
Split with a count to SplitN.
Do the same to package bytes.
Add a gofix module.

R=adg, dsymonds, alex.brainman, rsc
CC=golang-dev
https://golang.org/cl/4661051
2011-06-28 09:43:14 +10:00
Dmitry Chestnykh
d1dbfe5827 crypto: replace "crypto/block" with "crypto/cipher" in comments
Documentation mentioned the obsolete package "crypto/block",
which has been replaced with "crypto/cipher".

R=golang-dev, agl
CC=golang-dev
https://golang.org/cl/4654064
2011-06-27 09:16:42 -04:00
Robert Griesemer
712fb6dcd3 os.Error API: don't export os.ErrorString, use os.NewError consistently
This is a core API change.

1) gofix misc src
2) Manual adjustments to the following files under src/pkg:
   gob/decode.go
   rpc/client.go
   os/error.go
   io/io.go
   bufio/bufio.go
   http/request.go
   websocket/client.go
as well as:
   src/cmd/gofix/testdata/*.go.in (reverted)
   test/fixedbugs/bug243.go
3) Implemented gofix patch (oserrorstring.go) and test case (oserrorstring_test.go)

Compiles and runs all tests.

R=r, rsc, gri
CC=golang-dev
https://golang.org/cl/4607052
2011-06-22 10:52:47 -07:00
Adam Langley
f2e94de6d6 crypto/openpgp: add ElGamal support.
R=bradfitz, r
CC=golang-dev
https://golang.org/cl/4639049
2011-06-21 21:00:49 -04:00
Russ Cox
21e75da486 respect goto restrictions
R=gri
CC=golang-dev
https://golang.org/cl/4625044
2011-06-17 06:07:13 -04:00
Adam Langley
8834bb0bfa crypto/openpgp: flesh out Encrypt by adding support for signing.
R=bradfitz
CC=golang-dev
https://golang.org/cl/4572059
2011-06-13 13:04:59 -04:00
Adam Langley
531c01d990 crypto/openpgp: build fix (unreviewed)
R=agl
CC=golang-dev
https://golang.org/cl/4572057
2011-06-10 13:32:20 -04:00
Adam Langley
f0d21a773f crypto/openpgp: add ability to encrypt messages.
R=bradfitz, r
CC=golang-dev
https://golang.org/cl/4581051
2011-06-10 12:58:14 -04:00
Adam Langley
c281ddf1eb crypto: reorg, cleanup and add function for generating CRLs.
This change moves a number of common PKIX structures into
crypto/x509/pkix, from where x509, and ocsp can reference
them, saving duplication. It also removes x509/crl and merges it into
x509 and x509/pkix.

x509 is changed to take advantage of the big.Int support that now
exists in asn1. Because of this, the public/private key pair in
http/httptest/server.go had to be updated because it was serialised
with an old version of the code that didn't zero pad ASN.1 INTEGERs.

R=bradfitz, rsc
CC=golang-dev
https://golang.org/cl/4532115
2011-06-06 10:35:46 -04:00
Andrew Gerrand
a028a02395 crypto/twofish: fix Reset index overflow bug.
Fixes #1919.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/4530110
2011-06-06 14:30:48 +10:00
Adam Langley
e0cca45fcb crypto/openpgp: add support for symmetrically encrypting files.
This mostly adds the infrastructure for writing various forms of
packets as well as reading them. Adding symmetric encryption support
was simply an easy motivation.

There's also one brown-paper-bag fix in here. Previously I had the
conditional for the MDC hash check backwards: the code was checking
that the hash was *incorrect*. This was neatly counteracted by another
bug: it was hashing the ciphertext of the OCFB prefix, not the
plaintext.

R=bradfitz
CC=golang-dev
https://golang.org/cl/4564046
2011-06-01 15:23:22 -04:00
Rob Pike
a1d2cbf645 crypto/tls/generate_cert.go: fix misspelling of O_CREATE.
Fixes #1888.

R=ken
CC=golang-dev
https://golang.org/cl/4515148
2011-05-27 21:06:50 +10:00
Robert Hencke
6dced6d992 crypto/x509: fix incorrect prints found by govet
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/4526073
2011-05-22 09:23:22 +10:00
Adam Langley
4fdcb7b684 crypto/openpgp: add key generation support.
This change adds a function for generating new Entities and inchoate
support for reserialising Entities.

R=bradfitz, r, bradfitz
CC=golang-dev
https://golang.org/cl/4551044
2011-05-20 09:36:20 -07:00
Anthony Martin
24b2f48a4a crypto/rand: add utility functions for number generation
This code is extracted from crypto/rsa with
a few variables renamed and a comment fixed.

R=agl, rsc, agl
CC=golang-dev
https://golang.org/cl/4446068
2011-05-18 18:55:06 -07:00
Jonathan Allie
e7db6d78a2 crypto/x509: add support for parsing and verifying DSA signatures
(DSA with SHA1, DSA with SHA256). Cleanup getSignatureFromOID
function.

R=agl, agl, rsc
CC=golang-dev
https://golang.org/cl/4530055
2011-05-18 12:59:04 -07:00
Robert Hencke
c8727c81bb pkg: spelling tweaks, A-H
R=ality, bradfitz, rsc, dsymonds, adg, qyzhai, dchest
CC=golang-dev
https://golang.org/cl/4536063
2011-05-18 13:14:56 -04:00
Robert Hencke
3faa490f89 pkg: fix new incorrect prints found by govet
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/4539063
2011-05-16 21:15:06 -07:00
Adam Langley
d84415d8f0 crypto/x509: support DSA public keys in X.509 certs.
R=agl
CC=golang-dev
https://golang.org/cl/4517072
2011-05-16 11:16:48 -07:00
Robert Hencke
cc2fc02467 pkg: fix incorrect prints found by govet
Also, clarify some error messages

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/4548042
2011-05-14 20:43:18 -07:00
Adam Langley
4eb67563f6 crypto/openpgp: change PublicKey.Serialize to include the header.
Signature.Serialize already does this and they should be consistent.

R=bradfitz
CC=golang-dev
https://golang.org/cl/4521064
2011-05-14 19:13:12 -04:00
Adam Langley
55d43f0ce8 crypto/x509/crl: add package
crl parses CRLs and exposes their details. In the future, Verify
should be able to use this for revocation checking.

R=bradfitz
CC=golang-dev
https://golang.org/cl/4485045
2011-05-11 10:39:09 -04:00
Robert Griesemer
499ad9448b go/printer, gofmt: fix alignment of "=" in const/var declarations
gofmt -w src misc

Fixes #1414.

R=rsc, r
CC=golang-dev
https://golang.org/cl/4456054
2011-05-09 15:16:34 -07:00
Adam Langley
ffd550455c crypto/tls: export the verified chains.
The verified chains are the chains that were actually verified.

R=bradfitz
CC=golang-dev
https://golang.org/cl/4462046
2011-05-05 13:44:36 -04:00
Adam Langley
e1bf165b28 crypto/x509: export raw SubjectPublicKeyInfo.
The SPKI will probably be used for identifying public keys in future
HSTS specs.

R=bradfitz
CC=golang-dev
https://golang.org/cl/4485044
2011-05-05 13:37:42 -04:00
Adam Langley
8803d57f3e crypto/x509: memorize chain building.
I ran the new verification code against a large number of certificates
with a huge (>1000) number of intermediates.

I had previously convinced myself that a cycle in the certificate
graph implied a cycle in the hash graph (and thus, a contradiction).
This is bogus because the signatures don't cover each other.

Secondly, I managed to drive the verification into a time explosion
with a fully connected graph of certificates. The code would try to
walk the factorial number of paths.

This change switches the CertPool to dealing with indexes of
certificates rather than pointers: this makes equality easy. (I didn't
want to compare pointers because a reasonable gc could move objects
around over time.)

Secondly, verification now memorizes the chains from a given
certificate. This is dynamic programming for the lazy, but there's a
solid reason behind it: dynamic programming would ignore the Issuer
hints that we can exploit by walking up the chain rather than down.

R=bradfitzgo
CC=golang-dev
https://golang.org/cl/4439070
2011-04-26 10:26:22 -04:00
Russ Cox
07abf1c732 fix tree for reflect rename
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/4435067
2011-04-25 13:39:36 -04:00
Adam Langley
a9a6c90104 crypto/tls: use time(), not Time().
The unexported version returns a sensible default when the user hasn't
set a value. The exported version crashes in that case.

R=bradfitzgo, rsc1
CC=golang-dev
https://golang.org/cl/4435070
2011-04-25 10:27:36 -04:00
Adam Langley
361e4e5f64 crypto/rsa: add file that I forgot to add last time.
R=rsc
CC=golang-dev
https://golang.org/cl/4452041
2011-04-22 15:46:49 -04:00
Adam Langley
555685e26c crypto/rsa: support > 3 primes.
With full multi-prime support we can support version 1 PKCS#1 private
keys. This means exporting all the members of rsa.PrivateKey, thus
making the API a little messy. However there has already been another
request to export this so it seems to be something that's needed.

Over time, rsa.GenerateMultiPrimeKey will replace rsa.GenerateKey, but
I need to work on the prime balance first because we're no longer
generating primes which are a multiples of 8 bits.

Fixes #987.

R=rsc
CC=golang-dev
https://golang.org/cl/4378046
2011-04-22 15:33:41 -04:00
Nigel Tao
6a186d38d1 src/pkg: make package doc comments consistently start with "Package foo".
R=rsc
CC=golang-dev
https://golang.org/cl/4442064
2011-04-20 09:57:05 +10:00
Adam Langley
b8df1465cc crypto/openpgp: better handling of keyrings.
* Accept armored private key blocks
  * If an armored block is missing, return an InvalidArgumentError,
    rather than ignoring it.
  * If every key in a block is skipped due to being unsupported,
    return the last unsupported error.
  * Include the numeric type of unsupported public keys.
  * Don't assume that the self-signature comes immediately after the
    user id packet.

R=bradfitzgo
CC=golang-dev
https://golang.org/cl/4434048
2011-04-19 11:00:35 -04:00
Adam Langley
90d3837193 crypto/x509: fix build
This pulls in changes that should have been in 3faf9d0c10c0, but
weren't because x509.go was part of another changelist.

TBR=bradfitzgo

R=bradfitzgo
CC=golang-dev
https://golang.org/cl/4433056
2011-04-19 10:11:37 -04:00
Adam Langley
c24c6d8340 crypto: move certificate verification into x509.
People have a need to verify certificates in situations other than TLS
client handshaking. Thus this CL moves certificate verification into
x509 and expands its abilities.

R=bradfitzgo
CC=golang-dev
https://golang.org/cl/4407046
2011-04-19 09:57:58 -04:00