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

383 Commits

Author SHA1 Message Date
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
Adam Langley
6f921f22ae crypto/tls: add server-side OCSP stapling support.
We already had support on the client side. I also changed the name of
the flag in the ServerHello structure to match the name of the same
flag in the ClientHello (ocspStapling).

R=bradfitzgo
CC=golang-dev
https://golang.org/cl/4408044
2011-04-14 14:47:28 -04:00
Robert Griesemer
a2e286828b gofmt: gofmt -s -w src misc
R=r, bradfitzwork
CC=golang-dev
https://golang.org/cl/4406044
2011-04-13 15:13:59 -07:00
Adam Langley
6392fc75cf bufio: add ReadLine
It matches encoding/line exactly and the tests are copied from there.
If we land this, then encoding/line will get marked as deprecated then
deleted in time.

R=rsc, rog, peterGo
CC=golang-dev
https://golang.org/cl/4389046
2011-04-13 15:12:28 -04:00
Gustavo Niemeyer
c34aadf063 openpgp: Fix improper := shadowing
R=golang-dev, agl1, jnml
CC=golang-dev
https://golang.org/cl/4381058
2011-04-12 11:48:05 -03:00
Mikkel Krautz
e2348deeec crypto/x509: expose complete DER data
R=agl1
CC=golang-dev
https://golang.org/cl/4376049
2011-04-11 11:20:12 -04:00
Adam Langley
41971434d1 crypto/rsa: add 3-prime support.
R=golang-dev, rsc1
CC=golang-dev
https://golang.org/cl/4365041
2011-04-06 14:11:56 -04:00
Adam Langley
057bdfe39d crypto/rsa: flip the CRT code over so that it matches PKCS#1
The CRT is symmetrical in the case of two variables and I picked a
different form from PKCS#1.

R=golang-dev, rsc1
CC=golang-dev
https://golang.org/cl/4381041
2011-04-06 10:22:04 -04:00
Adam Langley
360ab50a9b crypto/rsa: add support for precomputing CRT values.
This speeds up private key operations by 3.5x (for a 2048-bit
modulus).

R=golang-dev, r, rsc1
CC=golang-dev
https://golang.org/cl/4348053
2011-04-05 18:07:01 -04:00
Dmitry Chestnykh
9f1394d270 crypto/ecdsa, crypto/rsa: use io.ReadFull to read from random source.
R=golang-dev, agl1
CC=golang-dev
https://golang.org/cl/4316057
2011-04-05 17:11:31 -04:00
Adam Langley
906b2e7679 crypto/des: cleanups
R=rsc
CC=golang-dev
https://golang.org/cl/4315050
2011-04-05 15:40:48 -04:00
Adam Langley
2db1769d7b crypto/block: remove deprecated package.
R=rsc
CC=golang-dev
https://golang.org/cl/4315051
2011-04-05 15:23:40 -04:00
Russ Cox
de3aac609c gofix: don't rewrite O_APPEND opens
R=r, rog
CC=golang-dev
https://golang.org/cl/4364041
2011-04-05 11:12:02 -04:00
Yasuhiro Matsumoto
7098f3d442 crypto/des: new package providing implementations of DES and TDEA
Original code by Chris Lennert <cale...@gmail.com>

R=rsc, agl1
CC=golang-dev
https://golang.org/cl/4331054
2011-04-05 10:59:10 -04:00
Rob Pike
8a90fd3c72 os: New Open API.
We replace the current Open with:
OpenFile(name, flag, perm) // same as old Open
Open(name) // same as old Open(name, O_RDONLY, 0)
Create(name) // same as old Open(name, O_RDWR|O_TRUNC|O_CREAT, 0666)

This CL includes a gofix module and full code updates: all.bash passes.
(There may be a few comments I missed.)

The interesting packages are:
        gofix
        os
Everything else is automatically generated except for hand tweaks to:
        src/pkg/io/ioutil/ioutil.go
        src/pkg/io/ioutil/tempfile.go
        src/pkg/crypto/tls/generate_cert.go
        src/cmd/goyacc/goyacc.go
        src/cmd/goyacc/units.y

R=golang-dev, bradfitzwork, rsc, r2
CC=golang-dev
https://golang.org/cl/4357052
2011-04-04 23:42:14 -07:00
Brad Fitzpatrick
cc40870f4b httptest: add NewTLSServer
Enables the use of https servers in tests.

R=agl, rsc, agl1
CC=golang-dev
https://golang.org/cl/4284063
2011-04-04 08:32:59 -07:00
Adam Langley
974d2c98e0 crypto/tls: extend NPN support to the client.
R=bradfitzgo, rsc1, bradfitzwork
CC=golang-dev
https://golang.org/cl/4277085
2011-03-29 17:53:09 -04:00
Rob Pike
d844aae690 prints: fix a couple of formatting errors caught by govet
R=rsc, agl, agl1
CC=golang-dev
https://golang.org/cl/4337041
2011-03-29 14:03:08 -07:00
Adam Langley
9225bbfc0c crypto/cipher: bad CTR IV length now triggers panic
R=rsc
CC=golang-dev
https://golang.org/cl/4326042
2011-03-29 15:47:35 -04:00
Mikkel Krautz
a7bb288f99 crypto/x509: Parse Extended Key Usage extension
This changeset makes it possible for crypto/x509 to parse
certificates that include the 'Extended Key Usage' extension
with the critical bit set.

R=agl1
CC=golang-dev
https://golang.org/cl/4277075
2011-03-29 10:35:34 -04:00
Russ Cox
41f93a430f net: drop laddr from Dial, cname from LookupHost; new functions
Drop laddr argument from Dial.

Drop cname return from LookupHost.

Add LookupIP, LookupCNAME, ParseCIDR, IP.Equal.
Export SplitHostPort, JoinHostPort.
Add AAAA (IPv6) support to host lookups.

Preparations for implementing some of the
lookups using cgo.

ParseCIDR and IP.Equal are logically new in this CL
but accidentally snuck into an earlier CL about unused
labels that was in the same client.

In crypto/tls, drop laddr from Dial to match net.

R=golang-dev, dsymonds, adg, rh
CC=golang-dev
https://golang.org/cl/4244055
2011-03-28 23:28:42 -04:00
Rob Pike
7f9acb53cb testing: shorten some more tests
R=rsc
CC=golang-dev
https://golang.org/cl/4314044
2011-03-26 11:25:22 -07:00
Rob Pike
f0cf7d296c testing: shorten some tests.
These are the top runners.  More to come.
Also print two digits of timing info under -test.v.

R=rsc
CC=golang-dev
https://golang.org/cl/4317044
2011-03-25 16:31:10 -07:00
Rob Pike
d406f8f650 testing: set up structure for faster testing using the new -test.short flag.
New make target "testshort" runs "gotest -test.short" and is invoked
by run.bash, which is invoked by all.bash.

Use -test.short to make one package (crypto ecdsa) run much faster.
More changes to come.

Once this is in, I will update the long-running tests to use the new flag.

R=rsc
CC=golang-dev
https://golang.org/cl/4317043
2011-03-25 14:50:44 -07:00
Adam Langley
df184ff2f0 crypto/openpgp: add DSA signature support.
R=bradfitzgo, nsz
CC=golang-dev
https://golang.org/cl/4280041
2011-03-16 10:50:06 -04:00
Adam Langley
7b094182e4 crypto/ecdsa: truncate hash values.
There is some disagreement about how to deal with hash values larger
than the curve order size. We choose to follow OpenSSL's lead here.

R=bradfitzgo, r
CC=golang-dev
https://golang.org/cl/4273059
2011-03-16 10:42:41 -04:00
Brad Fitzpatrick
5245b27ed8 openpgp: add PublicKey KeyId string accessors
R=agl, agl1
CC=golang-dev
https://golang.org/cl/4297041
2011-03-15 10:06:17 -07:00
Dave Cheney
43ae7da190 crypto/tls: fix compile error
Fixes #1555.

R=rsc, bradfitzgo
CC=golang-dev
https://golang.org/cl/4284047
2011-03-12 19:35:41 -08:00
Adam Langley
ee23ab16da crypto/openpgp: s/serialise/serialize/
(No code changes, Americanization only.)

R=rsc, bradfitzwork
CC=golang-dev
https://golang.org/cl/4250075
2011-03-10 10:36:04 -05:00
Brad Fitzpatrick
dc06ad5ad7 tls: move PeerCertificates to ConnectionState
R=agl, agl1
CC=golang-dev, rsc
https://golang.org/cl/4248078
2011-03-10 07:22:53 -08:00
Adam Langley
dd5adcc3c3 crypto/openpgp: bug fixes and fix misnamed function.
R=rsc, bradfitzwork
CC=golang-dev
https://golang.org/cl/4244066
2011-03-10 10:14:31 -05:00
Adam Langley
daf33c3ebe crypto/elliptic: add the N value of each curve.
R=rsc
CC=golang-dev
https://golang.org/cl/4240104
2011-03-10 10:04:06 -05:00
Adam Langley
f422242065 crypto/ecdsa: add package.
R=rsc, cw
CC=golang-dev
https://golang.org/cl/4253073
2011-03-10 09:42:34 -05:00
Rob Pike
54f0040723 crypto/openpgp: fix test prints
R=agl, agl1
CC=golang-dev
https://golang.org/cl/4255041
2011-02-25 13:44:37 -08:00
Adam Langley
6ca009f58d crypto/openpgp: add package
R=bradfitzgo
CC=golang-dev
https://golang.org/cl/3989052
2011-02-24 20:19:53 -05:00
Kyle Consalus
07cc8b9ad2 Make.pkg, doc: Replace references to "-benchmarks" and "-match" with "-test.bench" and "-test.run".
R=r
CC=golang-dev
https://golang.org/cl/4197041
2011-02-22 20:23:21 -08:00
Adam Langley
7b166cd73c crypto/openpgp/packet: comment typo fix.
R=rsc
CC=golang-dev
https://golang.org/cl/4178065
2011-02-19 10:41:57 -05:00
Rob Pike
7e6488f9ad crypto/openpgp/packet: fix testing print (missing arg)
R=agl
CC=golang-dev
https://golang.org/cl/4173062
2011-02-18 10:47:38 -08:00
Adam Langley
193709736f crypto/rsa: left-pad OAEP results when needed.
PKCS#1 v2.1 section 7.1.1 says that the result of an OAEP encryption
is "an octet string of length $k$". Since we didn't left-pad the
result it was previously possible for the result to be smaller when
the most-significant byte was zero.

Fixes #1519.

R=rsc
CC=golang-dev
https://golang.org/cl/4175059
2011-02-18 11:31:10 -05:00
Albert Strasheim
712888910b crypto/rand: Added read buffer to speed up requests for small amounts of bytes.
R=agl1, rsc
CC=golang-dev
https://golang.org/cl/4170056
2011-02-17 15:14:41 -05:00
Adam Langley
a0c3b96065 crypto/tls: make protocol negotiation failure fatal
R=r, r2
CC=golang-dev
https://golang.org/cl/4178054
2011-02-15 16:38:45 -05:00
Adam Langley
4ee90b764e crypto/openpgp: minor updates to subpackages
Now that packet/ is checked in, we can add its Makefile. Also, a couple
of updates to error/ and s2k/ for bugfixes and to use the new crypto
package.

R=bradfitzgo
CC=golang-dev
https://golang.org/cl/4179043
2011-02-11 08:34:19 -05:00
Adam Langley
28a2369414 crypto/openpgp/packet: add remainder of packet types.
(The unittest for Signature may seem a little small, but it's tested by
the higher level code.)

R=bradfitzgo
CC=golang-dev
https://golang.org/cl/4173043
2011-02-10 19:59:12 -05:00
Alex Brainman
cf75c86cdf syscall: change windows apis with bool return value to return errno instead
This change is to make these apis similar to their unix counterparts.

R=rsc
CC=golang-dev
https://golang.org/cl/4185042
2011-02-11 10:15:51 +11:00
Adam Langley
9fe490ee38 crypto/openpgp/packet: four more packet types.
R=bradfitzgo
CC=golang-dev
https://golang.org/cl/4156044
2011-02-10 07:56:30 -05:00
Rob Pike
34fc17a820 src/*: fix incorrect prints found by govet
R=gri
CC=golang-dev
https://golang.org/cl/4169044
2011-02-09 17:11:01 -08:00
Adam Langley
531fb5413e crypto/x509: add name constraints support.
R=golang-dev, r, rsc
CC=golang-dev
https://golang.org/cl/4130047
2011-02-09 08:39:31 -05:00
Adam Langley
1b8d373463 crypto/openpgp/packet: add UserId packet type
This was split from CL 4124054

R=bradfitzgo
CC=golang-dev
https://golang.org/cl/4126057
2011-02-07 21:40:33 -05:00
Adam Langley
ab2aca5e52 crypto/tls: select best ciphersuite, not worst.
Previously, the outer loop would continue until we selected the
client's least preferable ciphersuite.

R=golang-dev, r2
CC=golang-dev
https://golang.org/cl/4029056
2011-02-05 13:56:36 -05:00
Adam Langley
5626bd9e38 crypto/tls: load a chain of certificates from a file.
Many recently issued certificates are chained: there's one or more
intermediate certificates between the host certificate and the root CA
certificate. This change causes the code to load any number of
certificates from the certificate file. This matches the behaviour of
common webservers, and the output of OpenSSL's command line tools.

R=golang-dev, r2
CC=golang-dev
https://golang.org/cl/4119057
2011-02-05 13:54:25 -05:00
Adam Langley
c63a88072b crypto/openpgp/packet: two more packet types.
R=bradfitzgo, r
CC=golang-dev
https://golang.org/cl/4124054
2011-02-05 12:06:42 -05:00
Adam Langley
4a14bc524b crypto/openpgp/packet: add public key support
Note that DSA public key support is nascent and the verification
functions clearly don't support it yet. I'm intending to get RSA keys
working first.

R=bradfitzgo
CC=golang-dev
https://golang.org/cl/3973054
2011-02-04 09:00:17 -05:00
Adam Langley
364cb831f7 crypto/openpgp/packet: add basic routines
Since nobody suggested major changes to the higher level API, I'm
splitting up the lower level code for review. This is the first of the
changes for the packet reading/writing code.

It deliberately doesn't include a Makefile because the package is
incomplete.

R=bradfitzgo
CC=golang-dev
https://golang.org/cl/4080051
2011-02-03 09:22:40 -05:00
Adam Langley
2a2995cec8 crypto/openpgp/armor: bug fixes
* Don't require lines to be full.
* Don't forget to flush the line buffer.
* Update the test so that it doesn't happen to include only full lines
  in order to test the above.
* Always write the line after the header as GNUPG expects it.

R=bradfitzgo
CC=golang-dev
https://golang.org/cl/4124043
2011-02-03 09:19:20 -05:00
Adam Langley
fc5c1f0a18 crypto/cipher: add resync open to OCFB mode.
OpenPGP changed its OCFB mode for more modern packets (for example, the
MDC symmetrically encrypted packet). This change adds a bool to
determine which mode is used.

R=bradfitzgo, r, rsc
CC=golang-dev
https://golang.org/cl/4126041
2011-02-03 09:17:42 -05:00
Adam Langley
e308d55973 crypto: add package.
The crypto package is added as a common place to store identifiers for
hash functions. At the moment, the rsa package has an enumeration of
hash functions and knowledge of their digest lengths. This is an
unfortunate coupling and other high level crypto packages tend to need
to duplicate this enumeration and knowledge (i.e. openpgp).

crypto pulls this code out into a common location.

It would also make sense to add similar support for ciphers to crypto,
but the problem there isn't as acute that isn't done in this change.

R=bradfitzgo, r, rsc
CC=golang-dev
https://golang.org/cl/4080046
2011-02-01 11:02:48 -05:00
Adam Langley
166008b988 crypto/dsa: add support for DSA
R=bradfitzgo, r, bradfitzwork, nsz, rsc
CC=golang-dev
https://golang.org/cl/3990043
2011-01-25 12:25:53 -05:00
David Anderson
d0e6c7e134 crypto/rsa: correct docstring for SignPKCS1v15.
The docstring claims the function uses PSS message encoding,
when the function actually implements PKCS1-v1_5 encoding.

R=agl1, rsc
CC=danderson, golang-dev
https://golang.org/cl/4097042
2011-01-25 10:52:36 -05:00
Anschel Schaffer-Cohen
3921d26300 Use defer to unlock mutex in crypto/rand.
R=agl1
CC=golang-dev
https://golang.org/cl/3991045
2011-01-21 10:14:43 -05:00
Adam Langley
0bec484e6f crypto/openpgp: add s2k
s2k implements the string-to-key functions for OpenPGP

R=rsc
CC=golang-dev
https://golang.org/cl/3937043
2011-01-20 07:38:34 -05:00
Adam Langley
4a7fed4d90 crypto/twofish: update with rsc's comments
TBR=rsc

R=rsc
CC=berengar.lehr, golang-dev
https://golang.org/cl/4050042
2011-01-19 19:41:27 -05:00
Rob Pike
052ff45690 crypto/cipher: fix build (missing file in Makefile)
R=agl, adg
CC=golang-dev
https://golang.org/cl/4073041
2011-01-18 20:56:55 -08:00
Adam Langley
9b6d8b3c4f crypto/cipher: add OFB mode
R=rsc, r
CC=golang-dev
https://golang.org/cl/3994042
2011-01-18 18:16:06 -05:00
Adam Langley
5aeacadc5a crypto/openpgp: add error and armor
error is needed by all the OpenPGP packages as they return a shared
family of error types.

armor implements OpenPGP armoring. It's very like PEM except:
  a) it includes a CRC24 checksum
  b) PEM values are small (a few KB) and so encoding/pem assumes that
     they fit in memory. Armored data can be very large and so this
     package presents a streaming interface.

R=r, nsz, rsc
CC=golang-dev
https://golang.org/cl/3786043
2011-01-11 20:54:30 -05:00
Berengar Lehr
1aec7c7f34 crypto: add twofish package
The code was (as annotated in the source code) adopted from Tom's
LibCrypt (public domain code, [1]). It was neither optimised for speed
nor were any security features added.

[1] http://libtom.org/?page=features&newsitems=5&whatfile=crypt

R=rsc, berengarlehr, albert.strasheim, agl1
CC=golang-dev, schulze
https://golang.org/cl/2687042
2011-01-11 20:51:35 -05:00
Adam Langley
ee58cc799e crypto/block: mark as deprecated.
R=rsc
CC=golang-dev
https://golang.org/cl/3909041
2011-01-07 16:17:47 -05:00
Russ Cox
a46102d209 crypto/cipher: make NewCBCEncrypter return BlockMode
Fixes #1389.

R=agl1
CC=golang-dev
https://golang.org/cl/3827043
2011-01-06 11:21:04 -05:00
Adam Langley
03e259664f crypto/cipher: fix OCFB
I messed up when reading the OCFB spec.

TBR=rsc

R=rsc
CC=golang-dev
https://golang.org/cl/3739042
2010-12-27 12:55:49 -05:00
Rob Pike
ae6bfe3687 tls: fix argument mistake in Error call.
R=agl, agl1, rsc
CC=golang-dev
https://golang.org/cl/3753041
2010-12-17 13:47:52 -08:00
Anthony Martin
a890d70cc1 crypto/hmac: add HMAC-SHA256
R=agl1, rsc
CC=golang-dev
https://golang.org/cl/3730041
2010-12-17 12:19:37 -05:00
Adam Langley
be45ba712b crypto/tls: missed a file
R=rsc
CC=golang-dev
https://golang.org/cl/3674043
2010-12-16 17:14:02 -05:00
Adam Langley
4883b73982 crypto/tls: add ECDHE support
(ECDHE is "Elliptic Curve Diffie Hellman Ephemeral")

R=rsc
CC=golang-dev
https://golang.org/cl/3668042
2010-12-16 17:10:50 -05:00
Adam Langley
1e3b9524d2 crypto/elliptic: add serialisation and key pair generation.
This is a prerequisite to ECDHE support in crypto/tls.

R=r, rsc
CC=golang-dev
https://golang.org/cl/3685043
2010-12-16 16:04:01 -05:00
Adam Langley
fd021cbe8f crypto/tls: check in support code.
This support code helps in generating the handshake scripts
which are used for testing.

R=rsc, ality
CC=golang-dev
https://golang.org/cl/3680041
2010-12-16 10:39:53 -05:00
Adam Langley
1a072f4b37 crypto/tls: commit fixes which I hadn't saved.
R=rsc
CC=golang-dev
https://golang.org/cl/3685041
2010-12-15 13:58:57 -05:00
Adam Langley
eedf5c4529 crypto/tls: support CBC ciphers
This is largely based on ality's CL 2747042.

crypto/rc4: API break in order to conform to crypto/cipher's
Stream interface

cipher/cipher: promote to the default build

Since CBC differs between TLS 1.0 and 1.1, we downgrade and
support only 1.0 at the current time. 1.0 is what most of the
world uses.

Given this CL, it would be trival to add support for AES 256,
SHA 256 etc, but I haven't in order to keep the change smaller.

R=rsc
CC=ality, golang-dev
https://golang.org/cl/3659041
2010-12-15 11:49:55 -05:00
Russ Cox
0c54225b51 remove nacl
The recent linker changes broke NaCl support
a month ago, and there are no known users of it.

The NaCl code can always be recovered from the
repository history.

R=adg, r
CC=golang-dev
https://golang.org/cl/3671042
2010-12-15 11:49:23 -05:00
Anthony Martin
6a4b0191c0 crypto/tls: use rand.Reader in cert generation example
R=rsc, agl1
CC=golang-dev
https://golang.org/cl/3536043
2010-12-14 12:22:28 -05:00
Adam Langley
3a5efdf230 crypto/elliptic: remove mistakenly commited code
One of my own experiments ended up getting mistakenly commited when
        switching to Jacobian transformations.

R=rsc
CC=golang-dev
https://golang.org/cl/3473044
2010-12-08 15:01:53 -05:00
Rob Pike
1ce6245d6c throughout: fix broken calls to Printf etc.
I have written a tool to verify Printf calls, and although it's not
ready to be reviewed yet it's already uncovered a spate of problems
in the repository.  I'm sending this CL to break the changes into
pieces; as the tool improves it will find more, I'm sure.

R=rsc
CC=golang-dev
https://golang.org/cl/3427043
2010-12-07 16:42:54 -05:00
Russ Cox
b15c4245c5 crypto/tls: add *Config argument to Dial
Document undocumented exported names.
Allow nil Rand, Time, RootCAs in Config.

Fixes #1248.

R=agl1
CC=golang-dev
https://golang.org/cl/3481042
2010-12-07 16:15:15 -05:00
Christian Himpel
2660c2a7be crypto/tls: fix build of certificate generation example
R=agl1, rsc
CC=golang-dev
https://golang.org/cl/3366041
2010-12-07 16:14:55 -05:00
Kyle Consalus
009aebdba8 Removed bytes.Add and bytes.AddByte; we now have 'append'.
Changed all uses of bytes.Add (aside from those testing bytes.Add) to append(a, b...).
Also ran "gofmt -s" and made use of copy([]byte, string) in the fasta benchmark.

R=golang-dev, r, r2
CC=golang-dev
https://golang.org/cl/3302042
2010-12-01 11:59:13 -08:00
Adam Langley
3cb4bdb9ce utf8: make EncodeRune's destination the first argument.
R=r
CC=golang-dev
https://golang.org/cl/3364041
2010-11-30 16:59:43 -05:00
Adam Langley
287045085d crypto/elliptic: use a Jacobian transform
(Speeds up the code about 25x)

R=r
CC=golang-dev
https://golang.org/cl/3359042
2010-11-30 16:58:59 -05:00
Adam Langley
b84b20b820 crypto/cipher: add CFB and OCFB mode.
(Files which I left out of the initial commit to keep it small.)

R=rsc
CC=golang-dev
https://golang.org/cl/3183043
2010-11-19 16:17:58 -05:00
Adam Langley
07791d04d6 crypto/cipher: add package
cipher is intended to replace crypto/block over time. This
change only adds basic parts: CBC and CTR mode and doesn't add
the package to the top-level Makefile.

R=r, rsc
CC=golang-dev
https://golang.org/cl/3069041
2010-11-19 14:12:07 -05:00
Adam Langley
fb784785f5 crypto/elliptic: add package
elliptic implements several standard elliptic curves over prime fields.

R=r, r2
CC=golang-dev
https://golang.org/cl/3065041
2010-11-12 14:55:32 -05:00
Adam Langley
ffa9000b75 crypto/x509: policy OID support and fixes.
* Add support for certificate policy identifiers
        * Fix the version number of generated certificates
        * Fix the parsing of version numbers
        * Fix the case of multiple name entries (it should have been a list of
          tagged values, not a tagged list of values).

R=r
CC=golang-dev
https://golang.org/cl/3044041
2010-11-11 15:50:40 -05:00
Adam Langley
836529a63c crypto/tls: use pool building for certificate checking
Previously we checked the certificate chain from the leaf
upwards and expected to jump from the last cert in the chain to
a root certificate.

Although technically correct, there are a number of sites with
problems including out-of-order certs, superfluous certs and
missing certs.

The last of these requires AIA chasing, which is a lot of
complexity. However, we can address the more common cases by
using a pool building algorithm, as browsers do.

We build a pool of root certificates and a pool from the
server's chain. We then try to build a path to a root
certificate, using either of these pools.

This differs from the behaviour of, say, Firefox in that Firefox
will accumulate intermedite certificate in a persistent pool in
the hope that it can use them to fill in gaps in future chains.

We don't do that because it leads to confusing errors which only
occur based on the order to sites visited.

This change also enabled SNI for tls.Dial so that sites will return
the correct certificate chain.

R=rsc
CC=golang-dev
https://golang.org/cl/2916041
2010-11-05 09:54:56 -04:00
Adam Langley
02939dec80 crypto: switch block ciphers to detination first.
Previously all the functions took two arguments: src, dst. This is the
reverse of the usual Go style and worth changing sooner rather than
later.

Unfortunately, this is a change that the type system doesn't help
with. However, it's not a subtle change: any unittest worth the name
should catch this.

R=rsc, r
CC=golang-dev
https://golang.org/cl/2751042
2010-11-03 10:43:43 -04:00
Adam Langley
b5135b34c9 crypto: add cast5
CAST5 is the default OpenPGP cipher.

(This won't make Rob any happier about the size of crypto/, of course.)

It already has dst, src in that order but it doesn't have any users yet so I figure it's better than changing it later.

R=rsc, gri, r
CC=golang-dev
https://golang.org/cl/2762042
2010-11-03 10:39:15 -04:00
Russ Cox
69c4e9380b use append
R=gri, r, r2
CC=golang-dev
https://golang.org/cl/2743042
2010-10-27 19:47:23 -07:00
Russ Cox
d86ab015f7 use copy
R=gri
CC=golang-dev
https://golang.org/cl/2763041
2010-10-26 21:52:54 -07:00
Robert Griesemer
3478891d12 gofmt -s -w src misc
R=r, rsc
CC=golang-dev
https://golang.org/cl/2662041
2010-10-22 10:06:33 -07:00
Rob Pike
12da5a90e0 log: new interface
New logging interface simplifies and generalizes.

1) Loggers now have only one output.
2) log.Stdout, Stderr, Crash and friends are gone.
	Logging is now always to standard error by default.
3) log.Panic* replaces log.Crash*.
4) Exiting and panicking are not part of the logger's state; instead
	the functions Exit* and Panic* simply call Exit or panic after
	printing.
5) There is now one 'standard logger'.  Instead of calling Stderr,
	use Print etc.  There are now triples, by analogy with fmt:
		Print, Println, Printf
	What was log.Stderr is now best represented by log.Println,
	since there are now separate Print and Println functions
	(and methods).
6) New functions SetOutput, SetFlags, and SetPrefix allow global
	editing of the standard logger's properties.   This is new
	functionality. For instance, one can call
		log.SetFlags(log.Lshortfile|log.Ltime|log.Lmicroseconds)
	to get all logging output to show file name, line number, and
	time stamp.

In short, for most purposes
	log.Stderr -> log.Println or log.Print
	log.Stderrf -> log.Printf
	log.Crash -> log.Panicln or log.Panic
	log.Crashf -> log.Panicf
	log.Exit -> log.Exitln or log.Exit
	log.Exitf -> log.Exitf (no change)

This has a slight breakage: since loggers now write only to one
output, existing calls to log.New() need to delete the second argument.
Also, custom loggers with exit or panic properties will need to be
reworked.

All package code updated to new interface.

The test has been reworked somewhat.

The old interface will be removed after the new release.
For now, its elements are marked 'deprecated' in their comments.

Fixes #1184.

R=rsc
CC=golang-dev
https://golang.org/cl/2419042
2010-10-12 12:59:18 -07:00
Adam Langley
2d8e2482cc crypto/tls: make SetReadTimeout work.
Fixes #1181.

R=rsc, agl1, cw, r2
CC=golang-dev
https://golang.org/cl/2414041
2010-10-11 10:41:01 -04:00
Adam Langley
f6e2eab8e0 crypto/tls: better error messages for certificate issues.
Fixes #1146.

R=rsc, agl1
CC=golang-dev
https://golang.org/cl/2380042
2010-10-11 10:39:56 -04:00
Russ Cox
d8fc38c7b8 crypto/ocsp: update for asn1 change (fix build)
TBR=gri
CC=golang-dev
https://golang.org/cl/2221044
2010-09-24 13:08:35 -04:00
Russ Cox
8206bafb22 asn1: make interface consistent with json
Replace Marshal with MarshalToMemory
(no one was using old Marshal anyway).

Swap arguments to Unmarshal.

Fixes #1133.

R=agl1
CC=golang-dev
https://golang.org/cl/2249045
2010-09-24 12:34:18 -04:00
Adam Langley
8e5f673dac crypto/x509, crypto/tls: improve root matching and observe CA flag.
The key/value format of X.500 names means that it's possible to encode
a name with multiple values for, say, organisation. RFC5280
doesn't seem to consider this, but there are Verisign root
certificates which do this and, in order to find the correct
root certificate in some cases, we need to handle it.

Also, CA certificates should set the CA flag and we now check
this. After looking at the other X.509 extensions it appears
that they are universally ignored/bit rotted away so we ignore
them.

R=rsc
CC=golang-dev
https://golang.org/cl/2249042
2010-09-20 12:17:31 -04:00
Adam Langley
6989f6e312 Fix certificate validation.
asn1: add support for T61String because this is the string type which
    several www.google.com certificates are now using for fields like
    CommonName
tls: force a handshake in Dial so that certificates are ready
    afterwards.

Fixes #1114.

R=rsc
CC=golang-dev
https://golang.org/cl/2216043
2010-09-20 10:32:08 -04:00
Russ Cox
a4514c42dd http: check https certificate against host name
Fixes #1093.

R=agl, agl1
CC=golang-dev
https://golang.org/cl/2115045
2010-09-11 23:41:12 -04:00
Adam Langley
5011c27018 crypto/tls: don't return an error from Close()
Fixes #1037.

R=adg, rsc1
CC=golang-dev
https://golang.org/cl/2107048
2010-09-10 15:55:35 -04:00
Evan Shaw
3972908ead crypto/tls: Fix doc typo
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/2073041
2010-08-30 09:59:59 +10:00
Jukka-Pekka Kekkonen
ba5b09f786 crypto/hmac: make Sum idempotent
Fixes #978.

R=rsc
CC=golang-dev
https://golang.org/cl/1967045
2010-08-26 13:32:29 -04:00
Adam Langley
4abfc4fff0 crypto/ocsp: add missing Makefile
R=rsc
CC=golang-dev
https://golang.org/cl/2018041
2010-08-19 16:33:58 -04:00
Russ Cox
da392d9136 build: no required environment variables
R=adg, r, PeterGo
CC=golang-dev
https://golang.org/cl/1942044
2010-08-18 10:08:49 -04:00
Mikkel Krautz
c47123d07b crypto/tls: client certificate support.
This changeset implements client certificate support in crypto/tls
for both handshake_server.go and handshake_client.go

The updated server implementation sends an empty CertificateAuthorities
field in the CertificateRequest, thus allowing clients to send any
certificates they wish. Likewise, the client code will only respond
with its certificate when the server requests a certificate with this
field empty.

R=agl, rsc, agl1
CC=golang-dev
https://golang.org/cl/1975042
2010-08-16 11:22:22 -04:00
Rob Pike
c78be462a0 once: replace all uses of package once with sync.Once.
package once remains for now; will be deleted after next release.

R=golang-dev, brainman
CC=golang-dev
https://golang.org/cl/1914046
2010-08-06 06:14:41 +10:00
Adam Langley
7748a7f159 crypto/x509: unwrap Subject Key Identifier
RFC 5280, 4.2.1.2 says:
  SubjectKeyIdentifier ::= KeyIdentifier
  KeyIdentifier ::= OCTET STRING

Previously, we were failing to unwrap the second level of OCTET STRING
encoding.

Fixes #993.

R=rsc
CC=golang-dev
https://golang.org/cl/1917044
2010-08-03 12:26:48 -04:00
Fazlul Shahriar
4f64ecfdda http: add https client support
Fixes #851.

R=rsc
CC=golang-dev
https://golang.org/cl/1729052
2010-07-28 18:13:56 -07:00
Adam Langley
7be849d4a6 crypto/tls: add client-side SNI support and PeerCertificates.
SNI (Server Name Indication) is a way for a TLS client to
indicate to the server which name it knows the server by. This
allows the server to have several names and return the correct
certificate for each (virtual hosting).

PeerCertificates returns the list of certificates presented by
server.

R=r
CC=golang-dev
https://golang.org/cl/1741053
2010-07-21 11:36:01 -04:00
Adam Langley
8286ee4c5b crypto/ocsp: add package to parse OCSP responses.
OCSP is the preferred X.509 revocation mechanism. X.509 certificates
        can contain a URL from which can be fetched a signed response saying
        "this certificate is valid until $x" (where $x is usually 7 days in the
        future). These are called OCSP responses and they can also be included
        in the TLS handshake itself ("OCSP stapling")

R=rsc, r
CC=golang-dev
https://golang.org/cl/1875043
2010-07-21 10:07:22 -04:00
Adam Langley
c9406f930d crypto/tls: add client OCSP stapling support.
R=r, rsc
CC=golang-dev
https://golang.org/cl/1750042
2010-07-14 10:40:15 -04:00
Russ Cox
2e3dc2cc35 crypto/rand: add missing Unlock
R=r
CC=golang-dev
https://golang.org/cl/1812043
2010-07-13 12:37:47 -07:00
Peter Mundy
ccd28e8eb6 crypto/rand for Windows
R=rsc, brainman
CC=golang-dev
https://golang.org/cl/1773041
2010-07-12 16:37:53 -07:00
Adam Langley
a169e6cc6a http, crypto/tls: followup fixes from 1684051.
(TBR because this is just addressing previous review comments.)

R=r
CC=golang-dev
https://golang.org/cl/1697048
2010-07-02 16:43:48 -04:00
Adam Langley
fc23def67f crypto/tls, http: Make HTTPS servers easier.
R=r, adg, rsc
CC=golang-dev
https://golang.org/cl/1684051
2010-07-02 13:00:18 -04:00
Rob Pike
38f1231f3e strings and bytes.Split: make count of 0 mean 0, not infinite.
Use a count of -1 for infinity.  Ditto for Replace.

R=rsc
CC=golang-dev
https://golang.org/cl/1704044
2010-07-01 14:08:14 -07:00
Adam Langley
269df58270 x509: fix English.
(addressing comments from 1741045)

R=r
CC=golang-dev
https://golang.org/cl/1678047
2010-06-30 18:05:38 -04:00
Adam Langley
9c09ed13d2 x509: support non-self-signed certs.
For generating non-self-signed certs we need to be able to specify a
public key (for the signee) which is different from the private key (of
the signer).

R=rsc
CC=golang-dev
https://golang.org/cl/1741045
2010-06-30 18:02:31 -04:00
Russ Cox
bb84f4b5d2 changes &x -> x[0:] for array to slice conversion
R=gri
CC=golang-dev
https://golang.org/cl/1326042
2010-05-27 14:51:47 -07:00
Rob Pike
f023e859cf compress: renamings.
NewDeflater -> NewWriter
NewInflater -> NewReader
Deflater -> Compressor
Inflater -> Decompressor

R=rsc
CC=golang-dev
https://golang.org/cl/1166041
2010-05-07 14:32:34 -07:00
Robert Griesemer
b9caa4ac56 big: completed set of Int division routines & cleanups
- renamed Len -> BitLen, simplified implementation
- renamed old Div, Mod, DivMod -> Que, Rem, QuoRem
- implemented Div, Mod, DivMod (Euclidian definition, more
  useful in a mathematical context)
- fixed a bug in Exp (-0 was possible)
- added extra tests to check normalized results everywhere
- uniformly set Int.neg flag at the end of computations
- minor cosmetic cleanups
- ran all tests

R=rsc
CC=golang-dev
https://golang.org/cl/1091041
2010-05-03 18:48:05 -07:00
Russ Cox
72d9322032 crypto/tls: simpler implementation of record layer
Depends on CL 957045, 980043, 1004043.
Fixes #715.

R=agl1, agl
CC=golang-dev
https://golang.org/cl/943043
2010-04-26 22:19:04 -07:00
Russ Cox
99d258a2f0 crypto/tls: good defaults
R=agl1
CC=golang-dev
https://golang.org/cl/851041
2010-04-05 14:38:02 -07:00
Russ Cox
c7122a3c58 simplify various code using new map index rule
R=r
CC=golang-dev
https://golang.org/cl/833044
2010-03-30 10:51:11 -07:00
Russ Cox
00f9f0c056 single argument panic
note that sortmain.go has been run through hg gofmt;
only the formatting of the day initializers changed.
i'm happy to revert that formatting if you'd prefer.

stop on error in doc/progs/run

R=r
CC=golang-dev
https://golang.org/cl/850041
2010-03-30 10:34:57 -07:00
Andrew Gerrand
a618df0f5b comment typo in crypto/rsa/rsa.go
R=rsc
CC=golang-dev
https://golang.org/cl/823041
2010-03-29 13:13:12 +11:00
Rob Pike
325cf8ef21 delete all uses of panicln by rewriting them using panic or,
in the tests, println+panic.
gofmt some tests too.

R=rsc
CC=golang-dev
https://golang.org/cl/741041
2010-03-24 16:46:53 -07:00
Russ Cox
908efdb5ac crypto/rand: new package
Until proven insufficient, rely on the operating system
to give us good random bytes (/dev/urandom).

R=agl1
CC=golang-dev
https://golang.org/cl/569044
2010-03-16 23:12:20 -07:00
Conrad Meyer
899e2e6e0c sha512: add sha384 (truncated version)
R=rsc
CC=golang-dev
https://golang.org/cl/317041
2010-03-16 13:26:21 -07:00
Raif S. Naffah
96c9603a43 crypto/ripemd160: new package
R=rsc
CC=golang-dev
https://golang.org/cl/224081
2010-03-08 18:12:36 -08:00
Conrad Meyer
bbec504f60 crypto/sha256: add SHA-224
R=agl1, rsc
CC=golang-dev
https://golang.org/cl/253045
2010-03-08 18:12:30 -08:00
Conrad Meyer
5bebadf23f crypto/sha512: new package
R=rsc
CC=golang-dev
https://golang.org/cl/240043
2010-03-08 17:00:04 -08:00
Adam Langley
df53544f4f crypto/rsa: don't use safe primes.
Previously we would require safe primes for our RSA key generation.
Since this took rather a long time, this removes the requirement that
the primes be safe.

OpenSSL doesn't use safe primes for RSA key generation either
(openssl-0.9.8l/crypto/rsa/rsa_gen.c:122)

Fixes #649.

R=rsc
CC=golang-dev
https://golang.org/cl/253041
2010-03-08 09:25:24 -05:00
Robert Griesemer
e8a049b440 gofmt: modified algorithm for alignment of multi-line composite/list entries
- only manual changes are in src/pkg/go/printer/nodes.go
- use a heuristic to determine "outliers" such that not entire composites are
  forced to align with them
- improves several places that were not unligned before due too simple heuristic
- unalignes some cases that contain "outliers"
- gofmt -w src misc

Fixes #644.

R=rsc, r
CC=golang-dev
https://golang.org/cl/241041
2010-03-04 17:37:15 -08:00
Robert Griesemer
f44fa9b4c7 gofmt: experiment: align values in map composites where possible
- gofmt -w src misc
- looking for feedback

R=rsc, r
CC=golang-dev
https://golang.org/cl/223076
2010-03-02 13:46:51 -08:00
Raif S. Naffah
ef531c2b57 crypto/blowfish: new package
R=rsc
CC=golang-dev
https://golang.org/cl/217116
2010-02-26 15:24:46 -08:00
Russ Cox
9750adbbad strings: delete Runes, Bytes
gofmt -w -r 'strings.Bytes(a) -> []byte(a)' src/cmd src/pkg test/bench
gofmt -w -r 'strings.Runes(a) -> []int(a)' src/cmd src/pkg test/bench
delete unused imports

R=r
CC=golang-dev
https://golang.org/cl/224062
2010-02-25 16:01:29 -08:00
Mark Zavislak
6a0af8e118 crypto package documentation fix
Replaces stale references to modes.go.

R=golang-dev, agl, rsc
CC=golang-dev
https://golang.org/cl/218071
2010-02-23 12:01:09 -08:00
Adam Langley
32c3c95339 crypto/x509: support certificate creation.
R=rsc
CC=golang-dev
https://golang.org/cl/212041
2010-02-19 10:55:41 -05:00
Adam Langley
95e08bde44 asn1: Fixes and additions to marshalling
Marshalling:
* Fixes several silly bugs.
* Support the RawContents type.
* Support the RawValue type.
* Recurse into nested interface{}.

Both directions:
* Better handling of SETs. You can now tag an element in a
  structure with "set" to get the correct tag for serialisation.
* For types that aren't in a structure, you can now name them
  with "SET" on the end.
* SETs are no longer implicitly treated as SEQUENCEs.

R=rsc
CC=golang-dev
https://golang.org/cl/201049
2010-02-05 05:42:02 -05:00
Adam Langley
5d827fac39 crypto/tls: typo fix
R=rsc
CC=golang-dev
https://golang.org/cl/201047
2010-02-05 05:39:49 -05:00
Russ Cox
b9f26c32c3 hash: document that Sum does not change hash state
crypto/*: implement and test proper Sum

Fixes #216.

R=agl1
CC=golang-dev
https://golang.org/cl/186210
2010-01-19 10:50:04 -08:00
Robert Griesemer
e01459f567 Apply symmetric changes to sha1 and sha256 as to md4 and md5.
R=agl, agl1
CC=golang-dev
https://golang.org/cl/183083
2009-12-29 11:41:44 -08:00
Robert Griesemer
f0fcb2d59f Symmetric changes to md4.go as for md5.go.
Use uint index variables in some cases instead
of int to enable strength reduction; this makes
it possible for the compiler to reduce % into
masks.

Old code: 6g -S md4.go md4block.go | grep "md4block.go:44"
0471 (md4block.go:44) MOVL    AX,BX
0472 (md4block.go:44) MOVL    AX,BP
0473 (md4block.go:44) MOVL    AX,R8
0474 (md4block.go:44) SARL    $31,R8
0475 (md4block.go:44) SHRL    $30,R8
0476 (md4block.go:44) ADDL    R8,BP
0477 (md4block.go:44) SARL    $2,BP
0478 (md4block.go:44) IMULL   $4,BP
0479 (md4block.go:44) SUBL    BP,BX
0480 (md4block.go:44) MOVLQSX BX,BX
0481 (md4block.go:44) LEAQ    shift1+0(SB),BP
0482 (md4block.go:44) CMPL    BX,8(BP)
0483 (md4block.go:44) JCS     ,485
0484 (md4block.go:44) CALL    ,runtime.throwindex+0(SB)
0485 (md4block.go:44) MOVQ    (BP),BP
0486 (md4block.go:44) MOVL    (BP)(BX*4),DI

New code: 6g -S md4.go md4block.go | grep "md4block.go:44"
0471 (md4block.go:44) MOVL    AX,BX
0472 (md4block.go:44) ANDL    $3,BX
0473 (md4block.go:44) MOVLQZX BX,BX
0474 (md4block.go:44) LEAQ    shift1+0(SB),BP
0475 (md4block.go:44) CMPL    BX,8(BP)
0476 (md4block.go:44) JCS     ,478
0477 (md4block.go:44) CALL    ,runtime.throwindex+0(SB)
0478 (md4block.go:44) MOVQ    (BP),BP
0479 (md4block.go:44) MOVL    (BP)(BX*4),DI

R=agl, agl1
CC=golang-dev
https://golang.org/cl/181086
2009-12-28 17:20:33 -08:00
Robert Griesemer
9d07d37f31 A couple of tighter loops.
(I was looking at this code accidentally because of some gofmt
issues and thought that one could write this more effectively.
You may have deliberately chosen not to use ranges here to make
the index range clearer. Just let me know.)

R=agl, agl1
CC=golang-dev
https://golang.org/cl/181084
2009-12-28 15:48:58 -08:00
Adam Langley
3c6bf09539 crypto/tls: make Listener a pointer.
Listener contains private members and 6g now enforces that private
members cannot be assigned outside of their package.

R=rsc
CC=golang-dev
https://golang.org/cl/183073
2009-12-28 11:40:01 -08:00
Adam Langley
9ebb59634e crypto/tls: extensions and Next Protocol Negotiation
Add support for TLS extensions in general and Next Protocol
Negotiation in particular.

R=rsc
CC=golang-dev
https://golang.org/cl/181045
2009-12-23 11:13:09 -08:00
Robert Griesemer
5a1d3323fe 1) Change default gofmt default settings for
parsing and printing to new syntax.

                  Use -oldparser to parse the old syntax,
                  use -oldprinter to print the old syntax.

               2) Change default gofmt formatting settings
                  to use tabs for indentation only and to use
                  spaces for alignment. This will make the code
                  alignment insensitive to an editor's tabwidth.

                  Use -spaces=false to use tabs for alignment.

               3) Manually changed src/exp/parser/parser_test.go
                  so that it doesn't try to parse the parser's
                  source files using the old syntax (they have
                  new syntax now).

               4) gofmt -w src misc test/bench

	       1st set of files.

R=rsc
CC=agl, golang-dev, iant, ken2, r
https://golang.org/cl/180047
2009-12-15 15:33:31 -08:00
Andy Davis
2a52782f5c crypto/sha256: new package
R=rsc
CC=golang-dev
https://golang.org/cl/176062
2009-12-14 15:09:49 -08:00
Robert Griesemer
295ceb4526 remove uses of string concatenation from src and misc directory
R=rsc
https://golang.org/cl/172041
2009-12-09 16:54:07 -08:00
Adrian O'Grady
6ebfd1eff2 Added XTEA block cipher package to src/pkg/crypto
This is an adaption of the code from http://en.wikipedia.org/wiki/XTEA. The package also implements the block.Cipher
interface so that it can be used with the various block modes.

R=rsc
https://golang.org/cl/157152
2009-12-09 00:06:20 -08:00
Adam Langley
e93132c982 crypto/rsa: fix shadowing error.
Fixes bug 375.

R=rsc
https://golang.org/cl/165045
2009-12-03 19:33:23 -08:00
Christopher Wedgwood
a85c258e67 a[b:len(a)] -> a[b:]
R=r, rsc
CC=agl1
https://golang.org/cl/161070
2009-11-30 12:03:43 -08:00
Sergio Luis O. B. Correia
46892656c7 crypto/md4, exp/draw/x11: fix makefile to build when GOROOT has whitespaces
this is the exact same thing issue #115 is about. fix makefiles to use relative
path to work in the case we have whitespaces as part of GOROOT.

R=rsc
https://golang.org/cl/162055
2009-11-29 18:14:49 -08:00
Robert Griesemer
001a8b11ff Change to container/vector interface:
- removed New(len int) in favor of new(Vector).Resize(len, cap)
- removed Init(len int) in favor of Resize(len, cap)
- runs all.bash

Fixes #294.

R=rsc, r, r1
https://golang.org/cl/157143
2009-11-24 13:43:18 -08:00
Chris Lennert
8ebd7f7167 Provides implementation of MD4 hashing algorithm.
See IETF RFC 1320, http://tools.ietf.org/html/rfc1320.
Fixes #279.

R=rsc
https://golang.org/cl/159051
2009-11-23 17:44:44 -08:00
Sergio Luis O. B. Correia
6fc820729e go: makes it build for the case $GOROOT has whitespaces
the bash scripts and makefiles for building go didn't take into account
the fact $GOROOT / $GOBIN could both be directories containing whitespaces,
and was not possible to build it in such a situation.

this commit adjusts the various makefiles/scripts to make it aware of that
possibility, and now it builds successfully when using a path with whitespaces
as well.

Fixes #115.

R=rsc, dsymonds1
https://golang.org/cl/157067
2009-11-23 17:32:51 -08:00
Adam Langley
6e0842db8b crypto/tls: add initial client implementation.
R=rsc, agl
CC=golang-dev
https://golang.org/cl/157076
2009-11-21 15:53:03 -08:00
Russ Cox
9ac4449cb2 gofmt -r 'α[β:len(α)] -> α[β:]' -w src/cmd src/pkg
R=r, gri
CC=golang-dev
https://golang.org/cl/156115
2009-11-20 11:45:05 -08:00
Adam Langley
eac41e7eba crypto/x509: RawContents -> RawContent
TBR=rsc

R=rsc
https://golang.org/cl/157075
2009-11-18 16:38:30 -08:00
Adam Langley
cc56fc3860 crypto/x509: add certificate support.
R=rsc
CC=golang-dev
https://golang.org/cl/156054
2009-11-18 16:08:24 -08:00
Rob Pike
e70cedfaec remove bytes.Copy
replace all calls with calls to copy
use copy in regexp and bytes.Buffer

R=rsc
CC=golang-dev
https://golang.org/cl/157073
2009-11-18 15:24:24 -08:00
Adam Langley
a8ba40823c crypto/rsa: add PKCS#1 v1.5 signature support.
R=rsc
CC=golang-dev
https://golang.org/cl/156051
2009-11-17 18:21:47 -08:00
Adam Langley
80b7f6a8d4 asn1:
* add Marshal
  * add BitString.RightAlign
  * change to using a *time.Time (from time.Time) since that's what
    the time package uses.
  * return the unparsed data from Unmarshal.

R=rsc
CC=golang-dev
https://golang.org/cl/156047
2009-11-17 18:09:41 -08:00
Adam Langley
391e082ca9 crypto/md5: fix comment typo.
Fixes #210.

R=rsc
CC=golang-dev
https://golang.org/cl/155057
2009-11-15 14:00:46 -08:00
Adam Langley
ad05d29103 crypto/rsa: handle the case of non-coprime blinds.
We are dealing with the multiplicative group ℤ/pqℤ. Multiples of
either p or q are not members of the group since they cannot have an
inverse. (Such numbers are 0 in the subgroup ℤ/pℤ.)

With p and q of typical size (> 512 bits), the probability of a random
blind [1..pq-1] being a multiple of p or q is negligible. However, in
the unit tests, much smaller sizes are used and the event could occur.

This change checks the result of the ext GCD and deals with this case.

It also increases the size of p and q in the unit test as a large
number of the keys selected were p, q = 227,169.

R=rsc
CC=golang-dev
https://golang.org/cl/154141
2009-11-14 20:38:00 -08:00
Russ Cox
933d1850ce typos
Fixes #171.
Fixes #172.

R=agl1
https://golang.org/cl/154136
2009-11-14 10:28:53 -08:00
Adam Langley
1941855730 Reland a112249da741, this time with missing file. 2009-11-11 13:21:37 -08:00
Russ Cox
ed86d0e70a roll back 3985: build is broken
TBR=agl1
CC=golang-dev
https://golang.org/cl/154065
2009-11-11 12:54:52 -08:00
Adam Langley
af1fa43a81 big:
Turn methods that don't store the result in their receiver into
    functions in order to preserve the convention.
  Re-jig Exp and Div by moving their guts into nat.go.
  Add ProbablyPrime to perform Miller-Rabin primality tests.
crypto/rsa: reenable key generation since we now have ProbablyPrime.

R=gri
CC=go-dev
http://codereview.prom.corp.google.com/1024038
2009-11-11 12:34:46 -08:00
Russ Cox
364e564e3d use fully qualified names for hash interfaces
Fixes #38.

R=r1, r
https://golang.org/cl/152072
2009-11-11 12:00:15 -08:00
Robert Griesemer
baba292998 - replaced gofmt expression formatting algorithm with
rsc's algorithm
	- applied gofmt -w misc src
	- partial CL (remaining files in other CLs)

R=rsc, r
http://go/go-review/1026036
2009-11-09 21:13:17 -08:00
Robert Griesemer
40621d5c0d remove semis after statements in one-statement statement lists
R=rsc, r
http://go/go-review/1025029
2009-11-09 12:07:39 -08:00
Russ Cox
830813f019 assorted cleanup
R=r, iant
CC=go-dev
http://go/go-review/1025024
2009-11-08 21:08:27 -08:00