aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Langley <agl@golang.org>2010-12-16 10:39:53 -0500
committerAdam Langley <agl@golang.org>2010-12-16 10:39:53 -0500
commitfd021cbe8f768381285d9766360799cebdab3ac5 (patch)
treeb134a161009e9f65204620816fa393a3897785a5
parent0bf2aa1aa77b1280f4ad42779a3d4dcc74dab259 (diff)
downloadgo-fd021cbe8f768381285d9766360799cebdab3ac5.tar.gz
go-fd021cbe8f768381285d9766360799cebdab3ac5.zip
crypto/tls: check in support code.
This support code helps in generating the handshake scripts which are used for testing. R=rsc, ality CC=golang-dev https://golang.org/cl/3680041
-rw-r--r--src/pkg/crypto/tls/handshake_server_test.go9
-rw-r--r--src/pkg/crypto/tls/parse-gnutls-cli-debug-log.py55
2 files changed, 60 insertions, 4 deletions
diff --git a/src/pkg/crypto/tls/handshake_server_test.go b/src/pkg/crypto/tls/handshake_server_test.go
index ad82e3945f..255273cc3c 100644
--- a/src/pkg/crypto/tls/handshake_server_test.go
+++ b/src/pkg/crypto/tls/handshake_server_test.go
@@ -189,10 +189,11 @@ var testPrivateKey = &rsa.PrivateKey{
}
// Script of interaction with gnutls implementation.
-// The values for this test are obtained by building a test binary (gotest)
-// and then running 6.out -serve to start a server and then
-// gnutls-cli --insecure --debug 100 -p 10443 localhost
-// to dump a session.
+// The values for this test are obtained by building and running in server mode:
+// % gotest -match "TestRunServer" -serve
+// and then:
+// % gnutls-cli --insecure --debug 100 -p 10443 localhost > /tmp/log 2>&1
+// % python parse-gnutls-cli-debug-log.py < /tmp/log
var rc4ServerScript = [][]byte{
{
0x16, 0x03, 0x02, 0x00, 0x7f, 0x01, 0x00, 0x00,
diff --git a/src/pkg/crypto/tls/parse-gnutls-cli-debug-log.py b/src/pkg/crypto/tls/parse-gnutls-cli-debug-log.py
new file mode 100644
index 0000000000..c03eaa6eae
--- /dev/null
+++ b/src/pkg/crypto/tls/parse-gnutls-cli-debug-log.py
@@ -0,0 +1,55 @@
+# Copyright 2010 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.
+
+# This code is used to parse the debug log from gnutls-cli and generate a
+# script of the handshake. This script is included in handshake_server_test.go.
+# See the comments there for details.
+
+import sys
+
+blocks = []
+
+READ = 1
+WRITE = 2
+
+currentBlockType = 0
+currentBlock = []
+for line in sys.stdin.readlines():
+ line = line[:-1]
+ if line.startswith("|<7>| WRITE: "):
+ if currentBlockType != WRITE:
+ if len(currentBlock) > 0:
+ blocks.append(currentBlock)
+ currentBlock = []
+ currentBlockType = WRITE
+ elif line.startswith("|<7>| READ: "):
+ if currentBlockType != READ:
+ if len(currentBlock) > 0:
+ blocks.append(currentBlock)
+ currentBlock = []
+ currentBlockType = READ
+ elif line.startswith("|<7>| 0"):
+ line = line[13:]
+ line = line.strip()
+ bs = line.split()
+ for b in bs:
+ currentBlock.append(int(b, 16))
+
+if len(currentBlock) > 0:
+ blocks.append(currentBlock)
+
+for block in blocks:
+ sys.stdout.write("\t{\n")
+
+ i = 0
+ for b in block:
+ if i % 8 == 0:
+ sys.stdout.write("\t\t")
+ sys.stdout.write("0x%02x," % b)
+ if i % 8 == 7:
+ sys.stdout.write("\n")
+ else:
+ sys.stdout.write(" ")
+ i += 1
+ sys.stdout.write("\n\t},\n\n")