├── LICENSE ├── README.md ├── setup_cryptopp.sh ├── tls-diff-testing ├── Makefile ├── apps │ ├── attack_matrixssl │ │ ├── Makefile │ │ └── src │ │ │ └── attack_matrixssl.cpp │ ├── python_plot_cov │ │ ├── plot_cov.py │ │ └── print_totalcov.py │ ├── python_plot_urs │ │ └── plot_urs.py │ └── stimulator │ │ ├── Makefile │ │ └── src │ │ └── stimulator.cpp ├── bitman │ ├── Doxyfile │ ├── Makefile │ ├── inc │ │ ├── BC.h │ │ ├── Buffer.h │ │ ├── BufferModifier.h │ │ ├── BufferReader.h │ │ ├── BufferStreamReader.h │ │ ├── BufferWindowReader.h │ │ ├── BufferWriter.h │ │ ├── CompositeDataUnit.h │ │ ├── DataUnit.h │ │ ├── DataUnitConverter.h │ │ ├── DataUnitCursor.h │ │ ├── DataUnitFilter.h │ │ ├── DataUnitFragment.h │ │ ├── DataUnitOperator.h │ │ ├── DataUnitStream.h │ │ ├── DataUnitVisitor.h │ │ ├── DecisionReader.h │ │ ├── DequeRingBuffer.h │ │ ├── Dissector.h │ │ ├── EnumerationField.h │ │ ├── FieldDataUnit.h │ │ ├── FileStreamReader.h │ │ ├── FuzzOperator.h │ │ ├── IntegerField.h │ │ ├── OpaqueField.h │ │ ├── PropertyNode.h │ │ ├── RingBuffer.h │ │ ├── StaticVectorDataUnit.h │ │ ├── StreamReader.h │ │ ├── StreamStreamReader.h │ │ ├── StreamVectorDataUnit.h │ │ ├── StringField.h │ │ ├── StringUtils.h │ │ ├── String_.h │ │ ├── Value.h │ │ ├── VectorBuffer.h │ │ ├── VectorDataUnit.h │ │ └── VoidField.h │ └── src │ │ ├── BC.cpp │ │ ├── Buffer.cpp │ │ ├── BufferModifier.cpp │ │ ├── BufferReader.cpp │ │ ├── BufferStreamReader.cpp │ │ ├── BufferWindowReader.cpp │ │ ├── BufferWriter.cpp │ │ ├── CompositeDataUnit.cpp │ │ ├── DataUnit.cpp │ │ ├── DataUnitConverter.cpp │ │ ├── DataUnitCursor.cpp │ │ ├── DataUnitFilter.cpp │ │ ├── DataUnitFragment.cpp │ │ ├── DataUnitOperator.cpp │ │ ├── DataUnitStream.cpp │ │ ├── DataUnitVisitor.cpp │ │ ├── DecisionReader.cpp │ │ ├── DequeRingBuffer.cpp │ │ ├── Dissector.cpp │ │ ├── EnumerationField.cpp │ │ ├── FieldDataUnit.cpp │ │ ├── FileStreamReader.cpp │ │ ├── FuzzOperator.cpp │ │ ├── IntegerField.cpp │ │ ├── OpaqueField.cpp │ │ ├── PropertyNode.cpp │ │ ├── RingBuffer.cpp │ │ ├── StaticVectorDataUnit.cpp │ │ ├── StreamReader.cpp │ │ ├── StreamStreamReader.cpp │ │ ├── StreamVectorDataUnit.cpp │ │ ├── StringField.cpp │ │ ├── StringUtils.cpp │ │ ├── String_.cpp │ │ ├── Value.cpp │ │ ├── VectorBuffer.cpp │ │ ├── VectorDataUnit.cpp │ │ ├── VoidField.cpp │ │ └── main.cpp ├── cryptoman │ ├── Makefile │ ├── inc │ │ ├── HMAC.h │ │ ├── MessageDigest.h │ │ └── SHA256.h │ └── src │ │ ├── HMAC.cpp │ │ ├── MessageDigest.cpp │ │ ├── SHA256.cpp │ │ └── main.cpp ├── cryptopp.path ├── generator │ ├── Makefile │ ├── macros │ │ └── generate_multi.sh │ └── src │ │ └── generate.cpp ├── middleman │ ├── Makefile │ ├── inc │ │ ├── Socket.h │ │ ├── TCPBatchClientSocket.h │ │ ├── TCPClientSocket.h │ │ ├── TCPServerSocket.h │ │ ├── TCPSocket.h │ │ ├── TransportRelay.h │ │ ├── UDPClientSocket.h │ │ └── UDPSocket.h │ └── src │ │ ├── Socket.cpp │ │ ├── TCPBatchClientSocket.cpp │ │ ├── TCPClientSocket.cpp │ │ ├── TCPServerSocket.cpp │ │ ├── TCPSocket.cpp │ │ ├── TransportRelay.cpp │ │ ├── UDPClientSocket.cpp │ │ ├── UDPSocket.cpp │ │ └── middleman.cpp ├── tls-definitions.etpl └── tls-definitions.h └── tls-server-batch ├── cacert.pem ├── cert.pem ├── key.pem ├── launch.sh ├── setup.sh └── stop.sh /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (C) 2017 2 | Andreas Walz [andreas.walz@hs-offenburg.de] 3 | Offenburg University of Applied Sciences 4 | Institute of Reliable Embedded Systems and Communications Electronics (ivESK) 5 | [https://ivesk.hs-offenburg.de/] 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright notice, 12 | this list of conditions and the following disclaimer. 13 | 14 | 2. Redistributions in binary form must reproduce the above copyright notice, 15 | this list of conditions and the following disclaimer in the documentation 16 | and/or other materials provided with the distribution. 17 | 18 | 3. Neither the name of the copyright holder nor the names of its contributors 19 | may be used to endorse or promote products derived from this software 20 | without specific prior written permission. 21 | 22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 26 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | POSSIBILITY OF SUCH DAMAGE. 33 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Differential fuzz testing of the TLS handshake 2 | 3 | This is the software implementing our differential fuzz test approach for the 4 | TLS handshake as presented in our manuscript "Exploiting Dissent: Towards 5 | Fuzzing-based Differential Black-Box Testing of TLS Implementations". The paper 6 | will soon appear in IEEE Transactions on Dependable and Secure Computing (TDSC). 7 | A [preprint](https://ivesk.hs-offenburg.de/fileadmin/Einrichtungen/ivesk/files/preprint_TLS-Diff-Fuzzing_IEEE-TDSC.pdf) is available from our [institute's homepage](https://ivesk.hs-offenburg.de). 8 | 9 | The software consists of two main components: 10 | * A shell script ("tls-server-batch") allowing to set up the five TLS server implementations 11 | we used in our paper (OpenSSL, MatrixSSL, wolfSSL, mbedTLS and BoringSSL). 12 | * A C++ framework and some Python scripts ("tls-diff-testing") for generating TLS 13 | test messages, stimulating the five TLS servers, and for analyzing and visualizing 14 | data. 15 | 16 | Please note: our software is evolving and is likely going to be subject to 17 | refactoring and restructuring. We cannot guarantee API stability in any form. 18 | 19 | 20 | ## How to use the code? 21 | 22 | In order to use our software: 23 | 24 | 1. Download and build cryptopp 25 | 26 | Our software uses the [Crypto++ Cryptographic Library](https://www.cryptopp.com/) for cryptographic operations. You need to download and build Crypto++ before building our software. Everything is condensed in the shell script setup_cryptopp.sh: 27 | 28 | ```bash 29 | # Download and build cryptopp 30 | ./setup_cryptopp.sh 31 | ``` 32 | 33 | 2. Setup TLS implementations (servers). Some of them might require additional software/libraries to be installed. 34 | 35 | ```bash 36 | pushd tls-server-batch 37 | # Download and build OpenSSL, MatrixSSL, wolfSSL, mbedTLS and BoringSSL 38 | ./setup.sh 39 | popd 40 | ``` 41 | 42 | 3. Build tls-diff-testing components 43 | 44 | ```bash 45 | pushd tls-diff-testing 46 | # Build tls-diff-testing components 47 | make 48 | ``` 49 | 50 | 4. Generate test input (TLS ClientHello messages) 51 | 52 | ```bash 53 | pushd generator 54 | # Run input generation tool multiple times (adapt parameters to your needs within shell script) 55 | ./macros/generate_multi.sh 56 | popd 57 | popd 58 | ``` 59 | 60 | 5. Send test input to TLS servers 61 | 62 | ```bash 63 | pushd tls-server-batch 64 | # Launch servers (20 instances per implementation, adapt the number "20" to the performance of your machine) 65 | # You will need the "screen" tool for that. 66 | ./launch.sh 20 67 | popd 68 | 69 | pushd tls-diff-testing/apps/stimulator 70 | # Stimulate TLS servers (adapt "-s20" to the number chosen above) 71 | for fin in $(ls ../../generator/iteration-*/stimuli.hex); do 72 | ./stimulator -S5 -s20 $fin | tee ${fin}.responses 73 | done 74 | popd 75 | ``` 76 | 77 | 6. Plot data. You need to have Python 2.7.x and Matplotlib for Python installed. 78 | 79 | ```bash 80 | pushd tls-diff-testing/apps/python_plot_urs 81 | # Read response data and plot (adapt paths within Python script before) 82 | ./plot_urs.py 83 | popd 84 | ``` 85 | 86 | 87 | ## Contact 88 | 89 | In case you have any questions or suggestions regarding our approach or our software tools, please contact: Andreas Walz [andreas.walz@hs-offenburg.de]. 90 | 91 | 92 | ## Copyright and License 93 | 94 | This software is licensed under the 3-clause BSD license. This license gives 95 | everyone the right to use and distribute the code, either in binary or source 96 | code format, as long as the copyright license is retained in the source code. 97 | 98 | Copyright (C) 2017 99 | Andreas Walz [andreas.walz@hs-offenburg.de] 100 | Offenburg University of Applied Sciences 101 | Institute of Reliable Embedded Systems and Communications Electronics (ivESK) 102 | [https://ivesk.hs-offenburg.de/] 103 | All rights reserved. 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | -------------------------------------------------------------------------------- /setup_cryptopp.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | wget https://github.com/weidai11/cryptopp/archive/CRYPTOPP_5_6_5.tar.gz \ 4 | && tar -xzf CRYPTOPP_5_6_5.tar.gz \ 5 | && mv cryptopp-CRYPTOPP_5_6_5 cryptopp \ 6 | && cd cryptopp \ 7 | && make 8 | 9 | -------------------------------------------------------------------------------- /tls-diff-testing/Makefile: -------------------------------------------------------------------------------- 1 | export PROF 2 | 3 | export TOOLS_ROOT=$(shell pwd) 4 | 5 | all: bitman cryptoman middleman generator stimulator 6 | 7 | .PHONY: bitman cryptoman middleman clean generator stimulator 8 | 9 | bitman: 10 | @echo "\033[01;32m==> Building 'bitman'\033[00;00m" 11 | $(MAKE) -C bitman 12 | 13 | cryptoman: bitman 14 | @echo "\033[01;32m==> Building 'cryptoman'\033[00;00m" 15 | $(MAKE) -C cryptoman 16 | 17 | middleman: bitman cryptoman 18 | @echo "\033[01;32m==> Building 'middleman'\033[00;00m" 19 | $(MAKE) -C middleman 20 | 21 | generator: bitman cryptoman middleman 22 | @echo "\033[01;32m==> Building 'generator'\033[00;00m" 23 | $(MAKE) -C generator 24 | 25 | stimulator: bitman cryptoman middleman 26 | @echo "\033[01;32m==> Building 'stimulator'\033[00;00m" 27 | $(MAKE) -C apps/stimulator 28 | 29 | clean: 30 | @echo "\033[01;31m==> Cleaning directories:\033[00;00m" 31 | $(MAKE) -C bitman clean 32 | $(MAKE) -C cryptoman clean 33 | $(MAKE) -C middleman clean 34 | $(MAKE) -C generator clean 35 | $(MAKE) -C apps/stimulator clean 36 | @echo "" 37 | 38 | -------------------------------------------------------------------------------- /tls-diff-testing/apps/attack_matrixssl/Makefile: -------------------------------------------------------------------------------- 1 | SRC_SUFFIX = .cpp 2 | 3 | EXECUTABLE = $(shell basename $(shell pwd)) 4 | 5 | SRC_DIR = src 6 | INC_DIRS = inc ../../bitman/inc ../../cryptoman/inc ../../middleman/inc 7 | LIB_DIRS = ../../bitman/build ../../cryptoman/build ../../middleman/build 8 | 9 | BUILD_DIR = build 10 | OBJ_DIR = $(BUILD_DIR)/obj 11 | PREP_DIR = $(BUILD_DIR)/prep 12 | LIBOBJ_DIR = 13 | 14 | LIBS = middleman cryptoman bitman cryptopp 15 | 16 | 17 | # define compiler 18 | CC = g++ 19 | 20 | # define macros 21 | MACROS = _LINUX 22 | 23 | # define architecture 24 | ARCH = 25 | 26 | CFLAGS = -c -Wall $(foreach d, $(INC_DIRS), -I$d) $(foreach d, $(MACROS), -D$d) $(ARCH) -O0 -g $(PROF) 27 | LDFLAGS = $(ARCH) $(foreach d, $(LIB_DIRS), -L$d) $(foreach d, $(LIBS), -l$d) $(PROF) 28 | 29 | 30 | MAIN_SRC = $(SRC_DIR)/$(EXECUTABLE)$(SRC_SUFFIX) 31 | SOURCES_ = $(shell ls $(SRC_DIR)/*$(SRC_SUFFIX)) 32 | SOURCES = $(filter-out $(MAIN_SRC),$(SOURCES_)) 33 | 34 | OBJECTS_ = $(SOURCES:$(SRC_SUFFIX)=.o) 35 | OBJECTS = $(OBJECTS_:$(SRC_DIR)/%=$(OBJ_DIR)/%) 36 | PREPS = $(SOURCES_:$(SRC_DIR)/%=$(PREP_DIR)/%) 37 | MAIN_OBJ_ = $(MAIN_SRC:$(SRC_SUFFIX)=.o) 38 | MAIN_OBJ = $(MAIN_OBJ_:$(SRC_DIR)/%=$(OBJ_DIR)/%) 39 | 40 | LIB_OBJS = $(shell ls $(LIBOBJ_DIR)/*.o 2>/dev/null) 41 | 42 | 43 | all: executable 44 | 45 | exec: executable 46 | 47 | prep: preprocessed 48 | 49 | executable: $(OBJECTS) $(MAIN_OBJ) 50 | @echo "\033[01;33m==> Creating executable '$(BUILD_DIR)/$(EXECUTABLE)':\033[00;00m" 51 | @mkdir -p $(BUILD_DIR) 52 | $(CC) $(OBJECTS) $(MAIN_OBJ) -o $(BUILD_DIR)/$(EXECUTABLE) $(LDFLAGS) 53 | @echo "" 54 | @echo "\033[01;33m==> Creating link '$(EXECUTABLE)' to executable '$(BUILD_DIR)/$(EXECUTABLE)':\033[00;00m" 55 | @rm -rf $(EXECUTABLE) 56 | ln -s $(BUILD_DIR)/$(EXECUTABLE) $(EXECUTABLE) 57 | @echo "" 58 | 59 | preprocessed: $(PREPS) 60 | 61 | $(OBJ_DIR)/%.o: $(SRC_DIR)/%$(SRC_SUFFIX) 62 | @echo "\033[01;32m==> Compiling '$<':\033[00;00m" 63 | @mkdir -p $(OBJ_DIR) 64 | $(CC) $(CFLAGS) $< -o $@ 65 | @echo "" 66 | 67 | $(PREP_DIR)/%: $(SRC_DIR)/% 68 | @echo "\033[01;32m==> Preprocessing '$<':\033[00;00m" 69 | @mkdir -p $(PREP_DIR) 70 | $(CC) $(CFLAGS) $< -E > $@ 71 | @echo "" 72 | 73 | clean: 74 | @echo "\033[01;31m==> Cleaning directories:\033[00;00m" 75 | rm -rf $(BUILD_DIR)/ 76 | rm -rf $(EXECUTABLE) 77 | @echo "" 78 | -------------------------------------------------------------------------------- /tls-diff-testing/apps/python_plot_cov/plot_cov.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import sys 4 | import matplotlib.pyplot as plot 5 | import itertools 6 | import random 7 | from bitarray import bitarray 8 | 9 | 10 | # 11 | # _____________________________________________________________________________ 12 | # 13 | def main(argv): 14 | 15 | files1 = ['/home/walz/data/tls-diff-testing/stimuli-20170511-the-man-tools/iteration-{0:03}/stimuli.hex.accepted.coverage'.format(i) for i in range(10)] 16 | 17 | files2 = ['/home/walz/data/tls-diff-testing/stimuli-20170510-afl/stimuli_{0:08}.txt.accepted.coverage'.format(i) for i in range(1, 11)] 18 | 19 | files3 = ['/home/walz/data/tls-diff-testing/stimuli-20170511-TLSAttacker/iteration-{0:03}/stimuli_phase{1}.hex.accepted.coverage'.format(i, j) for i, j in itertools.product(range(7), range(1, 4))] 20 | 21 | plotCoverage(readCoverage(files1), 'red') 22 | plotCoverage(readCoverage(files2), 'blue') 23 | plotCoverage(readCoverage(files3), 'green') 24 | 25 | plot.xscale('log') 26 | 27 | plot.show() 28 | 29 | 30 | # 31 | # _____________________________________________________________________________ 32 | # 33 | def plotCoverage(coverage, color): 34 | 35 | accu = None 36 | 37 | X = range(len(coverage) + 1) 38 | Y = [0] 39 | 40 | for cov in coverage: 41 | if accu is None: 42 | accu = bitarray(len(cov)) 43 | elif len(accu) != len(cov): 44 | print('Inconsistent lengths!!') 45 | return 46 | accu = accu | cov 47 | Y += [accu.count(True)] 48 | 49 | plot.plot(X, Y, color=color) 50 | 51 | 52 | # 53 | # _____________________________________________________________________________ 54 | # 55 | def readCoverage(filenames, nmax=None): 56 | 57 | coverage = [] 58 | 59 | # left, right = 0, 479 60 | # left, right = 479, 1320 61 | # left, right = 1320, 1614 62 | left, right = 479, 1614 63 | 64 | for filename in filenames: 65 | print('Reading file {0} ...'.format(filename)) 66 | for line in open(filename): 67 | (myid, mycov) = line.split(':')[:2] 68 | coverage.append(bitarray(mycov.strip()[left:right])) 69 | 70 | print('Read {0} coverage entries!'.format(len(coverage))) 71 | 72 | return coverage 73 | 74 | 75 | # 76 | # _____________________________________________________________________________ 77 | # 78 | if __name__ == "__main__": 79 | main(sys.argv[1:]) 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /tls-diff-testing/apps/python_plot_cov/print_totalcov.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import sys 4 | import math 5 | import matplotlib.pyplot as plot 6 | import itertools 7 | import random 8 | from bitarray import bitarray 9 | import glob 10 | 11 | 12 | # 13 | # _____________________________________________________________________________ 14 | # 15 | def main(argv): 16 | 17 | # TODO: Change paths to point to your response files 18 | pathBase = 'tls-diff-testing' 19 | pathTheManTools = pathBase + '/stimuli-20170607-the-man-tools' 20 | pathAFL = pathBase + '/stimuli-20170607-afl' 21 | pathTLSAttacker = pathBase + '/stimuli-20170607-TLSAttacker' 22 | pathNezha = pathBase + '/stimuli-20170607-nezha' 23 | 24 | datasets = [ 25 | 26 | # the-man-tools 27 | { 28 | 'name': 'Our approach', 29 | 'master': True, 30 | 'files' : [pathTheManTools + '/iteration-{0:03}/stimuli.hex.cumulative-coverage'.format(n) for n in range(0, 100)], 31 | 'color': 'red', 32 | 'linestyle': '-', 33 | 'linewidth': 2., 34 | }, 35 | 36 | # AFL 37 | { 38 | 'name': '\\afl', 39 | 'files' : [pathAFL + '/iteration-{0:03}/stimuli_0000000x.txt.cumulative-coverage'.format(n + 1) for n in range(0, 100)], 40 | 'color': 'green', 41 | 'linestyle': '-', 42 | 'linewidth': 2., 43 | }, 44 | 45 | # TLS-Attacker 46 | { 47 | 'name': '\\tlsattacker', 48 | 'files' : [pathTLSAttacker + '/iteration-{0:03}/stimuli_phase1.hex.accepted.cumulative-coverage'.format(n + 1) for n in range(0, 100)], 49 | 'color': 'blue', 50 | 'linestyle': '-', 51 | 'linewidth': 2., 52 | }, 53 | 54 | # Nezha 55 | { 56 | 'name': '\\nezha', 57 | 'files' : [pathNezha + '/iteration-{0:03}/stimuli_0000000x.txt.cumulative-coverage'.format(n) for n in range(1, 101)], 58 | 'color': 'black', 59 | 'linestyle': '-', 60 | 'linewidth': 2., 61 | }, 62 | 63 | ] 64 | 65 | 66 | for dataset in datasets: 67 | cov = readCoverageFiles(dataset['files']) 68 | 69 | N = len(cov) 70 | s = sum(cov) 71 | s2 = sum(map(lambda x: x**2, cov)) 72 | 73 | mean = s / N 74 | stdv = math.sqrt(s2*N - s**2) / (N - 1) 75 | 76 | dataset['cov'] = cov 77 | dataset['mean'] = mean 78 | dataset['stdv'] = stdv 79 | 80 | 81 | # for dataset in datasets: 82 | # cov = map(lambda c: c / masterCov, dataset['cov']) 83 | # cov = dataset['cov'] 84 | # plot.hist(cov, bins=20, range=(20, 30), histtype='stepfilled', alpha=0.75, 85 | # color=dataset.get('color', 'black'), 86 | # linestyle=dataset.get('linestyle', '-'), 87 | # linewidth=dataset.get('linewidth', 0.5)) 88 | 89 | 90 | 91 | for cov, index in sorted([(-ds['mean'], index) \ 92 | for index, ds in enumerate(datasets)]): 93 | 94 | dataset = datasets[index] 95 | 96 | print('{0:25} & {1:2.1f} $\\pm$ {2:2.1f} \\\\'.format(dataset['name'], dataset['mean'], dataset['stdv'])) 97 | 98 | plot.show() 99 | 100 | # 101 | # _____________________________________________________________________________ 102 | # 103 | def readCoverage(filename): 104 | 105 | f = open(filename) 106 | 107 | # get last line 108 | for line in f: 109 | pass 110 | 111 | cov = float(line.split(':')[1].split('%')[0]) 112 | 113 | return cov 114 | 115 | 116 | # 117 | # _____________________________________________________________________________ 118 | # 119 | def readCoverageFiles(filenames, nmax=None): 120 | 121 | coverage = [] 122 | 123 | for pattern in filenames: 124 | print(' -> File pattern: "{0}"'.format(pattern)) 125 | files = sorted(glob.glob(pattern)) 126 | if len(files) == 0: 127 | print(' -> no matching files') 128 | continue 129 | 130 | for filename in files: 131 | print(' -> Reading file "{0}" ...'.format(filename)) 132 | coverage += [readCoverage(filename)] 133 | 134 | print('Read {0} coverage files!'.format(len(coverage))) 135 | 136 | return coverage 137 | 138 | 139 | # 140 | # _____________________________________________________________________________ 141 | # 142 | if __name__ == "__main__": 143 | main(sys.argv[1:]) 144 | 145 | 146 | 147 | 148 | -------------------------------------------------------------------------------- /tls-diff-testing/apps/stimulator/Makefile: -------------------------------------------------------------------------------- 1 | SRC_SUFFIX = .cpp 2 | 3 | EXECUTABLE = $(shell basename $(shell pwd)) 4 | 5 | SRC_DIR = src 6 | INC_DIRS = ../../bitman/inc ../../cryptoman/inc ../../middleman/inc 7 | LIB_DIRS = ../../bitman/build ../../cryptoman/build ../../middleman/build ../../../cryptopp 8 | 9 | BUILD_DIR = build 10 | OBJ_DIR = $(BUILD_DIR)/obj 11 | PREP_DIR = $(BUILD_DIR)/prep 12 | LIBOBJ_DIR = 13 | 14 | LIBS = middleman cryptoman bitman cryptopp 15 | 16 | 17 | # define compiler 18 | CC = g++ 19 | 20 | # define macros 21 | MACROS = _LINUX 22 | 23 | # define architecture 24 | ARCH = 25 | 26 | CFLAGS = -c -Wall $(foreach d, $(INC_DIRS), -I$d) $(foreach d, $(MACROS), -D$d) $(ARCH) -O0 -g $(PROF) 27 | LDFLAGS = $(ARCH) $(foreach d, $(LIB_DIRS), -L$d) $(foreach d, $(LIBS), -l$d) $(PROF) 28 | 29 | 30 | MAIN_SRC = $(SRC_DIR)/$(EXECUTABLE)$(SRC_SUFFIX) 31 | SOURCES_ = $(shell ls $(SRC_DIR)/*$(SRC_SUFFIX)) 32 | SOURCES = $(filter-out $(MAIN_SRC),$(SOURCES_)) 33 | 34 | OBJECTS_ = $(SOURCES:$(SRC_SUFFIX)=.o) 35 | OBJECTS = $(OBJECTS_:$(SRC_DIR)/%=$(OBJ_DIR)/%) 36 | PREPS = $(SOURCES_:$(SRC_DIR)/%=$(PREP_DIR)/%) 37 | MAIN_OBJ_ = $(MAIN_SRC:$(SRC_SUFFIX)=.o) 38 | MAIN_OBJ = $(MAIN_OBJ_:$(SRC_DIR)/%=$(OBJ_DIR)/%) 39 | 40 | LIB_OBJS = $(shell ls $(LIBOBJ_DIR)/*.o 2>/dev/null) 41 | 42 | 43 | all: executable 44 | 45 | exec: executable 46 | 47 | prep: preprocessed 48 | 49 | executable: $(OBJECTS) $(MAIN_OBJ) 50 | @echo "\033[01;33m==> Creating executable '$(BUILD_DIR)/$(EXECUTABLE)':\033[00;00m" 51 | @mkdir -p $(BUILD_DIR) 52 | $(CC) $(OBJECTS) $(MAIN_OBJ) -o $(BUILD_DIR)/$(EXECUTABLE) $(LDFLAGS) 53 | @echo "" 54 | @echo "\033[01;33m==> Creating link '$(EXECUTABLE)' to executable '$(BUILD_DIR)/$(EXECUTABLE)':\033[00;00m" 55 | @rm -rf $(EXECUTABLE) 56 | ln -s $(BUILD_DIR)/$(EXECUTABLE) $(EXECUTABLE) 57 | @echo "" 58 | 59 | preprocessed: $(PREPS) 60 | 61 | $(OBJ_DIR)/%.o: $(SRC_DIR)/%$(SRC_SUFFIX) 62 | @echo "\033[01;32m==> Compiling '$<':\033[00;00m" 63 | @mkdir -p $(OBJ_DIR) 64 | $(CC) $(CFLAGS) $< -o $@ 65 | @echo "" 66 | 67 | $(PREP_DIR)/%: $(SRC_DIR)/% 68 | @echo "\033[01;32m==> Preprocessing '$<':\033[00;00m" 69 | @mkdir -p $(PREP_DIR) 70 | $(CC) $(CFLAGS) $< -E > $@ 71 | @echo "" 72 | 73 | clean: 74 | @echo "\033[01;31m==> Cleaning directories:\033[00;00m" 75 | rm -rf $(BUILD_DIR)/ 76 | rm -rf $(EXECUTABLE) 77 | @echo "" 78 | -------------------------------------------------------------------------------- /tls-diff-testing/bitman/Makefile: -------------------------------------------------------------------------------- 1 | SRC_SUFFIX = .cpp 2 | 3 | LIBRARY = bitman 4 | EXECUTABLE = main 5 | 6 | SRC_DIR = src 7 | INC_DIRS = inc 8 | LIB_DIRS = lib 9 | 10 | BUILD_DIR = build 11 | OBJ_DIR = $(BUILD_DIR)/obj 12 | PREP_DIR = $(BUILD_DIR)/prep 13 | LIBOBJ_DIR = 14 | 15 | LIBS = 16 | 17 | 18 | # define compiler 19 | CC = g++ 20 | 21 | # define macros 22 | #MACROS = _LINUX 23 | MACROS = 24 | 25 | # define architecture 26 | ARCH = 27 | 28 | CFLAGS = -c -Wall $(foreach d, $(INC_DIRS), -I$d) $(foreach d, $(MACROS), -D$d) $(ARCH) -O0 -g $(PROF) 29 | LDFLAGS = $(ARCH) $(foreach d, $(LIB_DIRS), -L$d) $(foreach d, $(LIBS), -l$d) $(PROF) 30 | 31 | 32 | MAIN_SRC = $(SRC_DIR)/$(EXECUTABLE)$(SRC_SUFFIX) 33 | SOURCES_ = $(shell ls $(SRC_DIR)/*$(SRC_SUFFIX)) 34 | SOURCES = $(filter-out $(MAIN_SRC),$(SOURCES_)) 35 | 36 | OBJECTS_ = $(SOURCES:$(SRC_SUFFIX)=.o) 37 | OBJECTS = $(OBJECTS_:$(SRC_DIR)/%=$(OBJ_DIR)/%) 38 | PREPS = $(SOURCES_:$(SRC_DIR)/%=$(PREP_DIR)/%) 39 | MAIN_OBJ_ = $(MAIN_SRC:$(SRC_SUFFIX)=.o) 40 | MAIN_OBJ = $(MAIN_OBJ_:$(SRC_DIR)/%=$(OBJ_DIR)/%) 41 | 42 | LIB_OBJS = $(shell ls $(LIBOBJ_DIR)/*.o 2>/dev/null) 43 | 44 | 45 | all: executable library 46 | 47 | lib: library 48 | 49 | exec: executable 50 | 51 | prep: preprocessed 52 | 53 | .PHONY: doc 54 | doc: 55 | @mkdir -p doc/ 56 | @doxygen 57 | 58 | executable: $(OBJECTS) $(MAIN_OBJ) 59 | @echo "\033[01;33m==> Creating executable '$(BUILD_DIR)/$(EXECUTABLE)':\033[00;00m" 60 | @mkdir -p $(BUILD_DIR) 61 | $(CC) $(OBJECTS) $(MAIN_OBJ) -o $(BUILD_DIR)/$(EXECUTABLE) $(LDFLAGS) 62 | @echo "" 63 | @echo "\033[01;33m==> Creating link '$(EXECUTABLE)' to executable '$(BUILD_DIR)/$(EXECUTABLE)':\033[00;00m" 64 | @rm -rf $(EXECUTABLE) 65 | ln -s $(BUILD_DIR)/$(EXECUTABLE) $(EXECUTABLE) 66 | @echo "" 67 | 68 | library: $(OBJECTS) 69 | @echo "\033[01;33m==> Creating static library '$@':\033[00;00m" 70 | @mkdir -p $(BUILD_DIR) 71 | ar rcs $(BUILD_DIR)/lib$(LIBRARY).a $(OBJECTS) $(LIB_OBJS) 72 | @echo "" 73 | 74 | preprocessed: $(PREPS) 75 | 76 | $(OBJ_DIR)/%.o: $(SRC_DIR)/%$(SRC_SUFFIX) 77 | @echo "\033[01;32m==> Compiling '$<':\033[00;00m" 78 | @mkdir -p $(OBJ_DIR) 79 | $(CC) $(CFLAGS) $< -o $@ 80 | @echo "" 81 | 82 | $(PREP_DIR)/%: $(SRC_DIR)/% 83 | @echo "\033[01;32m==> Preprocessing '$<':\033[00;00m" 84 | @mkdir -p $(PREP_DIR) 85 | $(CC) $(CFLAGS) $< -E > $@ 86 | @echo "" 87 | 88 | clean: 89 | @echo "\033[01;31m==> Cleaning directories:\033[00;00m" 90 | rm -rf $(BUILD_DIR)/ 91 | rm -rf $(EXECUTABLE) 92 | @echo "" 93 | 94 | -------------------------------------------------------------------------------- /tls-diff-testing/bitman/inc/Buffer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 3 | * Andreas Walz [andreas.walz@hs-offenburg.de] 4 | * Offenburg University of Applied Sciences 5 | * Institute of Reliable Embedded Systems and Communications Electronics (ivESK) 6 | * [https://ivesk.hs-offenburg.de/] 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | */ 36 | 37 | #ifndef __Buffer_H__ 38 | #define __Buffer_H__ 39 | 40 | #include "BC.h" 41 | #include "BufferReader.h" 42 | #include "BufferWriter.h" 43 | #include "BufferModifier.h" 44 | 45 | 46 | class Buffer : public BufferReader, public BufferWriter, public BufferModifier { 47 | 48 | private: 49 | 50 | /* TODO: Add description */ 51 | BC capacity_; 52 | 53 | 54 | public: 55 | 56 | /* TODO: Add description */ 57 | Buffer(); 58 | 59 | /* TODO: Add description */ 60 | Buffer(const BC& capacity); 61 | 62 | 63 | /* TODO: Add description */ 64 | inline BC getCapacity() const { 65 | 66 | return capacity_; 67 | } 68 | 69 | /* TODO: Add description */ 70 | BC getRemainingCapacity() const; 71 | 72 | 73 | /* TODO: Add description */ 74 | virtual ~Buffer(); 75 | 76 | }; 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /tls-diff-testing/bitman/inc/BufferModifier.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 3 | * Andreas Walz [andreas.walz@hs-offenburg.de] 4 | * Offenburg University of Applied Sciences 5 | * Institute of Reliable Embedded Systems and Communications Electronics (ivESK) 6 | * [https://ivesk.hs-offenburg.de/] 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | */ 36 | 37 | #ifndef __BufferModifier_H__ 38 | #define __BufferModifier_H__ 39 | 40 | #include 41 | 42 | class BC; 43 | 44 | 45 | /* ========================================================================== 46 | * 47 | * Inheriting classes need to implement: 48 | * 49 | * 50 | * ========================================================================== */ 51 | 52 | class BufferModifier { 53 | 54 | public: 55 | 56 | /* TODO: Add description */ 57 | BufferModifier(); 58 | 59 | /* --------------------------------------------------------------------- */ 60 | 61 | /* TODO: Add description */ 62 | virtual bool setBit(const BC& bc, bool bit) = 0; 63 | 64 | /* TODO: Add description */ 65 | virtual bool setByte(const BC& bc, uint8_t byte) = 0; 66 | 67 | /* TODO: Add description */ 68 | virtual void clear() = 0; 69 | 70 | /* TODO: Add description */ 71 | virtual void truncate(const BC& length) = 0; 72 | 73 | /* --------------------------------------------------------------------- */ 74 | 75 | /* TODO: Add description */ 76 | virtual ~BufferModifier(); 77 | 78 | }; 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /tls-diff-testing/bitman/inc/BufferStreamReader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 3 | * Andreas Walz [andreas.walz@hs-offenburg.de] 4 | * Offenburg University of Applied Sciences 5 | * Institute of Reliable Embedded Systems and Communications Electronics (ivESK) 6 | * [https://ivesk.hs-offenburg.de/] 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | */ 36 | 37 | #ifndef __BufferStreamReader_H__ 38 | #define __BufferStreamReader_H__ 39 | 40 | #include "BC.h" 41 | #include "String_.h" 42 | #include "Buffer.h" 43 | #include "StreamReader.h" 44 | 45 | 46 | /* ========================================================================= 47 | * 48 | * 49 | * 50 | * ========================================================================= */ 51 | 52 | class BufferStreamReader : public StreamReader { 53 | 54 | private: 55 | 56 | /* TODO: Add description */ 57 | const BufferReader& reader_; 58 | 59 | /* TODO: Add description */ 60 | BC pos_; 61 | 62 | 63 | protected: 64 | 65 | /* --- from StreamReader class: ---------------------------------------- */ 66 | 67 | /* TODO: Add description */ 68 | virtual uint8_t readByte_(bool remove = true); 69 | 70 | /* TODO: Add description */ 71 | virtual bool readBit_(bool remove = true); 72 | 73 | /* --- from StreamReader -> BufferReader class: ------------------------ */ 74 | 75 | /* TODO: Add description */ 76 | virtual bool getBit_(const BC& bc) const; 77 | 78 | /* TODO: Add description */ 79 | virtual uint8_t getByte_(const BC& bc) const; 80 | 81 | /* TODO: Add description */ 82 | virtual BC copyTo_(BufferWriter& buffer) const; 83 | 84 | /* TODO: Add description */ 85 | virtual BC getLength_() const; 86 | 87 | /* --------------------------------------------------------------------- */ 88 | 89 | 90 | public: 91 | 92 | /* TODO: Add description */ 93 | BufferStreamReader(const BufferReader& reader); 94 | 95 | 96 | /* TODO: Add description */ 97 | inline void reset() { 98 | 99 | pos_ = 0; 100 | } 101 | 102 | /* TODO: Add description */ 103 | inline void setPosition(const BC& pos) { 104 | 105 | /* don't change 'pos_' if 'pos' is undefined */ 106 | pos_ = pos.isDef() ? pos : pos_; 107 | } 108 | 109 | /* TODO: Add description */ 110 | inline BC getPosition() const { 111 | 112 | return pos_; 113 | } 114 | 115 | 116 | /* TODO: Add description */ 117 | virtual ~BufferStreamReader(); 118 | 119 | }; 120 | 121 | #endif 122 | -------------------------------------------------------------------------------- /tls-diff-testing/bitman/inc/BufferWindowReader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 3 | * Andreas Walz [andreas.walz@hs-offenburg.de] 4 | * Offenburg University of Applied Sciences 5 | * Institute of Reliable Embedded Systems and Communications Electronics (ivESK) 6 | * [https://ivesk.hs-offenburg.de/] 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | */ 36 | 37 | #ifndef __BufferWindowReader_H__ 38 | #define __BufferWindowReader_H__ 39 | 40 | #include "BC.h" 41 | #include "BufferReader.h" 42 | 43 | 44 | /* ========================================================================= 45 | * 46 | * 47 | * 48 | * ========================================================================= */ 49 | 50 | class BufferWindowReader : public BufferReader { 51 | 52 | private: 53 | 54 | /* TODO: Add description */ 55 | const BufferReader& reader_; 56 | 57 | /* TODO: Add description */ 58 | BC offset_; 59 | 60 | /* TODO: Add description */ 61 | BC length_; 62 | 63 | 64 | protected: 65 | 66 | /* --- from BufferReader class: ---------------------------------------- */ 67 | 68 | /* TODO: Add description */ 69 | virtual bool getBit_(const BC& bc) const; 70 | 71 | /* TODO: Add description */ 72 | virtual uint8_t getByte_(const BC& bc) const; 73 | 74 | /* TODO: Add description */ 75 | virtual BC copyTo_(BufferWriter& buffer) const; 76 | 77 | /* TODO: Add description */ 78 | virtual BC getLength_() const; 79 | 80 | /* --------------------------------------------------------------------- */ 81 | 82 | 83 | public: 84 | 85 | /* TODO: Add description */ 86 | BufferWindowReader(const BufferReader& reader, 87 | BC offset = 0, BC length = -1); 88 | 89 | 90 | /* TODO: Add description */ 91 | virtual ~BufferWindowReader(); 92 | 93 | }; 94 | 95 | #endif 96 | -------------------------------------------------------------------------------- /tls-diff-testing/bitman/inc/DataUnitConverter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 3 | * Andreas Walz [andreas.walz@hs-offenburg.de] 4 | * Offenburg University of Applied Sciences 5 | * Institute of Reliable Embedded Systems and Communications Electronics (ivESK) 6 | * [https://ivesk.hs-offenburg.de/] 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | */ 36 | 37 | #ifndef __DataUnitConverter_H__ 38 | #define __DataUnitConverter_H__ 39 | 40 | #include "DataUnit.h" 41 | 42 | 43 | /* ========================================================================= 44 | * 45 | * 46 | * 47 | * ========================================================================= */ 48 | 49 | class DataUnitConverter { 50 | 51 | private: 52 | 53 | const DataUnit& dataUnit_; 54 | 55 | /* TODO: Add description */ 56 | std::string getAsJSON_(const DataUnit& dataUnit) const; 57 | 58 | 59 | public: 60 | 61 | /* TODO: Add description */ 62 | DataUnitConverter(const DataUnit& dataUnit); 63 | 64 | 65 | /* TODO: Add description */ 66 | std::string getAsJSON() const; 67 | 68 | 69 | /* TODO: Add description */ 70 | virtual ~DataUnitConverter(); 71 | 72 | }; 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /tls-diff-testing/bitman/inc/DataUnitStream.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 3 | * Andreas Walz [andreas.walz@hs-offenburg.de] 4 | * Offenburg University of Applied Sciences 5 | * Institute of Reliable Embedded Systems and Communications Electronics (ivESK) 6 | * [https://ivesk.hs-offenburg.de/] 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | */ 36 | 37 | #ifndef __Protocol_H__ 38 | #define __Protocol_H__ 39 | 40 | #include 41 | #include "StreamVectorDataUnit.h" 42 | 43 | class DataUnitFragment; 44 | 45 | 46 | /* ========================================================================== 47 | * 48 | * 49 | * 50 | * ========================================================================== */ 51 | 52 | class DataUnitStream : public StreamVectorDataUnit { 53 | 54 | private: 55 | 56 | /* this class type's descriptor */ 57 | static TypeDescriptor desc_; 58 | 59 | 60 | /* TODO: Add description */ 61 | std::vector fragments_; 62 | 63 | 64 | public: 65 | 66 | /* TODO: Add description */ 67 | static inline const TypeDescriptor& typeDescriptor() { 68 | 69 | return desc_; 70 | } 71 | 72 | 73 | /* TODO: Add description */ 74 | DataUnitStream(DataUnit* unit); 75 | 76 | 77 | /* TODO: Add description */ 78 | const TypeDescriptor& getTypeDescriptor() const; 79 | 80 | 81 | /* TODO: Add description */ 82 | DataUnitFragment* newFragment(const BC& size = -1); 83 | 84 | 85 | /* TODO: Add description */ 86 | virtual ~DataUnitStream(); 87 | 88 | }; 89 | 90 | #endif 91 | -------------------------------------------------------------------------------- /tls-diff-testing/bitman/inc/DataUnitVisitor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 3 | * Andreas Walz [andreas.walz@hs-offenburg.de] 4 | * Offenburg University of Applied Sciences 5 | * Institute of Reliable Embedded Systems and Communications Electronics (ivESK) 6 | * [https://ivesk.hs-offenburg.de/] 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | */ 36 | 37 | #ifndef __DataUnitVisitor_H__ 38 | #define __DataUnitVisitor_H__ 39 | 40 | #include 41 | 42 | class DataUnit; 43 | 44 | 45 | /* ========================================================================== 46 | * 47 | * 48 | * 49 | * ========================================================================== */ 50 | 51 | class DataUnitVisitor { 52 | 53 | private: 54 | 55 | /* TODO: Add description */ 56 | size_t visit(DataUnit& dataUnit, size_t index, size_t depth); 57 | 58 | 59 | protected: 60 | 61 | /* TODO: Add description */ 62 | virtual bool visiting(DataUnit& dataUnit, size_t index, size_t depth) = 0; 63 | 64 | 65 | public: 66 | 67 | /* TODO: Add description */ 68 | DataUnitVisitor(); 69 | 70 | /* TODO: Add description */ 71 | size_t visit(DataUnit& dataUnit); 72 | 73 | /* TODO: Add description */ 74 | virtual ~DataUnitVisitor(); 75 | 76 | }; 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /tls-diff-testing/bitman/inc/DecisionReader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 3 | * Andreas Walz [andreas.walz@hs-offenburg.de] 4 | * Offenburg University of Applied Sciences 5 | * Institute of Reliable Embedded Systems and Communications Electronics (ivESK) 6 | * [https://ivesk.hs-offenburg.de/] 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | */ 36 | 37 | #ifndef __DecisionReader_H__ 38 | #define __DecisionReader_H__ 39 | 40 | #include "StreamReader.h" 41 | 42 | 43 | /* ========================================================================== 44 | * 45 | * 46 | * 47 | * ========================================================================== */ 48 | 49 | class DecisionReader : public StreamReader { 50 | 51 | private: 52 | 53 | /* TODO: Add description */ 54 | StreamReader& streamer_; 55 | 56 | 57 | protected: 58 | 59 | /* --- from StreamReader class: ---------------------------------------- */ 60 | 61 | /* TODO: Add description */ 62 | inline uint8_t readByte_(bool remove = true) { 63 | 64 | return streamer_.readByte(remove); 65 | } 66 | 67 | /* TODO: Add description */ 68 | inline bool readBit_(bool remove = true) { 69 | 70 | return streamer_.readBit(remove); 71 | } 72 | 73 | /* --- from StreamReader -> BufferReader class: ------------------------ */ 74 | 75 | /* TODO: Add description */ 76 | inline bool getBit_(const BC& bc) const { 77 | 78 | return streamer_.getBit(bc); 79 | } 80 | 81 | /* TODO: Add description */ 82 | inline uint8_t getByte_(const BC& bc) const { 83 | 84 | return streamer_.getByte(bc); 85 | } 86 | 87 | /* TODO: Add description */ 88 | inline BC copyTo_(BufferWriter& buffer) const { 89 | 90 | return streamer_.copyTo(buffer); 91 | } 92 | 93 | /* TODO: Add description */ 94 | inline BC getLength_() const { 95 | 96 | return streamer_.getLength(); 97 | } 98 | 99 | /* --------------------------------------------------------------------- */ 100 | 101 | 102 | public: 103 | 104 | /* TODO: Add description */ 105 | DecisionReader(StreamReader& streamer); 106 | 107 | 108 | inline StreamReader& getStreamReader() { 109 | 110 | return streamer_; 111 | } 112 | 113 | 114 | /* TODO: Add description */ 115 | bool readBoolUniform(); 116 | 117 | /* TODO: Add description */ 118 | size_t readUIntUniform(size_t max); 119 | 120 | /* TODO: Add description */ 121 | size_t readUIntExponential(size_t num, size_t denom); 122 | 123 | 124 | /* TODO: Add description */ 125 | virtual ~DecisionReader(); 126 | 127 | }; 128 | 129 | #endif 130 | -------------------------------------------------------------------------------- /tls-diff-testing/bitman/inc/DequeRingBuffer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 3 | * Andreas Walz [andreas.walz@hs-offenburg.de] 4 | * Offenburg University of Applied Sciences 5 | * Institute of Reliable Embedded Systems and Communications Electronics (ivESK) 6 | * [https://ivesk.hs-offenburg.de/] 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | */ 36 | 37 | #ifndef __DequeRingBuffer_H__ 38 | #define __DequeRingBuffer_H__ 39 | 40 | #include 41 | #include 42 | #include "RingBuffer.h" 43 | 44 | 45 | /* ========================================================================== 46 | * 47 | * --------------------------------- 48 | * | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | 49 | * --------------------------------- 50 | * 51 | * ========================================================================== */ 52 | 53 | class DequeRingBuffer : public RingBuffer { 54 | 55 | private: 56 | 57 | /* TODO: Add description */ 58 | std::deque data_; 59 | 60 | /* TODO: Add description */ 61 | uint8_t writeBitOff_; 62 | 63 | /* TODO: Add description */ 64 | uint8_t readBitOff_; 65 | 66 | 67 | protected: 68 | 69 | /* --- from RingBuffer -> StreamReader -> BufferReader class: ---------- */ 70 | 71 | /* TODO: Add description */ 72 | virtual bool getBit_(const BC& bc) const; 73 | 74 | /* TODO: Add description */ 75 | virtual uint8_t getByte_(const BC& bc) const; 76 | 77 | /* TODO: Add description */ 78 | virtual BC copyTo_(BufferWriter& buffer) const; 79 | 80 | /* TODO: Add description */ 81 | virtual BC getLength_() const; 82 | 83 | /* --- from RingBuffer -> StreamReader class: -------------------------- */ 84 | 85 | /* TODO: Add description */ 86 | virtual uint8_t readByte_(bool remove = true); 87 | 88 | /* TODO: Add description */ 89 | virtual bool readBit_(bool remove = true); 90 | 91 | /* --- from RingBuffer class: ------------------------------------------ */ 92 | 93 | /* TODO: Add description */ 94 | virtual void clear_(); 95 | 96 | /* --------------------------------------------------------------------- */ 97 | 98 | 99 | public: 100 | 101 | /* TODO: Add description */ 102 | DequeRingBuffer(); 103 | 104 | /* TODO: Add description */ 105 | DequeRingBuffer(const BC& capacity); 106 | 107 | /* --- from RingBuffer -> BufferWriter class: -------------------------- */ 108 | 109 | /* TODO: Add description */ 110 | virtual bool appendBit(bool bit); 111 | 112 | /* TODO: Add description */ 113 | virtual bool appendByte(uint8_t byte); 114 | 115 | /* TODO: Add description */ 116 | virtual bool setBit(const BC& bc, bool bit); 117 | 118 | /* TODO: Add description */ 119 | virtual bool setByte(const BC& bc, uint8_t byte); 120 | 121 | /* --------------------------------------------------------------------- */ 122 | 123 | /* TODO: Add description */ 124 | virtual ~DequeRingBuffer(); 125 | 126 | }; 127 | 128 | #endif 129 | -------------------------------------------------------------------------------- /tls-diff-testing/bitman/inc/FileStreamReader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 3 | * Andreas Walz [andreas.walz@hs-offenburg.de] 4 | * Offenburg University of Applied Sciences 5 | * Institute of Reliable Embedded Systems and Communications Electronics (ivESK) 6 | * [https://ivesk.hs-offenburg.de/] 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | */ 36 | 37 | #ifndef __FileStreamReader_H__ 38 | #define __FileStreamReader_H__ 39 | 40 | #include 41 | #include 42 | #include 43 | #include "BC.h" 44 | #include "String_.h" 45 | #include "Buffer.h" 46 | #include "StreamReader.h" 47 | #include "DequeRingBuffer.h" 48 | 49 | 50 | /* ========================================================================== 51 | * 52 | * 53 | * 54 | * ========================================================================== */ 55 | 56 | class FileStreamReader : public StreamReader { 57 | 58 | private: 59 | 60 | /* TODO: Add description */ 61 | DequeRingBuffer buffer_; 62 | 63 | 64 | /* TODO: Add description */ 65 | const std::string& filename_; 66 | 67 | /* TODO: Add description */ 68 | std::ifstream* ifs_; 69 | 70 | /* TODO: Add description */ 71 | BC length_; 72 | 73 | 74 | /* TODO: Add description */ 75 | void read_(); 76 | 77 | 78 | protected: 79 | 80 | /* --- from StreamReader class: ---------------------------------------- */ 81 | 82 | /* TODO: Add description */ 83 | virtual uint8_t readByte_(bool remove = true); 84 | 85 | /* TODO: Add description */ 86 | virtual bool readBit_(bool remove = true); 87 | 88 | /* --- from StreamReader -> BufferReader class: ------------------------ */ 89 | 90 | /* TODO: Add description */ 91 | virtual bool getBit_(const BC& bc) const; 92 | 93 | /* TODO: Add description */ 94 | virtual uint8_t getByte_(const BC& bc) const; 95 | 96 | /* TODO: Add description */ 97 | virtual BC copyTo_(BufferWriter& buffer) const; 98 | 99 | /* TODO: Add description */ 100 | virtual BC getLength_() const; 101 | 102 | /* --------------------------------------------------------------------- */ 103 | 104 | 105 | public: 106 | 107 | /* TODO: Add description */ 108 | FileStreamReader(const std::string& filename, bool infinite = false); 109 | 110 | 111 | /* TODO: Add description */ 112 | virtual ~FileStreamReader(); 113 | 114 | }; 115 | 116 | #endif 117 | -------------------------------------------------------------------------------- /tls-diff-testing/bitman/inc/OpaqueField.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 3 | * Andreas Walz [andreas.walz@hs-offenburg.de] 4 | * Offenburg University of Applied Sciences 5 | * Institute of Reliable Embedded Systems and Communications Electronics (ivESK) 6 | * [https://ivesk.hs-offenburg.de/] 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | */ 36 | 37 | #ifndef __OpaqueField_H__ 38 | #define __OpaqueField_H__ 39 | 40 | #include 41 | #include 42 | #include 43 | #include "FieldDataUnit.h" 44 | 45 | class BufferReader; 46 | 47 | 48 | /* ========================================================================== 49 | * 50 | * TODO: Let OpaqueField replace FieldDataUnit class? 51 | * 52 | * ========================================================================== */ 53 | 54 | class OpaqueField : public FieldDataUnit { 55 | 56 | private: 57 | 58 | /* this class type's descriptor */ 59 | static TypeDescriptor desc_; 60 | 61 | 62 | protected: 63 | 64 | /* --- from FieldDataUnit class: --------------------------------------- */ 65 | 66 | /* TODO: Add description */ 67 | virtual bool decode_(const BufferReader& reader); 68 | 69 | /* TODO: Add description */ 70 | virtual bool encode_(); 71 | 72 | /* --- from DataUnit class: -------------------------------------------- */ 73 | 74 | /* TODO: Add description */ 75 | virtual bool isDecoded_() const; 76 | 77 | /* TODO: Add description */ 78 | virtual DataUnit* newInstance_() const; 79 | 80 | /* --------------------------------------------------------------------- */ 81 | 82 | 83 | public: 84 | 85 | /* TODO: Add description */ 86 | static inline const TypeDescriptor& typeDescriptor() { 87 | 88 | return desc_; 89 | } 90 | 91 | 92 | /* TODO: Add description */ 93 | OpaqueField(); 94 | 95 | /* TODO: Add description */ 96 | OpaqueField(const BC& capacity); 97 | 98 | /* TODO: Add description */ 99 | OpaqueField(const BufferReader& reader, const BC& max = -1); 100 | 101 | 102 | /* TODO: Add description */ 103 | const TypeDescriptor& getTypeDescriptor() const; 104 | 105 | 106 | /* TODO: Add description */ 107 | virtual ~OpaqueField(); 108 | 109 | }; 110 | 111 | #endif 112 | -------------------------------------------------------------------------------- /tls-diff-testing/bitman/inc/RingBuffer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 3 | * Andreas Walz [andreas.walz@hs-offenburg.de] 4 | * Offenburg University of Applied Sciences 5 | * Institute of Reliable Embedded Systems and Communications Electronics (ivESK) 6 | * [https://ivesk.hs-offenburg.de/] 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | */ 36 | 37 | #ifndef __RingBuffer_H__ 38 | #define __RingBuffer_H__ 39 | 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include "String_.h" 48 | #include "StreamReader.h" 49 | #include "BufferWriter.h" 50 | 51 | 52 | /* ========================================================================== 53 | * 54 | * 55 | * 56 | * ========================================================================== */ 57 | 58 | class RingBuffer : public StreamReader, public BufferWriter { 59 | 60 | private: 61 | 62 | BC capacity_; 63 | 64 | 65 | protected: 66 | 67 | /* === To be implemented by sub-classes: =============================== */ 68 | 69 | virtual void clear_() = 0; 70 | 71 | /* ===================================================================== */ 72 | 73 | 74 | public: 75 | 76 | RingBuffer(); 77 | RingBuffer(const BC& capacity); 78 | 79 | void clear(); 80 | 81 | BC getCapacity() const; 82 | BC getRemainingCapacity() const; 83 | 84 | virtual ~RingBuffer(); 85 | 86 | }; 87 | 88 | #endif 89 | -------------------------------------------------------------------------------- /tls-diff-testing/bitman/inc/StaticVectorDataUnit.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 3 | * Andreas Walz [andreas.walz@hs-offenburg.de] 4 | * Offenburg University of Applied Sciences 5 | * Institute of Reliable Embedded Systems and Communications Electronics (ivESK) 6 | * [https://ivesk.hs-offenburg.de/] 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | */ 36 | 37 | #ifndef __StaticVectorDataUnit_H__ 38 | #define __StaticVectorDataUnit_H__ 39 | 40 | #include "VectorDataUnit.h" 41 | 42 | 43 | /* ========================================================================== 44 | * 45 | * 46 | * 47 | * ========================================================================== */ 48 | 49 | class StaticVectorDataUnit : public VectorDataUnit { 50 | 51 | private: 52 | 53 | /* this class type's descriptor */ 54 | static TypeDescriptor desc_; 55 | 56 | 57 | /* TODO: Add description */ 58 | size_t N_; 59 | 60 | 61 | protected: 62 | 63 | /* --- from CompositeDataUnit class: ----------------------------------- */ 64 | 65 | /* TODO: Add description */ 66 | virtual bool expand_(size_t len, size_t decoded, bool dry, bool ahead); 67 | 68 | /* --- from DataUnit class: -------------------------------------------- */ 69 | 70 | /* TODO: Add description */ 71 | virtual DataUnit* newInstance_() const; 72 | 73 | /* --------------------------------------------------------------------- */ 74 | 75 | 76 | public: 77 | 78 | /* TODO: Add description */ 79 | static inline const TypeDescriptor& typeDescriptor() { 80 | 81 | return desc_; 82 | } 83 | 84 | 85 | /* TODO: Add description */ 86 | StaticVectorDataUnit(size_t N); 87 | 88 | 89 | /* TODO: Add description */ 90 | const TypeDescriptor& getTypeDescriptor() const; 91 | 92 | 93 | /* TODO: Add description */ 94 | virtual ~StaticVectorDataUnit(); 95 | 96 | }; 97 | 98 | #endif 99 | -------------------------------------------------------------------------------- /tls-diff-testing/bitman/inc/StreamReader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 3 | * Andreas Walz [andreas.walz@hs-offenburg.de] 4 | * Offenburg University of Applied Sciences 5 | * Institute of Reliable Embedded Systems and Communications Electronics (ivESK) 6 | * [https://ivesk.hs-offenburg.de/] 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | */ 36 | 37 | #ifndef __StreamReader_H__ 38 | #define __StreamReader_H__ 39 | 40 | #include "BufferReader.h" 41 | 42 | 43 | /* ========================================================================== 44 | * 45 | * 46 | * 47 | * ========================================================================== */ 48 | 49 | class StreamReader : public BufferReader { 50 | 51 | private: 52 | 53 | /* TODO: Add description */ 54 | BC accu_; 55 | 56 | 57 | protected: 58 | 59 | /* === To be implemented by sub-classes: =============================== */ 60 | 61 | /* TODO: Add description */ 62 | virtual uint8_t readByte_(bool remove = true) = 0; 63 | 64 | /* TODO: Add description */ 65 | virtual bool readBit_(bool remove = true) = 0; 66 | 67 | /* ===================================================================== */ 68 | 69 | 70 | public: 71 | 72 | /* TODO: Add description */ 73 | StreamReader(); 74 | 75 | /* TODO: Add description */ 76 | uint8_t readByte(bool remove = true); 77 | 78 | /* TODO: Add description */ 79 | bool readBit(bool remove = true); 80 | 81 | 82 | /* TODO: Add description */ 83 | BC flush(const BC& max = -1); 84 | 85 | 86 | /* TODO: Add description */ 87 | inline const BC& getAccumulator() const { 88 | 89 | return accu_; 90 | } 91 | 92 | /* TODO: Add description */ 93 | inline void resetAccumulator() { 94 | 95 | accu_ = 0; 96 | } 97 | 98 | virtual ~StreamReader(); 99 | 100 | }; 101 | 102 | #endif 103 | -------------------------------------------------------------------------------- /tls-diff-testing/bitman/inc/StreamStreamReader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 3 | * Andreas Walz [andreas.walz@hs-offenburg.de] 4 | * Offenburg University of Applied Sciences 5 | * Institute of Reliable Embedded Systems and Communications Electronics (ivESK) 6 | * [https://ivesk.hs-offenburg.de/] 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | */ 36 | 37 | #ifndef __StreamStreamReader_H__ 38 | #define __StreamStreamReader_H__ 39 | 40 | #include "BC.h" 41 | #include "StreamReader.h" 42 | 43 | 44 | /* ========================================================================== 45 | * 46 | * 47 | * 48 | * ========================================================================== */ 49 | 50 | class StreamStreamReader : public StreamReader { 51 | 52 | private: 53 | 54 | /* TODO: Add description */ 55 | BC len_; 56 | 57 | /* TODO: Add description */ 58 | StreamReader& reader_; 59 | 60 | protected: 61 | 62 | /* --- from StreamReader class: ---------------------------------------- */ 63 | 64 | /* TODO: Add description */ 65 | virtual uint8_t readByte_(bool remove = true); 66 | 67 | /* TODO: Add description */ 68 | virtual bool readBit_(bool remove = true); 69 | 70 | /* --- from StreamReader -> BufferReader class: ------------------------ */ 71 | 72 | /* TODO: Add description */ 73 | virtual bool getBit_(const BC& bc) const; 74 | 75 | /* TODO: Add description */ 76 | virtual uint8_t getByte_(const BC& bc) const; 77 | 78 | /* TODO: Add description */ 79 | virtual BC copyTo_(BufferWriter& buffer) const; 80 | 81 | /* TODO: Add description */ 82 | virtual BC getLength_() const; 83 | 84 | /* --------------------------------------------------------------------- */ 85 | 86 | 87 | public: 88 | 89 | /* TODO: Add description */ 90 | StreamStreamReader(StreamReader& reader); 91 | 92 | /* TODO: Add description */ 93 | StreamStreamReader(StreamReader& reader, const BC& len); 94 | 95 | 96 | /* TODO: Add description */ 97 | virtual ~StreamStreamReader(); 98 | 99 | }; 100 | 101 | #endif 102 | -------------------------------------------------------------------------------- /tls-diff-testing/bitman/inc/StreamVectorDataUnit.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 3 | * Andreas Walz [andreas.walz@hs-offenburg.de] 4 | * Offenburg University of Applied Sciences 5 | * Institute of Reliable Embedded Systems and Communications Electronics (ivESK) 6 | * [https://ivesk.hs-offenburg.de/] 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | */ 36 | 37 | #ifndef __StreamVectorDataUnit_H__ 38 | #define __StreamVectorDataUnit_H__ 39 | 40 | #include "VectorDataUnit.h" 41 | 42 | 43 | /* ========================================================================== 44 | * 45 | * 46 | * 47 | * ========================================================================== */ 48 | 49 | class StreamVectorDataUnit : public VectorDataUnit { 50 | 51 | private: 52 | 53 | /* this class type's descriptor */ 54 | static TypeDescriptor desc_; 55 | 56 | 57 | /* TODO: Add description */ 58 | BC N_; 59 | 60 | 61 | protected: 62 | 63 | /* --- from CompositeDataUnit class: ----------------------------------- */ 64 | 65 | /* TODO: Add description */ 66 | virtual bool expand_(size_t len, size_t decoded, bool dry, bool ahead); 67 | 68 | /* --- from DataUnit class: -------------------------------------------- */ 69 | 70 | /* TODO: Add description */ 71 | virtual DataUnit* newInstance_() const; 72 | 73 | /* --------------------------------------------------------------------- */ 74 | 75 | 76 | public: 77 | 78 | /* TODO: Add description */ 79 | static inline const TypeDescriptor& typeDescriptor() { 80 | 81 | return desc_; 82 | } 83 | 84 | 85 | /* TODO: Add description */ 86 | StreamVectorDataUnit(); 87 | 88 | /* TODO: Add description */ 89 | StreamVectorDataUnit(const BC& N); 90 | 91 | 92 | /* TODO: Add description */ 93 | const TypeDescriptor& getTypeDescriptor() const; 94 | 95 | 96 | /* TODO: Add description */ 97 | virtual ~StreamVectorDataUnit(); 98 | 99 | }; 100 | 101 | #endif 102 | -------------------------------------------------------------------------------- /tls-diff-testing/bitman/inc/StringField.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 3 | * Andreas Walz [andreas.walz@hs-offenburg.de] 4 | * Offenburg University of Applied Sciences 5 | * Institute of Reliable Embedded Systems and Communications Electronics (ivESK) 6 | * [https://ivesk.hs-offenburg.de/] 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | */ 36 | 37 | #ifndef __StringField_H__ 38 | #define __StringField_H__ 39 | 40 | #include 41 | #include 42 | #include "OpaqueField.h" 43 | 44 | class BufferReader; 45 | 46 | 47 | /* ========================================================================== 48 | * 49 | * TODO: Let StringField replace FieldDataUnit class? 50 | * 51 | * ========================================================================== */ 52 | 53 | class StringField : public OpaqueField { 54 | 55 | private: 56 | 57 | /* this class type's descriptor */ 58 | static TypeDescriptor desc_; 59 | 60 | 61 | protected: 62 | 63 | /* --- from DataUnit class: -------------------------------------------- */ 64 | 65 | /* TODO: Add description */ 66 | virtual std::string getInfo_() const; 67 | 68 | /* TODO: Add description */ 69 | virtual DataUnit* newInstance_() const; 70 | 71 | /* --------------------------------------------------------------------- */ 72 | 73 | 74 | public: 75 | 76 | /* TODO: Add description */ 77 | static inline const TypeDescriptor& typeDescriptor() { 78 | 79 | return desc_; 80 | } 81 | 82 | 83 | /* TODO: Add description */ 84 | StringField(); 85 | 86 | /* TODO: Add description */ 87 | StringField(const BC& capacity); 88 | 89 | /* TODO: Add description */ 90 | StringField(const BufferReader& reader, const BC& max = -1); 91 | 92 | 93 | /* TODO: Add description */ 94 | const TypeDescriptor& getTypeDescriptor() const; 95 | 96 | 97 | /* TODO: Add description */ 98 | virtual ~StringField(); 99 | 100 | }; 101 | 102 | #endif 103 | -------------------------------------------------------------------------------- /tls-diff-testing/bitman/inc/StringUtils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 3 | * Andreas Walz [andreas.walz@hs-offenburg.de] 4 | * Offenburg University of Applied Sciences 5 | * Institute of Reliable Embedded Systems and Communications Electronics (ivESK) 6 | * [https://ivesk.hs-offenburg.de/] 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | */ 36 | 37 | #ifndef __StringUtils_H__ 38 | #define __StringUtils_H__ 39 | 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | 47 | 48 | /* ========================================================================== 49 | * 50 | * 51 | * 52 | * ========================================================================== */ 53 | 54 | class StringUtils { 55 | 56 | public: 57 | 58 | static std::string getHexCharacters(); 59 | 60 | static int hexDigitToDec(char digit); 61 | 62 | static std::string filter(std::string input, std::string characters); 63 | 64 | static std::string filterHex(std::string input); 65 | 66 | static uint32_t hexToDec(std::string hex); 67 | 68 | static std::vector* readHex(std::string input); 69 | 70 | }; 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /tls-diff-testing/bitman/inc/VectorDataUnit.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 3 | * Andreas Walz [andreas.walz@hs-offenburg.de] 4 | * Offenburg University of Applied Sciences 5 | * Institute of Reliable Embedded Systems and Communications Electronics (ivESK) 6 | * [https://ivesk.hs-offenburg.de/] 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | */ 36 | 37 | #ifndef __VectorDataUnit_H__ 38 | #define __VectorDataUnit_H__ 39 | 40 | #include "CompositeDataUnit.h" 41 | 42 | 43 | /* ========================================================================== 44 | * 45 | * 46 | * 47 | * ========================================================================== */ 48 | 49 | class VectorDataUnit : public CompositeDataUnit { 50 | 51 | private: 52 | 53 | /* this class type's descriptor */ 54 | static TypeDescriptor desc_; 55 | 56 | 57 | /* TODO: Add description */ 58 | DataUnit* template_; 59 | 60 | 61 | protected: 62 | 63 | /* TODO: Add description */ 64 | VectorDataUnit(bool empty); 65 | 66 | 67 | public: 68 | 69 | /* TODO: Add description */ 70 | static inline const TypeDescriptor& typeDescriptor() { 71 | 72 | return desc_; 73 | } 74 | 75 | 76 | /* TODO: Add description */ 77 | VectorDataUnit(); 78 | 79 | /* TODO: Add description */ 80 | VectorDataUnit(DataUnit* elementTemplate); 81 | 82 | 83 | /* TODO: Add description */ 84 | const TypeDescriptor& getTypeDescriptor() const; 85 | 86 | 87 | /* TODO: Add description */ 88 | void setElementTemplate(DataUnit* elementTemplate); 89 | 90 | /* TODO: Add description */ 91 | DataUnit* getElementTemplate() const; 92 | 93 | 94 | /* TODO: Add description */ 95 | virtual ~VectorDataUnit(); 96 | 97 | }; 98 | 99 | #endif 100 | -------------------------------------------------------------------------------- /tls-diff-testing/bitman/inc/VoidField.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 3 | * Andreas Walz [andreas.walz@hs-offenburg.de] 4 | * Offenburg University of Applied Sciences 5 | * Institute of Reliable Embedded Systems and Communications Electronics (ivESK) 6 | * [https://ivesk.hs-offenburg.de/] 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | */ 36 | 37 | #ifndef __VoidField_H__ 38 | #define __VoidField_H__ 39 | 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include "FieldDataUnit.h" 45 | 46 | class BC; 47 | 48 | 49 | /* ========================================================================== 50 | * 51 | * 52 | * 53 | * ========================================================================== */ 54 | 55 | class VoidField : public FieldDataUnit { 56 | 57 | private: 58 | 59 | /* this class type's descriptor */ 60 | static TypeDescriptor desc_; 61 | 62 | 63 | protected: 64 | 65 | /* --- from FieldDataUnit class: --------------------------------------- */ 66 | 67 | /* TODO: Add description */ 68 | virtual bool decode_(const BufferReader& reader); 69 | 70 | /* TODO: Add description */ 71 | virtual bool encode_(); 72 | 73 | /* --- from DataUnit class: -------------------------------------------- */ 74 | 75 | /* TODO: Add description */ 76 | virtual bool isDecoded_() const; 77 | 78 | /* TODO: Add description */ 79 | virtual DataUnit* newInstance_() const; 80 | 81 | /* --------------------------------------------------------------------- */ 82 | 83 | 84 | public: 85 | 86 | /* TODO: Add description */ 87 | static inline const TypeDescriptor& typeDescriptor() { 88 | 89 | return desc_; 90 | } 91 | 92 | 93 | /* TODO: Add description */ 94 | VoidField(); 95 | 96 | 97 | /* TODO: Add description */ 98 | const TypeDescriptor& getTypeDescriptor() const; 99 | 100 | 101 | /* TODO: Add description */ 102 | virtual ~VoidField(); 103 | 104 | }; 105 | 106 | #endif 107 | -------------------------------------------------------------------------------- /tls-diff-testing/bitman/src/Buffer.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 3 | * Andreas Walz [andreas.walz@hs-offenburg.de] 4 | * Offenburg University of Applied Sciences 5 | * Institute of Reliable Embedded Systems and Communications Electronics (ivESK) 6 | * [https://ivesk.hs-offenburg.de/] 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | */ 36 | 37 | #include 38 | #include 39 | #include 40 | #include 41 | 42 | #include "BC.h" 43 | #include "Buffer.h" 44 | #include "BufferStreamReader.h" 45 | 46 | 47 | /* 48 | * ___________________________________________________________________________ 49 | */ 50 | Buffer::Buffer() : capacity_(-1) { 51 | } 52 | 53 | 54 | /* 55 | * ___________________________________________________________________________ 56 | */ 57 | Buffer::Buffer(const BC& capacity) : capacity_(capacity) { 58 | } 59 | 60 | 61 | /* 62 | * ___________________________________________________________________________ 63 | */ 64 | BC Buffer::getRemainingCapacity() const { 65 | 66 | BC remCap = capacity_; 67 | 68 | if (remCap.isDef()) { 69 | BC len = this->getLength(); 70 | if (remCap >= len) { 71 | remCap -= len; 72 | } else { 73 | remCap = 0; 74 | } 75 | } 76 | 77 | return remCap; 78 | } 79 | 80 | 81 | /* 82 | * ___________________________________________________________________________ 83 | */ 84 | Buffer::~Buffer() { 85 | } 86 | -------------------------------------------------------------------------------- /tls-diff-testing/bitman/src/BufferModifier.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 3 | * Andreas Walz [andreas.walz@hs-offenburg.de] 4 | * Offenburg University of Applied Sciences 5 | * Institute of Reliable Embedded Systems and Communications Electronics (ivESK) 6 | * [https://ivesk.hs-offenburg.de/] 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | */ 36 | 37 | #include "BufferModifier.h" 38 | 39 | 40 | /* 41 | * ___________________________________________________________________________ 42 | */ 43 | BufferModifier::BufferModifier() { 44 | } 45 | 46 | 47 | /* 48 | * ___________________________________________________________________________ 49 | */ 50 | BufferModifier::~BufferModifier() { 51 | } 52 | 53 | -------------------------------------------------------------------------------- /tls-diff-testing/bitman/src/BufferStreamReader.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 3 | * Andreas Walz [andreas.walz@hs-offenburg.de] 4 | * Offenburg University of Applied Sciences 5 | * Institute of Reliable Embedded Systems and Communications Electronics (ivESK) 6 | * [https://ivesk.hs-offenburg.de/] 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | */ 36 | 37 | #include 38 | #include "VectorBuffer.h" 39 | #include "BufferStreamReader.h" 40 | 41 | using std::vector; 42 | 43 | 44 | /* 45 | * ___________________________________________________________________________ 46 | */ 47 | BufferStreamReader::BufferStreamReader(const BufferReader& reader) : 48 | reader_(reader), pos_(0) { 49 | } 50 | 51 | 52 | /* 53 | * ___________________________________________________________________________ 54 | */ 55 | uint8_t BufferStreamReader::readByte_(bool remove) { 56 | 57 | /* bounds checked by underlying BufferReader */ 58 | uint8_t byte = reader_.getByte(pos_); 59 | if (remove) { 60 | ++pos_; 61 | } 62 | return byte; 63 | } 64 | 65 | 66 | /* 67 | * ___________________________________________________________________________ 68 | */ 69 | bool BufferStreamReader::readBit_(bool remove) { 70 | 71 | /* bounds checked by underlying BufferReader */ 72 | bool bit = reader_.getBit(pos_); 73 | if (remove) { 74 | pos_ <<= 1; 75 | } 76 | return bit; 77 | } 78 | 79 | 80 | /* 81 | * ___________________________________________________________________________ 82 | */ 83 | BC BufferStreamReader::getLength_() const { 84 | 85 | BC len = reader_.getLength(); 86 | if (len > pos_) { 87 | len -= pos_; 88 | } else { 89 | len = 0; 90 | } 91 | return len; 92 | } 93 | 94 | 95 | /* 96 | * ___________________________________________________________________________ 97 | */ 98 | bool BufferStreamReader::getBit_(const BC& bc) const { 99 | 100 | /* bounds checked by underlying BufferReader */ 101 | return reader_.getBit(pos_ + bc); 102 | } 103 | 104 | 105 | /* 106 | * ___________________________________________________________________________ 107 | */ 108 | uint8_t BufferStreamReader::getByte_(const BC& bc) const { 109 | 110 | /* bounds checked by underlying BufferReader */ 111 | return reader_.getByte(pos_ + bc); 112 | } 113 | 114 | 115 | /* 116 | * ___________________________________________________________________________ 117 | */ 118 | BC BufferStreamReader::copyTo_(BufferWriter& buffer) const { 119 | 120 | return BC::undef(); 121 | } 122 | 123 | 124 | /* 125 | * ___________________________________________________________________________ 126 | */ 127 | BufferStreamReader::~BufferStreamReader() { 128 | } 129 | -------------------------------------------------------------------------------- /tls-diff-testing/bitman/src/BufferWindowReader.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 3 | * Andreas Walz [andreas.walz@hs-offenburg.de] 4 | * Offenburg University of Applied Sciences 5 | * Institute of Reliable Embedded Systems and Communications Electronics (ivESK) 6 | * [https://ivesk.hs-offenburg.de/] 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | */ 36 | 37 | #include 38 | #include "VectorBuffer.h" 39 | #include "BufferWindowReader.h" 40 | 41 | using std::vector; 42 | 43 | 44 | /* 45 | * ___________________________________________________________________________ 46 | */ 47 | BufferWindowReader::BufferWindowReader( 48 | const BufferReader& reader, BC offset, BC length) : 49 | reader_(reader), offset_(offset), length_(length) { 50 | } 51 | 52 | 53 | /* 54 | * ___________________________________________________________________________ 55 | */ 56 | BC BufferWindowReader::getLength_() const { 57 | 58 | BC len = reader_.getLength(); 59 | if (len > offset_) { 60 | len -= offset_; 61 | } else { 62 | len = 0; 63 | } 64 | return BC::getMin(len, length_); 65 | } 66 | 67 | 68 | /* 69 | * ___________________________________________________________________________ 70 | */ 71 | bool BufferWindowReader::getBit_(const BC& bc) const { 72 | 73 | if (bc < this->getLength()) { 74 | return reader_.getBit(offset_ + bc); 75 | } else { 76 | throw std::runtime_error( 77 | "BufferWindowReader::getBit(...): Out of range"); 78 | } 79 | } 80 | 81 | 82 | /* 83 | * ___________________________________________________________________________ 84 | */ 85 | uint8_t BufferWindowReader::getByte_(const BC& bc) const { 86 | 87 | if ((bc + 1) <= this->getLength()) { 88 | return reader_.getByte(offset_ + bc); 89 | } else { 90 | throw std::runtime_error( 91 | "BufferWindowReader::getByte(...): Out of range"); 92 | } 93 | } 94 | 95 | 96 | /* 97 | * ___________________________________________________________________________ 98 | */ 99 | BC BufferWindowReader::copyTo_(BufferWriter& buffer) const { 100 | 101 | return BC::undef(); 102 | } 103 | 104 | 105 | /* 106 | * ___________________________________________________________________________ 107 | */ 108 | BufferWindowReader::~BufferWindowReader() { 109 | } 110 | -------------------------------------------------------------------------------- /tls-diff-testing/bitman/src/DataUnitConverter.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 3 | * Andreas Walz [andreas.walz@hs-offenburg.de] 4 | * Offenburg University of Applied Sciences 5 | * Institute of Reliable Embedded Systems and Communications Electronics (ivESK) 6 | * [https://ivesk.hs-offenburg.de/] 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | */ 36 | 37 | #include "DataUnitConverter.h" 38 | #include 39 | #include "String_.h" 40 | #include "FieldDataUnit.h" 41 | 42 | using std::string; 43 | 44 | 45 | /* 46 | * ___________________________________________________________________________ 47 | */ 48 | DataUnitConverter::DataUnitConverter(const DataUnit& dataUnit) 49 | : dataUnit_(dataUnit) { 50 | } 51 | 52 | 53 | /* 54 | * ___________________________________________________________________________ 55 | */ 56 | string DataUnitConverter::getAsJSON() const { 57 | 58 | return this->getAsJSON_(dataUnit_); 59 | } 60 | 61 | 62 | /* 63 | * ___________________________________________________________________________ 64 | */ 65 | string DataUnitConverter::getAsJSON_(const DataUnit& dataUnit) const { 66 | 67 | String json; 68 | 69 | json.appendFormat("\"__refname__\": \"%s\",\n", 70 | dataUnit.getRefName().c_str()); 71 | json.appendFormat("\"__type__\": \"%s\",\n", 72 | dataUnit.getTypeName().c_str()); 73 | 74 | if (dataUnit.containsType(FieldDataUnit::typeDescriptor())) { 75 | json.appendFormat("\"__data__\": \"%s\",\n", 76 | dataUnit.toHexString().c_str()); 77 | } else if (dataUnit.hasChild()) { 78 | 79 | String children; 80 | 81 | DataUnit* child = dataUnit.getChild(); 82 | while (child != 0) { 83 | children.append(this->getAsJSON_(*child)); 84 | child = child->getNext(); 85 | if (child != 0) { 86 | children.append(","); 87 | } 88 | children.append("\n"); 89 | } 90 | 91 | children.indentLines(" "); 92 | children.prepend("\"__data__\": [\n"); 93 | children.append("]\n"); 94 | json.append(children); 95 | } 96 | 97 | json.indentLines(" "); 98 | json.prepend("{\n"); 99 | json.append("}"); 100 | 101 | return json; 102 | } 103 | 104 | 105 | /* 106 | * ___________________________________________________________________________ 107 | */ 108 | DataUnitConverter::~DataUnitConverter() { 109 | } 110 | 111 | -------------------------------------------------------------------------------- /tls-diff-testing/bitman/src/DataUnitStream.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 3 | * Andreas Walz [andreas.walz@hs-offenburg.de] 4 | * Offenburg University of Applied Sciences 5 | * Institute of Reliable Embedded Systems and Communications Electronics (ivESK) 6 | * [https://ivesk.hs-offenburg.de/] 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | */ 36 | 37 | #include 38 | #include "StreamReader.h" 39 | #include "DataUnit.h" 40 | #include "DataUnitFragment.h" 41 | 42 | using std::vector; 43 | 44 | 45 | /* 46 | * ___________________________________________________________________________ 47 | */ 48 | TypeDescriptor DataUnitStream::desc_( 49 | StreamVectorDataUnit::typeDescriptor(), 0, "DataUnitStream"); 50 | 51 | 52 | /* 53 | * ___________________________________________________________________________ 54 | */ 55 | DataUnitStream::DataUnitStream(DataUnit* unit) { 56 | 57 | this->setElementTemplate(unit); 58 | } 59 | 60 | 61 | /* 62 | * ___________________________________________________________________________ 63 | */ 64 | const TypeDescriptor& DataUnitStream::getTypeDescriptor() const { 65 | 66 | return typeDescriptor(); 67 | } 68 | 69 | 70 | /* 71 | * ___________________________________________________________________________ 72 | */ 73 | DataUnitFragment* DataUnitStream::newFragment(const BC& size) { 74 | 75 | DataUnitFragment* sdu = new DataUnitFragment(*this, size); 76 | fragments_.push_back(sdu); 77 | return sdu; 78 | } 79 | 80 | 81 | /* 82 | * ___________________________________________________________________________ 83 | */ 84 | DataUnitStream::~DataUnitStream() { 85 | 86 | while (fragments_.size() > 0) { 87 | delete fragments_.back(); 88 | fragments_.pop_back(); 89 | } 90 | } 91 | 92 | -------------------------------------------------------------------------------- /tls-diff-testing/bitman/src/DataUnitVisitor.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 3 | * Andreas Walz [andreas.walz@hs-offenburg.de] 4 | * Offenburg University of Applied Sciences 5 | * Institute of Reliable Embedded Systems and Communications Electronics (ivESK) 6 | * [https://ivesk.hs-offenburg.de/] 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | */ 36 | 37 | #include "DataUnitVisitor.h" 38 | #include "DataUnit.h" 39 | 40 | 41 | /* 42 | * ___________________________________________________________________________ 43 | */ 44 | DataUnitVisitor::DataUnitVisitor() { 45 | } 46 | 47 | 48 | /* 49 | * ___________________________________________________________________________ 50 | */ 51 | size_t DataUnitVisitor::visit(DataUnit& dataUnit, size_t index, size_t depth) { 52 | 53 | size_t N = 0; 54 | 55 | if (this->visiting(dataUnit, index, depth)) { 56 | N++; 57 | /* visit children */ 58 | size_t i = 0; 59 | DataUnit* child = dataUnit.getChild(0); 60 | while (child != 0) { 61 | N += this->visit(*child, i++, depth + 1); 62 | child = child->getNext(); 63 | } 64 | } 65 | 66 | return N; 67 | } 68 | 69 | 70 | /* 71 | * ___________________________________________________________________________ 72 | */ 73 | size_t DataUnitVisitor::visit(DataUnit& dataUnit) { 74 | 75 | return this->visit(dataUnit, dataUnit.getIndexOffset(), 0); 76 | } 77 | 78 | 79 | /* 80 | * ___________________________________________________________________________ 81 | */ 82 | DataUnitVisitor::~DataUnitVisitor() { 83 | } 84 | 85 | -------------------------------------------------------------------------------- /tls-diff-testing/bitman/src/DecisionReader.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 3 | * Andreas Walz [andreas.walz@hs-offenburg.de] 4 | * Offenburg University of Applied Sciences 5 | * Institute of Reliable Embedded Systems and Communications Electronics (ivESK) 6 | * [https://ivesk.hs-offenburg.de/] 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | */ 36 | 37 | #include "DecisionReader.h" 38 | #include "IntegerField.h" 39 | #include 40 | 41 | 42 | /* 43 | * ___________________________________________________________________________ 44 | */ 45 | DecisionReader::DecisionReader(StreamReader& streamer) : streamer_(streamer) { 46 | } 47 | 48 | 49 | /* 50 | * ___________________________________________________________________________ 51 | */ 52 | bool DecisionReader::readBoolUniform() { 53 | 54 | return this->readBit(); 55 | } 56 | 57 | 58 | /* 59 | * ___________________________________________________________________________ 60 | */ 61 | size_t DecisionReader::readUIntUniform(size_t max) { 62 | 63 | if (max == 0) { 64 | throw std::runtime_error("DecisionReader::readUIntUniform(...): " 65 | "'max' needs to be larger than zero"); 66 | } 67 | 68 | /* determine bit width of requested integer */ 69 | size_t width = 1; 70 | while (width < 31 && max > (size_t)(1 << width)) { 71 | width++; 72 | } 73 | 74 | size_t value; 75 | IntegerField intField(BC(0, width)); 76 | 77 | do { 78 | intField.dissector().reset(); 79 | intField.dissector().dissect(*this); 80 | value = (size_t)intField.getValue(); 81 | } while (value >= max); 82 | 83 | return value; 84 | } 85 | 86 | 87 | /* 88 | * ___________________________________________________________________________ 89 | */ 90 | size_t DecisionReader::readUIntExponential(size_t num, size_t denom) { 91 | 92 | size_t value = 0; 93 | 94 | while (this->readUIntUniform(denom) <= num) { 95 | ++value; 96 | } 97 | 98 | return value; 99 | } 100 | 101 | 102 | /* 103 | * ___________________________________________________________________________ 104 | */ 105 | DecisionReader::~DecisionReader() { 106 | } 107 | 108 | -------------------------------------------------------------------------------- /tls-diff-testing/bitman/src/OpaqueField.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 3 | * Andreas Walz [andreas.walz@hs-offenburg.de] 4 | * Offenburg University of Applied Sciences 5 | * Institute of Reliable Embedded Systems and Communications Electronics (ivESK) 6 | * [https://ivesk.hs-offenburg.de/] 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | */ 36 | 37 | #include "OpaqueField.h" 38 | #include "BufferReader.h" 39 | #include "String_.h" 40 | 41 | using std::string; 42 | 43 | 44 | /* 45 | * ___________________________________________________________________________ 46 | */ 47 | TypeDescriptor OpaqueField::desc_( 48 | FieldDataUnit::typeDescriptor(), 0, "OpaqueField"); 49 | 50 | 51 | /* 52 | * ___________________________________________________________________________ 53 | */ 54 | OpaqueField::OpaqueField() : FieldDataUnit() { 55 | } 56 | 57 | 58 | /* 59 | * ___________________________________________________________________________ 60 | */ 61 | OpaqueField::OpaqueField(const BC& capacity) : FieldDataUnit(capacity) { 62 | } 63 | 64 | 65 | /* 66 | * ___________________________________________________________________________ 67 | */ 68 | OpaqueField::OpaqueField(const BufferReader& reader, const BC& max) 69 | : FieldDataUnit() { 70 | 71 | this->dissector().dissectFromBuffer(reader, max); 72 | } 73 | 74 | 75 | /* 76 | * ___________________________________________________________________________ 77 | */ 78 | const TypeDescriptor& OpaqueField::getTypeDescriptor() const { 79 | 80 | return typeDescriptor(); 81 | } 82 | 83 | 84 | /* 85 | * ___________________________________________________________________________ 86 | */ 87 | bool OpaqueField::decode_(const BufferReader& reader) { 88 | 89 | return true; 90 | } 91 | 92 | 93 | /* 94 | * ___________________________________________________________________________ 95 | */ 96 | bool OpaqueField::isDecoded_() const { 97 | 98 | return !this->dissector().isAccepting(); 99 | } 100 | 101 | 102 | /* 103 | * ___________________________________________________________________________ 104 | */ 105 | bool OpaqueField::encode_() { 106 | 107 | return true; 108 | } 109 | 110 | 111 | /* 112 | * ___________________________________________________________________________ 113 | */ 114 | DataUnit* OpaqueField::newInstance_() const { 115 | 116 | return new OpaqueField(this->getCapacity()); 117 | } 118 | 119 | 120 | /* 121 | * ___________________________________________________________________________ 122 | */ 123 | OpaqueField::~OpaqueField() { 124 | } 125 | 126 | -------------------------------------------------------------------------------- /tls-diff-testing/bitman/src/RingBuffer.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 3 | * Andreas Walz [andreas.walz@hs-offenburg.de] 4 | * Offenburg University of Applied Sciences 5 | * Institute of Reliable Embedded Systems and Communications Electronics (ivESK) 6 | * [https://ivesk.hs-offenburg.de/] 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | */ 36 | 37 | #include 38 | #include 39 | 40 | #include "BC.h" 41 | #include "RingBuffer.h" 42 | 43 | 44 | /* 45 | * ___________________________________________________________________________ 46 | */ 47 | RingBuffer::RingBuffer() : capacity_(-1) { 48 | } 49 | 50 | 51 | /* 52 | * ___________________________________________________________________________ 53 | */ 54 | RingBuffer::RingBuffer(const BC& capacity) : capacity_(capacity) { 55 | } 56 | 57 | 58 | /* 59 | * ___________________________________________________________________________ 60 | */ 61 | void RingBuffer::clear() { 62 | 63 | this->clear_(); 64 | } 65 | 66 | 67 | /* 68 | * ___________________________________________________________________________ 69 | */ 70 | BC RingBuffer::getCapacity() const { 71 | 72 | return capacity_; 73 | } 74 | 75 | 76 | /* 77 | * ___________________________________________________________________________ 78 | */ 79 | BC RingBuffer::getRemainingCapacity() const { 80 | 81 | BC remCap = capacity_; 82 | 83 | if (remCap.isDef()) { 84 | BC len = this->getLength(); 85 | if (remCap >= len) { 86 | remCap -= len; 87 | } else { 88 | remCap = 0; 89 | } 90 | } 91 | 92 | return remCap; 93 | } 94 | 95 | 96 | /* 97 | * ___________________________________________________________________________ 98 | */ 99 | RingBuffer::~RingBuffer() { 100 | } 101 | -------------------------------------------------------------------------------- /tls-diff-testing/bitman/src/StaticVectorDataUnit.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 3 | * Andreas Walz [andreas.walz@hs-offenburg.de] 4 | * Offenburg University of Applied Sciences 5 | * Institute of Reliable Embedded Systems and Communications Electronics (ivESK) 6 | * [https://ivesk.hs-offenburg.de/] 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | */ 36 | 37 | #include "StaticVectorDataUnit.h" 38 | 39 | using std::string; 40 | 41 | 42 | /* 43 | * ___________________________________________________________________________ 44 | */ 45 | TypeDescriptor StaticVectorDataUnit::desc_( 46 | VectorDataUnit::typeDescriptor(), 0, "StaticVectorDataUnit"); 47 | 48 | 49 | /* 50 | * ___________________________________________________________________________ 51 | */ 52 | StaticVectorDataUnit::StaticVectorDataUnit(size_t N) : 53 | VectorDataUnit(N == 0), N_(N) { 54 | 55 | } 56 | 57 | 58 | /* 59 | * ___________________________________________________________________________ 60 | */ 61 | const TypeDescriptor& StaticVectorDataUnit::getTypeDescriptor() const { 62 | 63 | return typeDescriptor(); 64 | } 65 | 66 | 67 | /* 68 | * ___________________________________________________________________________ 69 | */ 70 | bool StaticVectorDataUnit::expand_( 71 | size_t len, size_t decoded, bool dry, bool ahead) { 72 | 73 | DataUnit* elementTemplate = this->getElementTemplate(); 74 | for (size_t i = len; i < N_; i++) { 75 | this->appendChild(elementTemplate->newInstance()); 76 | } 77 | return true; 78 | } 79 | 80 | 81 | /* 82 | * ___________________________________________________________________________ 83 | */ 84 | DataUnit* StaticVectorDataUnit::newInstance_() const { 85 | 86 | StaticVectorDataUnit* vector = new StaticVectorDataUnit(N_); 87 | DataUnit* elementTemplate = this->getElementTemplate(); 88 | if (elementTemplate != 0) { 89 | vector->setElementTemplate(elementTemplate->newInstance()); 90 | } 91 | return vector; 92 | } 93 | 94 | 95 | /* 96 | * ___________________________________________________________________________ 97 | */ 98 | StaticVectorDataUnit::~StaticVectorDataUnit() { 99 | } 100 | 101 | -------------------------------------------------------------------------------- /tls-diff-testing/bitman/src/StreamReader.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 3 | * Andreas Walz [andreas.walz@hs-offenburg.de] 4 | * Offenburg University of Applied Sciences 5 | * Institute of Reliable Embedded Systems and Communications Electronics (ivESK) 6 | * [https://ivesk.hs-offenburg.de/] 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | */ 36 | 37 | #include "StreamReader.h" 38 | 39 | 40 | /* 41 | * ___________________________________________________________________________ 42 | */ 43 | StreamReader::StreamReader() : accu_(0) { 44 | } 45 | 46 | 47 | /* 48 | * ___________________________________________________________________________ 49 | */ 50 | uint8_t StreamReader::readByte(bool remove) { 51 | 52 | uint8_t byte = this->readByte_(remove); 53 | if (remove) { 54 | ++accu_; 55 | } 56 | return byte; 57 | } 58 | 59 | 60 | /* 61 | * ___________________________________________________________________________ 62 | */ 63 | bool StreamReader::readBit(bool remove) { 64 | 65 | bool bit = this->readBit_(remove); 66 | if (remove) { 67 | accu_ <<= 1; 68 | } 69 | return bit; 70 | } 71 | 72 | 73 | /* 74 | * ___________________________________________________________________________ 75 | */ 76 | BC StreamReader::flush(const BC& max) { 77 | 78 | BC len = BC::getMin(this->getLength(), max); 79 | BC ret = len; 80 | 81 | if (len.isDef()) { 82 | while (len >= 1) { 83 | this->readByte(); 84 | len--; 85 | } 86 | while (len > 0) { 87 | this->readBit(); 88 | len >>= 1; 89 | } 90 | } else { 91 | ret = 0; 92 | } 93 | 94 | return ret; 95 | } 96 | 97 | 98 | /* 99 | * ___________________________________________________________________________ 100 | */ 101 | StreamReader::~StreamReader() { 102 | } 103 | 104 | -------------------------------------------------------------------------------- /tls-diff-testing/bitman/src/StreamVectorDataUnit.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 3 | * Andreas Walz [andreas.walz@hs-offenburg.de] 4 | * Offenburg University of Applied Sciences 5 | * Institute of Reliable Embedded Systems and Communications Electronics (ivESK) 6 | * [https://ivesk.hs-offenburg.de/] 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | */ 36 | 37 | #include "StreamVectorDataUnit.h" 38 | 39 | using std::string; 40 | 41 | 42 | /* 43 | * ___________________________________________________________________________ 44 | */ 45 | TypeDescriptor StreamVectorDataUnit::desc_( 46 | VectorDataUnit::typeDescriptor(), 0, "StreamVectorDataUnit"); 47 | 48 | 49 | /* 50 | * ___________________________________________________________________________ 51 | */ 52 | StreamVectorDataUnit::StreamVectorDataUnit() : 53 | VectorDataUnit(false), N_(-1) { 54 | 55 | } 56 | 57 | 58 | /* 59 | * ___________________________________________________________________________ 60 | */ 61 | StreamVectorDataUnit::StreamVectorDataUnit(const BC& N) : 62 | VectorDataUnit(N == 0), N_(N) { 63 | 64 | this->dissector().setSize(N_); 65 | } 66 | 67 | 68 | /* 69 | * ___________________________________________________________________________ 70 | */ 71 | const TypeDescriptor& StreamVectorDataUnit::getTypeDescriptor() const { 72 | 73 | return typeDescriptor(); 74 | } 75 | 76 | 77 | /* 78 | * ___________________________________________________________________________ 79 | */ 80 | bool StreamVectorDataUnit::expand_( 81 | size_t len, size_t decoded, bool dry, bool ahead) { 82 | 83 | bool ret = true; 84 | 85 | if (N_.isUndef() || this->dissector().getLength() < N_) { 86 | 87 | DataUnit* tail = this->getChildTail(); 88 | if (!dry && (tail == 0 || !tail->dissector().isAccepting())) { 89 | /* create a new instance of the template data 90 | * unit and attach it to the list of children */ 91 | DataUnit* elementTemplate = this->getElementTemplate(); 92 | if (elementTemplate != 0) { 93 | this->appendChild(elementTemplate->newInstance()); 94 | } 95 | } 96 | 97 | /* this vector is not yet satisfied and expects to get more input */ 98 | ret = false; 99 | } 100 | 101 | return ret; 102 | } 103 | 104 | 105 | /* 106 | * ___________________________________________________________________________ 107 | */ 108 | DataUnit* StreamVectorDataUnit::newInstance_() const { 109 | 110 | StreamVectorDataUnit* vector = new StreamVectorDataUnit(N_); 111 | DataUnit* elementTemplate = this->getElementTemplate(); 112 | if (elementTemplate != 0) { 113 | vector->setElementTemplate(elementTemplate->newInstance()); 114 | } 115 | return vector; 116 | } 117 | 118 | 119 | /* 120 | * ___________________________________________________________________________ 121 | */ 122 | StreamVectorDataUnit::~StreamVectorDataUnit() { 123 | } 124 | 125 | -------------------------------------------------------------------------------- /tls-diff-testing/bitman/src/StringField.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 3 | * Andreas Walz [andreas.walz@hs-offenburg.de] 4 | * Offenburg University of Applied Sciences 5 | * Institute of Reliable Embedded Systems and Communications Electronics (ivESK) 6 | * [https://ivesk.hs-offenburg.de/] 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | */ 36 | 37 | #include "StringField.h" 38 | #include "BufferReader.h" 39 | #include "String_.h" 40 | 41 | using std::string; 42 | 43 | 44 | /* 45 | * ___________________________________________________________________________ 46 | */ 47 | TypeDescriptor StringField::desc_( 48 | OpaqueField::typeDescriptor(), 0, "StringField"); 49 | 50 | 51 | /* 52 | * ___________________________________________________________________________ 53 | */ 54 | StringField::StringField() : OpaqueField() { 55 | } 56 | 57 | 58 | /* 59 | * ___________________________________________________________________________ 60 | */ 61 | StringField::StringField(const BC& capacity) : OpaqueField(capacity) { 62 | } 63 | 64 | 65 | /* 66 | * ___________________________________________________________________________ 67 | */ 68 | StringField::StringField(const BufferReader& reader, const BC& max) 69 | : OpaqueField() { 70 | 71 | this->dissector().dissectFromBuffer(reader, max); 72 | } 73 | 74 | 75 | /* 76 | * ___________________________________________________________________________ 77 | */ 78 | const TypeDescriptor& StringField::getTypeDescriptor() const { 79 | 80 | return typeDescriptor(); 81 | } 82 | 83 | 84 | /* 85 | * ___________________________________________________________________________ 86 | */ 87 | DataUnit* StringField::newInstance_() const { 88 | 89 | return new StringField(this->getCapacity()); 90 | } 91 | 92 | 93 | /* 94 | * ___________________________________________________________________________ 95 | */ 96 | string StringField::getInfo_() const { 97 | 98 | uint8_t str[128]; 99 | 100 | BC len = this->getBuffer().copyTo(str, sizeof(str) - 1); 101 | str[len.byte()] = 0; 102 | 103 | return String::format("\"%s\"", str); 104 | } 105 | 106 | 107 | /* 108 | * ___________________________________________________________________________ 109 | */ 110 | StringField::~StringField() { 111 | } 112 | 113 | -------------------------------------------------------------------------------- /tls-diff-testing/bitman/src/StringUtils.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 3 | * Andreas Walz [andreas.walz@hs-offenburg.de] 4 | * Offenburg University of Applied Sciences 5 | * Institute of Reliable Embedded Systems and Communications Electronics (ivESK) 6 | * [https://ivesk.hs-offenburg.de/] 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | */ 36 | 37 | #include "StringUtils.h" 38 | 39 | using std::string; 40 | using std::vector; 41 | 42 | 43 | /* 44 | * 45 | */ 46 | string StringUtils::getHexCharacters() { 47 | 48 | return "0123456789abcdefABCDEF"; 49 | } 50 | 51 | 52 | /* 53 | * 54 | */ 55 | int StringUtils::hexDigitToDec(char digit) { 56 | 57 | /* convert to lower cases */ 58 | if (digit >= 'a' && digit <= 'z') { 59 | digit -= 'a' - 'A'; 60 | } 61 | 62 | string base = "0123456789ABCDEF"; 63 | 64 | size_t pos = base.find(digit); 65 | if (pos != string::npos) { 66 | return (int)pos; 67 | } else { 68 | return -1; 69 | } 70 | } 71 | 72 | 73 | /* 74 | * 75 | */ 76 | string StringUtils::filter(string input, string characters) { 77 | 78 | string output; 79 | 80 | for (size_t i = 0; i < input.length(); i++) { 81 | if (characters.find(input[i]) != string::npos) { 82 | output.append(input, i, 1); 83 | } 84 | } 85 | 86 | return output; 87 | } 88 | 89 | 90 | /* 91 | * 92 | */ 93 | string StringUtils::filterHex(string input) { 94 | 95 | size_t pos = 0; 96 | while (pos != string::npos) { 97 | pos = input.find("0x", pos, 2); 98 | if (pos != string::npos) { 99 | input[pos] = ' '; 100 | } 101 | } 102 | 103 | return StringUtils::filter(input, StringUtils::getHexCharacters()); 104 | } 105 | 106 | 107 | /* 108 | * 109 | */ 110 | uint32_t StringUtils::hexToDec(string hex) { 111 | 112 | uint32_t retVal = 0; 113 | string input = filterHex(hex); 114 | 115 | for (size_t i = 0; i < input.length(); i++) { 116 | int val = hexDigitToDec(input[i]); 117 | if (val != -1) { 118 | retVal *= 16; 119 | retVal += val; 120 | } 121 | } 122 | 123 | return retVal; 124 | } 125 | 126 | 127 | /* 128 | * 129 | */ 130 | vector* StringUtils::readHex(string input) { 131 | 132 | vector* vec = 0; 133 | string filtered = filterHex(input); 134 | 135 | if (filtered.length() % 2 == 0) { 136 | vec = new vector(); 137 | for (size_t i = 0; i < filtered.length(); i += 2) { 138 | string digit = filtered.substr(i, 2); 139 | uint8_t val = (uint8_t)hexToDec(digit); 140 | vec->push_back(val); 141 | } 142 | } 143 | 144 | return vec; 145 | } 146 | -------------------------------------------------------------------------------- /tls-diff-testing/bitman/src/VectorDataUnit.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 3 | * Andreas Walz [andreas.walz@hs-offenburg.de] 4 | * Offenburg University of Applied Sciences 5 | * Institute of Reliable Embedded Systems and Communications Electronics (ivESK) 6 | * [https://ivesk.hs-offenburg.de/] 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | */ 36 | 37 | #include "VectorDataUnit.h" 38 | 39 | 40 | /* 41 | * ___________________________________________________________________________ 42 | */ 43 | TypeDescriptor VectorDataUnit::desc_( 44 | CompositeDataUnit::typeDescriptor(), 0, "VectorDataUnit"); 45 | 46 | 47 | /* 48 | * ___________________________________________________________________________ 49 | */ 50 | VectorDataUnit::VectorDataUnit() : CompositeDataUnit(), template_(0) { 51 | } 52 | 53 | 54 | /* 55 | * ___________________________________________________________________________ 56 | */ 57 | VectorDataUnit::VectorDataUnit(bool empty) 58 | : CompositeDataUnit(empty), template_(0) { 59 | } 60 | 61 | 62 | /* 63 | * ___________________________________________________________________________ 64 | */ 65 | VectorDataUnit::VectorDataUnit(DataUnit* elementTemplate) : 66 | CompositeDataUnit(), template_(elementTemplate) { 67 | 68 | } 69 | 70 | 71 | /* 72 | * ___________________________________________________________________________ 73 | */ 74 | const TypeDescriptor& VectorDataUnit::getTypeDescriptor() const { 75 | 76 | return typeDescriptor(); 77 | } 78 | 79 | 80 | /* 81 | * ___________________________________________________________________________ 82 | */ 83 | void VectorDataUnit::setElementTemplate(DataUnit* elementTemplate) { 84 | 85 | if (template_ != 0) { 86 | delete template_; 87 | } 88 | template_ = elementTemplate; 89 | } 90 | 91 | 92 | /* 93 | * ___________________________________________________________________________ 94 | */ 95 | DataUnit* VectorDataUnit::getElementTemplate() const { 96 | 97 | return template_; 98 | } 99 | 100 | 101 | /* 102 | * ___________________________________________________________________________ 103 | */ 104 | VectorDataUnit::~VectorDataUnit() { 105 | 106 | /* delete the template if one has been given */ 107 | if (template_ != 0) { 108 | delete template_; 109 | } 110 | } 111 | 112 | -------------------------------------------------------------------------------- /tls-diff-testing/bitman/src/VoidField.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 3 | * Andreas Walz [andreas.walz@hs-offenburg.de] 4 | * Offenburg University of Applied Sciences 5 | * Institute of Reliable Embedded Systems and Communications Electronics (ivESK) 6 | * [https://ivesk.hs-offenburg.de/] 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | */ 36 | 37 | #include "VoidField.h" 38 | 39 | 40 | /* 41 | * ___________________________________________________________________________ 42 | */ 43 | TypeDescriptor VoidField::desc_( 44 | FieldDataUnit::typeDescriptor(), 0, "VoidField"); 45 | 46 | 47 | /* 48 | * ___________________________________________________________________________ 49 | */ 50 | VoidField::VoidField() : FieldDataUnit(0) { 51 | 52 | this->setName("void"); 53 | } 54 | 55 | 56 | /* 57 | * ___________________________________________________________________________ 58 | */ 59 | const TypeDescriptor& VoidField::getTypeDescriptor() const { 60 | 61 | return typeDescriptor(); 62 | } 63 | 64 | 65 | /* 66 | * ___________________________________________________________________________ 67 | */ 68 | bool VoidField::decode_(const BufferReader& reader) { 69 | 70 | /* there is nothing to do for a void field */ 71 | return true; 72 | } 73 | 74 | 75 | /* 76 | * ___________________________________________________________________________ 77 | */ 78 | bool VoidField::encode_() { 79 | 80 | /* there is nothing to do for a void field */ 81 | return true; 82 | } 83 | 84 | 85 | /* 86 | * ___________________________________________________________________________ 87 | */ 88 | bool VoidField::isDecoded_() const { 89 | 90 | return !this->dissector().isAccepting(); 91 | } 92 | 93 | 94 | /* 95 | * ___________________________________________________________________________ 96 | */ 97 | DataUnit* VoidField::newInstance_() const { 98 | 99 | return new VoidField(); 100 | } 101 | 102 | 103 | /* 104 | * ___________________________________________________________________________ 105 | */ 106 | VoidField::~VoidField() { 107 | } 108 | 109 | -------------------------------------------------------------------------------- /tls-diff-testing/bitman/src/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 3 | * Andreas Walz [andreas.walz@hs-offenburg.de] 4 | * Offenburg University of Applied Sciences 5 | * Institute of Reliable Embedded Systems and Communications Electronics (ivESK) 6 | * [https://ivesk.hs-offenburg.de/] 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | */ 36 | 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include "../../tls-definitions.h" 43 | 44 | using std::cout; 45 | using std::endl; 46 | using std::string; 47 | using std::vector; 48 | 49 | void dissect(const char* input); 50 | 51 | int main(int argc , char *argv[]) { 52 | 53 | if (argc < 2) { 54 | dissect( 55 | "0x160301012c01000128030340c70e243001b96d8c63687738696432d3e6f949" 56 | "107aabad8450cdffd6a266e4000092c030c02cc028c024c014c00a00a3009f" 57 | "006b006a0039003800880087c032c02ec02ac026c00fc005009d003d003500" 58 | "84c02fc02bc027c023c013c00900a2009e0067004000330032009a00990045" 59 | "0044c031c02dc029c025c00ec004009c003c002f00960041c011c007c00cc0" 60 | "0200050004c012c00800160013c00dc003000a001500120009001400110008" 61 | "0006000300ff0100006d000b000403000102000a00340032000e000d001900" 62 | "0b000c00180009000a00160017000800060007001400150004000500120013" 63 | "000100020003000f0010001100230000000d0020001e060106020603050105" 64 | "020503040104020403030103020303020102020203000f000101"); 65 | } else { 66 | if (strcmp(argv[1], "dissect") == 0) { 67 | if (argc < 3) { 68 | cout << "Missing hex string / filename to dissect. Stopping.\n"; 69 | return 1; 70 | } 71 | dissect(argv[2]); 72 | } else { 73 | cout << "Unknown command. Stopping.\n"; 74 | return 1; 75 | } 76 | } 77 | 78 | return EXIT_SUCCESS; 79 | } 80 | 81 | 82 | void dissect(const char* input) { 83 | 84 | String inputStr(input); 85 | VectorBuffer bufRecord; 86 | if (inputStr.removeLeadingText("0x")) { 87 | bufRecord.appendFromString(inputStr); 88 | } else { 89 | bufRecord.appendFromFile(inputStr); 90 | } 91 | 92 | TVector_MainType rec; 93 | rec.dissector().dissectFromBuffer(bufRecord); 94 | 95 | rec.print(); 96 | } 97 | 98 | -------------------------------------------------------------------------------- /tls-diff-testing/cryptoman/Makefile: -------------------------------------------------------------------------------- 1 | SRC_SUFFIX = .cpp 2 | 3 | LIBRARY = cryptoman 4 | EXECUTABLE = main 5 | 6 | LIB_CRYPTOPP=$(shell cat ../cryptopp.path) 7 | 8 | SRC_DIR = src 9 | INC_DIRS = inc ../bitman/inc $(LIB_CRYPTOPP)/../ 10 | LIB_DIRS = ../bitman/build $(LIB_CRYPTOPP) 11 | 12 | BUILD_DIR = build 13 | OBJ_DIR = $(BUILD_DIR)/obj 14 | PREP_DIR = $(BUILD_DIR)/prep 15 | LIBOBJ_DIR = 16 | 17 | LIBS = bitman cryptopp 18 | 19 | 20 | # define compiler 21 | CC = g++ 22 | 23 | # define macros 24 | MACROS = _LINUX 25 | 26 | # define architecture 27 | ARCH = 28 | 29 | CFLAGS = -c -Wall -Wno-unused-variable $(foreach d, $(INC_DIRS), -I$d) $(foreach d, $(MACROS), -D$d) $(ARCH) -O0 -g $(PROF) 30 | LDFLAGS = $(ARCH) $(foreach d, $(LIB_DIRS), -L$d) $(foreach d, $(LIBS), -l$d) $(PROF) 31 | 32 | 33 | MAIN_SRC = $(SRC_DIR)/$(EXECUTABLE)$(SRC_SUFFIX) 34 | SOURCES_ = $(shell ls $(SRC_DIR)/*$(SRC_SUFFIX)) 35 | SOURCES = $(filter-out $(MAIN_SRC),$(SOURCES_)) 36 | 37 | OBJECTS_ = $(SOURCES:$(SRC_SUFFIX)=.o) 38 | OBJECTS = $(OBJECTS_:$(SRC_DIR)/%=$(OBJ_DIR)/%) 39 | PREPS = $(SOURCES_:$(SRC_DIR)/%=$(PREP_DIR)/%) 40 | MAIN_OBJ_ = $(MAIN_SRC:$(SRC_SUFFIX)=.o) 41 | MAIN_OBJ = $(MAIN_OBJ_:$(SRC_DIR)/%=$(OBJ_DIR)/%) 42 | 43 | LIB_OBJS = $(shell ls $(LIBOBJ_DIR)/*.o 2>/dev/null) 44 | 45 | 46 | all: executable library 47 | 48 | lib: library 49 | 50 | exec: executable 51 | 52 | prep: preprocessed 53 | 54 | executable: $(OBJECTS) $(MAIN_OBJ) 55 | @echo "\033[01;33m==> Creating executable '$(BUILD_DIR)/$(EXECUTABLE)':\033[00;00m" 56 | @mkdir -p $(BUILD_DIR) 57 | $(CC) $(OBJECTS) $(MAIN_OBJ) -o $(BUILD_DIR)/$(EXECUTABLE) $(LDFLAGS) 58 | @echo "" 59 | @echo "\033[01;33m==> Creating link '$(EXECUTABLE)' to executable '$(BUILD_DIR)/$(EXECUTABLE)':\033[00;00m" 60 | @rm -rf $(EXECUTABLE) 61 | ln -s $(BUILD_DIR)/$(EXECUTABLE) $(EXECUTABLE) 62 | @echo "" 63 | 64 | library: $(OBJECTS) 65 | @echo "\033[01;33m==> Creating static library '$@':\033[00;00m" 66 | @mkdir -p $(BUILD_DIR) 67 | ar rcs $(BUILD_DIR)/lib$(LIBRARY).a $(OBJECTS) $(LIB_OBJS) 68 | @echo "" 69 | 70 | preprocessed: $(PREPS) 71 | 72 | $(OBJ_DIR)/%.o: $(SRC_DIR)/%$(SRC_SUFFIX) 73 | @echo "\033[01;32m==> Compiling '$<':\033[00;00m" 74 | @mkdir -p $(OBJ_DIR) 75 | $(CC) $(CFLAGS) $< -o $@ 76 | @echo "" 77 | 78 | $(PREP_DIR)/%: $(SRC_DIR)/% 79 | @echo "\033[01;32m==> Preprocessing '$<':\033[00;00m" 80 | @mkdir -p $(PREP_DIR) 81 | $(CC) $(CFLAGS) $< -E > $@ 82 | @echo "" 83 | 84 | clean: 85 | @echo "\033[01;31m==> Cleaning directories:\033[00;00m" 86 | rm -rf $(BUILD_DIR)/ 87 | rm -rf $(EXECUTABLE) 88 | @echo "" 89 | 90 | -------------------------------------------------------------------------------- /tls-diff-testing/cryptoman/inc/HMAC.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 3 | * Andreas Walz [andreas.walz@hs-offenburg.de] 4 | * Offenburg University of Applied Sciences 5 | * Institute of Reliable Embedded Systems and Communications Electronics (ivESK) 6 | * [https://ivesk.hs-offenburg.de/] 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | */ 36 | 37 | #ifndef __HMAC_H__ 38 | #define __HMAC_H__ 39 | 40 | #include 41 | #include 42 | #include "MessageDigest.h" 43 | #include "VectorBuffer.h" 44 | 45 | class BufferWriter; 46 | 47 | 48 | /* ========================================================================== 49 | * 50 | * 51 | * 52 | * ========================================================================== */ 53 | 54 | class HMAC : public MessageDigest { 55 | 56 | private: 57 | 58 | MessageDigest* digest_; 59 | VectorBuffer key_; 60 | 61 | void initDigest(); 62 | 63 | 64 | public: 65 | 66 | HMAC(MessageDigest* digest, const BufferReader& key); 67 | 68 | virtual const BC& getDigestSize() const; 69 | virtual const BC& getBlockSize() const; 70 | 71 | virtual void reset(); 72 | virtual void update(const BufferReader& message); 73 | virtual void finish(BufferWriter& hash); 74 | 75 | virtual ~HMAC(); 76 | 77 | }; 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /tls-diff-testing/cryptoman/inc/MessageDigest.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 3 | * Andreas Walz [andreas.walz@hs-offenburg.de] 4 | * Offenburg University of Applied Sciences 5 | * Institute of Reliable Embedded Systems and Communications Electronics (ivESK) 6 | * [https://ivesk.hs-offenburg.de/] 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | */ 36 | 37 | #ifndef __MessageDigest_H__ 38 | #define __MessageDigest_H__ 39 | 40 | #include 41 | #include 42 | 43 | class BufferReader; 44 | class BufferWriter; 45 | class BC; 46 | 47 | 48 | /* ========================================================================== 49 | * 50 | * 51 | * 52 | * ========================================================================== */ 53 | 54 | class MessageDigest { 55 | 56 | public: 57 | 58 | /* TODO: Add description */ 59 | MessageDigest(); 60 | 61 | /* TODO: Add description */ 62 | virtual const BC& getDigestSize() const = 0; 63 | 64 | /* TODO: Add description */ 65 | virtual const BC& getBlockSize() const = 0; 66 | 67 | 68 | /* TODO: Add description */ 69 | virtual void reset() = 0; 70 | 71 | /* TODO: Add description */ 72 | virtual void update(const BufferReader& message) = 0; 73 | 74 | /* TODO: Add description */ 75 | virtual void finish(BufferWriter& hash) = 0; 76 | 77 | 78 | /* TODO: Add description */ 79 | void digest(const BufferReader& message, BufferWriter& hash); 80 | 81 | 82 | /* TODO: Add description */ 83 | virtual ~MessageDigest(); 84 | 85 | }; 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /tls-diff-testing/cryptoman/inc/SHA256.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 3 | * Andreas Walz [andreas.walz@hs-offenburg.de] 4 | * Offenburg University of Applied Sciences 5 | * Institute of Reliable Embedded Systems and Communications Electronics (ivESK) 6 | * [https://ivesk.hs-offenburg.de/] 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | */ 36 | 37 | #ifndef __SHA256_H__ 38 | #define __SHA256_H__ 39 | 40 | #include 41 | #include 42 | #include "MessageDigest.h" 43 | #include "cryptopp/sha.h" 44 | 45 | class BufferReader; 46 | class BufferWriter; 47 | 48 | 49 | /* ========================================================================== 50 | * 51 | * 52 | * 53 | * ========================================================================== */ 54 | 55 | class SHA256 : public MessageDigest { 56 | 57 | private: 58 | 59 | CryptoPP::SHA256 sha256_; 60 | 61 | static BC digestSize_; 62 | static BC blockSize_; 63 | 64 | 65 | public: 66 | 67 | SHA256(); 68 | 69 | virtual const BC& getDigestSize() const; 70 | virtual const BC& getBlockSize() const; 71 | 72 | virtual void reset(); 73 | virtual void update(const BufferReader& message); 74 | virtual void finish(BufferWriter& hash); 75 | 76 | virtual ~SHA256(); 77 | 78 | }; 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /tls-diff-testing/cryptoman/src/MessageDigest.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 3 | * Andreas Walz [andreas.walz@hs-offenburg.de] 4 | * Offenburg University of Applied Sciences 5 | * Institute of Reliable Embedded Systems and Communications Electronics (ivESK) 6 | * [https://ivesk.hs-offenburg.de/] 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | */ 36 | 37 | #include "MessageDigest.h" 38 | 39 | 40 | /* 41 | * ___________________________________________________________________________ 42 | */ 43 | MessageDigest::MessageDigest() { 44 | } 45 | 46 | 47 | /* 48 | * ___________________________________________________________________________ 49 | */ 50 | void MessageDigest::digest(const BufferReader& message, BufferWriter& hash) { 51 | 52 | this->reset(); 53 | this->update(message); 54 | this->finish(hash); 55 | } 56 | 57 | 58 | /* 59 | * ___________________________________________________________________________ 60 | */ 61 | MessageDigest::~MessageDigest() { 62 | } 63 | 64 | -------------------------------------------------------------------------------- /tls-diff-testing/cryptoman/src/SHA256.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 3 | * Andreas Walz [andreas.walz@hs-offenburg.de] 4 | * Offenburg University of Applied Sciences 5 | * Institute of Reliable Embedded Systems and Communications Electronics (ivESK) 6 | * [https://ivesk.hs-offenburg.de/] 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | */ 36 | 37 | #include 38 | #include "SHA256.h" 39 | #include "BufferReader.h" 40 | #include "BufferWriter.h" 41 | 42 | 43 | BC SHA256::digestSize_; 44 | BC SHA256::blockSize_; 45 | 46 | 47 | /* 48 | * ___________________________________________________________________________ 49 | */ 50 | SHA256::SHA256() { 51 | } 52 | 53 | 54 | /* 55 | * ___________________________________________________________________________ 56 | */ 57 | const BC& SHA256::getDigestSize() const { 58 | 59 | digestSize_ = CryptoPP::SHA256::DIGESTSIZE; 60 | return digestSize_; 61 | } 62 | 63 | 64 | /* 65 | * ___________________________________________________________________________ 66 | */ 67 | const BC& SHA256::getBlockSize() const { 68 | 69 | SHA256::blockSize_ = CryptoPP::SHA256::BLOCKSIZE; 70 | return SHA256::blockSize_; 71 | } 72 | 73 | 74 | /* 75 | * ___________________________________________________________________________ 76 | */ 77 | void SHA256::reset() { 78 | 79 | sha256_.Restart(); 80 | } 81 | 82 | 83 | /* 84 | * ___________________________________________________________________________ 85 | */ 86 | void SHA256::update(const BufferReader& message) { 87 | 88 | BC len = message.getLength(); 89 | if (len.bit8() != 0) { 90 | throw std::runtime_error( 91 | "SHA256::update(...): Message is not byte-aligned"); 92 | } 93 | 94 | size_t n = len.byte(); 95 | uint8_t data[n]; 96 | message.copyTo(data, n); 97 | sha256_.Update(data, n); 98 | } 99 | 100 | 101 | /* 102 | * ___________________________________________________________________________ 103 | */ 104 | void SHA256::finish(BufferWriter& hash) { 105 | 106 | size_t n = this->getDigestSize().byte(); 107 | uint8_t digest[n]; 108 | sha256_.Final(digest); 109 | hash.appendBytes(digest, n); 110 | } 111 | 112 | 113 | /* 114 | * ___________________________________________________________________________ 115 | */ 116 | SHA256::~SHA256() { 117 | } 118 | 119 | -------------------------------------------------------------------------------- /tls-diff-testing/cryptoman/src/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 3 | * Andreas Walz [andreas.walz@hs-offenburg.de] 4 | * Offenburg University of Applied Sciences 5 | * Institute of Reliable Embedded Systems and Communications Electronics (ivESK) 6 | * [https://ivesk.hs-offenburg.de/] 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | */ 36 | 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include "VectorBuffer.h" 43 | #include "SHA256.h" 44 | #include "HMAC.h" 45 | 46 | using std::cout; 47 | using std::endl; 48 | 49 | 50 | int main(int argc , char *argv[]) { 51 | 52 | return EXIT_SUCCESS; 53 | } 54 | 55 | -------------------------------------------------------------------------------- /tls-diff-testing/cryptopp.path: -------------------------------------------------------------------------------- 1 | ../../cryptopp 2 | -------------------------------------------------------------------------------- /tls-diff-testing/generator/Makefile: -------------------------------------------------------------------------------- 1 | SRC_SUFFIX = .cpp 2 | 3 | LIBRARY = generate 4 | EXECUTABLE = generate 5 | 6 | LIB_CRYPTOPP=$(shell cat ../cryptopp.path) 7 | 8 | SRC_DIR = src 9 | INC_DIRS = inc ../bitman/inc ../cryptoman/inc ../middleman/inc $(LIB_CRYPTOPP)/../ 10 | LIB_DIRS = ../bitman/build ../cryptoman/build ../middleman/build $(LIB_CRYPTOPP) 11 | 12 | BUILD_DIR = build 13 | OBJ_DIR = $(BUILD_DIR)/obj 14 | PREP_DIR = $(BUILD_DIR)/prep 15 | LIBOBJ_DIR = 16 | 17 | LIBS = middleman cryptoman bitman cryptopp 18 | 19 | 20 | # define compiler 21 | CC = g++ 22 | 23 | # define macros 24 | MACROS = _LINUX 25 | 26 | # define architecture 27 | ARCH = 28 | 29 | CFLAGS = -c -Wall $(foreach d, $(INC_DIRS), -I$d) $(foreach d, $(MACROS), -D$d) $(ARCH) -O0 -g $(PROF) 30 | LDFLAGS = $(ARCH) $(foreach d, $(LIB_DIRS), -L$d) $(foreach d, $(LIBS), -l$d) $(PROF) 31 | 32 | 33 | MAIN_SRC = $(SRC_DIR)/$(EXECUTABLE)$(SRC_SUFFIX) 34 | SOURCES_ = $(shell ls $(SRC_DIR)/*$(SRC_SUFFIX)) 35 | SOURCES = $(filter-out $(MAIN_SRC),$(SOURCES_)) 36 | 37 | OBJECTS_ = $(SOURCES:$(SRC_SUFFIX)=.o) 38 | OBJECTS = $(OBJECTS_:$(SRC_DIR)/%=$(OBJ_DIR)/%) 39 | PREPS = $(SOURCES_:$(SRC_DIR)/%=$(PREP_DIR)/%) 40 | MAIN_OBJ_ = $(MAIN_SRC:$(SRC_SUFFIX)=.o) 41 | MAIN_OBJ = $(MAIN_OBJ_:$(SRC_DIR)/%=$(OBJ_DIR)/%) 42 | 43 | LIB_OBJS = $(shell ls $(LIBOBJ_DIR)/*.o 2>/dev/null) 44 | 45 | 46 | all: executable library 47 | 48 | lib: library 49 | 50 | exec: executable 51 | 52 | prep: preprocessed 53 | 54 | executable: $(OBJECTS) $(MAIN_OBJ) 55 | @echo "\033[01;33m==> Creating executable '$(BUILD_DIR)/$(EXECUTABLE)':\033[00;00m" 56 | @mkdir -p $(BUILD_DIR) 57 | $(CC) $(OBJECTS) $(MAIN_OBJ) -o $(BUILD_DIR)/$(EXECUTABLE) $(LDFLAGS) 58 | @echo "" 59 | @echo "\033[01;33m==> Creating link '$(EXECUTABLE)' to executable '$(BUILD_DIR)/$(EXECUTABLE)':\033[00;00m" 60 | @rm -rf $(EXECUTABLE) 61 | ln -s $(BUILD_DIR)/$(EXECUTABLE) $(EXECUTABLE) 62 | @echo "" 63 | 64 | library: $(OBJECTS) 65 | @echo "\033[01;33m==> Creating static library '$@':\033[00;00m" 66 | @mkdir -p $(BUILD_DIR) 67 | ar rcs $(BUILD_DIR)/lib$(LIBRARY).a $(OBJECTS) $(LIB_OBJS) 68 | @echo "" 69 | 70 | preprocessed: $(PREPS) 71 | 72 | $(OBJ_DIR)/%.o: $(SRC_DIR)/%$(SRC_SUFFIX) 73 | @echo "\033[01;32m==> Compiling '$<':\033[00;00m" 74 | @mkdir -p $(OBJ_DIR) 75 | $(CC) $(CFLAGS) $< -o $@ 76 | @echo "" 77 | 78 | $(PREP_DIR)/%: $(SRC_DIR)/% 79 | @echo "\033[01;32m==> Preprocessing '$<':\033[00;00m" 80 | @mkdir -p $(PREP_DIR) 81 | $(CC) $(CFLAGS) $< -E > $@ 82 | @echo "" 83 | 84 | clean: 85 | @echo "\033[01;31m==> Cleaning directories:\033[00;00m" 86 | rm -rf $(BUILD_DIR)/ 87 | rm -rf $(EXECUTABLE) 88 | @echo "" 89 | 90 | -------------------------------------------------------------------------------- /tls-diff-testing/generator/macros/generate_multi.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | DATADIR=. 4 | NSETS=100 5 | NPERSET=100000 6 | 7 | for i in $(seq 1 $NSETS); do 8 | 9 | ISTR=$(printf 'iteration-%03i' $i) 10 | echo "$ISTR:" 11 | mkdir -p $DATADIR/$ISTR 12 | 13 | echo " --> Generate random file ..." 14 | dd if=/dev/urandom of=$DATADIR/$ISTR/random.bin bs=1024 count=10240 >/dev/null 15 | 16 | echo " --> Generating TLS messages ..." 17 | ./generate $DATADIR/$ISTR/random.bin $DATADIR/$ISTR/stimuli.hex $NPERSET | tee $DATADIR/$ISTR/generation_log.txt 18 | 19 | done 20 | 21 | -------------------------------------------------------------------------------- /tls-diff-testing/middleman/Makefile: -------------------------------------------------------------------------------- 1 | SRC_SUFFIX = .cpp 2 | 3 | LIBRARY = middleman 4 | EXECUTABLE = middleman 5 | 6 | SRC_DIR = src 7 | INC_DIRS = inc ../bitman/inc ../cryptoman/inc 8 | LIB_DIRS = ../bitman/build ../cryptoman/build 9 | 10 | BUILD_DIR = build 11 | OBJ_DIR = $(BUILD_DIR)/obj 12 | PREP_DIR = $(BUILD_DIR)/prep 13 | LIBOBJ_DIR = 14 | 15 | LIBS = cryptoman bitman 16 | 17 | 18 | # define compiler 19 | CC = g++ 20 | 21 | # define macros 22 | MACROS = _LINUX 23 | 24 | # define architecture 25 | ARCH = 26 | 27 | CFLAGS = -c -Wall $(foreach d, $(INC_DIRS), -I$d) $(foreach d, $(MACROS), -D$d) $(ARCH) -O0 -g $(PROF) 28 | LDFLAGS = $(ARCH) $(foreach d, $(LIB_DIRS), -L$d) $(foreach d, $(LIBS), -l$d) $(PROF) 29 | 30 | 31 | MAIN_SRC = $(SRC_DIR)/$(EXECUTABLE)$(SRC_SUFFIX) 32 | SOURCES_ = $(shell ls $(SRC_DIR)/*$(SRC_SUFFIX)) 33 | SOURCES = $(filter-out $(MAIN_SRC),$(SOURCES_)) 34 | 35 | OBJECTS_ = $(SOURCES:$(SRC_SUFFIX)=.o) 36 | OBJECTS = $(OBJECTS_:$(SRC_DIR)/%=$(OBJ_DIR)/%) 37 | PREPS = $(SOURCES_:$(SRC_DIR)/%=$(PREP_DIR)/%) 38 | MAIN_OBJ_ = $(MAIN_SRC:$(SRC_SUFFIX)=.o) 39 | MAIN_OBJ = $(MAIN_OBJ_:$(SRC_DIR)/%=$(OBJ_DIR)/%) 40 | 41 | LIB_OBJS = $(shell ls $(LIBOBJ_DIR)/*.o 2>/dev/null) 42 | 43 | 44 | all: executable library 45 | 46 | lib: library 47 | 48 | exec: executable 49 | 50 | prep: preprocessed 51 | 52 | executable: $(OBJECTS) $(MAIN_OBJ) 53 | @echo "\033[01;33m==> Creating executable '$(BUILD_DIR)/$(EXECUTABLE)':\033[00;00m" 54 | @mkdir -p $(BUILD_DIR) 55 | $(CC) $(OBJECTS) $(MAIN_OBJ) -o $(BUILD_DIR)/$(EXECUTABLE) $(LDFLAGS) 56 | @echo "" 57 | @echo "\033[01;33m==> Creating link '$(EXECUTABLE)' to executable '$(BUILD_DIR)/$(EXECUTABLE)':\033[00;00m" 58 | @rm -rf $(EXECUTABLE) 59 | ln -s $(BUILD_DIR)/$(EXECUTABLE) $(EXECUTABLE) 60 | @echo "" 61 | 62 | library: $(OBJECTS) 63 | @echo "\033[01;33m==> Creating static library '$@':\033[00;00m" 64 | @mkdir -p $(BUILD_DIR) 65 | ar rcs $(BUILD_DIR)/lib$(LIBRARY).a $(OBJECTS) $(LIB_OBJS) 66 | @echo "" 67 | 68 | preprocessed: $(PREPS) 69 | 70 | $(OBJ_DIR)/%.o: $(SRC_DIR)/%$(SRC_SUFFIX) 71 | @echo "\033[01;32m==> Compiling '$<':\033[00;00m" 72 | @mkdir -p $(OBJ_DIR) 73 | $(CC) $(CFLAGS) $< -o $@ 74 | @echo "" 75 | 76 | $(PREP_DIR)/%: $(SRC_DIR)/% 77 | @echo "\033[01;32m==> Preprocessing '$<':\033[00;00m" 78 | @mkdir -p $(PREP_DIR) 79 | $(CC) $(CFLAGS) $< -E > $@ 80 | @echo "" 81 | 82 | clean: 83 | @echo "\033[01;31m==> Cleaning directories:\033[00;00m" 84 | rm -rf $(BUILD_DIR)/ 85 | rm -rf $(EXECUTABLE) 86 | @echo "" 87 | 88 | -------------------------------------------------------------------------------- /tls-diff-testing/middleman/inc/TCPBatchClientSocket.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 3 | * Andreas Walz [andreas.walz@hs-offenburg.de] 4 | * Offenburg University of Applied Sciences 5 | * Institute of Reliable Embedded Systems and Communications Electronics (ivESK) 6 | * [https://ivesk.hs-offenburg.de/] 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | */ 36 | 37 | #ifndef __TCPBatchClientSocket_H__ 38 | #define __TCPBatchClientSocket_H__ 39 | 40 | #include 41 | #include 42 | #include "TCPClientSocket.h" 43 | 44 | 45 | /* ========================================================================= 46 | * 47 | * 48 | * 49 | * ========================================================================= */ 50 | 51 | class TCPBatchClientSocket { 52 | 53 | private: 54 | 55 | /* TODO: Add description */ 56 | typedef std::vector socket_vector_type_t; 57 | 58 | 59 | /* TODO: Add description */ 60 | socket_vector_type_t sockets_; 61 | 62 | 63 | public: 64 | 65 | /* TODO: Add description */ 66 | TCPBatchClientSocket(); 67 | 68 | 69 | /* TODO: Add description */ 70 | bool addServer(const string& hostAndPort); 71 | 72 | /* TODO: Add description */ 73 | bool addServer(const string& host, int port); 74 | 75 | /* TODO: Add description */ 76 | inline size_t getNServer() const { 77 | 78 | return sockets_.size(); 79 | } 80 | 81 | 82 | /* TODO: Add description */ 83 | size_t connect(); 84 | 85 | /* TODO: Add description */ 86 | bool disconnect(); 87 | 88 | /* TODO: Add description */ 89 | bool close(); 90 | 91 | /* TODO: Add description */ 92 | bool allConnected() const; 93 | 94 | 95 | /* TODO: Add description */ 96 | bool setNonBlocking(bool nonBlocking); 97 | 98 | /* TODO: Add description */ 99 | void setTimeout(size_t seconds); 100 | 101 | 102 | /* TODO: Add description */ 103 | const TCPBatchClientSocket& operator<<(const BufferReader& reader); 104 | 105 | 106 | /* TODO: Add description */ 107 | inline TCPClientSocket& operator[](size_t index) { 108 | 109 | return *sockets_[index]; 110 | } 111 | 112 | 113 | /* TODO: Add description */ 114 | virtual ~TCPBatchClientSocket(); 115 | 116 | }; 117 | 118 | #endif 119 | -------------------------------------------------------------------------------- /tls-diff-testing/middleman/inc/TCPClientSocket.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 3 | * Andreas Walz [andreas.walz@hs-offenburg.de] 4 | * Offenburg University of Applied Sciences 5 | * Institute of Reliable Embedded Systems and Communications Electronics (ivESK) 6 | * [https://ivesk.hs-offenburg.de/] 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | */ 36 | 37 | #ifndef __TCPClientSocket_H__ 38 | #define __TCPClientSocket_H__ 39 | 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | #include 50 | #include "TCPSocket.h" 51 | 52 | 53 | /* ========================================================================== 54 | * 55 | * 56 | * 57 | * ========================================================================== */ 58 | 59 | class TCPClientSocket : public TCPSocket { 60 | 61 | public: 62 | 63 | /* TODO: Add description */ 64 | TCPClientSocket(const string& hostAndPort); 65 | 66 | /* TODO: Add description */ 67 | TCPClientSocket(const string& host, int port); 68 | 69 | 70 | /* TODO: Add description */ 71 | bool connect(); 72 | 73 | 74 | /* TODO: Add description */ 75 | virtual ~TCPClientSocket(); 76 | 77 | }; 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /tls-diff-testing/middleman/inc/TCPServerSocket.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 3 | * Andreas Walz [andreas.walz@hs-offenburg.de] 4 | * Offenburg University of Applied Sciences 5 | * Institute of Reliable Embedded Systems and Communications Electronics (ivESK) 6 | * [https://ivesk.hs-offenburg.de/] 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | */ 36 | 37 | #ifndef __TCPServerSocket_H__ 38 | #define __TCPServerSocket_H__ 39 | 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | 49 | #include "TCPSocket.h" 50 | 51 | #include 52 | #include 53 | 54 | using std::vector; 55 | using std::string; 56 | 57 | 58 | /* ========================================================================== 59 | * 60 | * 61 | * 62 | * ========================================================================== */ 63 | 64 | class TCPServerSocket : public TCPSocket { 65 | 66 | private: 67 | 68 | int port_; 69 | 70 | bool bind_(int port); 71 | bool listen_(int maxConnections = 5) const; 72 | int accept_() const; 73 | 74 | 75 | public: 76 | 77 | TCPServerSocket(); 78 | TCPServerSocket(int port); 79 | 80 | TCPSocket* accept(); 81 | 82 | virtual ~TCPServerSocket(); 83 | 84 | }; 85 | 86 | #endif 87 | -------------------------------------------------------------------------------- /tls-diff-testing/middleman/inc/TCPSocket.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 3 | * Andreas Walz [andreas.walz@hs-offenburg.de] 4 | * Offenburg University of Applied Sciences 5 | * Institute of Reliable Embedded Systems and Communications Electronics (ivESK) 6 | * [https://ivesk.hs-offenburg.de/] 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | */ 36 | 37 | #ifndef __TCPSocket_H__ 38 | #define __TCPSocket_H__ 39 | 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include "Socket.h" 45 | 46 | class BufferReader; 47 | class BufferWriter; 48 | 49 | 50 | /* ========================================================================== 51 | * 52 | * 53 | * 54 | * ========================================================================== */ 55 | 56 | class TCPSocket : public Socket { 57 | 58 | protected: 59 | 60 | /* TODO: Add description */ 61 | bool connected_; 62 | 63 | /* TODO: Add description */ 64 | bool create_(); 65 | 66 | /* TODO: Add description */ 67 | ssize_t send_(const uint8_t* const data, size_t len); 68 | 69 | /* TODO: Add description */ 70 | ssize_t recv_(uint8_t* const data, size_t maxLen); 71 | 72 | 73 | public: 74 | 75 | /* TODO: Add description */ 76 | TCPSocket(); 77 | 78 | /* TODO: Add description */ 79 | TCPSocket(int socket); 80 | 81 | 82 | /* TODO: Add description */ 83 | inline bool isConnected() const { 84 | 85 | return this->isValid() && connected_; 86 | } 87 | 88 | 89 | /* TODO: Add description */ 90 | bool disconnect(); 91 | 92 | 93 | /* TODO: Add description */ 94 | virtual ~TCPSocket(); 95 | 96 | }; 97 | 98 | #endif 99 | -------------------------------------------------------------------------------- /tls-diff-testing/middleman/inc/TransportRelay.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 3 | * Andreas Walz [andreas.walz@hs-offenburg.de] 4 | * Offenburg University of Applied Sciences 5 | * Institute of Reliable Embedded Systems and Communications Electronics (ivESK) 6 | * [https://ivesk.hs-offenburg.de/] 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | */ 36 | 37 | #ifndef __TransportRelay_H__ 38 | #define __TransportRelay_H__ 39 | 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | 50 | #include 51 | #include 52 | 53 | using std::vector; 54 | using std::string; 55 | 56 | class TCPSocket; 57 | class TCPServerSocket; 58 | class TCPClientSocket; 59 | 60 | 61 | /* ========================================================================== 62 | * 63 | * 64 | * 65 | * ========================================================================== */ 66 | 67 | class TransportRelay { 68 | 69 | private: 70 | 71 | TCPServerSocket& serverSocket_; 72 | TCPClientSocket& outSocket_; 73 | TCPSocket* inSocket_; 74 | 75 | uint8_t* buffer_; 76 | int bufferLen_; 77 | 78 | int logLevel_; 79 | string logPrefix_; 80 | 81 | 82 | void log(int minLevel, const string& msg); 83 | 84 | void bufferToVector(uint8_t* buffer, size_t bufferLen, vector& data); 85 | 86 | 87 | public: 88 | 89 | TransportRelay(int inPort, const string& destAddr, int destPort); 90 | 91 | void setLogPrefix(string prefix); 92 | void setLogLevel(int logLevel); 93 | int getLogLevel() const; 94 | 95 | bool process(); 96 | bool close(); 97 | 98 | ssize_t injectToServer(vector& data); 99 | ssize_t injectToClient(vector& data); 100 | 101 | virtual bool interceptToServer(vector& data); 102 | virtual bool interceptToClient(vector& data); 103 | 104 | virtual ~TransportRelay(); 105 | 106 | }; 107 | 108 | #endif 109 | -------------------------------------------------------------------------------- /tls-diff-testing/middleman/inc/UDPClientSocket.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 3 | * Andreas Walz [andreas.walz@hs-offenburg.de] 4 | * Offenburg University of Applied Sciences 5 | * Institute of Reliable Embedded Systems and Communications Electronics (ivESK) 6 | * [https://ivesk.hs-offenburg.de/] 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | */ 36 | 37 | #ifndef __UDPClientSocket_H__ 38 | #define __UDPClientSocket_H__ 39 | 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | 49 | #include "UDPSocket.h" 50 | 51 | #include 52 | 53 | using std::vector; 54 | using std::string; 55 | 56 | 57 | /* ========================================================================== 58 | * 59 | * 60 | * 61 | * ========================================================================== */ 62 | 63 | class UDPClientSocket : public UDPSocket { 64 | 65 | public: 66 | 67 | /* TODO: Add description */ 68 | UDPClientSocket(const string& hostAndPort); 69 | 70 | /* TODO: Add description */ 71 | UDPClientSocket(const string& host, int port); 72 | 73 | 74 | /* TODO: Add description */ 75 | virtual ~UDPClientSocket(); 76 | 77 | }; 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /tls-diff-testing/middleman/inc/UDPSocket.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 3 | * Andreas Walz [andreas.walz@hs-offenburg.de] 4 | * Offenburg University of Applied Sciences 5 | * Institute of Reliable Embedded Systems and Communications Electronics (ivESK) 6 | * [https://ivesk.hs-offenburg.de/] 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | */ 36 | 37 | #ifndef __UDPSocket_H__ 38 | #define __UDPSocket_H__ 39 | 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include "Socket.h" 45 | 46 | class BufferReader; 47 | class BufferWriter; 48 | 49 | using std::vector; 50 | using std::string; 51 | 52 | 53 | /* ========================================================================== 54 | * 55 | * 56 | * 57 | * ========================================================================== */ 58 | 59 | class UDPSocket : public Socket { 60 | 61 | protected: 62 | 63 | bool create_(); 64 | 65 | ssize_t send_(const uint8_t* const data, size_t len); 66 | ssize_t recv_(uint8_t* const data, size_t maxLen); 67 | 68 | 69 | public: 70 | 71 | UDPSocket(); 72 | UDPSocket(int socket); 73 | 74 | virtual ~UDPSocket(); 75 | 76 | }; 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /tls-diff-testing/middleman/src/TCPClientSocket.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 3 | * Andreas Walz [andreas.walz@hs-offenburg.de] 4 | * Offenburg University of Applied Sciences 5 | * Institute of Reliable Embedded Systems and Communications Electronics (ivESK) 6 | * [https://ivesk.hs-offenburg.de/] 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | */ 36 | 37 | #include "TCPClientSocket.h" 38 | #include "String_.h" 39 | #include "errno.h" 40 | #include 41 | #include 42 | 43 | using std::vector; 44 | using std::string; 45 | 46 | 47 | /* 48 | * ___________________________________________________________________________ 49 | */ 50 | TCPClientSocket::TCPClientSocket(const string& hostAndPort) { 51 | 52 | if (!this->setRemoteAddress(hostAndPort)) { 53 | throw std::runtime_error( 54 | "TCPClientSocket(...): Failed to resolve host address"); 55 | } 56 | } 57 | 58 | 59 | /* 60 | * ___________________________________________________________________________ 61 | */ 62 | TCPClientSocket::TCPClientSocket(const string& host, int port) { 63 | 64 | if (!this->setRemoteAddress(host, port)) { 65 | throw std::runtime_error( 66 | "TCPClientSocket(...): Failed to resolve host address"); 67 | } 68 | } 69 | 70 | 71 | /* 72 | * ___________________________________________________________________________ 73 | */ 74 | bool TCPClientSocket::connect() { 75 | 76 | if (!this->isValid() && !this->create_()) { 77 | return false; 78 | } 79 | 80 | int status = ::connect(this->getSocketFd_(), 81 | (sockaddr*)this->remoteAddress_(), this->remoteAddressSize_()); 82 | if (status == 0) { 83 | connected_ = true; 84 | } 85 | 86 | return this->isConnected(); 87 | } 88 | 89 | 90 | /* 91 | * ___________________________________________________________________________ 92 | */ 93 | TCPClientSocket::~TCPClientSocket() { 94 | } 95 | -------------------------------------------------------------------------------- /tls-diff-testing/middleman/src/TCPServerSocket.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 3 | * Andreas Walz [andreas.walz@hs-offenburg.de] 4 | * Offenburg University of Applied Sciences 5 | * Institute of Reliable Embedded Systems and Communications Electronics (ivESK) 6 | * [https://ivesk.hs-offenburg.de/] 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | */ 36 | 37 | #include "TCPServerSocket.h" 38 | #include "String_.h" 39 | #include "errno.h" 40 | #include 41 | #include 42 | 43 | 44 | /* 45 | * ___________________________________________________________________________ 46 | */ 47 | TCPServerSocket::TCPServerSocket(int port) { 48 | 49 | port_ = port; 50 | 51 | if (!this->bind_(port)) { 52 | throw std::runtime_error( 53 | "TCPServerSocket(...): Could not bind to port."); 54 | } 55 | if (!this->listen_()) { 56 | throw std::runtime_error( 57 | "TCPServerSocket(...): Could not listen to socket."); 58 | } 59 | } 60 | 61 | 62 | /* 63 | * ___________________________________________________________________________ 64 | */ 65 | bool TCPServerSocket::bind_(int port) { 66 | 67 | if (!this->isValid()) { 68 | return false; 69 | } 70 | 71 | sockaddr_in addr; 72 | addr.sin_family = AF_INET; 73 | addr.sin_addr.s_addr = INADDR_ANY; 74 | addr.sin_port = htons(port); 75 | 76 | int bind_return = ::bind(this->getSocketFd_(), 77 | (struct sockaddr*)&addr, sizeof(addr)); 78 | 79 | return (bind_return != -1); 80 | } 81 | 82 | 83 | /* 84 | * ___________________________________________________________________________ 85 | */ 86 | bool TCPServerSocket::listen_(int maxConnections) const { 87 | 88 | if (!this->isValid()) { 89 | return false; 90 | } 91 | 92 | int listen_return = ::listen(this->getSocketFd_(), maxConnections); 93 | 94 | return (listen_return != -1); 95 | } 96 | 97 | 98 | /* 99 | * ___________________________________________________________________________ 100 | */ 101 | int TCPServerSocket::accept_() const { 102 | 103 | if (!this->isValid()) { 104 | return false; 105 | } 106 | 107 | sockaddr_in addr; 108 | socklen_t addr_length = (socklen_t)sizeof(addr); 109 | 110 | return ::accept(this->getSocketFd_(), (sockaddr*)&addr, &addr_length); 111 | } 112 | 113 | 114 | /* 115 | * ___________________________________________________________________________ 116 | */ 117 | TCPSocket* TCPServerSocket::accept() { 118 | 119 | TCPSocket* srvSock = (TCPSocket*)0; 120 | 121 | int socket = accept_(); 122 | if (socket > 0) { 123 | srvSock = new TCPSocket(socket); 124 | } 125 | 126 | return srvSock; 127 | } 128 | 129 | 130 | /* 131 | * ___________________________________________________________________________ 132 | */ 133 | TCPServerSocket::~TCPServerSocket() { 134 | } 135 | -------------------------------------------------------------------------------- /tls-diff-testing/middleman/src/UDPClientSocket.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 3 | * Andreas Walz [andreas.walz@hs-offenburg.de] 4 | * Offenburg University of Applied Sciences 5 | * Institute of Reliable Embedded Systems and Communications Electronics (ivESK) 6 | * [https://ivesk.hs-offenburg.de/] 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | */ 36 | 37 | #include "UDPClientSocket.h" 38 | #include 39 | 40 | 41 | /* 42 | * ___________________________________________________________________________ 43 | */ 44 | UDPClientSocket::UDPClientSocket(const string& hostAndPort) { 45 | 46 | if (!this->setRemoteAddress(hostAndPort)) { 47 | throw std::runtime_error( 48 | "UDPClientSocket(...): Failed to resolve host address"); 49 | } 50 | } 51 | 52 | 53 | /* 54 | * ___________________________________________________________________________ 55 | */ 56 | UDPClientSocket::UDPClientSocket(const string& host, int port) { 57 | 58 | if (!this->setRemoteAddress(host, port)) { 59 | throw std::runtime_error( 60 | "UDPClientSocket(...): Failed to resolve host address"); 61 | } 62 | } 63 | 64 | 65 | /* 66 | * ___________________________________________________________________________ 67 | */ 68 | UDPClientSocket::~UDPClientSocket() { 69 | } 70 | -------------------------------------------------------------------------------- /tls-diff-testing/middleman/src/UDPSocket.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 3 | * Andreas Walz [andreas.walz@hs-offenburg.de] 4 | * Offenburg University of Applied Sciences 5 | * Institute of Reliable Embedded Systems and Communications Electronics (ivESK) 6 | * [https://ivesk.hs-offenburg.de/] 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | */ 36 | 37 | #include "errno.h" 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | 45 | #include "BufferReader.h" 46 | #include "BufferWriter.h" 47 | #include "String_.h" 48 | #include "UDPSocket.h" 49 | 50 | 51 | /* 52 | * ___________________________________________________________________________ 53 | */ 54 | UDPSocket::UDPSocket() { 55 | 56 | if (!this->create_()) { 57 | throw std::runtime_error( 58 | "TCPSocket(...): Could not create UDP socket."); 59 | } 60 | } 61 | 62 | 63 | /* 64 | * ___________________________________________________________________________ 65 | */ 66 | UDPSocket::UDPSocket(int socket) : Socket(socket) { 67 | } 68 | 69 | 70 | /* 71 | * ___________________________________________________________________________ 72 | */ 73 | bool UDPSocket::create_() { 74 | 75 | if (this->isValid()) { 76 | return false; 77 | } 78 | 79 | int socket = ::socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); 80 | if (socket < 0) { 81 | return false; 82 | } 83 | 84 | int on = 1; 85 | if (setsockopt(socket, SOL_SOCKET, SO_REUSEADDR, 86 | (const char*)&on, sizeof(on)) == -1) { 87 | return false; 88 | } 89 | 90 | return this->setSocketFd_(socket); 91 | } 92 | 93 | 94 | /* 95 | * ___________________________________________________________________________ 96 | */ 97 | ssize_t UDPSocket::send_(const uint8_t* const data, size_t len) { 98 | 99 | if (!this->hasRemoteAddress_()) { 100 | return -1; 101 | } 102 | 103 | int status = sendto(this->getSocketFd_(), data, len, 0, 104 | (struct sockaddr*)this->remoteAddress_(), 105 | this->remoteAddressSize_()); 106 | 107 | return status; 108 | } 109 | 110 | 111 | /* 112 | * ___________________________________________________________________________ 113 | */ 114 | ssize_t UDPSocket::recv_(uint8_t* const data, size_t maxLen) { 115 | 116 | return -1; 117 | } 118 | 119 | 120 | /* 121 | * ___________________________________________________________________________ 122 | */ 123 | UDPSocket::~UDPSocket() { 124 | } 125 | -------------------------------------------------------------------------------- /tls-server-batch/cacert.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIICljCCAf+gAwIBAgIJAIu8TOYPpxO+MA0GCSqGSIb3DQEBCwUAMGQxCzAJBgNV 3 | BAYTAkRFMRswGQYDVQQIDBJCYWRlbi1XdWVydHRlbWJlcmcxEjAQBgNVBAcMCU9m 4 | ZmVuYnVyZzEWMBQGA1UECgwNVHJ1c3QgR3JvdXAgQTEMMAoGA1UEAwwDQ0EwMB4X 5 | DTE3MDQwNjA3MzUxNVoXDTE4MDQwNjA3MzUxNVowZDELMAkGA1UEBhMCREUxGzAZ 6 | BgNVBAgMEkJhZGVuLVd1ZXJ0dGVtYmVyZzESMBAGA1UEBwwJT2ZmZW5idXJnMRYw 7 | FAYDVQQKDA1UcnVzdCBHcm91cCBBMQwwCgYDVQQDDANDQTAwgZ8wDQYJKoZIhvcN 8 | AQEBBQADgY0AMIGJAoGBAMuZZmbeFSbie1rqKRuJT3M9WVXHQqwBnwPnrlBwxZ7d 9 | cun88jzdRtq6b7Yhp0ZRHZTicXI5CVhTdCxJuYKx3wu3aU3R9uBaJUuZZcgZT6m5 10 | lb0ARTyUlnRvH+FATqMdPQVzqzXKLm/xtBHrjZmUdagPppiCMBqIf4v9qM2Oteyx 11 | AgMBAAGjUDBOMB0GA1UdDgQWBBTfwKs1xYqcGLVBAnJ9yIJxiLoBajAfBgNVHSME 12 | GDAWgBTfwKs1xYqcGLVBAnJ9yIJxiLoBajAMBgNVHRMEBTADAQH/MA0GCSqGSIb3 13 | DQEBCwUAA4GBALnNg5UKKTOD6UfeG72iQVDNXCIRXIy9HcKF8ze2Ez7Q6NTYPWTn 14 | vvPqtmRn+ztuLX8tMnFQlN6uBp8IOOfUx/x/aoY6X5p6hDeqo/r5NK07mv9d9oAe 15 | aD5Hmxz0RLzos5OwAyoy9l4+Y41YEAK+trO+lVge6EGYDpZfKsdjRdng 16 | -----END CERTIFICATE----- 17 | -------------------------------------------------------------------------------- /tls-server-batch/cert.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIICuzCCAiSgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwZDELMAkGA1UEBhMCREUx 3 | GzAZBgNVBAgMEkJhZGVuLVd1ZXJ0dGVtYmVyZzESMBAGA1UEBwwJT2ZmZW5idXJn 4 | MRYwFAYDVQQKDA1UcnVzdCBHcm91cCBBMQwwCgYDVQQDDANDQTAwHhcNMTcwNDA2 5 | MDczNTE1WhcNMTgwNDA2MDczNTE1WjBWMQswCQYDVQQGEwJERTEbMBkGA1UECAwS 6 | QmFkZW4tV3VlcnR0ZW1iZXJnMRYwFAYDVQQKDA1UcnVzdCBHcm91cCBBMRIwEAYD 7 | VQQDDAkxMjcuMC4wLjEwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANcCh0jF 8 | Pgo8Zwji5HdKRld93RLgds9iLUrEwFF6GYybGWiFw5er5AkJeQtFjmlDUw5z94MO 9 | BTEUwe1hxsMY5LZiybUg1njQu3F16EzZ0acdD4MQuedt5jcQCb+DbKqVpJl8ZcUo 10 | +omHCDnKeCPP6WC1S/riqWtXzzywuxsgaPTNAgMBAAGjgYkwgYYwCQYDVR0TBAIw 11 | ADALBgNVHQ8EBAMCBeAwLAYJYIZIAYb4QgENBB8WHU9wZW5TU0wgR2VuZXJhdGVk 12 | IENlcnRpZmljYXRlMB0GA1UdDgQWBBTFY1ug+j6KOZrbk/o17UOvWdY/qTAfBgNV 13 | HSMEGDAWgBTfwKs1xYqcGLVBAnJ9yIJxiLoBajANBgkqhkiG9w0BAQsFAAOBgQBD 14 | AM/5JTAwDbkyCWS3c5nJAMFvmm4RPy6segtuyo63Oxk3QI/eOzEJVuPzLTTBvQBR 15 | QfFI6AALZMJ3emUtG8OLggbeTOMDYvjCYPicLUvFilPwPgPrr1nvkbYor5uGwkiD 16 | 008Uzmy2rfskqBsH2sd18gECT8cLf75YXqJl1+tcIQ== 17 | -----END CERTIFICATE----- 18 | -------------------------------------------------------------------------------- /tls-server-batch/key.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIICXAIBAAKBgQDXAodIxT4KPGcI4uR3SkZXfd0S4HbPYi1KxMBRehmMmxlohcOX 3 | q+QJCXkLRY5pQ1MOc/eDDgUxFMHtYcbDGOS2Ysm1INZ40LtxdehM2dGnHQ+DELnn 4 | beY3EAm/g2yqlaSZfGXFKPqJhwg5yngjz+lgtUv64qlrV888sLsbIGj0zQIDAQAB 5 | AoGAGTFbpqQt28cuD3V+bZfPXCsMP0z7vtrzEaKyIhnbaoU12fBqdZgXdROeEjsJ 6 | L75KuhPOeZWn+BNFkcn2HyAIlDs9CiUy8466UnOB7z6AL+HMJS8HcayjXekYUuHm 7 | 9wCRuyOW1tg8uWj+pQyf/T2usBuelHjUYWs4tlY8th4OQyUCQQD2eXa1s3nkS6iQ 8 | +H3rsULZsu1ckMg2W8RCqtp/y224hWtOu7sTEC2vfqPTE4uHh9EshBVH9mAW5Dk3 9 | icZQNwPDAkEA31HDulgCxKKvdpwJ/XKOZwg1L3SszKAiCwEVR5O9OrWkndAYt+Je 10 | lcKoj0+63Wcik5e4jStRaMkXLXsyHdNsLwJBAOWAdGj8laNeT7etqpKsm/LaCOsI 11 | ZWU4TadGL+6PHbuTgDfv1mIJzoB7C1CgAmxQqxUoaCh54T9vg1eTknVexMECQF/n 12 | rGftfhrWRwZoEr4+oTtMQhMER2WFa7lQGMRphT2eXnjLsqHd3ILyWxNYyUZmEWpT 13 | IRW3Qbn/ii2lF6vJbU8CQA612Xc+Secj49WO/t59RZkNlicpIpQVZQk/dp06AcrT 14 | VFIqoBbVG5Pkll2JRH85hlz9WI5mEUywY9mB7PIIP5o= 15 | -----END RSA PRIVATE KEY----- 16 | -------------------------------------------------------------------------------- /tls-server-batch/launch.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SERVERS="openssl-1.0.2h mbedtls-2.2.0 wolfssl-3.9.8 matrixssl-3.8.4 boringssl-2883" 4 | 5 | PORT_STEP=100 6 | 7 | if [[ "$1" == "" ]]; then 8 | echo -e "Missing number of instances" 9 | exit 1 10 | fi 11 | N=$1 12 | 13 | if [[ "$2" != "" ]]; then 14 | PORT_OFFSET=$2 15 | else 16 | PORT_OFFSET=10000 17 | fi 18 | 19 | rm -f __sessions 20 | 21 | for i in $(seq 0 $(($N-1))); do 22 | 23 | echo "Launching batch instance $(($i+1))/$N" 24 | 25 | let ISERVER=0 26 | for SERVER in $SERVERS 27 | do 28 | PORT=$((${PORT_OFFSET}+${PORT_STEP}*$i+$ISERVER)) 29 | SESSION=${SERVER}_server_p${PORT} 30 | 31 | echo "$(printf ' [%5d]' $PORT) <--> $(printf '%-20s (%s)' $SERVER $SESSION)" 32 | 33 | screen -d -m -S $SESSION ./__launch_impl_${SERVER}_server.sh $PORT 34 | 35 | echo "$SESSION" >> __sessions 36 | 37 | let ISERVER=ISERVER+1 38 | done 39 | 40 | done 41 | 42 | 43 | -------------------------------------------------------------------------------- /tls-server-batch/stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ -f __sessions ]; then 4 | SESSIONS=$(cat __sessions) 5 | for SESSION in $SESSIONS; do 6 | echo "Stopping session $SESSION" 7 | screen -X -S $SESSION quit 8 | done 9 | rm -f __sessions 10 | else 11 | echo "No sessions to stop" 12 | fi 13 | 14 | --------------------------------------------------------------------------------