From af92e385667da3fc91ac7f9f0867a56c111110b8 Mon Sep 17 00:00:00 2001
From: Ian Lance Taylor
Date: Wed, 25 Jan 2012 21:54:22 +0000
Subject: [PATCH] libgo: Update to weekly.2012-01-20.
From-SVN: r183540
---
libgo/MERGE | 2 +-
libgo/Makefile.am | 112 +--
libgo/Makefile.in | 296 ++++----
libgo/go/bytes/example_test.go | 4 +
libgo/go/container/heap/heap.go | 8 +-
libgo/go/crypto/ecdsa/ecdsa.go | 29 +-
libgo/go/crypto/ecdsa/ecdsa_test.go | 4 +-
libgo/go/crypto/elliptic/elliptic.go | 107 ++-
libgo/go/crypto/elliptic/elliptic_test.go | 28 +-
libgo/go/crypto/elliptic/p224.go | 685 ++++++++++++++++++
libgo/go/crypto/elliptic/p224_test.go | 47 ++
libgo/go/crypto/hmac/hmac.go | 44 +-
libgo/go/crypto/hmac/hmac_test.go | 312 +++++++-
libgo/go/crypto/md4/md4.go | 5 +
libgo/go/crypto/md5/md5.go | 5 +
libgo/go/crypto/ocsp/ocsp_test.go | 4 +
libgo/go/crypto/openpgp/canonical_text.go | 4 +
.../go/crypto/openpgp/canonical_text_test.go | 4 +
libgo/go/crypto/ripemd160/ripemd160.go | 2 +
libgo/go/crypto/sha1/sha1.go | 5 +
libgo/go/crypto/sha256/sha256.go | 5 +
libgo/go/crypto/sha512/sha512.go | 5 +
libgo/go/crypto/tls/cipher_suites.go | 2 +-
libgo/go/crypto/tls/conn.go | 26 +-
libgo/go/crypto/tls/key_agreement.go | 18 +-
libgo/go/crypto/tls/root_unix.go | 9 +-
libgo/go/crypto/x509/x509.go | 51 +-
libgo/go/{exp => database}/sql/convert.go | 2 +-
.../go/{exp => database}/sql/convert_test.go | 37 +-
.../go/{exp => database}/sql/driver/driver.go | 0
.../go/{exp => database}/sql/driver/types.go | 48 +-
.../sql/driver/types_test.go | 0
libgo/go/{exp => database}/sql/fakedb_test.go | 7 +-
libgo/go/{exp => database}/sql/sql.go | 78 +-
libgo/go/{exp => database}/sql/sql_test.go | 103 ++-
libgo/go/encoding/gob/debug.go | 4 +
libgo/go/encoding/gob/dump.go | 4 +
libgo/go/encoding/json/encode.go | 14 +-
libgo/go/encoding/json/tagkey_test.go | 13 +-
libgo/go/encoding/xml/marshal_test.go | 17 +
libgo/go/encoding/xml/read.go | 4 +
libgo/go/encoding/xml/typeinfo.go | 4 +-
libgo/go/exp/gotype/testdata/test1.go | 4 +
libgo/go/exp/inotify/inotify_linux_test.go | 9 +-
libgo/go/exp/norm/trie_test.go | 4 +
libgo/go/exp/proxy/proxy.go | 12 +-
libgo/go/exp/ssh/client.go | 5 +-
libgo/go/exp/ssh/messages.go | 20 +
libgo/go/exp/ssh/session.go | 8 +-
libgo/go/exp/ssh/tcpip.go | 31 +-
libgo/go/exp/ssh/transport.go | 36 +-
libgo/go/exp/ssh/transport_test.go | 18 +-
libgo/go/exp/types/check_test.go | 18 +-
libgo/go/exp/types/gcimporter.go | 31 +-
.../utf8 => exp/utf8string}/string.go | 26 +-
.../utf8 => exp/utf8string}/string_test.go | 15 +-
libgo/go/fmt/fmt_test.go | 25 +-
libgo/go/go/build/path.go | 4 +-
libgo/go/go/build/pkgtest/sqrt_test.go | 4 +
libgo/go/go/build/pkgtest/xsqrt_test.go | 4 +
libgo/go/go/doc/comment.go | 18 +-
libgo/go/go/doc/doc.go | 6 +-
libgo/go/go/doc/doc_test.go | 198 +++--
libgo/go/go/doc/exports.go | 3 +
libgo/go/go/doc/reader.go | 22 +
libgo/go/go/doc/testdata/a.out | 13 +
libgo/go/go/doc/testdata/a0.go | 8 +
libgo/go/go/doc/testdata/a1.go | 8 +
libgo/go/go/doc/testdata/b.go | 13 +
libgo/go/go/doc/testdata/b.out | 34 +
libgo/go/go/doc/testdata/benchmark.go | 293 ++++++++
libgo/go/go/doc/testdata/example.go | 81 +++
libgo/go/go/doc/testdata/template.txt | 65 ++
libgo/go/go/doc/testdata/testing.go | 404 +++++++++++
libgo/go/go/doc/testdata/testing.out | 156 ++++
libgo/go/go/parser/interface.go | 6 +-
libgo/go/go/scanner/scanner.go | 2 +-
libgo/go/go/token/position.go | 271 +++----
libgo/go/go/token/position_test.go | 9 +-
libgo/go/hash/adler32/adler32.go | 2 +
libgo/go/hash/crc32/crc32.go | 2 +
libgo/go/hash/crc64/crc64.go | 2 +
libgo/go/hash/fnv/fnv.go | 5 +
libgo/go/hash/hash.go | 6 +
libgo/go/html/parse.go | 4 +-
libgo/go/html/parse_test.go | 2 +-
libgo/go/html/template/doc.go | 14 +-
libgo/go/html/template/escape_test.go | 26 +-
libgo/go/image/color/color.go | 63 +-
libgo/go/image/color/ycbcr.go | 12 +-
libgo/go/image/draw/draw.go | 52 +-
libgo/go/image/geom.go | 2 +-
libgo/go/image/image.go | 144 ++--
libgo/go/image/jpeg/reader.go | 15 +-
libgo/go/image/tiff/reader.go | 12 +-
libgo/go/image/ycbcr.go | 105 ++-
libgo/go/image/ycbcr_test.go | 104 +++
libgo/go/io/ioutil/ioutil.go | 2 +-
libgo/go/log/syslog/syslog_test.go | 3 +-
libgo/go/math/rand/rand.go | 4 +-
libgo/go/math/rand/rand_test.go | 10 +-
libgo/go/mime/mediatype.go | 17 +-
libgo/go/mime/mediatype_test.go | 21 +
libgo/go/mime/type.go | 15 +-
libgo/go/net/dnsclient_unix.go | 6 +-
libgo/go/net/doc.go | 59 ++
libgo/go/net/fd.go | 55 +-
libgo/go/net/fd_windows.go | 46 +-
libgo/go/net/http/cgi/host.go | 2 +-
libgo/go/net/http/cgi/host_test.go | 2 +-
libgo/go/net/http/client.go | 19 +-
libgo/go/net/http/client_test.go | 87 +++
libgo/go/net/http/doc.go | 3 +-
libgo/go/net/http/fs_test.go | 12 +-
libgo/go/net/http/httputil/dump.go | 25 +-
libgo/go/net/http/httputil/reverseproxy.go | 5 -
libgo/go/net/http/readrequest_test.go | 30 +-
libgo/go/net/http/request.go | 22 +-
libgo/go/net/http/requestwrite_test.go | 16 +-
libgo/go/net/http/serve_test.go | 22 +-
libgo/go/net/http/server.go | 15 +-
libgo/go/net/http/transport.go | 7 +-
libgo/go/net/ipraw_test.go | 3 +-
libgo/go/net/iprawsock_plan9.go | 33 +-
libgo/go/net/iprawsock_posix.go | 25 +-
libgo/go/net/ipsock_plan9.go | 22 +-
libgo/go/net/ipsock_posix.go | 4 +-
libgo/go/net/lookup_plan9.go | 38 +-
libgo/go/net/lookup_unix.go | 38 +-
libgo/go/net/lookup_windows.go | 25 +-
libgo/go/net/net.go | 57 +-
libgo/go/net/pipe.go | 13 +-
libgo/go/net/sendfile_linux.go | 9 -
libgo/go/net/server_test.go | 9 +-
libgo/go/net/smtp/auth.go | 3 +-
libgo/go/net/sock.go | 14 +-
libgo/go/net/sockopt.go | 15 +-
libgo/go/net/sockopt_bsd.go | 5 +-
libgo/go/net/sockopt_linux.go | 5 +-
libgo/go/net/sockopt_windows.go | 2 +-
libgo/go/net/tcpsock_plan9.go | 16 +
libgo/go/net/tcpsock_posix.go | 26 +-
libgo/go/net/timeout_test.go | 48 +-
libgo/go/net/udpsock_plan9.go | 20 +-
libgo/go/net/udpsock_posix.go | 23 +-
libgo/go/net/unicast_test.go | 30 +-
libgo/go/net/unixsock_plan9.go | 13 +-
libgo/go/net/unixsock_posix.go | 60 +-
libgo/go/net/url/url.go | 365 +++++-----
libgo/go/net/url/url_test.go | 354 ++++-----
libgo/go/old/netchan/common.go | 2 +
libgo/go/old/regexp/regexp.go | 1 +
libgo/go/os/dir.go | 14 +-
libgo/go/os/dir_plan9.go | 31 +-
libgo/go/os/dir_unix.go | 14 +-
libgo/go/os/doc.go | 52 ++
libgo/go/os/error_plan9.go | 4 -
libgo/go/os/error_posix.go | 4 -
libgo/go/os/exec/lp_unix.go | 5 +-
libgo/go/os/exec/lp_windows.go | 5 +
libgo/go/os/exec_plan9.go | 5 +-
libgo/go/os/exec_unix.go | 5 +-
libgo/go/os/exec_windows.go | 5 +-
libgo/go/os/file.go | 4 +-
libgo/go/os/file_posix.go | 24 +-
libgo/go/os/file_unix.go | 21 +-
libgo/go/os/path.go | 2 +-
libgo/go/os/stat_openbsd.go | 3 +
libgo/go/os/sys_bsd.go | 2 +-
libgo/go/os/sys_linux.go | 3 +-
libgo/go/os/sys_plan9.go | 2 +-
libgo/go/os/types.go | 5 +-
libgo/go/patch/textdiff.go | 4 +
libgo/go/path/example_test.go | 65 ++
libgo/go/reflect/all_test.go | 15 +-
libgo/go/reflect/type.go | 2 +-
libgo/go/regexp/all_test.go | 51 +-
libgo/go/regexp/exec.go | 4 +
libgo/go/regexp/regexp.go | 24 +-
libgo/go/regexp/syntax/compile.go | 4 +
libgo/go/regexp/syntax/prog.go | 4 +
libgo/go/regexp/syntax/prog_test.go | 4 +
libgo/go/regexp/syntax/regexp.go | 16 +
libgo/go/runtime/extern.go | 2 +-
libgo/go/runtime/gc_test.go | 4 +
libgo/go/sync/atomic/atomic_test.go | 4 +-
libgo/go/syscall/syscall.go | 8 +
libgo/go/testing/example.go | 7 -
libgo/go/testing/testing.go | 30 +-
libgo/go/text/template/multi_test.go | 19 +-
libgo/go/text/template/parse/node.go | 67 +-
libgo/go/text/template/parse/parse_test.go | 56 +-
libgo/go/text/template/template.go | 2 +-
libgo/go/time/format.go | 4 +
libgo/go/time/time.go | 32 +-
libgo/go/websocket/hixie.go | 8 +-
libgo/go/websocket/hybi.go | 4 +-
libgo/go/websocket/websocket.go | 27 +-
198 files changed, 5123 insertions(+), 1951 deletions(-)
create mode 100644 libgo/go/crypto/elliptic/p224.go
create mode 100644 libgo/go/crypto/elliptic/p224_test.go
rename libgo/go/{exp => database}/sql/convert.go (99%)
rename libgo/go/{exp => database}/sql/convert_test.go (85%)
rename libgo/go/{exp => database}/sql/driver/driver.go (100%)
rename libgo/go/{exp => database}/sql/driver/types.go (82%)
rename libgo/go/{exp => database}/sql/driver/types_test.go (100%)
rename libgo/go/{exp => database}/sql/fakedb_test.go (99%)
rename libgo/go/{exp => database}/sql/sql.go (90%)
rename libgo/go/{exp => database}/sql/sql_test.go (70%)
rename libgo/go/{unicode/utf8 => exp/utf8string}/string.go (88%)
rename libgo/go/{unicode/utf8 => exp/utf8string}/string_test.go (88%)
create mode 100644 libgo/go/go/doc/testdata/a.out
create mode 100644 libgo/go/go/doc/testdata/a0.go
create mode 100644 libgo/go/go/doc/testdata/a1.go
create mode 100644 libgo/go/go/doc/testdata/b.go
create mode 100644 libgo/go/go/doc/testdata/b.out
create mode 100644 libgo/go/go/doc/testdata/benchmark.go
create mode 100644 libgo/go/go/doc/testdata/example.go
create mode 100644 libgo/go/go/doc/testdata/template.txt
create mode 100644 libgo/go/go/doc/testdata/testing.go
create mode 100644 libgo/go/go/doc/testdata/testing.out
create mode 100644 libgo/go/image/ycbcr_test.go
create mode 100644 libgo/go/net/doc.go
create mode 100644 libgo/go/os/doc.go
create mode 100644 libgo/go/path/example_test.go
diff --git a/libgo/MERGE b/libgo/MERGE
index b72962fecbe..4207948a9cb 100644
--- a/libgo/MERGE
+++ b/libgo/MERGE
@@ -1,4 +1,4 @@
-354b17404643
+9f2be4fbbf69
The first line of this file holds the Mercurial revision number of the
last merge done from the master library sources.
diff --git a/libgo/Makefile.am b/libgo/Makefile.am
index 770a849e744..84b70191384 100644
--- a/libgo/Makefile.am
+++ b/libgo/Makefile.am
@@ -197,6 +197,16 @@ toolexeclibgocryptox509dir = $(toolexeclibgocryptodir)/x509
toolexeclibgocryptox509_DATA = \
crypto/x509/pkix.gox
+toolexeclibgodatabasedir = $(toolexeclibgodir)/database
+
+toolexeclibgodatabase_DATA = \
+ database/sql.gox
+
+toolexeclibgodatabasesqldir = $(toolexeclibgodatabasedir)/sql
+
+toolexeclibgodatabasesql_DATA = \
+ database/sql/driver.gox
+
toolexeclibgodebugdir = $(toolexeclibgodir)/debug
toolexeclibgodebug_DATA = \
@@ -237,15 +247,10 @@ toolexeclibgoexp_DATA = \
exp/norm.gox \
exp/proxy.gox \
exp/spdy.gox \
- exp/sql.gox \
exp/ssh.gox \
exp/terminal.gox \
- exp/types.gox
-
-toolexeclibgoexpsqldir = $(toolexeclibgoexpdir)/sql
-
-toolexeclibgoexpsql_DATA = \
- exp/sql/driver.gox
+ exp/types.gox \
+ exp/utf8string.gox
toolexeclibgogodir = $(toolexeclibgodir)/go
@@ -717,6 +722,7 @@ go_net_files = \
go/net/dnsclient_unix.go \
go/net/dnsconfig.go \
go/net/dnsmsg.go \
+ go/net/doc.go \
$(go_net_newpollserver_file) \
go/net/fd.go \
$(go_net_fd_os_file) \
@@ -793,6 +799,7 @@ endif
go_os_files = \
$(go_os_dir_file) \
go/os/dir.go \
+ go/os/doc.go \
go/os/env.go \
go/os/error.go \
go/os/error_posix.go \
@@ -1005,7 +1012,8 @@ go_crypto_dsa_files = \
go_crypto_ecdsa_files = \
go/crypto/ecdsa/ecdsa.go
go_crypto_elliptic_files = \
- go/crypto/elliptic/elliptic.go
+ go/crypto/elliptic/elliptic.go \
+ go/crypto/elliptic/p224.go
go_crypto_hmac_files = \
go/crypto/hmac/hmac.go
go_crypto_md4_files = \
@@ -1094,6 +1102,14 @@ go_crypto_openpgp_s2k_files = \
go_crypto_x509_pkix_files = \
go/crypto/x509/pkix/pkix.go
+go_database_sql_files = \
+ go/database/sql/convert.go \
+ go/database/sql/sql.go
+
+go_database_sql_driver_files = \
+ go/database/sql/driver/driver.go \
+ go/database/sql/driver/types.go
+
go_debug_dwarf_files = \
go/debug/dwarf/buf.go \
go/debug/dwarf/const.go \
@@ -1179,9 +1195,6 @@ go_exp_spdy_files = \
go/exp/spdy/read.go \
go/exp/spdy/types.go \
go/exp/spdy/write.go
-go_exp_sql_files = \
- go/exp/sql/convert.go \
- go/exp/sql/sql.go
go_exp_ssh_files = \
go/exp/ssh/channel.go \
go/exp/ssh/cipher.go \
@@ -1205,10 +1218,8 @@ go_exp_types_files = \
go/exp/types/gcimporter.go \
go/exp/types/types.go \
go/exp/types/universe.go
-
-go_exp_sql_driver_files = \
- go/exp/sql/driver/driver.go \
- go/exp/sql/driver/types.go
+go_exp_utf8string_files = \
+ go/exp/utf8string/string.go
go_go_ast_files = \
go/go/ast/ast.go \
@@ -1467,7 +1478,6 @@ go_text_scanner_files = \
go_unicode_utf16_files = \
go/unicode/utf16/utf16.go
go_unicode_utf8_files = \
- go/unicode/utf8/string.go \
go/unicode/utf8/utf8.go
# Define Syscall and Syscall6.
@@ -1751,6 +1761,8 @@ libgo_go_objs = \
crypto/openpgp/packet.lo \
crypto/openpgp/s2k.lo \
crypto/x509/pkix.lo \
+ database/sql.lo \
+ database/sql/driver.lo \
debug/dwarf.lo \
debug/elf.lo \
debug/gosym.lo \
@@ -1772,11 +1784,10 @@ libgo_go_objs = \
exp/norm.lo \
exp/proxy.lo \
exp/spdy.lo \
- exp/sql.lo \
exp/ssh.lo \
exp/terminal.lo \
exp/types.lo \
- exp/sql/driver.lo \
+ exp/utf8string.lo \
html/template.lo \
go/ast.lo \
go/build.lo \
@@ -2646,6 +2657,26 @@ crypto/x509/pkix/check: $(CHECK_DEPS)
@$(CHECK)
.PHONY: crypto/x509/pkix/check
+@go_include@ database/sql.lo.dep
+database/sql.lo.dep: $(go_database_sql_files)
+ $(BUILDDEPS)
+database/sql.lo: $(go_database_sql_files)
+ $(BUILDPACKAGE)
+database/sql/check: $(CHECK_DEPS)
+ @$(MKDIR_P) database/sql
+ @$(CHECK)
+.PHONY: database/sql/check
+
+@go_include@ database/sql/driver.lo.dep
+database/sql/driver.lo.dep: $(go_database_sql_driver_files)
+ $(BUILDDEPS)
+database/sql/driver.lo: $(go_database_sql_driver_files)
+ $(BUILDPACKAGE)
+database/sql/driver/check: $(CHECK_DEPS)
+ @$(MKDIR_P) database/sql/driver
+ @$(CHECK)
+.PHONY: database/sql/driver/check
+
@go_include@ debug/dwarf.lo.dep
debug/dwarf.lo.dep: $(go_debug_dwarf_files)
$(BUILDDEPS)
@@ -2856,16 +2887,6 @@ exp/spdy/check: $(CHECK_DEPS)
@$(CHECK)
.PHONY: exp/spdy/check
-@go_include@ exp/sql.lo.dep
-exp/sql.lo.dep: $(go_exp_sql_files)
- $(BUILDDEPS)
-exp/sql.lo: $(go_exp_sql_files)
- $(BUILDPACKAGE)
-exp/sql/check: $(CHECK_DEPS)
- @$(MKDIR_P) exp/sql
- @$(CHECK)
-.PHONY: exp/sql/check
-
@go_include@ exp/ssh.lo.dep
exp/ssh.lo.dep: $(go_exp_ssh_files)
$(BUILDDEPS)
@@ -2896,6 +2917,16 @@ exp/types/check: $(CHECK_DEPS)
@$(CHECK)
.PHONY: exp/types/check
+@go_include@ exp/utf8string.lo.dep
+exp/utf8string.lo.dep: $(go_exp_utf8string_files)
+ $(BUILDDEPS)
+exp/utf8string.lo: $(go_exp_utf8string_files)
+ $(BUILDPACKAGE)
+exp/utf8string/check: $(CHECK_DEPS)
+ @$(MKDIR_P) exp/utf8string
+ @$(CHECK)
+.PHONY: exp/utf8string/check
+
@go_include@ exp/inotify.lo.dep
exp/inotify.lo.dep: $(go_exp_inotify_files)
$(BUILDDEPS)
@@ -2906,16 +2937,6 @@ exp/inotify/check: $(CHECK_DEPS)
@$(CHECK)
.PHONY: exp/inotify/check
-@go_include@ exp/sql/driver.lo.dep
-exp/sql/driver.lo.dep: $(go_exp_sql_driver_files)
- $(BUILDDEPS)
-exp/sql/driver.lo: $(go_exp_sql_driver_files)
- $(BUILDPACKAGE)
-exp/sql/driver/check: $(CHECK_DEPS)
- @$(MKDIR_P) exp/sql/driver
- @$(CHECK)
-.PHONY: exp/sql/driver/check
-
@go_include@ html/template.lo.dep
html/template.lo.dep: $(go_html_template_files)
$(BUILDDEPS)
@@ -3670,6 +3691,12 @@ crypto/openpgp/s2k.gox: crypto/openpgp/s2k.lo
crypto/x509/pkix.gox: crypto/x509/pkix.lo
$(BUILDGOX)
+database/sql.gox: database/sql.lo
+ $(BUILDGOX)
+
+database/sql/driver.gox: database/sql/driver.lo
+ $(BUILDGOX)
+
debug/dwarf.gox: debug/dwarf.lo
$(BUILDGOX)
debug/elf.gox: debug/elf.lo
@@ -3716,16 +3743,13 @@ exp/proxy.gox: exp/proxy.lo
$(BUILDGOX)
exp/spdy.gox: exp/spdy.lo
$(BUILDGOX)
-exp/sql.gox: exp/sql.lo
- $(BUILDGOX)
exp/ssh.gox: exp/ssh.lo
$(BUILDGOX)
exp/terminal.gox: exp/terminal.lo
$(BUILDGOX)
exp/types.gox: exp/types.lo
$(BUILDGOX)
-
-exp/sql/driver.gox: exp/sql/driver.lo
+exp/utf8string.gox: exp/utf8string.lo
$(BUILDGOX)
html/template.gox: html/template.lo
@@ -3941,6 +3965,8 @@ TEST_PACKAGES = \
crypto/openpgp/elgamal/check \
crypto/openpgp/packet/check \
crypto/openpgp/s2k/check \
+ database/sql/check \
+ database/sql/driver/check \
debug/dwarf/check \
debug/elf/check \
debug/macho/check \
@@ -3962,9 +3988,9 @@ TEST_PACKAGES = \
exp/norm/check \
exp/proxy/check \
exp/spdy/check \
- exp/sql/check \
exp/ssh/check \
exp/terminal/check \
+ exp/utf8string/check \
html/template/check \
go/ast/check \
$(go_build_check_omitted_since_it_calls_6g) \
diff --git a/libgo/Makefile.in b/libgo/Makefile.in
index b82bf422e55..31c58d912a7 100644
--- a/libgo/Makefile.in
+++ b/libgo/Makefile.in
@@ -99,10 +99,11 @@ am__installdirs = "$(DESTDIR)$(toolexeclibdir)" \
"$(DESTDIR)$(toolexeclibgocryptodir)" \
"$(DESTDIR)$(toolexeclibgocryptoopenpgpdir)" \
"$(DESTDIR)$(toolexeclibgocryptox509dir)" \
+ "$(DESTDIR)$(toolexeclibgodatabasedir)" \
+ "$(DESTDIR)$(toolexeclibgodatabasesqldir)" \
"$(DESTDIR)$(toolexeclibgodebugdir)" \
"$(DESTDIR)$(toolexeclibgoencodingdir)" \
"$(DESTDIR)$(toolexeclibgoexpdir)" \
- "$(DESTDIR)$(toolexeclibgoexpsqldir)" \
"$(DESTDIR)$(toolexeclibgogodir)" \
"$(DESTDIR)$(toolexeclibgohashdir)" \
"$(DESTDIR)$(toolexeclibgohtmldir)" \
@@ -154,33 +155,33 @@ am__DEPENDENCIES_2 = bufio/bufio.lo bytes/bytes.lo bytes/index.lo \
crypto/tls.lo crypto/twofish.lo crypto/x509.lo crypto/xtea.lo \
crypto/openpgp/armor.lo crypto/openpgp/elgamal.lo \
crypto/openpgp/errors.lo crypto/openpgp/packet.lo \
- crypto/openpgp/s2k.lo crypto/x509/pkix.lo debug/dwarf.lo \
- debug/elf.lo debug/gosym.lo debug/macho.lo debug/pe.lo \
- encoding/ascii85.lo encoding/asn1.lo encoding/base32.lo \
- encoding/base64.lo encoding/binary.lo encoding/csv.lo \
- encoding/git85.lo encoding/gob.lo encoding/hex.lo \
- encoding/json.lo encoding/pem.lo encoding/xml.lo exp/ebnf.lo \
- exp/norm.lo exp/proxy.lo exp/spdy.lo exp/sql.lo exp/ssh.lo \
- exp/terminal.lo exp/types.lo exp/sql/driver.lo \
- html/template.lo go/ast.lo go/build.lo go/doc.lo go/parser.lo \
- go/printer.lo go/scanner.lo go/token.lo hash/adler32.lo \
- hash/crc32.lo hash/crc64.lo hash/fnv.lo net/http/cgi.lo \
- net/http/fcgi.lo net/http/httptest.lo net/http/httputil.lo \
- net/http/pprof.lo image/bmp.lo image/color.lo image/draw.lo \
- image/gif.lo image/jpeg.lo image/png.lo image/tiff.lo \
- index/suffixarray.lo io/ioutil.lo log/syslog.lo \
- log/syslog/syslog_c.lo math/big.lo math/cmplx.lo math/rand.lo \
- mime/mime.lo mime/multipart.lo net/dict.lo net/http.lo \
- net/mail.lo net/rpc.lo net/smtp.lo net/textproto.lo net/url.lo \
- old/netchan.lo old/regexp.lo old/template.lo \
- $(am__DEPENDENCIES_1) os/user.lo os/signal.lo path/filepath.lo \
- regexp/syntax.lo net/rpc/jsonrpc.lo runtime/debug.lo \
- runtime/pprof.lo sync/atomic.lo sync/atomic_c.lo \
- syscall/syscall.lo syscall/errno.lo syscall/wait.lo \
- text/scanner.lo text/tabwriter.lo text/template.lo \
- text/template/parse.lo testing/testing.lo testing/iotest.lo \
- testing/quick.lo testing/script.lo unicode/utf16.lo \
- unicode/utf8.lo
+ crypto/openpgp/s2k.lo crypto/x509/pkix.lo database/sql.lo \
+ database/sql/driver.lo debug/dwarf.lo debug/elf.lo \
+ debug/gosym.lo debug/macho.lo debug/pe.lo encoding/ascii85.lo \
+ encoding/asn1.lo encoding/base32.lo encoding/base64.lo \
+ encoding/binary.lo encoding/csv.lo encoding/git85.lo \
+ encoding/gob.lo encoding/hex.lo encoding/json.lo \
+ encoding/pem.lo encoding/xml.lo exp/ebnf.lo exp/norm.lo \
+ exp/proxy.lo exp/spdy.lo exp/ssh.lo exp/terminal.lo \
+ exp/types.lo exp/utf8string.lo html/template.lo go/ast.lo \
+ go/build.lo go/doc.lo go/parser.lo go/printer.lo go/scanner.lo \
+ go/token.lo hash/adler32.lo hash/crc32.lo hash/crc64.lo \
+ hash/fnv.lo net/http/cgi.lo net/http/fcgi.lo \
+ net/http/httptest.lo net/http/httputil.lo net/http/pprof.lo \
+ image/bmp.lo image/color.lo image/draw.lo image/gif.lo \
+ image/jpeg.lo image/png.lo image/tiff.lo index/suffixarray.lo \
+ io/ioutil.lo log/syslog.lo log/syslog/syslog_c.lo math/big.lo \
+ math/cmplx.lo math/rand.lo mime/mime.lo mime/multipart.lo \
+ net/dict.lo net/http.lo net/mail.lo net/rpc.lo net/smtp.lo \
+ net/textproto.lo net/url.lo old/netchan.lo old/regexp.lo \
+ old/template.lo $(am__DEPENDENCIES_1) os/user.lo os/signal.lo \
+ path/filepath.lo regexp/syntax.lo net/rpc/jsonrpc.lo \
+ runtime/debug.lo runtime/pprof.lo sync/atomic.lo \
+ sync/atomic_c.lo syscall/syscall.lo syscall/errno.lo \
+ syscall/wait.lo text/scanner.lo text/tabwriter.lo \
+ text/template.lo text/template/parse.lo testing/testing.lo \
+ testing/iotest.lo testing/quick.lo testing/script.lo \
+ unicode/utf16.lo unicode/utf8.lo
libgo_la_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) \
$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
$(am__DEPENDENCIES_1)
@@ -289,20 +290,20 @@ RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
DATA = $(toolexeclibgo_DATA) $(toolexeclibgoarchive_DATA) \
$(toolexeclibgocompress_DATA) $(toolexeclibgocontainer_DATA) \
$(toolexeclibgocrypto_DATA) $(toolexeclibgocryptoopenpgp_DATA) \
- $(toolexeclibgocryptox509_DATA) $(toolexeclibgodebug_DATA) \
+ $(toolexeclibgocryptox509_DATA) $(toolexeclibgodatabase_DATA) \
+ $(toolexeclibgodatabasesql_DATA) $(toolexeclibgodebug_DATA) \
$(toolexeclibgoencoding_DATA) $(toolexeclibgoexp_DATA) \
- $(toolexeclibgoexpsql_DATA) $(toolexeclibgogo_DATA) \
- $(toolexeclibgohash_DATA) $(toolexeclibgohtml_DATA) \
- $(toolexeclibgoimage_DATA) $(toolexeclibgoindex_DATA) \
- $(toolexeclibgoio_DATA) $(toolexeclibgolog_DATA) \
- $(toolexeclibgomath_DATA) $(toolexeclibgomime_DATA) \
- $(toolexeclibgonet_DATA) $(toolexeclibgonethttp_DATA) \
- $(toolexeclibgonetrpc_DATA) $(toolexeclibgoold_DATA) \
- $(toolexeclibgoos_DATA) $(toolexeclibgopath_DATA) \
- $(toolexeclibgoregexp_DATA) $(toolexeclibgoruntime_DATA) \
- $(toolexeclibgosync_DATA) $(toolexeclibgotesting_DATA) \
- $(toolexeclibgotext_DATA) $(toolexeclibgotexttemplate_DATA) \
- $(toolexeclibgounicode_DATA)
+ $(toolexeclibgogo_DATA) $(toolexeclibgohash_DATA) \
+ $(toolexeclibgohtml_DATA) $(toolexeclibgoimage_DATA) \
+ $(toolexeclibgoindex_DATA) $(toolexeclibgoio_DATA) \
+ $(toolexeclibgolog_DATA) $(toolexeclibgomath_DATA) \
+ $(toolexeclibgomime_DATA) $(toolexeclibgonet_DATA) \
+ $(toolexeclibgonethttp_DATA) $(toolexeclibgonetrpc_DATA) \
+ $(toolexeclibgoold_DATA) $(toolexeclibgoos_DATA) \
+ $(toolexeclibgopath_DATA) $(toolexeclibgoregexp_DATA) \
+ $(toolexeclibgoruntime_DATA) $(toolexeclibgosync_DATA) \
+ $(toolexeclibgotesting_DATA) $(toolexeclibgotext_DATA) \
+ $(toolexeclibgotexttemplate_DATA) $(toolexeclibgounicode_DATA)
RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
distclean-recursive maintainer-clean-recursive
AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \
@@ -661,6 +662,14 @@ toolexeclibgocryptox509dir = $(toolexeclibgocryptodir)/x509
toolexeclibgocryptox509_DATA = \
crypto/x509/pkix.gox
+toolexeclibgodatabasedir = $(toolexeclibgodir)/database
+toolexeclibgodatabase_DATA = \
+ database/sql.gox
+
+toolexeclibgodatabasesqldir = $(toolexeclibgodatabasedir)/sql
+toolexeclibgodatabasesql_DATA = \
+ database/sql/driver.gox
+
toolexeclibgodebugdir = $(toolexeclibgodir)/debug
toolexeclibgodebug_DATA = \
debug/dwarf.gox \
@@ -695,14 +704,10 @@ toolexeclibgoexp_DATA = \
exp/norm.gox \
exp/proxy.gox \
exp/spdy.gox \
- exp/sql.gox \
exp/ssh.gox \
exp/terminal.gox \
- exp/types.gox
-
-toolexeclibgoexpsqldir = $(toolexeclibgoexpdir)/sql
-toolexeclibgoexpsql_DATA = \
- exp/sql/driver.gox
+ exp/types.gox \
+ exp/utf8string.gox
toolexeclibgogodir = $(toolexeclibgodir)/go
toolexeclibgogo_DATA = \
@@ -1072,6 +1077,7 @@ go_net_files = \
go/net/dnsclient_unix.go \
go/net/dnsconfig.go \
go/net/dnsmsg.go \
+ go/net/doc.go \
$(go_net_newpollserver_file) \
go/net/fd.go \
$(go_net_fd_os_file) \
@@ -1118,6 +1124,7 @@ go_net_files = \
go_os_files = \
$(go_os_dir_file) \
go/os/dir.go \
+ go/os/doc.go \
go/os/env.go \
go/os/error.go \
go/os/error_posix.go \
@@ -1320,7 +1327,8 @@ go_crypto_ecdsa_files = \
go/crypto/ecdsa/ecdsa.go
go_crypto_elliptic_files = \
- go/crypto/elliptic/elliptic.go
+ go/crypto/elliptic/elliptic.go \
+ go/crypto/elliptic/p224.go
go_crypto_hmac_files = \
go/crypto/hmac/hmac.go
@@ -1430,6 +1438,14 @@ go_crypto_openpgp_s2k_files = \
go_crypto_x509_pkix_files = \
go/crypto/x509/pkix/pkix.go
+go_database_sql_files = \
+ go/database/sql/convert.go \
+ go/database/sql/sql.go
+
+go_database_sql_driver_files = \
+ go/database/sql/driver/driver.go \
+ go/database/sql/driver/types.go
+
go_debug_dwarf_files = \
go/debug/dwarf/buf.go \
go/debug/dwarf/const.go \
@@ -1535,10 +1551,6 @@ go_exp_spdy_files = \
go/exp/spdy/types.go \
go/exp/spdy/write.go
-go_exp_sql_files = \
- go/exp/sql/convert.go \
- go/exp/sql/sql.go
-
go_exp_ssh_files = \
go/exp/ssh/channel.go \
go/exp/ssh/cipher.go \
@@ -1565,9 +1577,8 @@ go_exp_types_files = \
go/exp/types/types.go \
go/exp/types/universe.go
-go_exp_sql_driver_files = \
- go/exp/sql/driver/driver.go \
- go/exp/sql/driver/types.go
+go_exp_utf8string_files = \
+ go/exp/utf8string/string.go
go_go_ast_files = \
go/go/ast/ast.go \
@@ -1854,7 +1865,6 @@ go_unicode_utf16_files = \
go/unicode/utf16/utf16.go
go_unicode_utf8_files = \
- go/unicode/utf8/string.go \
go/unicode/utf8/utf8.go
@LIBGO_IS_RTEMS_FALSE@syscall_syscall_file = go/syscall/syscall_unix.go
@@ -2025,6 +2035,8 @@ libgo_go_objs = \
crypto/openpgp/packet.lo \
crypto/openpgp/s2k.lo \
crypto/x509/pkix.lo \
+ database/sql.lo \
+ database/sql/driver.lo \
debug/dwarf.lo \
debug/elf.lo \
debug/gosym.lo \
@@ -2046,11 +2058,10 @@ libgo_go_objs = \
exp/norm.lo \
exp/proxy.lo \
exp/spdy.lo \
- exp/sql.lo \
exp/ssh.lo \
exp/terminal.lo \
exp/types.lo \
- exp/sql/driver.lo \
+ exp/utf8string.lo \
html/template.lo \
go/ast.lo \
go/build.lo \
@@ -2294,6 +2305,8 @@ TEST_PACKAGES = \
crypto/openpgp/elgamal/check \
crypto/openpgp/packet/check \
crypto/openpgp/s2k/check \
+ database/sql/check \
+ database/sql/driver/check \
debug/dwarf/check \
debug/elf/check \
debug/macho/check \
@@ -2315,9 +2328,9 @@ TEST_PACKAGES = \
exp/norm/check \
exp/proxy/check \
exp/spdy/check \
- exp/sql/check \
exp/ssh/check \
exp/terminal/check \
+ exp/utf8string/check \
html/template/check \
go/ast/check \
$(go_build_check_omitted_since_it_calls_6g) \
@@ -3365,6 +3378,46 @@ uninstall-toolexeclibgocryptox509DATA:
test -n "$$files" || exit 0; \
echo " ( cd '$(DESTDIR)$(toolexeclibgocryptox509dir)' && rm -f" $$files ")"; \
cd "$(DESTDIR)$(toolexeclibgocryptox509dir)" && rm -f $$files
+install-toolexeclibgodatabaseDATA: $(toolexeclibgodatabase_DATA)
+ @$(NORMAL_INSTALL)
+ test -z "$(toolexeclibgodatabasedir)" || $(MKDIR_P) "$(DESTDIR)$(toolexeclibgodatabasedir)"
+ @list='$(toolexeclibgodatabase_DATA)'; test -n "$(toolexeclibgodatabasedir)" || list=; \
+ for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ echo "$$d$$p"; \
+ done | $(am__base_list) | \
+ while read files; do \
+ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(toolexeclibgodatabasedir)'"; \
+ $(INSTALL_DATA) $$files "$(DESTDIR)$(toolexeclibgodatabasedir)" || exit $$?; \
+ done
+
+uninstall-toolexeclibgodatabaseDATA:
+ @$(NORMAL_UNINSTALL)
+ @list='$(toolexeclibgodatabase_DATA)'; test -n "$(toolexeclibgodatabasedir)" || list=; \
+ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+ test -n "$$files" || exit 0; \
+ echo " ( cd '$(DESTDIR)$(toolexeclibgodatabasedir)' && rm -f" $$files ")"; \
+ cd "$(DESTDIR)$(toolexeclibgodatabasedir)" && rm -f $$files
+install-toolexeclibgodatabasesqlDATA: $(toolexeclibgodatabasesql_DATA)
+ @$(NORMAL_INSTALL)
+ test -z "$(toolexeclibgodatabasesqldir)" || $(MKDIR_P) "$(DESTDIR)$(toolexeclibgodatabasesqldir)"
+ @list='$(toolexeclibgodatabasesql_DATA)'; test -n "$(toolexeclibgodatabasesqldir)" || list=; \
+ for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ echo "$$d$$p"; \
+ done | $(am__base_list) | \
+ while read files; do \
+ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(toolexeclibgodatabasesqldir)'"; \
+ $(INSTALL_DATA) $$files "$(DESTDIR)$(toolexeclibgodatabasesqldir)" || exit $$?; \
+ done
+
+uninstall-toolexeclibgodatabasesqlDATA:
+ @$(NORMAL_UNINSTALL)
+ @list='$(toolexeclibgodatabasesql_DATA)'; test -n "$(toolexeclibgodatabasesqldir)" || list=; \
+ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+ test -n "$$files" || exit 0; \
+ echo " ( cd '$(DESTDIR)$(toolexeclibgodatabasesqldir)' && rm -f" $$files ")"; \
+ cd "$(DESTDIR)$(toolexeclibgodatabasesqldir)" && rm -f $$files
install-toolexeclibgodebugDATA: $(toolexeclibgodebug_DATA)
@$(NORMAL_INSTALL)
test -z "$(toolexeclibgodebugdir)" || $(MKDIR_P) "$(DESTDIR)$(toolexeclibgodebugdir)"
@@ -3425,26 +3478,6 @@ uninstall-toolexeclibgoexpDATA:
test -n "$$files" || exit 0; \
echo " ( cd '$(DESTDIR)$(toolexeclibgoexpdir)' && rm -f" $$files ")"; \
cd "$(DESTDIR)$(toolexeclibgoexpdir)" && rm -f $$files
-install-toolexeclibgoexpsqlDATA: $(toolexeclibgoexpsql_DATA)
- @$(NORMAL_INSTALL)
- test -z "$(toolexeclibgoexpsqldir)" || $(MKDIR_P) "$(DESTDIR)$(toolexeclibgoexpsqldir)"
- @list='$(toolexeclibgoexpsql_DATA)'; test -n "$(toolexeclibgoexpsqldir)" || list=; \
- for p in $$list; do \
- if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
- echo "$$d$$p"; \
- done | $(am__base_list) | \
- while read files; do \
- echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(toolexeclibgoexpsqldir)'"; \
- $(INSTALL_DATA) $$files "$(DESTDIR)$(toolexeclibgoexpsqldir)" || exit $$?; \
- done
-
-uninstall-toolexeclibgoexpsqlDATA:
- @$(NORMAL_UNINSTALL)
- @list='$(toolexeclibgoexpsql_DATA)'; test -n "$(toolexeclibgoexpsqldir)" || list=; \
- files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
- test -n "$$files" || exit 0; \
- echo " ( cd '$(DESTDIR)$(toolexeclibgoexpsqldir)' && rm -f" $$files ")"; \
- cd "$(DESTDIR)$(toolexeclibgoexpsqldir)" && rm -f $$files
install-toolexeclibgogoDATA: $(toolexeclibgogo_DATA)
@$(NORMAL_INSTALL)
test -z "$(toolexeclibgogodir)" || $(MKDIR_P) "$(DESTDIR)$(toolexeclibgogodir)"
@@ -4202,7 +4235,7 @@ all-am: Makefile $(LIBRARIES) $(LTLIBRARIES) all-multi $(DATA) \
config.h
installdirs: installdirs-recursive
installdirs-am:
- for dir in "$(DESTDIR)$(toolexeclibdir)" "$(DESTDIR)$(toolexeclibdir)" "$(DESTDIR)$(toolexeclibgodir)" "$(DESTDIR)$(toolexeclibgoarchivedir)" "$(DESTDIR)$(toolexeclibgocompressdir)" "$(DESTDIR)$(toolexeclibgocontainerdir)" "$(DESTDIR)$(toolexeclibgocryptodir)" "$(DESTDIR)$(toolexeclibgocryptoopenpgpdir)" "$(DESTDIR)$(toolexeclibgocryptox509dir)" "$(DESTDIR)$(toolexeclibgodebugdir)" "$(DESTDIR)$(toolexeclibgoencodingdir)" "$(DESTDIR)$(toolexeclibgoexpdir)" "$(DESTDIR)$(toolexeclibgoexpsqldir)" "$(DESTDIR)$(toolexeclibgogodir)" "$(DESTDIR)$(toolexeclibgohashdir)" "$(DESTDIR)$(toolexeclibgohtmldir)" "$(DESTDIR)$(toolexeclibgoimagedir)" "$(DESTDIR)$(toolexeclibgoindexdir)" "$(DESTDIR)$(toolexeclibgoiodir)" "$(DESTDIR)$(toolexeclibgologdir)" "$(DESTDIR)$(toolexeclibgomathdir)" "$(DESTDIR)$(toolexeclibgomimedir)" "$(DESTDIR)$(toolexeclibgonetdir)" "$(DESTDIR)$(toolexeclibgonethttpdir)" "$(DESTDIR)$(toolexeclibgonetrpcdir)" "$(DESTDIR)$(toolexeclibgoolddir)" "$(DESTDIR)$(toolexeclibgoosdir)" "$(DESTDIR)$(toolexeclibgopathdir)" "$(DESTDIR)$(toolexeclibgoregexpdir)" "$(DESTDIR)$(toolexeclibgoruntimedir)" "$(DESTDIR)$(toolexeclibgosyncdir)" "$(DESTDIR)$(toolexeclibgotestingdir)" "$(DESTDIR)$(toolexeclibgotextdir)" "$(DESTDIR)$(toolexeclibgotexttemplatedir)" "$(DESTDIR)$(toolexeclibgounicodedir)"; do \
+ for dir in "$(DESTDIR)$(toolexeclibdir)" "$(DESTDIR)$(toolexeclibdir)" "$(DESTDIR)$(toolexeclibgodir)" "$(DESTDIR)$(toolexeclibgoarchivedir)" "$(DESTDIR)$(toolexeclibgocompressdir)" "$(DESTDIR)$(toolexeclibgocontainerdir)" "$(DESTDIR)$(toolexeclibgocryptodir)" "$(DESTDIR)$(toolexeclibgocryptoopenpgpdir)" "$(DESTDIR)$(toolexeclibgocryptox509dir)" "$(DESTDIR)$(toolexeclibgodatabasedir)" "$(DESTDIR)$(toolexeclibgodatabasesqldir)" "$(DESTDIR)$(toolexeclibgodebugdir)" "$(DESTDIR)$(toolexeclibgoencodingdir)" "$(DESTDIR)$(toolexeclibgoexpdir)" "$(DESTDIR)$(toolexeclibgogodir)" "$(DESTDIR)$(toolexeclibgohashdir)" "$(DESTDIR)$(toolexeclibgohtmldir)" "$(DESTDIR)$(toolexeclibgoimagedir)" "$(DESTDIR)$(toolexeclibgoindexdir)" "$(DESTDIR)$(toolexeclibgoiodir)" "$(DESTDIR)$(toolexeclibgologdir)" "$(DESTDIR)$(toolexeclibgomathdir)" "$(DESTDIR)$(toolexeclibgomimedir)" "$(DESTDIR)$(toolexeclibgonetdir)" "$(DESTDIR)$(toolexeclibgonethttpdir)" "$(DESTDIR)$(toolexeclibgonetrpcdir)" "$(DESTDIR)$(toolexeclibgoolddir)" "$(DESTDIR)$(toolexeclibgoosdir)" "$(DESTDIR)$(toolexeclibgopathdir)" "$(DESTDIR)$(toolexeclibgoregexpdir)" "$(DESTDIR)$(toolexeclibgoruntimedir)" "$(DESTDIR)$(toolexeclibgosyncdir)" "$(DESTDIR)$(toolexeclibgotestingdir)" "$(DESTDIR)$(toolexeclibgotextdir)" "$(DESTDIR)$(toolexeclibgotexttemplatedir)" "$(DESTDIR)$(toolexeclibgounicodedir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-recursive
@@ -4270,14 +4303,16 @@ install-exec-am: install-multi install-toolexeclibLIBRARIES \
install-toolexeclibgocryptoDATA \
install-toolexeclibgocryptoopenpgpDATA \
install-toolexeclibgocryptox509DATA \
+ install-toolexeclibgodatabaseDATA \
+ install-toolexeclibgodatabasesqlDATA \
install-toolexeclibgodebugDATA \
install-toolexeclibgoencodingDATA install-toolexeclibgoexpDATA \
- install-toolexeclibgoexpsqlDATA install-toolexeclibgogoDATA \
- install-toolexeclibgohashDATA install-toolexeclibgohtmlDATA \
- install-toolexeclibgoimageDATA install-toolexeclibgoindexDATA \
- install-toolexeclibgoioDATA install-toolexeclibgologDATA \
- install-toolexeclibgomathDATA install-toolexeclibgomimeDATA \
- install-toolexeclibgonetDATA install-toolexeclibgonethttpDATA \
+ install-toolexeclibgogoDATA install-toolexeclibgohashDATA \
+ install-toolexeclibgohtmlDATA install-toolexeclibgoimageDATA \
+ install-toolexeclibgoindexDATA install-toolexeclibgoioDATA \
+ install-toolexeclibgologDATA install-toolexeclibgomathDATA \
+ install-toolexeclibgomimeDATA install-toolexeclibgonetDATA \
+ install-toolexeclibgonethttpDATA \
install-toolexeclibgonetrpcDATA install-toolexeclibgooldDATA \
install-toolexeclibgoosDATA install-toolexeclibgopathDATA \
install-toolexeclibgoregexpDATA \
@@ -4334,11 +4369,12 @@ uninstall-am: uninstall-toolexeclibLIBRARIES \
uninstall-toolexeclibgocryptoDATA \
uninstall-toolexeclibgocryptoopenpgpDATA \
uninstall-toolexeclibgocryptox509DATA \
+ uninstall-toolexeclibgodatabaseDATA \
+ uninstall-toolexeclibgodatabasesqlDATA \
uninstall-toolexeclibgodebugDATA \
uninstall-toolexeclibgoencodingDATA \
- uninstall-toolexeclibgoexpDATA \
- uninstall-toolexeclibgoexpsqlDATA \
- uninstall-toolexeclibgogoDATA uninstall-toolexeclibgohashDATA \
+ uninstall-toolexeclibgoexpDATA uninstall-toolexeclibgogoDATA \
+ uninstall-toolexeclibgohashDATA \
uninstall-toolexeclibgohtmlDATA \
uninstall-toolexeclibgoimageDATA \
uninstall-toolexeclibgoindexDATA uninstall-toolexeclibgoioDATA \
@@ -4382,14 +4418,16 @@ uninstall-am: uninstall-toolexeclibLIBRARIES \
install-toolexeclibgocryptoDATA \
install-toolexeclibgocryptoopenpgpDATA \
install-toolexeclibgocryptox509DATA \
+ install-toolexeclibgodatabaseDATA \
+ install-toolexeclibgodatabasesqlDATA \
install-toolexeclibgodebugDATA \
install-toolexeclibgoencodingDATA install-toolexeclibgoexpDATA \
- install-toolexeclibgoexpsqlDATA install-toolexeclibgogoDATA \
- install-toolexeclibgohashDATA install-toolexeclibgohtmlDATA \
- install-toolexeclibgoimageDATA install-toolexeclibgoindexDATA \
- install-toolexeclibgoioDATA install-toolexeclibgologDATA \
- install-toolexeclibgomathDATA install-toolexeclibgomimeDATA \
- install-toolexeclibgonetDATA install-toolexeclibgonethttpDATA \
+ install-toolexeclibgogoDATA install-toolexeclibgohashDATA \
+ install-toolexeclibgohtmlDATA install-toolexeclibgoimageDATA \
+ install-toolexeclibgoindexDATA install-toolexeclibgoioDATA \
+ install-toolexeclibgologDATA install-toolexeclibgomathDATA \
+ install-toolexeclibgomimeDATA install-toolexeclibgonetDATA \
+ install-toolexeclibgonethttpDATA \
install-toolexeclibgonetrpcDATA install-toolexeclibgooldDATA \
install-toolexeclibgoosDATA install-toolexeclibgopathDATA \
install-toolexeclibgoregexpDATA \
@@ -4410,11 +4448,12 @@ uninstall-am: uninstall-toolexeclibLIBRARIES \
uninstall-toolexeclibgocryptoDATA \
uninstall-toolexeclibgocryptoopenpgpDATA \
uninstall-toolexeclibgocryptox509DATA \
+ uninstall-toolexeclibgodatabaseDATA \
+ uninstall-toolexeclibgodatabasesqlDATA \
uninstall-toolexeclibgodebugDATA \
uninstall-toolexeclibgoencodingDATA \
- uninstall-toolexeclibgoexpDATA \
- uninstall-toolexeclibgoexpsqlDATA \
- uninstall-toolexeclibgogoDATA uninstall-toolexeclibgohashDATA \
+ uninstall-toolexeclibgoexpDATA uninstall-toolexeclibgogoDATA \
+ uninstall-toolexeclibgohashDATA \
uninstall-toolexeclibgohtmlDATA \
uninstall-toolexeclibgoimageDATA \
uninstall-toolexeclibgoindexDATA uninstall-toolexeclibgoioDATA \
@@ -5230,6 +5269,26 @@ crypto/x509/pkix/check: $(CHECK_DEPS)
@$(CHECK)
.PHONY: crypto/x509/pkix/check
+@go_include@ database/sql.lo.dep
+database/sql.lo.dep: $(go_database_sql_files)
+ $(BUILDDEPS)
+database/sql.lo: $(go_database_sql_files)
+ $(BUILDPACKAGE)
+database/sql/check: $(CHECK_DEPS)
+ @$(MKDIR_P) database/sql
+ @$(CHECK)
+.PHONY: database/sql/check
+
+@go_include@ database/sql/driver.lo.dep
+database/sql/driver.lo.dep: $(go_database_sql_driver_files)
+ $(BUILDDEPS)
+database/sql/driver.lo: $(go_database_sql_driver_files)
+ $(BUILDPACKAGE)
+database/sql/driver/check: $(CHECK_DEPS)
+ @$(MKDIR_P) database/sql/driver
+ @$(CHECK)
+.PHONY: database/sql/driver/check
+
@go_include@ debug/dwarf.lo.dep
debug/dwarf.lo.dep: $(go_debug_dwarf_files)
$(BUILDDEPS)
@@ -5440,16 +5499,6 @@ exp/spdy/check: $(CHECK_DEPS)
@$(CHECK)
.PHONY: exp/spdy/check
-@go_include@ exp/sql.lo.dep
-exp/sql.lo.dep: $(go_exp_sql_files)
- $(BUILDDEPS)
-exp/sql.lo: $(go_exp_sql_files)
- $(BUILDPACKAGE)
-exp/sql/check: $(CHECK_DEPS)
- @$(MKDIR_P) exp/sql
- @$(CHECK)
-.PHONY: exp/sql/check
-
@go_include@ exp/ssh.lo.dep
exp/ssh.lo.dep: $(go_exp_ssh_files)
$(BUILDDEPS)
@@ -5480,6 +5529,16 @@ exp/types/check: $(CHECK_DEPS)
@$(CHECK)
.PHONY: exp/types/check
+@go_include@ exp/utf8string.lo.dep
+exp/utf8string.lo.dep: $(go_exp_utf8string_files)
+ $(BUILDDEPS)
+exp/utf8string.lo: $(go_exp_utf8string_files)
+ $(BUILDPACKAGE)
+exp/utf8string/check: $(CHECK_DEPS)
+ @$(MKDIR_P) exp/utf8string
+ @$(CHECK)
+.PHONY: exp/utf8string/check
+
@go_include@ exp/inotify.lo.dep
exp/inotify.lo.dep: $(go_exp_inotify_files)
$(BUILDDEPS)
@@ -5490,16 +5549,6 @@ exp/inotify/check: $(CHECK_DEPS)
@$(CHECK)
.PHONY: exp/inotify/check
-@go_include@ exp/sql/driver.lo.dep
-exp/sql/driver.lo.dep: $(go_exp_sql_driver_files)
- $(BUILDDEPS)
-exp/sql/driver.lo: $(go_exp_sql_driver_files)
- $(BUILDPACKAGE)
-exp/sql/driver/check: $(CHECK_DEPS)
- @$(MKDIR_P) exp/sql/driver
- @$(CHECK)
-.PHONY: exp/sql/driver/check
-
@go_include@ html/template.lo.dep
html/template.lo.dep: $(go_html_template_files)
$(BUILDDEPS)
@@ -6249,6 +6298,12 @@ crypto/openpgp/s2k.gox: crypto/openpgp/s2k.lo
crypto/x509/pkix.gox: crypto/x509/pkix.lo
$(BUILDGOX)
+database/sql.gox: database/sql.lo
+ $(BUILDGOX)
+
+database/sql/driver.gox: database/sql/driver.lo
+ $(BUILDGOX)
+
debug/dwarf.gox: debug/dwarf.lo
$(BUILDGOX)
debug/elf.gox: debug/elf.lo
@@ -6295,16 +6350,13 @@ exp/proxy.gox: exp/proxy.lo
$(BUILDGOX)
exp/spdy.gox: exp/spdy.lo
$(BUILDGOX)
-exp/sql.gox: exp/sql.lo
- $(BUILDGOX)
exp/ssh.gox: exp/ssh.lo
$(BUILDGOX)
exp/terminal.gox: exp/terminal.lo
$(BUILDGOX)
exp/types.gox: exp/types.lo
$(BUILDGOX)
-
-exp/sql/driver.gox: exp/sql/driver.lo
+exp/utf8string.gox: exp/utf8string.lo
$(BUILDGOX)
html/template.gox: html/template.lo
diff --git a/libgo/go/bytes/example_test.go b/libgo/go/bytes/example_test.go
index 02da1ac082b..0234a012a4e 100644
--- a/libgo/go/bytes/example_test.go
+++ b/libgo/go/bytes/example_test.go
@@ -1,3 +1,7 @@
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
package bytes_test
import (
diff --git a/libgo/go/container/heap/heap.go b/libgo/go/container/heap/heap.go
index ca911396754..7af636b4513 100644
--- a/libgo/go/container/heap/heap.go
+++ b/libgo/go/container/heap/heap.go
@@ -3,7 +3,13 @@
// license that can be found in the LICENSE file.
// Package heap provides heap operations for any type that implements
-// heap.Interface.
+// heap.Interface. A heap is a tree with the property that each node is the
+// highest-valued node in its subtree.
+//
+// A heap is a common way to impement a priority queue. To build a priority
+// queue, implement the Heap interface with the (negative) priority as the
+// ordering for the Less method, so Push adds items while Pop removes the
+// highest-priority item from the queue.
//
package heap
diff --git a/libgo/go/crypto/ecdsa/ecdsa.go b/libgo/go/crypto/ecdsa/ecdsa.go
index 2f199990c24..d2f7d8f9bb3 100644
--- a/libgo/go/crypto/ecdsa/ecdsa.go
+++ b/libgo/go/crypto/ecdsa/ecdsa.go
@@ -20,7 +20,7 @@ import (
// PublicKey represents an ECDSA public key.
type PublicKey struct {
- *elliptic.Curve
+ elliptic.Curve
X, Y *big.Int
}
@@ -34,22 +34,23 @@ var one = new(big.Int).SetInt64(1)
// randFieldElement returns a random element of the field underlying the given
// curve using the procedure given in [NSA] A.2.1.
-func randFieldElement(c *elliptic.Curve, rand io.Reader) (k *big.Int, err error) {
- b := make([]byte, c.BitSize/8+8)
+func randFieldElement(c elliptic.Curve, rand io.Reader) (k *big.Int, err error) {
+ params := c.Params()
+ b := make([]byte, params.BitSize/8+8)
_, err = io.ReadFull(rand, b)
if err != nil {
return
}
k = new(big.Int).SetBytes(b)
- n := new(big.Int).Sub(c.N, one)
+ n := new(big.Int).Sub(params.N, one)
k.Mod(k, n)
k.Add(k, one)
return
}
// GenerateKey generates a public&private key pair.
-func GenerateKey(c *elliptic.Curve, rand io.Reader) (priv *PrivateKey, err error) {
+func GenerateKey(c elliptic.Curve, rand io.Reader) (priv *PrivateKey, err error) {
k, err := randFieldElement(c, rand)
if err != nil {
return
@@ -66,8 +67,8 @@ func GenerateKey(c *elliptic.Curve, rand io.Reader) (priv *PrivateKey, err error
// about how this is done. [NSA] suggests that this is done in the obvious
// manner, but [SECG] truncates the hash to the bit-length of the curve order
// first. We follow [SECG] because that's what OpenSSL does.
-func hashToInt(hash []byte, c *elliptic.Curve) *big.Int {
- orderBits := c.N.BitLen()
+func hashToInt(hash []byte, c elliptic.Curve) *big.Int {
+ orderBits := c.Params().N.BitLen()
orderBytes := (orderBits + 7) / 8
if len(hash) > orderBytes {
hash = hash[:orderBytes]
@@ -88,6 +89,7 @@ func hashToInt(hash []byte, c *elliptic.Curve) *big.Int {
func Sign(rand io.Reader, priv *PrivateKey, hash []byte) (r, s *big.Int, err error) {
// See [NSA] 3.4.1
c := priv.PublicKey.Curve
+ N := c.Params().N
var k, kInv *big.Int
for {
@@ -98,9 +100,9 @@ func Sign(rand io.Reader, priv *PrivateKey, hash []byte) (r, s *big.Int, err err
return
}
- kInv = new(big.Int).ModInverse(k, c.N)
+ kInv = new(big.Int).ModInverse(k, N)
r, _ = priv.Curve.ScalarBaseMult(k.Bytes())
- r.Mod(r, priv.Curve.N)
+ r.Mod(r, N)
if r.Sign() != 0 {
break
}
@@ -110,7 +112,7 @@ func Sign(rand io.Reader, priv *PrivateKey, hash []byte) (r, s *big.Int, err err
s = new(big.Int).Mul(priv.D, r)
s.Add(s, e)
s.Mul(s, kInv)
- s.Mod(s, priv.PublicKey.Curve.N)
+ s.Mod(s, N)
if s.Sign() != 0 {
break
}
@@ -124,15 +126,16 @@ func Sign(rand io.Reader, priv *PrivateKey, hash []byte) (r, s *big.Int, err err
func Verify(pub *PublicKey, hash []byte, r, s *big.Int) bool {
// See [NSA] 3.4.2
c := pub.Curve
+ N := c.Params().N
if r.Sign() == 0 || s.Sign() == 0 {
return false
}
- if r.Cmp(c.N) >= 0 || s.Cmp(c.N) >= 0 {
+ if r.Cmp(N) >= 0 || s.Cmp(N) >= 0 {
return false
}
e := hashToInt(hash, c)
- w := new(big.Int).ModInverse(s, c.N)
+ w := new(big.Int).ModInverse(s, N)
u1 := e.Mul(e, w)
u2 := w.Mul(r, w)
@@ -143,6 +146,6 @@ func Verify(pub *PublicKey, hash []byte, r, s *big.Int) bool {
return false
}
x, _ := c.Add(x1, y1, x2, y2)
- x.Mod(x, c.N)
+ x.Mod(x, N)
return x.Cmp(r) == 0
}
diff --git a/libgo/go/crypto/ecdsa/ecdsa_test.go b/libgo/go/crypto/ecdsa/ecdsa_test.go
index 45433e10203..3a2b3efbab3 100644
--- a/libgo/go/crypto/ecdsa/ecdsa_test.go
+++ b/libgo/go/crypto/ecdsa/ecdsa_test.go
@@ -13,7 +13,7 @@ import (
"testing"
)
-func testKeyGeneration(t *testing.T, c *elliptic.Curve, tag string) {
+func testKeyGeneration(t *testing.T, c elliptic.Curve, tag string) {
priv, err := GenerateKey(c, rand.Reader)
if err != nil {
t.Errorf("%s: error: %s", tag, err)
@@ -34,7 +34,7 @@ func TestKeyGeneration(t *testing.T) {
testKeyGeneration(t, elliptic.P521(), "p521")
}
-func testSignAndVerify(t *testing.T, c *elliptic.Curve, tag string) {
+func testSignAndVerify(t *testing.T, c elliptic.Curve, tag string) {
priv, _ := GenerateKey(c, rand.Reader)
hashed := []byte("testing")
diff --git a/libgo/go/crypto/elliptic/elliptic.go b/libgo/go/crypto/elliptic/elliptic.go
index b7232a2fad0..30835a90b91 100644
--- a/libgo/go/crypto/elliptic/elliptic.go
+++ b/libgo/go/crypto/elliptic/elliptic.go
@@ -21,7 +21,25 @@ import (
// A Curve represents a short-form Weierstrass curve with a=-3.
// See http://www.hyperelliptic.org/EFD/g1p/auto-shortw.html
-type Curve struct {
+type Curve interface {
+ // Params returns the parameters for the curve.
+ Params() *CurveParams
+ // IsOnCurve returns true if the given (x,y) lies on the curve.
+ IsOnCurve(x, y *big.Int) bool
+ // Add returns the sum of (x1,y1) and (x2,y2)
+ Add(x1, y1, x2, y2 *big.Int) (x, y *big.Int)
+ // Double returns 2*(x,y)
+ Double(x1, y1 *big.Int) (x, y *big.Int)
+ // ScalarMult returns k*(Bx,By) where k is a number in big-endian form.
+ ScalarMult(x1, y1 *big.Int, scalar []byte) (x, y *big.Int)
+ // ScalarBaseMult returns k*G, where G is the base point of the group and k
+ // is an integer in big-endian form.
+ ScalarBaseMult(scalar []byte) (x, y *big.Int)
+}
+
+// CurveParams contains the parameters of an elliptic curve and also provides
+// a generic, non-constant time implementation of Curve.
+type CurveParams struct {
P *big.Int // the order of the underlying field
N *big.Int // the order of the base point
B *big.Int // the constant of the curve equation
@@ -29,8 +47,11 @@ type Curve struct {
BitSize int // the size of the underlying field
}
-// IsOnCurve returns true if the given (x,y) lies on the curve.
-func (curve *Curve) IsOnCurve(x, y *big.Int) bool {
+func (curve *CurveParams) Params() *CurveParams {
+ return curve
+}
+
+func (curve *CurveParams) IsOnCurve(x, y *big.Int) bool {
// y² = x³ - 3x + b
y2 := new(big.Int).Mul(y, y)
y2.Mod(y2, curve.P)
@@ -50,7 +71,7 @@ func (curve *Curve) IsOnCurve(x, y *big.Int) bool {
// affineFromJacobian reverses the Jacobian transform. See the comment at the
// top of the file.
-func (curve *Curve) affineFromJacobian(x, y, z *big.Int) (xOut, yOut *big.Int) {
+func (curve *CurveParams) affineFromJacobian(x, y, z *big.Int) (xOut, yOut *big.Int) {
zinv := new(big.Int).ModInverse(z, curve.P)
zinvsq := new(big.Int).Mul(zinv, zinv)
@@ -62,15 +83,14 @@ func (curve *Curve) affineFromJacobian(x, y, z *big.Int) (xOut, yOut *big.Int) {
return
}
-// Add returns the sum of (x1,y1) and (x2,y2)
-func (curve *Curve) Add(x1, y1, x2, y2 *big.Int) (*big.Int, *big.Int) {
+func (curve *CurveParams) Add(x1, y1, x2, y2 *big.Int) (*big.Int, *big.Int) {
z := new(big.Int).SetInt64(1)
return curve.affineFromJacobian(curve.addJacobian(x1, y1, z, x2, y2, z))
}
// addJacobian takes two points in Jacobian coordinates, (x1, y1, z1) and
// (x2, y2, z2) and returns their sum, also in Jacobian form.
-func (curve *Curve) addJacobian(x1, y1, z1, x2, y2, z2 *big.Int) (*big.Int, *big.Int, *big.Int) {
+func (curve *CurveParams) addJacobian(x1, y1, z1, x2, y2, z2 *big.Int) (*big.Int, *big.Int, *big.Int) {
// See http://hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html#addition-add-2007-bl
z1z1 := new(big.Int).Mul(z1, z1)
z1z1.Mod(z1z1, curve.P)
@@ -133,15 +153,14 @@ func (curve *Curve) addJacobian(x1, y1, z1, x2, y2, z2 *big.Int) (*big.Int, *big
return x3, y3, z3
}
-// Double returns 2*(x,y)
-func (curve *Curve) Double(x1, y1 *big.Int) (*big.Int, *big.Int) {
+func (curve *CurveParams) Double(x1, y1 *big.Int) (*big.Int, *big.Int) {
z1 := new(big.Int).SetInt64(1)
return curve.affineFromJacobian(curve.doubleJacobian(x1, y1, z1))
}
// doubleJacobian takes a point in Jacobian coordinates, (x, y, z), and
// returns its double, also in Jacobian form.
-func (curve *Curve) doubleJacobian(x, y, z *big.Int) (*big.Int, *big.Int, *big.Int) {
+func (curve *CurveParams) doubleJacobian(x, y, z *big.Int) (*big.Int, *big.Int, *big.Int) {
// See http://hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html#doubling-dbl-2001-b
delta := new(big.Int).Mul(z, z)
delta.Mod(delta, curve.P)
@@ -199,8 +218,7 @@ func (curve *Curve) doubleJacobian(x, y, z *big.Int) (*big.Int, *big.Int, *big.I
return x3, y3, z3
}
-// ScalarMult returns k*(Bx,By) where k is a number in big-endian form.
-func (curve *Curve) ScalarMult(Bx, By *big.Int, k []byte) (*big.Int, *big.Int) {
+func (curve *CurveParams) ScalarMult(Bx, By *big.Int, k []byte) (*big.Int, *big.Int) {
// We have a slight problem in that the identity of the group (the
// point at infinity) cannot be represented in (x, y) form on a finite
// machine. Thus the standard add/double algorithm has to be tweaked
@@ -238,18 +256,17 @@ func (curve *Curve) ScalarMult(Bx, By *big.Int, k []byte) (*big.Int, *big.Int) {
return curve.affineFromJacobian(x, y, z)
}
-// ScalarBaseMult returns k*G, where G is the base point of the group and k is
-// an integer in big-endian form.
-func (curve *Curve) ScalarBaseMult(k []byte) (*big.Int, *big.Int) {
+func (curve *CurveParams) ScalarBaseMult(k []byte) (*big.Int, *big.Int) {
return curve.ScalarMult(curve.Gx, curve.Gy, k)
}
var mask = []byte{0xff, 0x1, 0x3, 0x7, 0xf, 0x1f, 0x3f, 0x7f}
-// GenerateKey returns a public/private key pair. The private key is generated
-// using the given reader, which must return random data.
-func (curve *Curve) GenerateKey(rand io.Reader) (priv []byte, x, y *big.Int, err error) {
- byteLen := (curve.BitSize + 7) >> 3
+// GenerateKey returns a public/private key pair. The private key is
+// generated using the given reader, which must return random data.
+func GenerateKey(curve Curve, rand io.Reader) (priv []byte, x, y *big.Int, err error) {
+ bitSize := curve.Params().BitSize
+ byteLen := (bitSize + 7) >> 3
priv = make([]byte, byteLen)
for x == nil {
@@ -259,7 +276,7 @@ func (curve *Curve) GenerateKey(rand io.Reader) (priv []byte, x, y *big.Int, err
}
// We have to mask off any excess bits in the case that the size of the
// underlying field is not a whole number of bytes.
- priv[0] &= mask[curve.BitSize%8]
+ priv[0] &= mask[bitSize%8]
// This is because, in tests, rand will return all zeros and we don't
// want to get the point at infinity and loop forever.
priv[1] ^= 0x42
@@ -268,10 +285,9 @@ func (curve *Curve) GenerateKey(rand io.Reader) (priv []byte, x, y *big.Int, err
return
}
-// Marshal converts a point into the form specified in section 4.3.6 of ANSI
-// X9.62.
-func (curve *Curve) Marshal(x, y *big.Int) []byte {
- byteLen := (curve.BitSize + 7) >> 3
+// Marshal converts a point into the form specified in section 4.3.6 of ANSI X9.62.
+func Marshal(curve Curve, x, y *big.Int) []byte {
+ byteLen := (curve.Params().BitSize + 7) >> 3
ret := make([]byte, 1+2*byteLen)
ret[0] = 4 // uncompressed point
@@ -283,10 +299,9 @@ func (curve *Curve) Marshal(x, y *big.Int) []byte {
return ret
}
-// Unmarshal converts a point, serialized by Marshal, into an x, y pair. On
-// error, x = nil.
-func (curve *Curve) Unmarshal(data []byte) (x, y *big.Int) {
- byteLen := (curve.BitSize + 7) >> 3
+// Unmarshal converts a point, serialized by Marshal, into an x, y pair. On error, x = nil.
+func Unmarshal(curve Curve, data []byte) (x, y *big.Int) {
+ byteLen := (curve.Params().BitSize + 7) >> 3
if len(data) != 1+2*byteLen {
return
}
@@ -299,10 +314,9 @@ func (curve *Curve) Unmarshal(data []byte) (x, y *big.Int) {
}
var initonce sync.Once
-var p224 *Curve
-var p256 *Curve
-var p384 *Curve
-var p521 *Curve
+var p256 *CurveParams
+var p384 *CurveParams
+var p521 *CurveParams
func initAll() {
initP224()
@@ -311,20 +325,9 @@ func initAll() {
initP521()
}
-func initP224() {
- // See FIPS 186-3, section D.2.2
- p224 = new(Curve)
- p224.P, _ = new(big.Int).SetString("26959946667150639794667015087019630673557916260026308143510066298881", 10)
- p224.N, _ = new(big.Int).SetString("26959946667150639794667015087019625940457807714424391721682722368061", 10)
- p224.B, _ = new(big.Int).SetString("b4050a850c04b3abf54132565044b0b7d7bfd8ba270b39432355ffb4", 16)
- p224.Gx, _ = new(big.Int).SetString("b70e0cbd6bb4bf7f321390b94a03c1d356c21122343280d6115c1d21", 16)
- p224.Gy, _ = new(big.Int).SetString("bd376388b5f723fb4c22dfe6cd4375a05a07476444d5819985007e34", 16)
- p224.BitSize = 224
-}
-
func initP256() {
// See FIPS 186-3, section D.2.3
- p256 = new(Curve)
+ p256 = new(CurveParams)
p256.P, _ = new(big.Int).SetString("115792089210356248762697446949407573530086143415290314195533631308867097853951", 10)
p256.N, _ = new(big.Int).SetString("115792089210356248762697446949407573529996955224135760342422259061068512044369", 10)
p256.B, _ = new(big.Int).SetString("5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b", 16)
@@ -335,7 +338,7 @@ func initP256() {
func initP384() {
// See FIPS 186-3, section D.2.4
- p384 = new(Curve)
+ p384 = new(CurveParams)
p384.P, _ = new(big.Int).SetString("39402006196394479212279040100143613805079739270465446667948293404245721771496870329047266088258938001861606973112319", 10)
p384.N, _ = new(big.Int).SetString("39402006196394479212279040100143613805079739270465446667946905279627659399113263569398956308152294913554433653942643", 10)
p384.B, _ = new(big.Int).SetString("b3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef", 16)
@@ -346,7 +349,7 @@ func initP384() {
func initP521() {
// See FIPS 186-3, section D.2.5
- p521 = new(Curve)
+ p521 = new(CurveParams)
p521.P, _ = new(big.Int).SetString("6864797660130609714981900799081393217269435300143305409394463459185543183397656052122559640661454554977296311391480858037121987999716643812574028291115057151", 10)
p521.N, _ = new(big.Int).SetString("6864797660130609714981900799081393217269435300143305409394463459185543183397655394245057746333217197532963996371363321113864768612440380340372808892707005449", 10)
p521.B, _ = new(big.Int).SetString("051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00", 16)
@@ -355,26 +358,20 @@ func initP521() {
p521.BitSize = 521
}
-// P224 returns a Curve which implements P-224 (see FIPS 186-3, section D.2.2)
-func P224() *Curve {
- initonce.Do(initAll)
- return p224
-}
-
// P256 returns a Curve which implements P-256 (see FIPS 186-3, section D.2.3)
-func P256() *Curve {
+func P256() Curve {
initonce.Do(initAll)
return p256
}
// P384 returns a Curve which implements P-384 (see FIPS 186-3, section D.2.4)
-func P384() *Curve {
+func P384() Curve {
initonce.Do(initAll)
return p384
}
// P256 returns a Curve which implements P-521 (see FIPS 186-3, section D.2.5)
-func P521() *Curve {
+func P521() Curve {
initonce.Do(initAll)
return p521
}
diff --git a/libgo/go/crypto/elliptic/elliptic_test.go b/libgo/go/crypto/elliptic/elliptic_test.go
index a68a3807dfd..c23af754f78 100644
--- a/libgo/go/crypto/elliptic/elliptic_test.go
+++ b/libgo/go/crypto/elliptic/elliptic_test.go
@@ -13,7 +13,7 @@ import (
func TestOnCurve(t *testing.T) {
p224 := P224()
- if !p224.IsOnCurve(p224.Gx, p224.Gy) {
+ if !p224.IsOnCurve(p224.Params().Gx, p224.Params().Gy) {
t.Errorf("FAIL")
}
}
@@ -295,7 +295,25 @@ func TestBaseMult(t *testing.T) {
}
x, y := p224.ScalarBaseMult(k.Bytes())
if fmt.Sprintf("%x", x) != e.x || fmt.Sprintf("%x", y) != e.y {
- t.Errorf("%d: bad output for k=%s: got (%x, %s), want (%x, %s)", i, e.k, x, y, e.x, e.y)
+ t.Errorf("%d: bad output for k=%s: got (%x, %x), want (%s, %s)", i, e.k, x, y, e.x, e.y)
+ }
+ if testing.Short() && i > 5 {
+ break
+ }
+ }
+}
+
+func TestGenericBaseMult(t *testing.T) {
+ // We use the P224 CurveParams directly in order to test the generic implementation.
+ p224 := P224().Params()
+ for i, e := range p224BaseMultTests {
+ k, ok := new(big.Int).SetString(e.k, 10)
+ if !ok {
+ t.Errorf("%d: bad value for k: %s", i, e.k)
+ }
+ x, y := p224.ScalarBaseMult(k.Bytes())
+ if fmt.Sprintf("%x", x) != e.x || fmt.Sprintf("%x", y) != e.y {
+ t.Errorf("%d: bad output for k=%s: got (%x, %x), want (%s, %s)", i, e.k, x, y, e.x, e.y)
}
if testing.Short() && i > 5 {
break
@@ -316,13 +334,13 @@ func BenchmarkBaseMult(b *testing.B) {
func TestMarshal(t *testing.T) {
p224 := P224()
- _, x, y, err := p224.GenerateKey(rand.Reader)
+ _, x, y, err := GenerateKey(p224, rand.Reader)
if err != nil {
t.Error(err)
return
}
- serialized := p224.Marshal(x, y)
- xx, yy := p224.Unmarshal(serialized)
+ serialized := Marshal(p224, x, y)
+ xx, yy := Unmarshal(p224, serialized)
if xx == nil {
t.Error("failed to unmarshal")
return
diff --git a/libgo/go/crypto/elliptic/p224.go b/libgo/go/crypto/elliptic/p224.go
new file mode 100644
index 00000000000..08db5bcc679
--- /dev/null
+++ b/libgo/go/crypto/elliptic/p224.go
@@ -0,0 +1,685 @@
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package elliptic
+
+// This is a constant-time, 32-bit implementation of P224. See FIPS 186-3,
+// section D.2.2.
+//
+// See http://www.imperialviolet.org/2010/12/04/ecc.html ([1]) for background.
+
+import (
+ "math/big"
+)
+
+var p224 p224Curve
+
+type p224Curve struct {
+ *CurveParams
+ gx, gy, b p224FieldElement
+}
+
+func initP224() {
+ // See FIPS 186-3, section D.2.2
+ p224.CurveParams = new(CurveParams)
+ p224.P, _ = new(big.Int).SetString("26959946667150639794667015087019630673557916260026308143510066298881", 10)
+ p224.N, _ = new(big.Int).SetString("26959946667150639794667015087019625940457807714424391721682722368061", 10)
+ p224.B, _ = new(big.Int).SetString("b4050a850c04b3abf54132565044b0b7d7bfd8ba270b39432355ffb4", 16)
+ p224.Gx, _ = new(big.Int).SetString("b70e0cbd6bb4bf7f321390b94a03c1d356c21122343280d6115c1d21", 16)
+ p224.Gy, _ = new(big.Int).SetString("bd376388b5f723fb4c22dfe6cd4375a05a07476444d5819985007e34", 16)
+ p224.BitSize = 224
+
+ p224FromBig(&p224.gx, p224.Gx)
+ p224FromBig(&p224.gy, p224.Gy)
+ p224FromBig(&p224.b, p224.B)
+}
+
+// P224 returns a Curve which implements P-224 (see FIPS 186-3, section D.2.2)
+func P224() Curve {
+ initonce.Do(initAll)
+ return p224
+}
+
+func (curve p224Curve) Params() *CurveParams {
+ return curve.CurveParams
+}
+
+func (curve p224Curve) IsOnCurve(bigX, bigY *big.Int) bool {
+ var x, y p224FieldElement
+ p224FromBig(&x, bigX)
+ p224FromBig(&y, bigY)
+
+ // y² = x³ - 3x + b
+ var tmp p224LargeFieldElement
+ var x3 p224FieldElement
+ p224Square(&x3, &x, &tmp)
+ p224Mul(&x3, &x3, &x, &tmp)
+
+ for i := 0; i < 8; i++ {
+ x[i] *= 3
+ }
+ p224Sub(&x3, &x3, &x)
+ p224Reduce(&x3)
+ p224Add(&x3, &x3, &curve.b)
+ p224Contract(&x3, &x3)
+
+ p224Square(&y, &y, &tmp)
+ p224Contract(&y, &y)
+
+ for i := 0; i < 8; i++ {
+ if y[i] != x3[i] {
+ return false
+ }
+ }
+ return true
+}
+
+func (p224Curve) Add(bigX1, bigY1, bigX2, bigY2 *big.Int) (x, y *big.Int) {
+ var x1, y1, z1, x2, y2, z2, x3, y3, z3 p224FieldElement
+
+ p224FromBig(&x1, bigX1)
+ p224FromBig(&y1, bigY1)
+ z1[0] = 1
+ p224FromBig(&x2, bigX2)
+ p224FromBig(&y2, bigY2)
+ z2[0] = 1
+
+ p224AddJacobian(&x3, &y3, &z3, &x1, &y1, &z1, &x2, &y2, &z2)
+ return p224ToAffine(&x3, &y3, &z3)
+}
+
+func (p224Curve) Double(bigX1, bigY1 *big.Int) (x, y *big.Int) {
+ var x1, y1, z1, x2, y2, z2 p224FieldElement
+
+ p224FromBig(&x1, bigX1)
+ p224FromBig(&y1, bigY1)
+ z1[0] = 1
+
+ p224DoubleJacobian(&x2, &y2, &z2, &x1, &y1, &z1)
+ return p224ToAffine(&x2, &y2, &z2)
+}
+
+func (p224Curve) ScalarMult(bigX1, bigY1 *big.Int, scalar []byte) (x, y *big.Int) {
+ var x1, y1, z1, x2, y2, z2 p224FieldElement
+
+ p224FromBig(&x1, bigX1)
+ p224FromBig(&y1, bigY1)
+ z1[0] = 1
+
+ p224ScalarMult(&x2, &y2, &z2, &x1, &y1, &z1, scalar)
+ return p224ToAffine(&x2, &y2, &z2)
+}
+
+func (curve p224Curve) ScalarBaseMult(scalar []byte) (x, y *big.Int) {
+ var z1, x2, y2, z2 p224FieldElement
+
+ z1[0] = 1
+ p224ScalarMult(&x2, &y2, &z2, &curve.gx, &curve.gy, &z1, scalar)
+ return p224ToAffine(&x2, &y2, &z2)
+}
+
+// Field element functions.
+//
+// The field that we're dealing with is ℤ/pℤ where p = 2**224 - 2**96 + 1.
+//
+// Field elements are represented by a FieldElement, which is a typedef to an
+// array of 8 uint32's. The value of a FieldElement, a, is:
+// a[0] + 2**28·a[1] + 2**56·a[1] + ... + 2**196·a[7]
+//
+// Using 28-bit limbs means that there's only 4 bits of headroom, which is less
+// than we would really like. But it has the useful feature that we hit 2**224
+// exactly, making the reflections during a reduce much nicer.
+type p224FieldElement [8]uint32
+
+// p224Add computes *out = a+b
+//
+// a[i] + b[i] < 2**32
+func p224Add(out, a, b *p224FieldElement) {
+ for i := 0; i < 8; i++ {
+ out[i] = a[i] + b[i]
+ }
+}
+
+const two31p3 = 1<<31 + 1<<3
+const two31m3 = 1<<31 - 1<<3
+const two31m15m3 = 1<<31 - 1<<15 - 1<<3
+
+// p224ZeroModP31 is 0 mod p where bit 31 is set in all limbs so that we can
+// subtract smaller amounts without underflow. See the section "Subtraction" in
+// [1] for reasoning.
+var p224ZeroModP31 = []uint32{two31p3, two31m3, two31m3, two31m15m3, two31m3, two31m3, two31m3, two31m3}
+
+// p224Sub computes *out = a-b
+//
+// a[i], b[i] < 2**30
+// out[i] < 2**32
+func p224Sub(out, a, b *p224FieldElement) {
+ for i := 0; i < 8; i++ {
+ out[i] = a[i] + p224ZeroModP31[i] - b[i]
+ }
+}
+
+// LargeFieldElement also represents an element of the field. The limbs are
+// still spaced 28-bits apart and in little-endian order. So the limbs are at
+// 0, 28, 56, ..., 392 bits, each 64-bits wide.
+type p224LargeFieldElement [15]uint64
+
+const two63p35 = 1<<63 + 1<<35
+const two63m35 = 1<<63 - 1<<35
+const two63m35m19 = 1<<63 - 1<<35 - 1<<19
+
+// p224ZeroModP63 is 0 mod p where bit 63 is set in all limbs. See the section
+// "Subtraction" in [1] for why.
+var p224ZeroModP63 = [8]uint64{two63p35, two63m35, two63m35, two63m35, two63m35m19, two63m35, two63m35, two63m35}
+
+const bottom12Bits = 0xfff
+const bottom28Bits = 0xfffffff
+
+// p224Mul computes *out = a*b
+//
+// a[i] < 2**29, b[i] < 2**30 (or vice versa)
+// out[i] < 2**29
+func p224Mul(out, a, b *p224FieldElement, tmp *p224LargeFieldElement) {
+ for i := 0; i < 15; i++ {
+ tmp[i] = 0
+ }
+
+ for i := 0; i < 8; i++ {
+ for j := 0; j < 8; j++ {
+ tmp[i+j] += uint64(a[i]) * uint64(b[j])
+ }
+ }
+
+ p224ReduceLarge(out, tmp)
+}
+
+// Square computes *out = a*a
+//
+// a[i] < 2**29
+// out[i] < 2**29
+func p224Square(out, a *p224FieldElement, tmp *p224LargeFieldElement) {
+ for i := 0; i < 15; i++ {
+ tmp[i] = 0
+ }
+
+ for i := 0; i < 8; i++ {
+ for j := 0; j <= i; j++ {
+ r := uint64(a[i]) * uint64(a[j])
+ if i == j {
+ tmp[i+j] += r
+ } else {
+ tmp[i+j] += r << 1
+ }
+ }
+ }
+
+ p224ReduceLarge(out, tmp)
+}
+
+// ReduceLarge converts a p224LargeFieldElement to a p224FieldElement.
+//
+// in[i] < 2**62
+func p224ReduceLarge(out *p224FieldElement, in *p224LargeFieldElement) {
+ for i := 0; i < 8; i++ {
+ in[i] += p224ZeroModP63[i]
+ }
+
+ // Elimintate the coefficients at 2**224 and greater.
+ for i := 14; i >= 8; i-- {
+ in[i-8] -= in[i]
+ in[i-5] += (in[i] & 0xffff) << 12
+ in[i-4] += in[i] >> 16
+ }
+ in[8] = 0
+ // in[0..8] < 2**64
+
+ // As the values become small enough, we start to store them in |out|
+ // and use 32-bit operations.
+ for i := 1; i < 8; i++ {
+ in[i+1] += in[i] >> 28
+ out[i] = uint32(in[i] & bottom28Bits)
+ }
+ in[0] -= in[8]
+ out[3] += uint32(in[8]&0xffff) << 12
+ out[4] += uint32(in[8] >> 16)
+ // in[0] < 2**64
+ // out[3] < 2**29
+ // out[4] < 2**29
+ // out[1,2,5..7] < 2**28
+
+ out[0] = uint32(in[0] & bottom28Bits)
+ out[1] += uint32((in[0] >> 28) & bottom28Bits)
+ out[2] += uint32(in[0] >> 56)
+ // out[0] < 2**28
+ // out[1..4] < 2**29
+ // out[5..7] < 2**28
+}
+
+// Reduce reduces the coefficients of a to smaller bounds.
+//
+// On entry: a[i] < 2**31 + 2**30
+// On exit: a[i] < 2**29
+func p224Reduce(a *p224FieldElement) {
+ for i := 0; i < 7; i++ {
+ a[i+1] += a[i] >> 28
+ a[i] &= bottom28Bits
+ }
+ top := a[7] >> 28
+ a[7] &= bottom28Bits
+
+ // top < 2**4
+ mask := top
+ mask |= mask >> 2
+ mask |= mask >> 1
+ mask <<= 31
+ mask = uint32(int32(mask) >> 31)
+ // Mask is all ones if top != 0, all zero otherwise
+
+ a[0] -= top
+ a[3] += top << 12
+
+ // We may have just made a[0] negative but, if we did, then we must
+ // have added something to a[3], this it's > 2**12. Therefore we can
+ // carry down to a[0].
+ a[3] -= 1 & mask
+ a[2] += mask & (1<<28 - 1)
+ a[1] += mask & (1<<28 - 1)
+ a[0] += mask & (1 << 28)
+}
+
+// p224Invert calcuates *out = in**-1 by computing in**(2**224 - 2**96 - 1),
+// i.e. Fermat's little theorem.
+func p224Invert(out, in *p224FieldElement) {
+ var f1, f2, f3, f4 p224FieldElement
+ var c p224LargeFieldElement
+
+ p224Square(&f1, in, &c) // 2
+ p224Mul(&f1, &f1, in, &c) // 2**2 - 1
+ p224Square(&f1, &f1, &c) // 2**3 - 2
+ p224Mul(&f1, &f1, in, &c) // 2**3 - 1
+ p224Square(&f2, &f1, &c) // 2**4 - 2
+ p224Square(&f2, &f2, &c) // 2**5 - 4
+ p224Square(&f2, &f2, &c) // 2**6 - 8
+ p224Mul(&f1, &f1, &f2, &c) // 2**6 - 1
+ p224Square(&f2, &f1, &c) // 2**7 - 2
+ for i := 0; i < 5; i++ { // 2**12 - 2**6
+ p224Square(&f2, &f2, &c)
+ }
+ p224Mul(&f2, &f2, &f1, &c) // 2**12 - 1
+ p224Square(&f3, &f2, &c) // 2**13 - 2
+ for i := 0; i < 11; i++ { // 2**24 - 2**12
+ p224Square(&f3, &f3, &c)
+ }
+ p224Mul(&f2, &f3, &f2, &c) // 2**24 - 1
+ p224Square(&f3, &f2, &c) // 2**25 - 2
+ for i := 0; i < 23; i++ { // 2**48 - 2**24
+ p224Square(&f3, &f3, &c)
+ }
+ p224Mul(&f3, &f3, &f2, &c) // 2**48 - 1
+ p224Square(&f4, &f3, &c) // 2**49 - 2
+ for i := 0; i < 47; i++ { // 2**96 - 2**48
+ p224Square(&f4, &f4, &c)
+ }
+ p224Mul(&f3, &f3, &f4, &c) // 2**96 - 1
+ p224Square(&f4, &f3, &c) // 2**97 - 2
+ for i := 0; i < 23; i++ { // 2**120 - 2**24
+ p224Square(&f4, &f4, &c)
+ }
+ p224Mul(&f2, &f4, &f2, &c) // 2**120 - 1
+ for i := 0; i < 6; i++ { // 2**126 - 2**6
+ p224Square(&f2, &f2, &c)
+ }
+ p224Mul(&f1, &f1, &f2, &c) // 2**126 - 1
+ p224Square(&f1, &f1, &c) // 2**127 - 2
+ p224Mul(&f1, &f1, in, &c) // 2**127 - 1
+ for i := 0; i < 97; i++ { // 2**224 - 2**97
+ p224Square(&f1, &f1, &c)
+ }
+ p224Mul(out, &f1, &f3, &c) // 2**224 - 2**96 - 1
+}
+
+// p224Contract converts a FieldElement to its unique, minimal form.
+//
+// On entry, in[i] < 2**32
+// On exit, in[i] < 2**28
+func p224Contract(out, in *p224FieldElement) {
+ copy(out[:], in[:])
+
+ for i := 0; i < 7; i++ {
+ out[i+1] += out[i] >> 28
+ out[i] &= bottom28Bits
+ }
+ top := out[7] >> 28
+ out[7] &= bottom28Bits
+
+ out[0] -= top
+ out[3] += top << 12
+
+ // We may just have made out[i] negative. So we carry down. If we made
+ // out[0] negative then we know that out[3] is sufficiently positive
+ // because we just added to it.
+ for i := 0; i < 3; i++ {
+ mask := uint32(int32(out[i]) >> 31)
+ out[i] += (1 << 28) & mask
+ out[i+1] -= 1 & mask
+ }
+
+ // Now we see if the value is >= p and, if so, subtract p.
+
+ // First we build a mask from the top four limbs, which must all be
+ // equal to bottom28Bits if the whole value is >= p. If top4AllOnes
+ // ends up with any zero bits in the bottom 28 bits, then this wasn't
+ // true.
+ top4AllOnes := uint32(0xffffffff)
+ for i := 4; i < 8; i++ {
+ top4AllOnes &= (out[i] & bottom28Bits) - 1
+ }
+ top4AllOnes |= 0xf0000000
+ // Now we replicate any zero bits to all the bits in top4AllOnes.
+ top4AllOnes &= top4AllOnes >> 16
+ top4AllOnes &= top4AllOnes >> 8
+ top4AllOnes &= top4AllOnes >> 4
+ top4AllOnes &= top4AllOnes >> 2
+ top4AllOnes &= top4AllOnes >> 1
+ top4AllOnes = uint32(int32(top4AllOnes<<31) >> 31)
+
+ // Now we test whether the bottom three limbs are non-zero.
+ bottom3NonZero := out[0] | out[1] | out[2]
+ bottom3NonZero |= bottom3NonZero >> 16
+ bottom3NonZero |= bottom3NonZero >> 8
+ bottom3NonZero |= bottom3NonZero >> 4
+ bottom3NonZero |= bottom3NonZero >> 2
+ bottom3NonZero |= bottom3NonZero >> 1
+ bottom3NonZero = uint32(int32(bottom3NonZero<<31) >> 31)
+
+ // Everything depends on the value of out[3].
+ // If it's > 0xffff000 and top4AllOnes != 0 then the whole value is >= p
+ // If it's = 0xffff000 and top4AllOnes != 0 and bottom3NonZero != 0,
+ // then the whole value is >= p
+ // If it's < 0xffff000, then the whole value is < p
+ n := out[3] - 0xffff000
+ out3Equal := n
+ out3Equal |= out3Equal >> 16
+ out3Equal |= out3Equal >> 8
+ out3Equal |= out3Equal >> 4
+ out3Equal |= out3Equal >> 2
+ out3Equal |= out3Equal >> 1
+ out3Equal = ^uint32(int32(out3Equal<<31) >> 31)
+
+ // If out[3] > 0xffff000 then n's MSB will be zero.
+ out3GT := ^uint32(int32(n<<31) >> 31)
+
+ mask := top4AllOnes & ((out3Equal & bottom3NonZero) | out3GT)
+ out[0] -= 1 & mask
+ out[3] -= 0xffff000 & mask
+ out[4] -= 0xfffffff & mask
+ out[5] -= 0xfffffff & mask
+ out[6] -= 0xfffffff & mask
+ out[7] -= 0xfffffff & mask
+}
+
+// Group element functions.
+//
+// These functions deal with group elements. The group is an elliptic curve
+// group with a = -3 defined in FIPS 186-3, section D.2.2.
+
+// p224AddJacobian computes *out = a+b where a != b.
+func p224AddJacobian(x3, y3, z3, x1, y1, z1, x2, y2, z2 *p224FieldElement) {
+ // See http://hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html#addition-p224Add-2007-bl
+ var z1z1, z2z2, u1, u2, s1, s2, h, i, j, r, v p224FieldElement
+ var c p224LargeFieldElement
+
+ // Z1Z1 = Z1²
+ p224Square(&z1z1, z1, &c)
+ // Z2Z2 = Z2²
+ p224Square(&z2z2, z2, &c)
+ // U1 = X1*Z2Z2
+ p224Mul(&u1, x1, &z2z2, &c)
+ // U2 = X2*Z1Z1
+ p224Mul(&u2, x2, &z1z1, &c)
+ // S1 = Y1*Z2*Z2Z2
+ p224Mul(&s1, z2, &z2z2, &c)
+ p224Mul(&s1, y1, &s1, &c)
+ // S2 = Y2*Z1*Z1Z1
+ p224Mul(&s2, z1, &z1z1, &c)
+ p224Mul(&s2, y2, &s2, &c)
+ // H = U2-U1
+ p224Sub(&h, &u2, &u1)
+ p224Reduce(&h)
+ // I = (2*H)²
+ for j := 0; j < 8; j++ {
+ i[j] = h[j] << 1
+ }
+ p224Reduce(&i)
+ p224Square(&i, &i, &c)
+ // J = H*I
+ p224Mul(&j, &h, &i, &c)
+ // r = 2*(S2-S1)
+ p224Sub(&r, &s2, &s1)
+ p224Reduce(&r)
+ for i := 0; i < 8; i++ {
+ r[i] <<= 1
+ }
+ p224Reduce(&r)
+ // V = U1*I
+ p224Mul(&v, &u1, &i, &c)
+ // Z3 = ((Z1+Z2)²-Z1Z1-Z2Z2)*H
+ p224Add(&z1z1, &z1z1, &z2z2)
+ p224Add(&z2z2, z1, z2)
+ p224Reduce(&z2z2)
+ p224Square(&z2z2, &z2z2, &c)
+ p224Sub(z3, &z2z2, &z1z1)
+ p224Reduce(z3)
+ p224Mul(z3, z3, &h, &c)
+ // X3 = r²-J-2*V
+ for i := 0; i < 8; i++ {
+ z1z1[i] = v[i] << 1
+ }
+ p224Add(&z1z1, &j, &z1z1)
+ p224Reduce(&z1z1)
+ p224Square(x3, &r, &c)
+ p224Sub(x3, x3, &z1z1)
+ p224Reduce(x3)
+ // Y3 = r*(V-X3)-2*S1*J
+ for i := 0; i < 8; i++ {
+ s1[i] <<= 1
+ }
+ p224Mul(&s1, &s1, &j, &c)
+ p224Sub(&z1z1, &v, x3)
+ p224Reduce(&z1z1)
+ p224Mul(&z1z1, &z1z1, &r, &c)
+ p224Sub(y3, &z1z1, &s1)
+ p224Reduce(y3)
+}
+
+// p224DoubleJacobian computes *out = a+a.
+func p224DoubleJacobian(x3, y3, z3, x1, y1, z1 *p224FieldElement) {
+ var delta, gamma, beta, alpha, t p224FieldElement
+ var c p224LargeFieldElement
+
+ p224Square(&delta, z1, &c)
+ p224Square(&gamma, y1, &c)
+ p224Mul(&beta, x1, &gamma, &c)
+
+ // alpha = 3*(X1-delta)*(X1+delta)
+ p224Add(&t, x1, &delta)
+ for i := 0; i < 8; i++ {
+ t[i] += t[i] << 1
+ }
+ p224Reduce(&t)
+ p224Sub(&alpha, x1, &delta)
+ p224Reduce(&alpha)
+ p224Mul(&alpha, &alpha, &t, &c)
+
+ // Z3 = (Y1+Z1)²-gamma-delta
+ p224Add(z3, y1, z1)
+ p224Reduce(z3)
+ p224Square(z3, z3, &c)
+ p224Sub(z3, z3, &gamma)
+ p224Reduce(z3)
+ p224Sub(z3, z3, &delta)
+ p224Reduce(z3)
+
+ // X3 = alpha²-8*beta
+ for i := 0; i < 8; i++ {
+ delta[i] = beta[i] << 3
+ }
+ p224Reduce(&delta)
+ p224Square(x3, &alpha, &c)
+ p224Sub(x3, x3, &delta)
+ p224Reduce(x3)
+
+ // Y3 = alpha*(4*beta-X3)-8*gamma²
+ for i := 0; i < 8; i++ {
+ beta[i] <<= 2
+ }
+ p224Sub(&beta, &beta, x3)
+ p224Reduce(&beta)
+ p224Square(&gamma, &gamma, &c)
+ for i := 0; i < 8; i++ {
+ gamma[i] <<= 3
+ }
+ p224Reduce(&gamma)
+ p224Mul(y3, &alpha, &beta, &c)
+ p224Sub(y3, y3, &gamma)
+ p224Reduce(y3)
+}
+
+// p224CopyConditional sets *out = *in iff the least-significant-bit of control
+// is true, and it runs in constant time.
+func p224CopyConditional(out, in *p224FieldElement, control uint32) {
+ control <<= 31
+ control = uint32(int32(control) >> 31)
+
+ for i := 0; i < 8; i++ {
+ out[i] ^= (out[i] ^ in[i]) & control
+ }
+}
+
+func p224ScalarMult(outX, outY, outZ, inX, inY, inZ *p224FieldElement, scalar []byte) {
+ var xx, yy, zz p224FieldElement
+ for i := 0; i < 8; i++ {
+ outZ[i] = 0
+ }
+
+ firstBit := uint32(1)
+ for _, byte := range scalar {
+ for bitNum := uint(0); bitNum < 8; bitNum++ {
+ p224DoubleJacobian(outX, outY, outZ, outX, outY, outZ)
+ bit := uint32((byte >> (7 - bitNum)) & 1)
+ p224AddJacobian(&xx, &yy, &zz, inX, inY, inZ, outX, outY, outZ)
+ p224CopyConditional(outX, inX, firstBit&bit)
+ p224CopyConditional(outY, inY, firstBit&bit)
+ p224CopyConditional(outZ, inZ, firstBit&bit)
+ p224CopyConditional(outX, &xx, ^firstBit&bit)
+ p224CopyConditional(outY, &yy, ^firstBit&bit)
+ p224CopyConditional(outZ, &zz, ^firstBit&bit)
+ firstBit = firstBit & ^bit
+ }
+ }
+}
+
+// p224ToAffine converts from Jacobian to affine form.
+func p224ToAffine(x, y, z *p224FieldElement) (*big.Int, *big.Int) {
+ var zinv, zinvsq, outx, outy p224FieldElement
+ var tmp p224LargeFieldElement
+
+ isPointAtInfinity := true
+ for i := 0; i < 8; i++ {
+ if z[i] != 0 {
+ isPointAtInfinity = false
+ break
+ }
+ }
+
+ if isPointAtInfinity {
+ return nil, nil
+ }
+
+ p224Invert(&zinv, z)
+ p224Square(&zinvsq, &zinv, &tmp)
+ p224Mul(x, x, &zinvsq, &tmp)
+ p224Mul(&zinvsq, &zinvsq, &zinv, &tmp)
+ p224Mul(y, y, &zinvsq, &tmp)
+
+ p224Contract(&outx, x)
+ p224Contract(&outy, y)
+ return p224ToBig(&outx), p224ToBig(&outy)
+}
+
+// get28BitsFromEnd returns the least-significant 28 bits from buf>>shift,
+// where buf is interpreted as a big-endian number.
+func get28BitsFromEnd(buf []byte, shift uint) (uint32, []byte) {
+ var ret uint32
+
+ for i := uint(0); i < 4; i++ {
+ var b byte
+ if l := len(buf); l > 0 {
+ b = buf[l-1]
+ // We don't remove the byte if we're about to return and we're not
+ // reading all of it.
+ if i != 3 || shift == 4 {
+ buf = buf[:l-1]
+ }
+ }
+ ret |= uint32(b) << (8 * i) >> shift
+ }
+ ret &= bottom28Bits
+ return ret, buf
+}
+
+// p224FromBig sets *out = *in.
+func p224FromBig(out *p224FieldElement, in *big.Int) {
+ bytes := in.Bytes()
+ out[0], bytes = get28BitsFromEnd(bytes, 0)
+ out[1], bytes = get28BitsFromEnd(bytes, 4)
+ out[2], bytes = get28BitsFromEnd(bytes, 0)
+ out[3], bytes = get28BitsFromEnd(bytes, 4)
+ out[4], bytes = get28BitsFromEnd(bytes, 0)
+ out[5], bytes = get28BitsFromEnd(bytes, 4)
+ out[6], bytes = get28BitsFromEnd(bytes, 0)
+ out[7], bytes = get28BitsFromEnd(bytes, 4)
+}
+
+// p224ToBig returns in as a big.Int.
+func p224ToBig(in *p224FieldElement) *big.Int {
+ var buf [28]byte
+ buf[27] = byte(in[0])
+ buf[26] = byte(in[0] >> 8)
+ buf[25] = byte(in[0] >> 16)
+ buf[24] = byte(((in[0] >> 24) & 0x0f) | (in[1]<<4)&0xf0)
+
+ buf[23] = byte(in[1] >> 4)
+ buf[22] = byte(in[1] >> 12)
+ buf[21] = byte(in[1] >> 20)
+
+ buf[20] = byte(in[2])
+ buf[19] = byte(in[2] >> 8)
+ buf[18] = byte(in[2] >> 16)
+ buf[17] = byte(((in[2] >> 24) & 0x0f) | (in[3]<<4)&0xf0)
+
+ buf[16] = byte(in[3] >> 4)
+ buf[15] = byte(in[3] >> 12)
+ buf[14] = byte(in[3] >> 20)
+
+ buf[13] = byte(in[4])
+ buf[12] = byte(in[4] >> 8)
+ buf[11] = byte(in[4] >> 16)
+ buf[10] = byte(((in[4] >> 24) & 0x0f) | (in[5]<<4)&0xf0)
+
+ buf[9] = byte(in[5] >> 4)
+ buf[8] = byte(in[5] >> 12)
+ buf[7] = byte(in[5] >> 20)
+
+ buf[6] = byte(in[6])
+ buf[5] = byte(in[6] >> 8)
+ buf[4] = byte(in[6] >> 16)
+ buf[3] = byte(((in[6] >> 24) & 0x0f) | (in[7]<<4)&0xf0)
+
+ buf[2] = byte(in[7] >> 4)
+ buf[1] = byte(in[7] >> 12)
+ buf[0] = byte(in[7] >> 20)
+
+ return new(big.Int).SetBytes(buf[:])
+}
diff --git a/libgo/go/crypto/elliptic/p224_test.go b/libgo/go/crypto/elliptic/p224_test.go
new file mode 100644
index 00000000000..4b26d1610ed
--- /dev/null
+++ b/libgo/go/crypto/elliptic/p224_test.go
@@ -0,0 +1,47 @@
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package elliptic
+
+import (
+ "math/big"
+ "testing"
+)
+
+var toFromBigTests = []string{
+ "0",
+ "1",
+ "23",
+ "b70e0cb46bb4bf7f321390b94a03c1d356c01122343280d6105c1d21",
+ "706a46d476dcb76798e6046d89474788d164c18032d268fd10704fa6",
+}
+
+func p224AlternativeToBig(in *p224FieldElement) *big.Int {
+ ret := new(big.Int)
+ tmp := new(big.Int)
+
+ for i := uint(0); i < 8; i++ {
+ tmp.SetInt64(int64(in[i]))
+ tmp.Lsh(tmp, 28*i)
+ ret.Add(ret, tmp)
+ }
+ ret.Mod(ret, p224.P)
+ return ret
+}
+
+func TestToFromBig(t *testing.T) {
+ for i, test := range toFromBigTests {
+ n, _ := new(big.Int).SetString(test, 16)
+ var x p224FieldElement
+ p224FromBig(&x, n)
+ m := p224ToBig(&x)
+ if n.Cmp(m) != 0 {
+ t.Errorf("#%d: %x != %x", i, n, m)
+ }
+ q := p224AlternativeToBig(&x)
+ if n.Cmp(q) != 0 {
+ t.Errorf("#%d: %x != %x (alternative)", i, n, m)
+ }
+ }
+}
diff --git a/libgo/go/crypto/hmac/hmac.go b/libgo/go/crypto/hmac/hmac.go
index 6e7dd8762c8..a97ce09727a 100644
--- a/libgo/go/crypto/hmac/hmac.go
+++ b/libgo/go/crypto/hmac/hmac.go
@@ -9,32 +9,20 @@
package hmac
import (
- "crypto/md5"
- "crypto/sha1"
- "crypto/sha256"
"hash"
)
// FIPS 198:
// http://csrc.nist.gov/publications/fips/fips198/fips-198a.pdf
-// key is zero padded to 64 bytes
-// ipad = 0x36 byte repeated to 64 bytes
-// opad = 0x5c byte repeated to 64 bytes
+// key is zero padded to the block size of the hash function
+// ipad = 0x36 byte repeated for key length
+// opad = 0x5c byte repeated for key length
// hmac = H([key ^ opad] H([key ^ ipad] text))
-const (
- // NOTE(rsc): This constant is actually the
- // underlying hash function's block size.
- // HMAC is only conventionally used with
- // MD5 and SHA1, and both use 64-byte blocks.
- // The hash.Hash interface doesn't provide a
- // way to find out the block size.
- padSize = 64
-)
-
type hmac struct {
size int
+ blocksize int
key, tmp []byte
outer, inner hash.Hash
}
@@ -43,7 +31,7 @@ func (h *hmac) tmpPad(xor byte) {
for i, k := range h.key {
h.tmp[i] = xor ^ k
}
- for i := len(h.key); i < padSize; i++ {
+ for i := len(h.key); i < h.blocksize; i++ {
h.tmp[i] = xor
}
}
@@ -52,7 +40,7 @@ func (h *hmac) Sum(in []byte) []byte {
origLen := len(in)
in = h.inner.Sum(in)
h.tmpPad(0x5c)
- copy(h.tmp[padSize:], in[origLen:])
+ copy(h.tmp[h.blocksize:], in[origLen:])
h.outer.Reset()
h.outer.Write(h.tmp)
return h.outer.Sum(in[:origLen])
@@ -64,20 +52,23 @@ func (h *hmac) Write(p []byte) (n int, err error) {
func (h *hmac) Size() int { return h.size }
+func (h *hmac) BlockSize() int { return h.blocksize }
+
func (h *hmac) Reset() {
h.inner.Reset()
h.tmpPad(0x36)
- h.inner.Write(h.tmp[0:padSize])
+ h.inner.Write(h.tmp[0:h.blocksize])
}
-// New returns a new HMAC hash using the given hash generator and key.
+// New returns a new HMAC hash using the given hash.Hash type and key.
func New(h func() hash.Hash, key []byte) hash.Hash {
hm := new(hmac)
hm.outer = h()
hm.inner = h()
hm.size = hm.inner.Size()
- hm.tmp = make([]byte, padSize+hm.size)
- if len(key) > padSize {
+ hm.blocksize = hm.inner.BlockSize()
+ hm.tmp = make([]byte, hm.blocksize+hm.size)
+ if len(key) > hm.blocksize {
// If key is too big, hash it.
hm.outer.Write(key)
key = hm.outer.Sum(nil)
@@ -87,12 +78,3 @@ func New(h func() hash.Hash, key []byte) hash.Hash {
hm.Reset()
return hm
}
-
-// NewMD5 returns a new HMAC-MD5 hash using the given key.
-func NewMD5(key []byte) hash.Hash { return New(md5.New, key) }
-
-// NewSHA1 returns a new HMAC-SHA1 hash using the given key.
-func NewSHA1(key []byte) hash.Hash { return New(sha1.New, key) }
-
-// NewSHA256 returns a new HMAC-SHA256 hash using the given key.
-func NewSHA256(key []byte) hash.Hash { return New(sha256.New, key) }
diff --git a/libgo/go/crypto/hmac/hmac_test.go b/libgo/go/crypto/hmac/hmac_test.go
index eac254b9d19..07957414c88 100644
--- a/libgo/go/crypto/hmac/hmac_test.go
+++ b/libgo/go/crypto/hmac/hmac_test.go
@@ -5,13 +5,17 @@
package hmac
import (
+ "crypto/md5"
+ "crypto/sha1"
+ "crypto/sha256"
+ "crypto/sha512"
"fmt"
"hash"
"testing"
)
type hmacTest struct {
- hash func([]byte) hash.Hash
+ hash func() hash.Hash
key []byte
in []byte
out string
@@ -21,7 +25,7 @@ var hmacTests = []hmacTest{
// Tests from US FIPS 198
// http://csrc.nist.gov/publications/fips/fips198/fips-198a.pdf
{
- NewSHA1,
+ sha1.New,
[]byte{
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
@@ -36,7 +40,7 @@ var hmacTests = []hmacTest{
"4f4ca3d5d68ba7cc0a1208c9c61e9c5da0403c0a",
},
{
- NewSHA1,
+ sha1.New,
[]byte{
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
@@ -46,7 +50,7 @@ var hmacTests = []hmacTest{
"0922d3405faa3d194f82a45830737d5cc6c75d24",
},
{
- NewSHA1,
+ sha1.New,
[]byte{
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
@@ -68,7 +72,7 @@ var hmacTests = []hmacTest{
// Test from Plan 9.
{
- NewMD5,
+ md5.New,
[]byte("Jefe"),
[]byte("what do ya want for nothing?"),
"750c783e6ab0b503eaa86e310a5db738",
@@ -76,7 +80,7 @@ var hmacTests = []hmacTest{
// Tests from RFC 4231
{
- NewSHA256,
+ sha256.New,
[]byte{
0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
@@ -86,13 +90,13 @@ var hmacTests = []hmacTest{
"b0344c61d8db38535ca8afceaf0bf12b881dc200c9833da726e9376c2e32cff7",
},
{
- NewSHA256,
+ sha256.New,
[]byte("Jefe"),
[]byte("what do ya want for nothing?"),
"5bdcc146bf60754e6a042426089575c75a003f089d2739839dec58b964ec3843",
},
{
- NewSHA256,
+ sha256.New,
[]byte{
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
@@ -110,7 +114,7 @@ var hmacTests = []hmacTest{
"773ea91e36800e46854db8ebd09181a72959098b3ef8c122d9635514ced565fe",
},
{
- NewSHA256,
+ sha256.New,
[]byte{
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
@@ -129,7 +133,7 @@ var hmacTests = []hmacTest{
"82558a389a443c0ea4cc819899f2083a85f0faa3e578f8077a2e3ff46729665b",
},
{
- NewSHA256,
+ sha256.New,
[]byte{
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
@@ -153,7 +157,7 @@ var hmacTests = []hmacTest{
"60e431591ee0b67f0d8a26aacbf5b77f8e0bc6213728c5140546040f0ee37f54",
},
{
- NewSHA256,
+ sha256.New,
[]byte{
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
@@ -178,11 +182,295 @@ var hmacTests = []hmacTest{
"be hashed before being used by the HMAC algorithm."),
"9b09ffa71b942fcb27635fbcd5b0e944bfdc63644f0713938a7f51535c3a35e2",
},
+
+ // Tests from http://csrc.nist.gov/groups/ST/toolkit/examples.html
+ // (truncated tag tests are left out)
+ {
+ sha1.New,
+ []byte{
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+ 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
+ 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
+ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+ },
+ []byte("Sample message for keylen=blocklen"),
+ "5fd596ee78d5553c8ff4e72d266dfd192366da29",
+ },
+ {
+ sha1.New,
+ []byte{
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13,
+ },
+ []byte("Sample message for keylen>3)
+ preMasterSecret := make([]byte, (ka.curve.Params().BitSize+7)>>3)
xBytes := x.Bytes()
copy(preMasterSecret[len(preMasterSecret)-len(xBytes):], xBytes)
@@ -205,7 +205,7 @@ func (ka *ecdheRSAKeyAgreement) processServerKeyExchange(config *Config, clientH
if publicLen+4 > len(skx.key) {
return errServerKeyExchange
}
- ka.x, ka.y = ka.curve.Unmarshal(skx.key[4 : 4+publicLen])
+ ka.x, ka.y = elliptic.Unmarshal(ka.curve, skx.key[4:4+publicLen])
if ka.x == nil {
return errServerKeyExchange
}
@@ -229,16 +229,16 @@ func (ka *ecdheRSAKeyAgreement) generateClientKeyExchange(config *Config, client
if ka.curve == nil {
return nil, nil, errors.New("missing ServerKeyExchange message")
}
- priv, mx, my, err := ka.curve.GenerateKey(config.rand())
+ priv, mx, my, err := elliptic.GenerateKey(ka.curve, config.rand())
if err != nil {
return nil, nil, err
}
x, _ := ka.curve.ScalarMult(ka.x, ka.y, priv)
- preMasterSecret := make([]byte, (ka.curve.BitSize+7)>>3)
+ preMasterSecret := make([]byte, (ka.curve.Params().BitSize+7)>>3)
xBytes := x.Bytes()
copy(preMasterSecret[len(preMasterSecret)-len(xBytes):], xBytes)
- serialized := ka.curve.Marshal(mx, my)
+ serialized := elliptic.Marshal(ka.curve, mx, my)
ckx := new(clientKeyExchangeMsg)
ckx.ciphertext = make([]byte, 1+len(serialized))
diff --git a/libgo/go/crypto/tls/root_unix.go b/libgo/go/crypto/tls/root_unix.go
index 5bbd9825dca..acaf3dd9d67 100644
--- a/libgo/go/crypto/tls/root_unix.go
+++ b/libgo/go/crypto/tls/root_unix.go
@@ -13,10 +13,11 @@ import (
// Possible certificate files; stop after finding one.
var certFiles = []string{
- "/etc/ssl/certs/ca-certificates.crt", // Linux etc
- "/etc/pki/tls/certs/ca-bundle.crt", // Fedora/RHEL
- "/etc/ssl/ca-bundle.pem", // OpenSUSE
- "/etc/ssl/cert.pem", // OpenBSD
+ "/etc/ssl/certs/ca-certificates.crt", // Linux etc
+ "/etc/pki/tls/certs/ca-bundle.crt", // Fedora/RHEL
+ "/etc/ssl/ca-bundle.pem", // OpenSUSE
+ "/etc/ssl/cert.pem", // OpenBSD
+ "/usr/local/share/certs/ca-root-nss.crt", // FreeBSD
}
func initDefaultRoots() {
diff --git a/libgo/go/crypto/x509/x509.go b/libgo/go/crypto/x509/x509.go
index 28c7880e531..bf39c5dec0a 100644
--- a/libgo/go/crypto/x509/x509.go
+++ b/libgo/go/crypto/x509/x509.go
@@ -899,6 +899,14 @@ var (
oidRSA = []int{1, 2, 840, 113549, 1, 1, 1}
)
+func subjectBytes(cert *Certificate) ([]byte, error) {
+ if len(cert.RawSubject) > 0 {
+ return cert.RawSubject, nil
+ }
+
+ return asn1.Marshal(cert.Subject.ToRDNSequence())
+}
+
// CreateCertificate creates a new certificate based on a template. The
// following members of template are used: SerialNumber, Subject, NotBefore,
// NotAfter, KeyUsage, BasicConstraintsValid, IsCA, MaxPathLen, SubjectKeyId,
@@ -909,10 +917,23 @@ var (
// signee and priv is the private key of the signer.
//
// The returned slice is the certificate in DER encoding.
-func CreateCertificate(rand io.Reader, template, parent *Certificate, pub *rsa.PublicKey, priv *rsa.PrivateKey) (cert []byte, err error) {
+//
+// The only supported key type is RSA (*rsa.PublicKey for pub, *rsa.PrivateKey
+// for priv).
+func CreateCertificate(rand io.Reader, template, parent *Certificate, pub interface{}, priv interface{}) (cert []byte, err error) {
+ rsaPub, ok := pub.(*rsa.PublicKey)
+ if !ok {
+ return nil, errors.New("x509: non-RSA public keys not supported")
+ }
+
+ rsaPriv, ok := priv.(*rsa.PrivateKey)
+ if !ok {
+ return nil, errors.New("x509: non-RSA private keys not supported")
+ }
+
asn1PublicKey, err := asn1.Marshal(rsaPublicKey{
- N: pub.N,
- E: pub.E,
+ N: rsaPub.N,
+ E: rsaPub.E,
})
if err != nil {
return
@@ -927,16 +948,12 @@ func CreateCertificate(rand io.Reader, template, parent *Certificate, pub *rsa.P
return
}
- var asn1Issuer []byte
- if len(parent.RawSubject) > 0 {
- asn1Issuer = parent.RawSubject
- } else {
- if asn1Issuer, err = asn1.Marshal(parent.Subject.ToRDNSequence()); err != nil {
- return
- }
+ asn1Issuer, err := subjectBytes(parent)
+ if err != nil {
+ return
}
- asn1Subject, err := asn1.Marshal(template.Subject.ToRDNSequence())
+ asn1Subject, err := subjectBytes(template)
if err != nil {
return
}
@@ -964,7 +981,7 @@ func CreateCertificate(rand io.Reader, template, parent *Certificate, pub *rsa.P
h.Write(tbsCertContents)
digest := h.Sum(nil)
- signature, err := rsa.SignPKCS1v15(rand, priv, crypto.SHA1, digest)
+ signature, err := rsa.SignPKCS1v15(rand, rsaPriv, crypto.SHA1, digest)
if err != nil {
return
}
@@ -1011,7 +1028,13 @@ func ParseDERCRL(derBytes []byte) (certList *pkix.CertificateList, err error) {
// CreateCRL returns a DER encoded CRL, signed by this Certificate, that
// contains the given list of revoked certificates.
-func (c *Certificate) CreateCRL(rand io.Reader, priv *rsa.PrivateKey, revokedCerts []pkix.RevokedCertificate, now, expiry time.Time) (crlBytes []byte, err error) {
+//
+// The only supported key type is RSA (*rsa.PrivateKey for priv).
+func (c *Certificate) CreateCRL(rand io.Reader, priv interface{}, revokedCerts []pkix.RevokedCertificate, now, expiry time.Time) (crlBytes []byte, err error) {
+ rsaPriv, ok := priv.(*rsa.PrivateKey)
+ if !ok {
+ return nil, errors.New("x509: non-RSA private keys not supported")
+ }
tbsCertList := pkix.TBSCertificateList{
Version: 2,
Signature: pkix.AlgorithmIdentifier{
@@ -1032,7 +1055,7 @@ func (c *Certificate) CreateCRL(rand io.Reader, priv *rsa.PrivateKey, revokedCer
h.Write(tbsCertListContents)
digest := h.Sum(nil)
- signature, err := rsa.SignPKCS1v15(rand, priv, crypto.SHA1, digest)
+ signature, err := rsa.SignPKCS1v15(rand, rsaPriv, crypto.SHA1, digest)
if err != nil {
return
}
diff --git a/libgo/go/exp/sql/convert.go b/libgo/go/database/sql/convert.go
similarity index 99%
rename from libgo/go/exp/sql/convert.go
rename to libgo/go/database/sql/convert.go
index feb79aeafe0..9835e38de7e 100644
--- a/libgo/go/exp/sql/convert.go
+++ b/libgo/go/database/sql/convert.go
@@ -7,8 +7,8 @@
package sql
import (
+ "database/sql/driver"
"errors"
- "exp/sql/driver"
"fmt"
"reflect"
"strconv"
diff --git a/libgo/go/exp/sql/convert_test.go b/libgo/go/database/sql/convert_test.go
similarity index 85%
rename from libgo/go/exp/sql/convert_test.go
rename to libgo/go/database/sql/convert_test.go
index 702ba4399d5..b188864f623 100644
--- a/libgo/go/exp/sql/convert_test.go
+++ b/libgo/go/database/sql/convert_test.go
@@ -5,6 +5,7 @@
package sql
import (
+ "database/sql/driver"
"fmt"
"reflect"
"testing"
@@ -154,8 +155,8 @@ func TestConversions(t *testing.T) {
}
}
-func TestNullableString(t *testing.T) {
- var ns NullableString
+func TestNullString(t *testing.T) {
+ var ns NullString
convertAssign(&ns, []byte("foo"))
if !ns.Valid {
t.Errorf("expecting not null")
@@ -171,3 +172,35 @@ func TestNullableString(t *testing.T) {
t.Errorf("expecting blank on nil; got %q", ns.String)
}
}
+
+type valueConverterTest struct {
+ c driver.ValueConverter
+ in, out interface{}
+ err string
+}
+
+var valueConverterTests = []valueConverterTest{
+ {driver.DefaultParameterConverter, NullString{"hi", true}, "hi", ""},
+ {driver.DefaultParameterConverter, NullString{"", false}, nil, ""},
+}
+
+func TestValueConverters(t *testing.T) {
+ for i, tt := range valueConverterTests {
+ out, err := tt.c.ConvertValue(tt.in)
+ goterr := ""
+ if err != nil {
+ goterr = err.Error()
+ }
+ if goterr != tt.err {
+ t.Errorf("test %d: %s(%T(%v)) error = %q; want error = %q",
+ i, tt.c, tt.in, tt.in, goterr, tt.err)
+ }
+ if tt.err != "" {
+ continue
+ }
+ if !reflect.DeepEqual(out, tt.out) {
+ t.Errorf("test %d: %s(%T(%v)) = %v (%T); want %v (%T)",
+ i, tt.c, tt.in, tt.in, out, out, tt.out, tt.out)
+ }
+ }
+}
diff --git a/libgo/go/exp/sql/driver/driver.go b/libgo/go/database/sql/driver/driver.go
similarity index 100%
rename from libgo/go/exp/sql/driver/driver.go
rename to libgo/go/database/sql/driver/driver.go
diff --git a/libgo/go/exp/sql/driver/types.go b/libgo/go/database/sql/driver/types.go
similarity index 82%
rename from libgo/go/exp/sql/driver/types.go
rename to libgo/go/database/sql/driver/types.go
index d6ba641cb26..f3838852311 100644
--- a/libgo/go/exp/sql/driver/types.go
+++ b/libgo/go/database/sql/driver/types.go
@@ -32,6 +32,15 @@ type ValueConverter interface {
ConvertValue(v interface{}) (interface{}, error)
}
+// SubsetValuer is the interface providing the SubsetValue method.
+//
+// Types implementing SubsetValuer interface are able to convert
+// themselves to one of the driver's allowed subset values.
+type SubsetValuer interface {
+ // SubsetValue returns a driver parameter subset value.
+ SubsetValue() (interface{}, error)
+}
+
// Bool is a ValueConverter that converts input values to bools.
//
// The conversion rules are:
@@ -136,6 +145,32 @@ func (stringType) ConvertValue(v interface{}) (interface{}, error) {
return fmt.Sprintf("%v", v), nil
}
+// Null is a type that implements ValueConverter by allowing nil
+// values but otherwise delegating to another ValueConverter.
+type Null struct {
+ Converter ValueConverter
+}
+
+func (n Null) ConvertValue(v interface{}) (interface{}, error) {
+ if v == nil {
+ return nil, nil
+ }
+ return n.Converter.ConvertValue(v)
+}
+
+// NotNull is a type that implements ValueConverter by disallowing nil
+// values but otherwise delegating to another ValueConverter.
+type NotNull struct {
+ Converter ValueConverter
+}
+
+func (n NotNull) ConvertValue(v interface{}) (interface{}, error) {
+ if v == nil {
+ return nil, fmt.Errorf("nil value not allowed")
+ }
+ return n.Converter.ConvertValue(v)
+}
+
// IsParameterSubsetType reports whether v is of a valid type for a
// parameter. These types are:
//
@@ -200,6 +235,17 @@ func (defaultConverter) ConvertValue(v interface{}) (interface{}, error) {
return v, nil
}
+ if svi, ok := v.(SubsetValuer); ok {
+ sv, err := svi.SubsetValue()
+ if err != nil {
+ return nil, err
+ }
+ if !IsParameterSubsetType(sv) {
+ return nil, fmt.Errorf("non-subset type %T returned from SubsetValue", sv)
+ }
+ return sv, nil
+ }
+
rv := reflect.ValueOf(v)
switch rv.Kind() {
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
@@ -215,5 +261,5 @@ func (defaultConverter) ConvertValue(v interface{}) (interface{}, error) {
case reflect.Float32, reflect.Float64:
return rv.Float(), nil
}
- return nil, fmt.Errorf("unsupported type %s", rv.Kind())
+ return nil, fmt.Errorf("unsupported type %T, a %s", v, rv.Kind())
}
diff --git a/libgo/go/exp/sql/driver/types_test.go b/libgo/go/database/sql/driver/types_test.go
similarity index 100%
rename from libgo/go/exp/sql/driver/types_test.go
rename to libgo/go/database/sql/driver/types_test.go
diff --git a/libgo/go/exp/sql/fakedb_test.go b/libgo/go/database/sql/fakedb_test.go
similarity index 99%
rename from libgo/go/exp/sql/fakedb_test.go
rename to libgo/go/database/sql/fakedb_test.go
index 70aa68c1385..b0d137cd715 100644
--- a/libgo/go/exp/sql/fakedb_test.go
+++ b/libgo/go/database/sql/fakedb_test.go
@@ -5,6 +5,7 @@
package sql
import (
+ "database/sql/driver"
"errors"
"fmt"
"io"
@@ -13,8 +14,6 @@ import (
"strings"
"sync"
"time"
-
- "exp/sql/driver"
)
var _ = log.Printf
@@ -589,7 +588,9 @@ func converterForType(typ string) driver.ValueConverter {
case "int32":
return driver.Int32
case "string":
- return driver.String
+ return driver.NotNull{driver.String}
+ case "nullstring":
+ return driver.Null{driver.String}
case "datetime":
return driver.DefaultParameterConverter
}
diff --git a/libgo/go/exp/sql/sql.go b/libgo/go/database/sql/sql.go
similarity index 90%
rename from libgo/go/exp/sql/sql.go
rename to libgo/go/database/sql/sql.go
index 4e68c3ee095..a8bf2a8b00c 100644
--- a/libgo/go/exp/sql/sql.go
+++ b/libgo/go/database/sql/sql.go
@@ -7,12 +7,11 @@
package sql
import (
+ "database/sql/driver"
"errors"
"fmt"
"io"
"sync"
-
- "exp/sql/driver"
)
var drivers = make(map[string]driver.Driver)
@@ -30,11 +29,16 @@ func Register(name string, driver driver.Driver) {
drivers[name] = driver
}
-// NullableString represents a string that may be null.
-// NullableString implements the ScannerInto interface so
+// RawBytes is a byte slice that holds a reference to memory owned by
+// the database itself. After a Scan into a RawBytes, the slice is only
+// valid until the next call to Next, Scan, or Close.
+type RawBytes []byte
+
+// NullString represents a string that may be null.
+// NullString implements the ScannerInto interface so
// it can be used as a scan destination:
//
-// var s NullableString
+// var s NullString
// err := db.QueryRow("SELECT name FROM foo WHERE id=?", id).Scan(&s)
// ...
// if s.Valid {
@@ -44,19 +48,27 @@ func Register(name string, driver driver.Driver) {
// }
//
// TODO(bradfitz): add other types.
-type NullableString struct {
+type NullString struct {
String string
Valid bool // Valid is true if String is not NULL
}
// ScanInto implements the ScannerInto interface.
-func (ms *NullableString) ScanInto(value interface{}) error {
+func (ns *NullString) ScanInto(value interface{}) error {
if value == nil {
- ms.String, ms.Valid = "", false
+ ns.String, ns.Valid = "", false
return nil
}
- ms.Valid = true
- return convertAssign(&ms.String, value)
+ ns.Valid = true
+ return convertAssign(&ns.String, value)
+}
+
+// SubsetValue implements the driver SubsetValuer interface.
+func (ns NullString) SubsetValue() (interface{}, error) {
+ if !ns.Valid {
+ return nil, nil
+ }
+ return ns.String, nil
}
// ScannerInto is an interface used by Scan.
@@ -525,6 +537,27 @@ func (s *Stmt) Exec(args ...interface{}) (Result, error) {
// Convert args to subset types.
if cc, ok := si.(driver.ColumnConverter); ok {
for n, arg := range args {
+ // First, see if the value itself knows how to convert
+ // itself to a driver type. For example, a NullString
+ // struct changing into a string or nil.
+ if svi, ok := arg.(driver.SubsetValuer); ok {
+ sv, err := svi.SubsetValue()
+ if err != nil {
+ return nil, fmt.Errorf("sql: argument index %d from SubsetValue: %v", n, err)
+ }
+ if !driver.IsParameterSubsetType(sv) {
+ return nil, fmt.Errorf("sql: argument index %d: non-subset type %T returned from SubsetValue", n, sv)
+ }
+ arg = sv
+ }
+
+ // Second, ask the column to sanity check itself. For
+ // example, drivers might use this to make sure that
+ // an int64 values being inserted into a 16-bit
+ // integer field is in range (before getting
+ // truncated), or that a nil can't go into a NOT NULL
+ // column before going across the network to get the
+ // same error.
args[n], err = cc.ColumnConverter(n).ConvertValue(arg)
if err != nil {
return nil, fmt.Errorf("sql: converting Exec argument #%d's type: %v", n, err)
@@ -760,9 +793,13 @@ func (rs *Rows) Columns() ([]string, error) {
}
// Scan copies the columns in the current row into the values pointed
-// at by dest. If dest contains pointers to []byte, the slices should
-// not be modified and should only be considered valid until the next
-// call to Next or Scan.
+// at by dest.
+//
+// If an argument has type *[]byte, Scan saves in that argument a copy
+// of the corresponding data. The copy is owned by the caller and can
+// be modified and held indefinitely. The copy can be avoided by using
+// an argument of type *RawBytes instead; see the documentation for
+// RawBytes for restrictions on its use.
func (rs *Rows) Scan(dest ...interface{}) error {
if rs.closed {
return errors.New("sql: Rows closed")
@@ -782,6 +819,18 @@ func (rs *Rows) Scan(dest ...interface{}) error {
return fmt.Errorf("sql: Scan error on column index %d: %v", i, err)
}
}
+ for _, dp := range dest {
+ b, ok := dp.(*[]byte)
+ if !ok {
+ continue
+ }
+ if _, ok = dp.(*RawBytes); ok {
+ continue
+ }
+ clone := make([]byte, len(*b))
+ copy(clone, *b)
+ *b = clone
+ }
return nil
}
@@ -838,6 +887,9 @@ func (r *Row) Scan(dest ...interface{}) error {
// they were obtained from the network anyway) But for now we
// don't care.
for _, dp := range dest {
+ if _, ok := dp.(*RawBytes); ok {
+ return errors.New("sql: RawBytes isn't allowed on Row.Scan")
+ }
b, ok := dp.(*[]byte)
if !ok {
continue
diff --git a/libgo/go/exp/sql/sql_test.go b/libgo/go/database/sql/sql_test.go
similarity index 70%
rename from libgo/go/exp/sql/sql_test.go
rename to libgo/go/database/sql/sql_test.go
index 3f98a8cd9f2..3fe93986faa 100644
--- a/libgo/go/exp/sql/sql_test.go
+++ b/libgo/go/database/sql/sql_test.go
@@ -76,7 +76,7 @@ func TestQuery(t *testing.T) {
{age: 3, name: "Chris"},
}
if !reflect.DeepEqual(got, want) {
- t.Logf(" got: %#v\nwant: %#v", got, want)
+ t.Errorf("mismatch.\n got: %#v\nwant: %#v", got, want)
}
// And verify that the final rows.Next() call, which hit EOF,
@@ -86,6 +86,43 @@ func TestQuery(t *testing.T) {
}
}
+func TestByteOwnership(t *testing.T) {
+ db := newTestDB(t, "people")
+ defer closeDB(t, db)
+ rows, err := db.Query("SELECT|people|name,photo|")
+ if err != nil {
+ t.Fatalf("Query: %v", err)
+ }
+ type row struct {
+ name []byte
+ photo RawBytes
+ }
+ got := []row{}
+ for rows.Next() {
+ var r row
+ err = rows.Scan(&r.name, &r.photo)
+ if err != nil {
+ t.Fatalf("Scan: %v", err)
+ }
+ got = append(got, r)
+ }
+ corruptMemory := []byte("\xffPHOTO")
+ want := []row{
+ {name: []byte("Alice"), photo: corruptMemory},
+ {name: []byte("Bob"), photo: corruptMemory},
+ {name: []byte("Chris"), photo: corruptMemory},
+ }
+ if !reflect.DeepEqual(got, want) {
+ t.Errorf("mismatch.\n got: %#v\nwant: %#v", got, want)
+ }
+
+ var photo RawBytes
+ err = db.QueryRow("SELECT|people|photo|name=?", "Alice").Scan(&photo)
+ if err == nil {
+ t.Error("want error scanning into RawBytes from QueryRow")
+ }
+}
+
func TestRowsColumns(t *testing.T) {
db := newTestDB(t, "people")
defer closeDB(t, db)
@@ -300,6 +337,68 @@ func TestQueryRowClosingStmt(t *testing.T) {
}
fakeConn := db.freeConn[0].(*fakeConn)
if made, closed := fakeConn.stmtsMade, fakeConn.stmtsClosed; made != closed {
- t.Logf("statement close mismatch: made %d, closed %d", made, closed)
+ t.Errorf("statement close mismatch: made %d, closed %d", made, closed)
+ }
+}
+
+func TestNullStringParam(t *testing.T) {
+ db := newTestDB(t, "")
+ defer closeDB(t, db)
+ exec(t, db, "CREATE|t|id=int32,name=string,favcolor=nullstring")
+
+ // Inserts with db.Exec:
+ exec(t, db, "INSERT|t|id=?,name=?,favcolor=?", 1, "alice", NullString{"aqua", true})
+ exec(t, db, "INSERT|t|id=?,name=?,favcolor=?", 2, "bob", NullString{"brown", false})
+
+ _, err := db.Exec("INSERT|t|id=?,name=?,favcolor=?", 999, nil, nil)
+ if err == nil {
+ // TODO: this test fails, but it's just because
+ // fakeConn implements the optional Execer interface,
+ // so arguably this is the correct behavior. But
+ // maybe I should flesh out the fakeConn.Exec
+ // implementation so this properly fails.
+ // t.Errorf("expected error inserting nil name with Exec")
+ }
+
+ // Inserts with a prepared statement:
+ stmt, err := db.Prepare("INSERT|t|id=?,name=?,favcolor=?")
+ if err != nil {
+ t.Fatalf("prepare: %v", err)
+ }
+ if _, err := stmt.Exec(3, "chris", "chartreuse"); err != nil {
+ t.Errorf("exec insert chris: %v", err)
+ }
+ if _, err := stmt.Exec(4, "dave", NullString{"darkred", true}); err != nil {
+ t.Errorf("exec insert dave: %v", err)
+ }
+ if _, err := stmt.Exec(5, "eleanor", NullString{"eel", false}); err != nil {
+ t.Errorf("exec insert dave: %v", err)
+ }
+
+ // Can't put null name into non-nullstring column,
+ if _, err := stmt.Exec(5, NullString{"", false}, nil); err == nil {
+ t.Errorf("expected error inserting nil name with prepared statement Exec")
+ }
+
+ type nameColor struct {
+ name string
+ favColor NullString
+ }
+
+ wantMap := map[int]nameColor{
+ 1: nameColor{"alice", NullString{"aqua", true}},
+ 2: nameColor{"bob", NullString{"", false}},
+ 3: nameColor{"chris", NullString{"chartreuse", true}},
+ 4: nameColor{"dave", NullString{"darkred", true}},
+ 5: nameColor{"eleanor", NullString{"", false}},
+ }
+ for id, want := range wantMap {
+ var got nameColor
+ if err := db.QueryRow("SELECT|t|name,favcolor|id=?", id).Scan(&got.name, &got.favColor); err != nil {
+ t.Errorf("id=%d Scan: %v", id, err)
+ }
+ if got != want {
+ t.Errorf("id=%d got %#v, want %#v", id, got, want)
+ }
}
}
diff --git a/libgo/go/encoding/gob/debug.go b/libgo/go/encoding/gob/debug.go
index b21c7fa0b2b..4a61d0fb2f8 100644
--- a/libgo/go/encoding/gob/debug.go
+++ b/libgo/go/encoding/gob/debug.go
@@ -1,3 +1,7 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
package gob
// This file is not normally included in the gob package. Used only for debugging the package itself.
diff --git a/libgo/go/encoding/gob/dump.go b/libgo/go/encoding/gob/dump.go
index 0d0017cc783..f7d822c11e4 100644
--- a/libgo/go/encoding/gob/dump.go
+++ b/libgo/go/encoding/gob/dump.go
@@ -1,3 +1,7 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
package main
// Need to compile package gob with debug.go to build this program.
diff --git a/libgo/go/encoding/json/encode.go b/libgo/go/encoding/json/encode.go
index 033da2d0ade..eac14a47ed7 100644
--- a/libgo/go/encoding/json/encode.go
+++ b/libgo/go/encoding/json/encode.go
@@ -39,6 +39,8 @@ import (
//
// String values encode as JSON strings, with each invalid UTF-8 sequence
// replaced by the encoding of the Unicode replacement character U+FFFD.
+// The angle brackets "<" and ">" are escaped to "\u003c" and "\u003e"
+// to keep some browsers from misinterpreting JSON output as HTML.
//
// Array and slice values encode as JSON arrays, except that
// []byte encodes as a base64-encoded string.
@@ -77,7 +79,8 @@ import (
// Int64String int64 `json:",string"`
//
// The key name will be used if it's a non-empty string consisting of
-// only Unicode letters, digits, dollar signs, hyphens, and underscores.
+// only Unicode letters, digits, dollar signs, percent signs, hyphens,
+// underscores and slashes.
//
// Map values encode as JSON objects.
// The map's key type must be string; the object keys are used directly
@@ -417,8 +420,13 @@ func isValidTag(s string) bool {
return false
}
for _, c := range s {
- if c != '$' && c != '-' && c != '_' && !unicode.IsLetter(c) && !unicode.IsDigit(c) {
- return false
+ switch c {
+ case '$', '-', '_', '/', '%':
+ // Acceptable
+ default:
+ if !unicode.IsLetter(c) && !unicode.IsDigit(c) {
+ return false
+ }
}
}
return true
diff --git a/libgo/go/encoding/json/tagkey_test.go b/libgo/go/encoding/json/tagkey_test.go
index 31fe2be3621..bba5730353d 100644
--- a/libgo/go/encoding/json/tagkey_test.go
+++ b/libgo/go/encoding/json/tagkey_test.go
@@ -9,7 +9,7 @@ import (
)
type basicLatin2xTag struct {
- V string `json:"$-"`
+ V string `json:"$%-/"`
}
type basicLatin3xTag struct {
@@ -36,6 +36,10 @@ type miscPlaneTag struct {
V string `json:"色は匂へど"`
}
+type percentSlashTag struct {
+ V string `json:"text/html%"` // http://golang.org/issue/2718
+}
+
type emptyTag struct {
W string
}
@@ -49,7 +53,7 @@ type badFormatTag struct {
}
type badCodeTag struct {
- Z string `json:" !\"#%&'()*+,./"`
+ Z string `json:" !\"#&'()*+,."`
}
var structTagObjectKeyTests = []struct {
@@ -57,7 +61,7 @@ var structTagObjectKeyTests = []struct {
value string
key string
}{
- {basicLatin2xTag{"2x"}, "2x", "$-"},
+ {basicLatin2xTag{"2x"}, "2x", "$%-/"},
{basicLatin3xTag{"3x"}, "3x", "0123456789"},
{basicLatin4xTag{"4x"}, "4x", "ABCDEFGHIJKLMO"},
{basicLatin5xTag{"5x"}, "5x", "PQRSTUVWXYZ_"},
@@ -68,6 +72,7 @@ var structTagObjectKeyTests = []struct {
{misnamedTag{"Animal Kingdom"}, "Animal Kingdom", "X"},
{badFormatTag{"Orfevre"}, "Orfevre", "Y"},
{badCodeTag{"Reliable Man"}, "Reliable Man", "Z"},
+ {percentSlashTag{"brut"}, "brut", "text/html%"},
}
func TestStructTagObjectKey(t *testing.T) {
@@ -88,7 +93,7 @@ func TestStructTagObjectKey(t *testing.T) {
t.Fatalf("Unexpected value: %#q, want %v", s, tt.value)
}
default:
- t.Fatalf("Unexpected key: %#q", i)
+ t.Fatalf("Unexpected key: %#q, from %#q", i, b)
}
}
}
diff --git a/libgo/go/encoding/xml/marshal_test.go b/libgo/go/encoding/xml/marshal_test.go
index bec53761e1a..f23b2cb7e08 100644
--- a/libgo/go/encoding/xml/marshal_test.go
+++ b/libgo/go/encoding/xml/marshal_test.go
@@ -150,6 +150,10 @@ type XMLNameWithoutTag struct {
Value string ",chardata"
}
+type NameInField struct {
+ Foo Name `xml:"ns foo"`
+}
+
type AttrTest struct {
Int int `xml:",attr"`
Lower int `xml:"int,attr"`
@@ -483,6 +487,19 @@ var marshalTests = []struct {
UnmarshalOnly: true,
},
+ // xml.Name works in a plain field as well.
+ {
+ Value: &NameInField{Name{Space: "ns", Local: "foo"}},
+ ExpectXML: ``,
+ },
+
+ // Marshaling zero xml.Name uses the tag or field name.
+ {
+ Value: &NameInField{},
+ ExpectXML: ``,
+ MarshalOnly: true,
+ },
+
// Test attributes
{
Value: &AttrTest{
diff --git a/libgo/go/encoding/xml/read.go b/libgo/go/encoding/xml/read.go
index dde68de3e78..4419ed1e477 100644
--- a/libgo/go/encoding/xml/read.go
+++ b/libgo/go/encoding/xml/read.go
@@ -271,6 +271,10 @@ func (p *Parser) unmarshal(val reflect.Value, start *StartElement) error {
case reflect.Struct:
sv = v
typ := sv.Type()
+ if typ == nameType {
+ v.Set(reflect.ValueOf(start.Name))
+ break
+ }
tinfo, err = getTypeInfo(typ)
if err != nil {
return err
diff --git a/libgo/go/encoding/xml/typeinfo.go b/libgo/go/encoding/xml/typeinfo.go
index 8f79c4e78bb..36b35ed2ee8 100644
--- a/libgo/go/encoding/xml/typeinfo.go
+++ b/libgo/go/encoding/xml/typeinfo.go
@@ -46,6 +46,8 @@ const (
var tinfoMap = make(map[reflect.Type]*typeInfo)
var tinfoLock sync.RWMutex
+var nameType = reflect.TypeOf(Name{})
+
// getTypeInfo returns the typeInfo structure with details necessary
// for marshalling and unmarshalling typ.
func getTypeInfo(typ reflect.Type) (*typeInfo, error) {
@@ -56,7 +58,7 @@ func getTypeInfo(typ reflect.Type) (*typeInfo, error) {
return tinfo, nil
}
tinfo = &typeInfo{}
- if typ.Kind() == reflect.Struct {
+ if typ.Kind() == reflect.Struct && typ != nameType {
n := typ.NumField()
for i := 0; i < n; i++ {
f := typ.Field(i)
diff --git a/libgo/go/exp/gotype/testdata/test1.go b/libgo/go/exp/gotype/testdata/test1.go
index a3298e6e5fe..ba8a51f135e 100644
--- a/libgo/go/exp/gotype/testdata/test1.go
+++ b/libgo/go/exp/gotype/testdata/test1.go
@@ -1,3 +1,7 @@
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
package p
func _() {
diff --git a/libgo/go/exp/inotify/inotify_linux_test.go b/libgo/go/exp/inotify/inotify_linux_test.go
index d035ec1410f..c2160fc6537 100644
--- a/libgo/go/exp/inotify/inotify_linux_test.go
+++ b/libgo/go/exp/inotify/inotify_linux_test.go
@@ -83,14 +83,15 @@ func TestInotifyClose(t *testing.T) {
watcher, _ := NewWatcher()
watcher.Close()
- done := false
+ done := make(chan bool)
go func() {
watcher.Close()
- done = true
+ done <- true
}()
- time.Sleep(50 * time.Millisecond)
- if !done {
+ select {
+ case <-done:
+ case <-time.After(50 * time.Millisecond):
t.Fatal("double Close() test failed: second Close() call didn't return")
}
diff --git a/libgo/go/exp/norm/trie_test.go b/libgo/go/exp/norm/trie_test.go
index 7308d281b50..c457c9d974a 100644
--- a/libgo/go/exp/norm/trie_test.go
+++ b/libgo/go/exp/norm/trie_test.go
@@ -1,3 +1,7 @@
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
package norm
import (
diff --git a/libgo/go/exp/proxy/proxy.go b/libgo/go/exp/proxy/proxy.go
index ccd3d1d8b8b..b6cfd45108a 100644
--- a/libgo/go/exp/proxy/proxy.go
+++ b/libgo/go/exp/proxy/proxy.go
@@ -11,7 +11,6 @@ import (
"net"
"net/url"
"os"
- "strings"
)
// A Dialer is a means to establish a connection.
@@ -70,14 +69,11 @@ func RegisterDialerType(scheme string, f func(*url.URL, Dialer) (Dialer, error))
// Dialer for it to make network requests.
func FromURL(u *url.URL, forward Dialer) (Dialer, error) {
var auth *Auth
- if len(u.RawUserinfo) > 0 {
+ if u.User != nil {
auth = new(Auth)
- parts := strings.SplitN(u.RawUserinfo, ":", 1)
- if len(parts) == 1 {
- auth.User = parts[0]
- } else if len(parts) >= 2 {
- auth.User = parts[0]
- auth.Password = parts[1]
+ auth.User = u.User.Username()
+ if p, ok := u.User.Password(); ok {
+ auth.Password = p
}
}
diff --git a/libgo/go/exp/ssh/client.go b/libgo/go/exp/ssh/client.go
index 8df81457bf5..eb6c0352210 100644
--- a/libgo/go/exp/ssh/client.go
+++ b/libgo/go/exp/ssh/client.go
@@ -306,9 +306,8 @@ type clientChan struct {
stdout *chanReader // receives the payload of channelData messages
stderr *chanReader // receives the payload of channelExtendedData messages
msg chan interface{} // incoming messages
-
- theyClosed bool // indicates the close msg has been received from the remote side
- weClosed bool // incidates the close msg has been sent from our side
+ theyClosed bool // indicates the close msg has been received from the remote side
+ weClosed bool // incidates the close msg has been sent from our side
}
// newClientChan returns a partially constructed *clientChan
diff --git a/libgo/go/exp/ssh/messages.go b/libgo/go/exp/ssh/messages.go
index cebb5609db3..34ad131ff64 100644
--- a/libgo/go/exp/ssh/messages.go
+++ b/libgo/go/exp/ssh/messages.go
@@ -484,6 +484,26 @@ func intLength(n *big.Int) int {
return length
}
+func marshalUint32(to []byte, n uint32) []byte {
+ to[0] = byte(n >> 24)
+ to[1] = byte(n >> 16)
+ to[2] = byte(n >> 8)
+ to[3] = byte(n)
+ return to[4:]
+}
+
+func marshalUint64(to []byte, n uint64) []byte {
+ to[0] = byte(n >> 56)
+ to[1] = byte(n >> 48)
+ to[2] = byte(n >> 40)
+ to[3] = byte(n >> 32)
+ to[4] = byte(n >> 24)
+ to[5] = byte(n >> 16)
+ to[6] = byte(n >> 8)
+ to[7] = byte(n)
+ return to[8:]
+}
+
func marshalInt(to []byte, n *big.Int) []byte {
lengthBytes := to
to = to[4:]
diff --git a/libgo/go/exp/ssh/session.go b/libgo/go/exp/ssh/session.go
index 807dd8740d7..ea4addbd50b 100644
--- a/libgo/go/exp/ssh/session.go
+++ b/libgo/go/exp/ssh/session.go
@@ -70,7 +70,7 @@ type Session struct {
started bool // true once Start, Run or Shell is invoked.
copyFuncs []func() error
- errch chan error // one send per copyFunc
+ errors chan error // one send per copyFunc
// true if pipe method is active
stdinpipe, stdoutpipe, stderrpipe bool
@@ -244,10 +244,10 @@ func (s *Session) start() error {
setupFd(s)
}
- s.errch = make(chan error, len(s.copyFuncs))
+ s.errors = make(chan error, len(s.copyFuncs))
for _, fn := range s.copyFuncs {
go func(fn func() error) {
- s.errch <- fn()
+ s.errors <- fn()
}(fn)
}
return nil
@@ -270,7 +270,7 @@ func (s *Session) Wait() error {
var copyError error
for _ = range s.copyFuncs {
- if err := <-s.errch; err != nil && copyError == nil {
+ if err := <-s.errors; err != nil && copyError == nil {
copyError = err
}
}
diff --git a/libgo/go/exp/ssh/tcpip.go b/libgo/go/exp/ssh/tcpip.go
index bee41eeb0db..e0c47bca1fc 100644
--- a/libgo/go/exp/ssh/tcpip.go
+++ b/libgo/go/exp/ssh/tcpip.go
@@ -9,6 +9,7 @@ import (
"fmt"
"io"
"net"
+ "time"
)
// Dial initiates a connection to the addr from the remote host.
@@ -107,27 +108,25 @@ func (t *tcpchanconn) RemoteAddr() net.Addr {
return t.raddr
}
-// SetTimeout sets the read and write deadlines associated
+// SetDeadline sets the read and write deadlines associated
// with the connection.
-func (t *tcpchanconn) SetTimeout(nsec int64) error {
- if err := t.SetReadTimeout(nsec); err != nil {
+func (t *tcpchanconn) SetDeadline(deadline time.Time) error {
+ if err := t.SetReadDeadline(deadline); err != nil {
return err
}
- return t.SetWriteTimeout(nsec)
+ return t.SetWriteDeadline(deadline)
}
-// SetReadTimeout sets the time (in nanoseconds) that
-// Read will wait for data before returning an error with Timeout() == true.
-// Setting nsec == 0 (the default) disables the deadline.
-func (t *tcpchanconn) SetReadTimeout(nsec int64) error {
- return errors.New("ssh: tcpchan: timeout not supported")
+// SetReadDeadline sets the read deadline.
+// A zero value for t means Read will not time out.
+// After the deadline, the error from Read will implement net.Error
+// with Timeout() == true.
+func (t *tcpchanconn) SetReadDeadline(deadline time.Time) error {
+ return errors.New("ssh: tcpchan: deadline not supported")
}
-// SetWriteTimeout sets the time (in nanoseconds) that
-// Write will wait to send its data before returning an error with Timeout() == true.
-// Setting nsec == 0 (the default) disables the deadline.
-// Even if write times out, it may return n > 0, indicating that
-// some of the data was successfully written.
-func (t *tcpchanconn) SetWriteTimeout(nsec int64) error {
- return errors.New("ssh: tcpchan: timeout not supported")
+// SetWriteDeadline exists to satisfy the net.Conn interface
+// but is not implemented by this type. It always returns an error.
+func (t *tcpchanconn) SetWriteDeadline(deadline time.Time) error {
+ return errors.New("ssh: tcpchan: deadline not supported")
}
diff --git a/libgo/go/exp/ssh/transport.go b/libgo/go/exp/ssh/transport.go
index 2e7c955a12d..e21bc4ba202 100644
--- a/libgo/go/exp/ssh/transport.go
+++ b/libgo/go/exp/ssh/transport.go
@@ -9,6 +9,7 @@ import (
"crypto"
"crypto/cipher"
"crypto/hmac"
+ "crypto/sha1"
"crypto/subtle"
"errors"
"hash"
@@ -266,7 +267,7 @@ func (c *common) setupKeys(d direction, K, H, sessionId []byte, hashFunc crypto.
generateKeyMaterial(key, d.keyTag, K, H, sessionId, h)
generateKeyMaterial(macKey, d.macKeyTag, K, H, sessionId, h)
- c.mac = truncatingMAC{12, hmac.NewSHA1(macKey)}
+ c.mac = truncatingMAC{12, hmac.New(sha1.New, macKey)}
cipher, err := cipherMode.createCipher(key, iv)
if err != nil {
@@ -328,6 +329,8 @@ func (t truncatingMAC) Size() int {
return t.length
}
+func (t truncatingMAC) BlockSize() int { return t.hmac.BlockSize() }
+
// maxVersionStringBytes is the maximum number of bytes that we'll accept as a
// version string. In the event that the client is talking a different protocol
// we need to set a limit otherwise we will keep using more and more memory
@@ -337,7 +340,7 @@ const maxVersionStringBytes = 1024
// Read version string as specified by RFC 4253, section 4.2.
func readVersion(r io.Reader) ([]byte, error) {
versionString := make([]byte, 0, 64)
- var ok, seenCR bool
+ var ok bool
var buf [1]byte
forEachByte:
for len(versionString) < maxVersionStringBytes {
@@ -345,27 +348,22 @@ forEachByte:
if err != nil {
return nil, err
}
- b := buf[0]
-
- if !seenCR {
- if b == '\r' {
- seenCR = true
- }
- } else {
- if b == '\n' {
- ok = true
- break forEachByte
- } else {
- seenCR = false
- }
+ // The RFC says that the version should be terminated with \r\n
+ // but several SSH servers actually only send a \n.
+ if buf[0] == '\n' {
+ ok = true
+ break forEachByte
}
- versionString = append(versionString, b)
+ versionString = append(versionString, buf[0])
}
if !ok {
- return nil, errors.New("failed to read version string")
+ return nil, errors.New("ssh: failed to read version string")
}
- // We need to remove the CR from versionString
- return versionString[:len(versionString)-1], nil
+ // There might be a '\r' on the end which we should remove.
+ if len(versionString) > 0 && versionString[len(versionString)-1] == '\r' {
+ versionString = versionString[:len(versionString)-1]
+ }
+ return versionString, nil
}
diff --git a/libgo/go/exp/ssh/transport_test.go b/libgo/go/exp/ssh/transport_test.go
index b2e2a7fc92a..ab9177f0d11 100644
--- a/libgo/go/exp/ssh/transport_test.go
+++ b/libgo/go/exp/ssh/transport_test.go
@@ -11,7 +11,7 @@ import (
)
func TestReadVersion(t *testing.T) {
- buf := []byte(serverVersion)
+ buf := serverVersion
result, err := readVersion(bufio.NewReader(bytes.NewBuffer(buf)))
if err != nil {
t.Errorf("readVersion didn't read version correctly: %s", err)
@@ -21,6 +21,20 @@ func TestReadVersion(t *testing.T) {
}
}
+func TestReadVersionWithJustLF(t *testing.T) {
+ var buf []byte
+ buf = append(buf, serverVersion...)
+ buf = buf[:len(buf)-1]
+ buf[len(buf)-1] = '\n'
+ result, err := readVersion(bufio.NewReader(bytes.NewBuffer(buf)))
+ if err != nil {
+ t.Error("readVersion failed to handle just a \n")
+ }
+ if !bytes.Equal(buf[:len(buf)-1], result) {
+ t.Errorf("version read did not match expected: got %x, want %x", result, buf[:len(buf)-1])
+ }
+}
+
func TestReadVersionTooLong(t *testing.T) {
buf := make([]byte, maxVersionStringBytes+1)
if _, err := readVersion(bufio.NewReader(bytes.NewBuffer(buf))); err == nil {
@@ -29,7 +43,7 @@ func TestReadVersionTooLong(t *testing.T) {
}
func TestReadVersionWithoutCRLF(t *testing.T) {
- buf := []byte(serverVersion)
+ buf := serverVersion
buf = buf[:len(buf)-1]
if _, err := readVersion(bufio.NewReader(bytes.NewBuffer(buf))); err == nil {
t.Error("readVersion did not notice \\n was missing")
diff --git a/libgo/go/exp/types/check_test.go b/libgo/go/exp/types/check_test.go
index ea9218ff51d..0e20646a005 100644
--- a/libgo/go/exp/types/check_test.go
+++ b/libgo/go/exp/types/check_test.go
@@ -47,17 +47,17 @@ var tests = []struct {
var fset = token.NewFileSet()
-// TODO(gri) This functionality should be in token.Fileset.
-func getFile(filename string) *token.File {
- for f := range fset.Files() {
+func getFile(filename string) (file *token.File) {
+ fset.Iterate(func(f *token.File) bool {
if f.Name() == filename {
- return f
+ file = f
+ return false // end iteration
}
- }
- return nil
+ return true
+ })
+ return file
}
-// TODO(gri) This functionality should be in token.Fileset.
func getPos(filename string, offset int) token.Pos {
if f := getFile(filename); f != nil {
return f.Pos(offset)
@@ -65,8 +65,6 @@ func getPos(filename string, offset int) token.Pos {
return token.NoPos
}
-// TODO(gri) Need to revisit parser interface. We should be able to use parser.ParseFiles
-// or a similar function instead.
func parseFiles(t *testing.T, testname string, filenames []string) (map[string]*ast.File, error) {
files := make(map[string]*ast.File)
var errors scanner.ErrorList
@@ -145,8 +143,6 @@ func eliminate(t *testing.T, expected map[token.Pos]string, errors error) {
for _, error := range errors.(scanner.ErrorList) {
// error.Pos is a token.Position, but we want
// a token.Pos so we can do a map lookup
- // TODO(gri) Need to move scanner.Errors over
- // to use token.Pos and file set info.
pos := getPos(error.Pos.Filename, error.Pos.Offset)
if msg, found := expected[pos]; found {
// we expect a message at pos; check if it matches
diff --git a/libgo/go/exp/types/gcimporter.go b/libgo/go/exp/types/gcimporter.go
index 10c56db21ff..a573fbb2463 100644
--- a/libgo/go/exp/types/gcimporter.go
+++ b/libgo/go/exp/types/gcimporter.go
@@ -460,29 +460,32 @@ func (p *gcParser) parseSignature() *Func {
return &Func{Params: params, Results: results, IsVariadic: isVariadic}
}
-// MethodSpec = ( identifier | ExportedName ) Signature .
+// MethodOrEmbedSpec = Name [ Signature ] .
//
-func (p *gcParser) parseMethodSpec() *ast.Object {
- if p.tok == scanner.Ident {
- p.expect(scanner.Ident)
- } else {
- p.parseExportedName()
+func (p *gcParser) parseMethodOrEmbedSpec() *ast.Object {
+ p.parseName()
+ if p.tok == '(' {
+ p.parseSignature()
+ // TODO(gri) compute method object
+ return ast.NewObj(ast.Fun, "_")
}
- p.parseSignature()
-
- // TODO(gri) compute method object
- return ast.NewObj(ast.Fun, "_")
+ // TODO lookup name and return that type
+ return ast.NewObj(ast.Typ, "_")
}
-// InterfaceType = "interface" "{" [ MethodList ] "}" .
-// MethodList = MethodSpec { ";" MethodSpec } .
+// InterfaceType = "interface" "{" [ MethodOrEmbedList ] "}" .
+// MethodOrEmbedList = MethodOrEmbedSpec { ";" MethodOrEmbedSpec } .
//
func (p *gcParser) parseInterfaceType() Type {
var methods ObjList
parseMethod := func() {
- meth := p.parseMethodSpec()
- methods = append(methods, meth)
+ switch m := p.parseMethodOrEmbedSpec(); m.Kind {
+ case ast.Typ:
+ // TODO expand embedded methods
+ case ast.Fun:
+ methods = append(methods, m)
+ }
}
p.expectKeyword("interface")
diff --git a/libgo/go/unicode/utf8/string.go b/libgo/go/exp/utf8string/string.go
similarity index 88%
rename from libgo/go/unicode/utf8/string.go
rename to libgo/go/exp/utf8string/string.go
index 443decf056c..da1e2de1ea2 100644
--- a/libgo/go/unicode/utf8/string.go
+++ b/libgo/go/exp/utf8string/string.go
@@ -2,9 +2,13 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-package utf8
+// Package utf8string provides an efficient way to index strings by rune rather than by byte.
+package utf8string
-import "errors"
+import (
+ "errors"
+ "unicode/utf8"
+)
// String wraps a regular string with a small structure that provides more
// efficient indexing by code point index, as opposed to byte index.
@@ -37,10 +41,10 @@ func (s *String) Init(contents string) *String {
s.bytePos = 0
s.runePos = 0
for i := 0; i < len(contents); i++ {
- if contents[i] >= RuneSelf {
+ if contents[i] >= utf8.RuneSelf {
// Not ASCII.
- s.numRunes = RuneCountInString(contents)
- _, s.width = DecodeRuneInString(contents)
+ s.numRunes = utf8.RuneCountInString(contents)
+ _, s.width = utf8.DecodeRuneInString(contents)
s.nonASCII = i
return s
}
@@ -121,7 +125,7 @@ func (s *String) At(i int) rune {
switch {
case i == s.runePos-1: // backing up one rune
- r, s.width = DecodeLastRuneInString(s.str[0:s.bytePos])
+ r, s.width = utf8.DecodeLastRuneInString(s.str[0:s.bytePos])
s.runePos = i
s.bytePos -= s.width
return r
@@ -130,16 +134,16 @@ func (s *String) At(i int) rune {
s.bytePos += s.width
fallthrough
case i == s.runePos:
- r, s.width = DecodeRuneInString(s.str[s.bytePos:])
+ r, s.width = utf8.DecodeRuneInString(s.str[s.bytePos:])
return r
case i == 0: // start of string
- r, s.width = DecodeRuneInString(s.str)
+ r, s.width = utf8.DecodeRuneInString(s.str)
s.runePos = 0
s.bytePos = 0
return r
case i == s.numRunes-1: // last rune in string
- r, s.width = DecodeLastRuneInString(s.str)
+ r, s.width = utf8.DecodeLastRuneInString(s.str)
s.runePos = i
s.bytePos = len(s.str) - s.width
return r
@@ -175,7 +179,7 @@ func (s *String) At(i int) rune {
if forward {
// TODO: Is it much faster to use a range loop for this scan?
for {
- r, s.width = DecodeRuneInString(s.str[s.bytePos:])
+ r, s.width = utf8.DecodeRuneInString(s.str[s.bytePos:])
if s.runePos == i {
break
}
@@ -184,7 +188,7 @@ func (s *String) At(i int) rune {
}
} else {
for {
- r, s.width = DecodeLastRuneInString(s.str[0:s.bytePos])
+ r, s.width = utf8.DecodeLastRuneInString(s.str[0:s.bytePos])
s.runePos--
s.bytePos -= s.width
if s.runePos == i {
diff --git a/libgo/go/unicode/utf8/string_test.go b/libgo/go/exp/utf8string/string_test.go
similarity index 88%
rename from libgo/go/unicode/utf8/string_test.go
rename to libgo/go/exp/utf8string/string_test.go
index 2c139bea98c..28511b2f5f1 100644
--- a/libgo/go/unicode/utf8/string_test.go
+++ b/libgo/go/exp/utf8string/string_test.go
@@ -2,14 +2,23 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-package utf8_test
+package utf8string
import (
"math/rand"
"testing"
- . "unicode/utf8"
+ "unicode/utf8"
)
+var testStrings = []string{
+ "",
+ "abcd",
+ "☺☻☹",
+ "日a本b語ç日ð本Ê語þ日¥本¼語i日©",
+ "日a本b語ç日ð本Ê語þ日¥本¼語i日©日a本b語ç日ð本Ê語þ日¥本¼語i日©日a本b語ç日ð本Ê語þ日¥本¼語i日©",
+ "\x80\x80\x80\x80",
+}
+
func TestScanForwards(t *testing.T) {
for _, s := range testStrings {
runes := []rune(s)
@@ -106,7 +115,7 @@ func TestLimitSliceAccess(t *testing.T) {
if str.Slice(0, 0) != "" {
t.Error("failure with empty slice at beginning")
}
- nr := RuneCountInString(s)
+ nr := utf8.RuneCountInString(s)
if str.Slice(nr, nr) != "" {
t.Error("failure with empty slice at end")
}
diff --git a/libgo/go/fmt/fmt_test.go b/libgo/go/fmt/fmt_test.go
index beb410fa117..504194ce467 100644
--- a/libgo/go/fmt/fmt_test.go
+++ b/libgo/go/fmt/fmt_test.go
@@ -508,27 +508,28 @@ func BenchmarkSprintfFloat(b *testing.B) {
var mallocBuf bytes.Buffer
+// gccgo numbers are different because gccgo does not have escape
+// analysis yet.
var mallocTest = []struct {
count int
desc string
fn func()
}{
- {0, `Sprintf("")`, func() { Sprintf("") }},
- {1, `Sprintf("xxx")`, func() { Sprintf("xxx") }},
- {1, `Sprintf("%x")`, func() { Sprintf("%x", 7) }},
- {2, `Sprintf("%s")`, func() { Sprintf("%s", "hello") }},
- {1, `Sprintf("%x %x")`, func() { Sprintf("%x %x", 7, 112) }},
- {1, `Sprintf("%g")`, func() { Sprintf("%g", 3.14159) }},
- {0, `Fprintf(buf, "%x %x %x")`, func() { mallocBuf.Reset(); Fprintf(&mallocBuf, "%x %x %x", 7, 8, 9) }},
- {1, `Fprintf(buf, "%s")`, func() { mallocBuf.Reset(); Fprintf(&mallocBuf, "%s", "hello") }},
+ {5, `Sprintf("")`, func() { Sprintf("") }},
+ {5, `Sprintf("xxx")`, func() { Sprintf("xxx") }},
+ {5, `Sprintf("%x")`, func() { Sprintf("%x", 7) }},
+ {5, `Sprintf("%s")`, func() { Sprintf("%s", "hello") }},
+ {5, `Sprintf("%x %x")`, func() { Sprintf("%x %x", 7, 112) }},
+ // For %g we use a float32, not float64, to guarantee passing the argument
+ // does not need to allocate memory to store the result in a pointer-sized word.
+ {20, `Sprintf("%g")`, func() { Sprintf("%g", float32(3.14159)) }},
+ {5, `Fprintf(buf, "%x %x %x")`, func() { mallocBuf.Reset(); Fprintf(&mallocBuf, "%x %x %x", 7, 8, 9) }},
+ {5, `Fprintf(buf, "%s")`, func() { mallocBuf.Reset(); Fprintf(&mallocBuf, "%s", "hello") }},
}
var _ bytes.Buffer
func TestCountMallocs(t *testing.T) {
- if testing.Short() {
- return
- }
for _, mt := range mallocTest {
const N = 100
runtime.UpdateMemStats()
@@ -538,7 +539,7 @@ func TestCountMallocs(t *testing.T) {
}
runtime.UpdateMemStats()
mallocs += runtime.MemStats.Mallocs
- if mallocs/N != uint64(mt.count) {
+ if mallocs/N > uint64(mt.count) {
t.Errorf("%s: expected %d mallocs, got %d", mt.desc, mt.count, mallocs/N)
}
}
diff --git a/libgo/go/go/build/path.go b/libgo/go/go/build/path.go
index bb9b8ca642a..b86f8288ea6 100644
--- a/libgo/go/go/build/path.go
+++ b/libgo/go/go/build/path.go
@@ -105,14 +105,14 @@ func FindTree(path string) (tree *Tree, pkg string, err error) {
continue
}
tree = t
- pkg = path[len(tpath):]
+ pkg = filepath.ToSlash(path[len(tpath):])
return
}
err = fmt.Errorf("path %q not inside a GOPATH", path)
return
}
tree = defaultTree
- pkg = path
+ pkg = filepath.ToSlash(path)
for _, t := range Path {
if t.HasSrc(pkg) {
tree = t
diff --git a/libgo/go/go/build/pkgtest/sqrt_test.go b/libgo/go/go/build/pkgtest/sqrt_test.go
index 95fb625525c..ee9fd5de688 100644
--- a/libgo/go/go/build/pkgtest/sqrt_test.go
+++ b/libgo/go/go/build/pkgtest/sqrt_test.go
@@ -1,3 +1,7 @@
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
package pkgtest
import "fmt"
diff --git a/libgo/go/go/build/pkgtest/xsqrt_test.go b/libgo/go/go/build/pkgtest/xsqrt_test.go
index 77e903d96ca..3898d1dda59 100644
--- a/libgo/go/go/build/pkgtest/xsqrt_test.go
+++ b/libgo/go/go/build/pkgtest/xsqrt_test.go
@@ -1,3 +1,7 @@
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
package pkgtest_test
import "pkgtest"
diff --git a/libgo/go/go/doc/comment.go b/libgo/go/go/doc/comment.go
index 060e37bff14..d73b1315954 100644
--- a/libgo/go/go/doc/comment.go
+++ b/libgo/go/go/doc/comment.go
@@ -68,7 +68,8 @@ var (
html_endp = []byte("
\n")
html_pre = []byte("")
html_endpre = []byte("
\n")
- html_h = []byte("