Pass additional parameters to decrypt() in test runner.

By having the caller provide the sequence number and the record header
length, the decrypt function doesn't need to know anything about the
format of the record header.

Change-Id: If3389e79d6823c63c884bb9ddb764fa68223e765
Bug: 715
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/69948
Commit-Queue: Bob Beck <bbe@google.com>
Reviewed-by: Bob Beck <bbe@google.com>
diff --git a/ssl/test/runner/conn.go b/ssl/test/runner/conn.go
index b2a81fb..9cb9fde 100644
--- a/ssl/test/runner/conn.go
+++ b/ssl/test/runner/conn.go
@@ -416,9 +416,7 @@
 // success boolean, the number of bytes to skip from the start of the record in
 // order to get the application payload, the encrypted record type (or 0
 // if there is none), and an optional alert value.
-func (hc *halfConn) decrypt(b *block) (ok bool, prefixLen int, contentType recordType, alertValue alert) {
-	recordHeaderLen := hc.recordHeaderLen()
-
+func (hc *halfConn) decrypt(seq []byte, recordHeaderLen int, b *block) (ok bool, prefixLen int, contentType recordType, alertValue alert) {
 	// pull out payload
 	payload := b.data[recordHeaderLen:]
 
@@ -430,12 +428,6 @@
 	paddingGood := byte(255)
 	explicitIVLen := 0
 
-	seq := hc.seq[:]
-	if hc.isDTLS {
-		// DTLS sequence numbers are explicit.
-		seq = b.data[3:11]
-	}
-
 	// decrypt
 	if hc.cipher != nil {
 		switch c := hc.cipher.(type) {
@@ -873,7 +865,7 @@
 
 	// Process message.
 	b, c.rawInput = c.in.splitBlock(b, recordHeaderLen+n)
-	ok, off, encTyp, alertValue := c.in.decrypt(b)
+	ok, off, encTyp, alertValue := c.in.decrypt(c.in.seq[:], recordHeaderLen, b)
 
 	// Handle skipping over early data.
 	if !ok && c.skipEarlyData {
diff --git a/ssl/test/runner/dtls.go b/ssl/test/runner/dtls.go
index d407867..9be916a 100644
--- a/ssl/test/runner/dtls.go
+++ b/ssl/test/runner/dtls.go
@@ -101,7 +101,7 @@
 	b, c.rawInput = c.in.splitBlock(b, recordHeaderLen+n)
 
 	// Process message.
-	ok, off, _, alertValue := c.in.decrypt(b)
+	ok, off, _, alertValue := c.in.decrypt(b.data[3:11], recordHeaderLen, b)
 	if !ok {
 		// A real DTLS implementation would silently ignore bad records,
 		// but we want to notice errors from the implementation under