~ubuntu-branches/ubuntu/vivid/golang/vivid

« back to all changes in this revision

Viewing changes to src/pkg/crypto/tls/parse-gnutls-cli-debug-log.py

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2013-08-20 14:06:23 UTC
  • mfrom: (14.1.23 saucy-proposed)
  • Revision ID: package-import@ubuntu.com-20130820140623-b414jfxi3m0qkmrq
Tags: 2:1.1.2-2ubuntu1
* Merge from Debian unstable (LP: #1211749, #1202027). Remaining changes:
  - 016-armhf-elf-header.patch: Use correct ELF header for armhf binaries.
  - d/control,control.cross: Update Breaks/Replaces for Ubuntu
    versions to ensure smooth upgrades, regenerate control file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright 2010 The Go Authors. All rights reserved.
2
 
# Use of this source code is governed by a BSD-style
3
 
# license that can be found in the LICENSE file.
4
 
 
5
 
# This code is used to parse the debug log from gnutls-cli and generate a
6
 
# script of the handshake. This script is included in handshake_server_test.go.
7
 
# See the comments there for details.
8
 
 
9
 
import sys
10
 
 
11
 
blocks = []
12
 
 
13
 
READ = 1
14
 
WRITE = 2
15
 
 
16
 
currentBlockType = 0
17
 
currentBlock = []
18
 
for line in sys.stdin.readlines():
19
 
        line = line[:-1]
20
 
        if line.startswith("|<7>| WRITE: "):
21
 
                if currentBlockType != WRITE:
22
 
                        if len(currentBlock) > 0:
23
 
                                blocks.append(currentBlock)
24
 
                        currentBlock = []
25
 
                        currentBlockType = WRITE
26
 
        elif line.startswith("|<7>| READ: "):
27
 
                if currentBlockType != READ:
28
 
                        if len(currentBlock) > 0:
29
 
                                blocks.append(currentBlock)
30
 
                        currentBlock = []
31
 
                        currentBlockType = READ
32
 
        elif line.startswith("|<7>| 0"):
33
 
                line = line[13:]
34
 
                line = line.strip()
35
 
                bs = line.split()
36
 
                for b in bs:
37
 
                        currentBlock.append(int(b, 16))
38
 
        elif line.startswith("|<7>| RB-PEEK: Read 1 bytes"):
39
 
                currentBlock = currentBlock[:-1]
40
 
 
41
 
if len(currentBlock) > 0:
42
 
        blocks.append(currentBlock)
43
 
 
44
 
for block in blocks:
45
 
        sys.stdout.write("\t{\n")
46
 
 
47
 
        i = 0
48
 
        for b in block:
49
 
                if i % 8 == 0:
50
 
                        sys.stdout.write("\t\t")
51
 
                sys.stdout.write("0x%02x," % b)
52
 
                if i % 8 == 7:
53
 
                        sys.stdout.write("\n")
54
 
                else:
55
 
                        sys.stdout.write(" ")
56
 
                i += 1
57
 
        sys.stdout.write("\n\t},\n\n")