summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Wu <lekensteyn@gmail.com>2013-09-16 14:17:46 +0200
committerPeter Wu <lekensteyn@gmail.com>2013-09-16 14:17:46 +0200
commit290682f032b4516c11d8882bf27ec3dca9b750dd (patch)
tree60c6cc43c98b8b9d1d44b61d56f2a0415b50fb12
parent492adbe1c145156b094d5a0442cecb4715c739ba (diff)
downloadwireshark-notes-290682f032b4516c11d8882bf27ec3dca9b750dd.tar.gz
openssl-connect: print keys earlier
-rwxr-xr-xopenssl-connect26
1 files changed, 17 insertions, 9 deletions
diff --git a/openssl-connect b/openssl-connect
index d4e2689..af6fa9b 100755
--- a/openssl-connect
+++ b/openssl-connect
@@ -9,7 +9,9 @@ s_client_client_random() {
awk '
# match Master-Key from SSL Session dump
/Master-Key:/{key=$2}
- {
+
+ # start matching bytes when requested
+ l > 0 {
b=1;e=16;
if(l==3)b=7;
if(l==1)e=6;
@@ -18,20 +20,26 @@ s_client_client_random() {
# at the end, save random value in map r
if (l--==1)
- r[s]=1
+ queued[s] = 1;
}
# Match block containing Crandom bytes (over three lines)
/ ClientHello|ServerHello$/{l=3;s=""}
- END{
- has_random = 0;
- for (rnd in r) {
+ # whenever a key and random is available, print it. This allows the random
+ # to be known before the connection is finished.
+ key {
+ for (rnd in queued) {
has_random = 1;
- if (key)
- print "CLIENT_RANDOM", rnd, key
- else
- print "# No master key for random", rnd
+ print "CLIENT_RANDOM", rnd, key
+ delete queued[rnd];
+ }
+ fflush();
+ }
+
+ END {
+ for (rnd in queued) {
+ print "# No master key for random", rnd
}
# should not be possible since the first thing we sent out is a
# ClientHello, but just to be sure...