Commit graph

12 commits

Author SHA1 Message Date
Gilles Peskine
47aab850da Batch cipher translations to go faster
Python has a high startup cost, so go back to invoking it only once per
server start, rather than once per client start. This is a measurable
performance improvement (running time ~*0.5 with PSK, less dramatic with
asymmetric crypto).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-01-26 21:45:45 +01:00
Yanray Wang
ee97f05d35 Translate cipher suite names based on standard naming convention
With this commit, translate_ciphers.py would be based on standard
cipher suite names instead of MbedTLS naming convention.

Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-01-17 14:56:37 +08:00
Joe Subbiani
e5d6106071 Extend test in translate_ciphers.py
The list was trimmed previously according to code coverage, however
this did not really evalute all test cases, e.g in the case of re.sub
or m_cipher.replace. These lines are executed no matter what, so code
coverage is not suitable.

I have gone through each step in the translate functions and made sure
there is at least one ciphersuite per step

Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
2021-09-03 13:30:44 +01:00
Joe Subbiani
49d57bcf19 Improve indentation according to pylint
Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
2021-09-03 13:19:58 +01:00
Joe Subbiani
54110b3b6f Reduce translate_ciphers.py test list
Having a list of every ciphersuite suggests that it should be maintained with
any new ciphersuites that are added in the future. This in turn almost defeats
the purpose of having translation functions to begin with
Instead, the unit test now only test a much smaller subset of ciphersuite names
that exercise each stage in the OpenSSL and GnuTLS translate functions.
In the future, if a new cipersuite is added that requires an extra stage in
translation, then that cipher can be added to the test suite, otherwise it
should not be necessary.

Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
2021-09-03 13:19:57 +01:00
Joe Subbiani
b0aba9a46e Improve comments to be more accurate
Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
2021-09-03 13:19:57 +01:00
Joe Subbiani
79f5790370 Remove test_translate_format()
As test_translate_ciphers_format.sh was made as a testing ground before
utilising translate_ciphers.py in compat.sh, once it was translated to
python code - as a unit test, it became redundant.

Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
2021-09-03 13:19:56 +01:00
Joe Subbiani
a25ffab422 Integrate tests as unit tests into one file
Rather than having the tests seperated into different files, they were integrated
into translate_ciphers.py and can be run from root using:
`python -m unittest tests/scripts/translate_ciphers.py`

test_translate_ciphers_format.sh was originally made as a testing ground before
having the translation tool being implmented into compat.sh. Translating it to
python code makes it redundant and therefore it will be removed.

Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
2021-09-03 13:19:50 +01:00
Joe Subbiani
f2de374fc1 Remove unused import
Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
2021-09-03 13:18:55 +01:00
Joe Subbiani
918ee797ce Improve consitancy and useability
test_translate_ciphers_names.py
- Combined m, o and g ciphers all into one a single list of tuples to
  avoid needing to rely on indexes

test_translate_ciphers_format.sh
- Removed redundant test
- Added return errors

compat.sh
- Improved how translate_ciphers.py is called

translate_ciphers.py
- Improve regex and translation to be more intutive and efficient
- change how arguments are taken and handelled to be more reliable

Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
2021-09-03 13:18:54 +01:00
Joe Subbiani
f849a93d94 Improve python coding style
As per check-python-files.sh, added string documentation for
files and functions.

Modified for loops to use enumerate rather than range(len(
although as the same iteration index is used for multiple
lists it does not seem quite appropriate

Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
2021-09-02 18:53:52 +01:00
Joe Subbiani
f3fcc29eb1 Move translate scripts to appropriate folder
"tests/scripts/*.py is executable programs used only for testing"

Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
2021-09-02 18:53:52 +01:00
Renamed from tests/translate_ciphers.py (Browse further)