Skip to content

Commit

Permalink
Implement record roundtrip tests (matthewstevenson88#53)
Browse files Browse the repository at this point in the history
* draft code

* finished write impl.

* fixed record, added tests

* fixed tests

* fixed writing to buffer

* fixed merge conflicts with master

* added comments

* fixed some pr issues, fixed comments, added new methods and tests

* added constants

* added comments, fixed var names

* compeletely removed hex notation

* fixed pr issues, still working on tests

* fixed all tests except for read multiple records, impl create record with plaintext len 0

* fixed pr issues, all tests pass, added exceed maxPayloadLength test

* fixed constant definitions, pr issues

* split plaintext test passes, organized code

* added comments

* removed unusedBuf allocation

* fixed split record exceeding maxlength test

* added test max payload for all ciphersuites

* fixed return value to only be plaintext bytes, fixed pr issues.

* fixed comments, test descriptions, pr issues

* changed error bytes written calculation, removed error check in tests

* fixed multiple record writing to buffer

* removed min from totalNumOfrecordBytes, added tests for re-allocate buffer

* added test comments, moved constants, fixed pr issues

* fixed small comment

* added round trip tests

* fixed test error messages

* added different traffic secret test

* added more tests

* expanded conversation test

* fixed error msg

* removed TODO

* fixed read implementation and tests

* removed excess space

* added helper function, fixed pr issues

* fixed tests

* fixed roundtrip test
  • Loading branch information
davisgu authored Aug 6, 2020
1 parent 1109179 commit 7c6fba0
Show file tree
Hide file tree
Showing 2 changed files with 291 additions and 41 deletions.
4 changes: 2 additions & 2 deletions security/s2a/internal/record/record.go
Original file line number Diff line number Diff line change
Expand Up @@ -515,11 +515,11 @@ func (p *conn) readFullRecord() (fullRecord []byte, err error) {
// Keep reading from the wire until we have a complete record.
for len(fullRecord) == 0 {
if len(p.unusedBuf) == cap(p.unusedBuf) {
tmp := make([]byte, len(p.unusedBuf), cap(p.unusedBuf)+tlsRecordMaxPayloadSize)
tmp := make([]byte, len(p.unusedBuf), cap(p.unusedBuf)+tlsRecordMaxSize)
copy(tmp, p.unusedBuf)
p.unusedBuf = tmp
}
n, err := p.Conn.Read(p.unusedBuf[len(p.unusedBuf):min(cap(p.unusedBuf), len(p.unusedBuf)+tlsRecordMaxPayloadSize)])
n, err := p.Conn.Read(p.unusedBuf[len(p.unusedBuf):min(cap(p.unusedBuf), len(p.unusedBuf)+tlsRecordMaxSize)])
if err != nil {
return nil, err
}
Expand Down
Loading

0 comments on commit 7c6fba0

Please sign in to comment.