Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 
 
 

56 rader
1.8 KiB

  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. # This code is used to parse the debug log from gnutls-cli and generate a
  5. # script of the handshake. This script is included in handshake_server_test.go.
  6. # See the comments there for details.
  7. import sys
  8. blocks = []
  9. READ = 1
  10. WRITE = 2
  11. currentBlockType = 0
  12. currentBlock = []
  13. for line in sys.stdin.readlines():
  14. line = line[:-1]
  15. if line.startswith("|<7>| WRITE: "):
  16. if currentBlockType != WRITE:
  17. if len(currentBlock) > 0:
  18. blocks.append(currentBlock)
  19. currentBlock = []
  20. currentBlockType = WRITE
  21. elif line.startswith("|<7>| READ: "):
  22. if currentBlockType != READ:
  23. if len(currentBlock) > 0:
  24. blocks.append(currentBlock)
  25. currentBlock = []
  26. currentBlockType = READ
  27. elif line.startswith("|<7>| 0"):
  28. line = line[13:]
  29. line = line.strip()
  30. bs = line.split()
  31. for b in bs:
  32. currentBlock.append(int(b, 16))
  33. if len(currentBlock) > 0:
  34. blocks.append(currentBlock)
  35. for block in blocks:
  36. sys.stdout.write("\t{\n")
  37. i = 0
  38. for b in block:
  39. if i % 8 == 0:
  40. sys.stdout.write("\t\t")
  41. sys.stdout.write("0x%02x," % b)
  42. if i % 8 == 7:
  43. sys.stdout.write("\n")
  44. else:
  45. sys.stdout.write(" ")
  46. i += 1
  47. sys.stdout.write("\n\t},\n\n")