n2n/tools/tests-elliptic.c
Hamish Coleman 80b33cd1a9
Basic C Code lint checker and shell checker (#859)
* Factor build packages out into a more maintainable list

* Create a location for scripts to live

* Provide a make target to return the source dir as close as reasonable to the original distributed state

* Add a code lint step, checking the coding style

* Change test harness as recommended by shellcheck

* Ensure we actually have the linter tool installed

* Use the correct directory for cmake to run the tests

* Adjust for the older uncrustify in the current github ubuntu-latest

* Make one file pass the linter

* Integrate the lint with the existing test workflow

* Add files with minimal changes needed to the linter

* Add more files with minimal changes needed to the linter

* Dont build binaries if we fail the lint test

* Update the phony targets with the lint steps

* Ensure the flake8 package is installed in the new lint workflow job

* Use the makefile to drive the packages needed to install for linting

* No need to add dependancies on lint, just rely on the workflow status to show failure

* Update the scripts dir README to reflect current assumptions

* Rename and briefly document the indent.sh script

* Fix the ignore to ignore the right Makefile

* Rename the test_harness script to make it clear it is a shell script

* Provide a master lint make target and add a shell script lint tool

* Elminate stray tabs

* Drop include/auth.h from linter - there are inconsistant results with function definitions when using the current uncrustify rules
2021-10-24 01:21:18 +05:45

57 lines
1.5 KiB
C

/*
* (C) 2007-21 - ntop.org and contributors
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>
*
*/
#include "n2n.h"
#include "hexdump.h"
void test_curve25519 (unsigned char *pkt_input, unsigned char *key) {
char *test_name = "curve25519";
unsigned char pkt_output[32];
curve25519(pkt_output, key, pkt_input);
printf("%s: output\n", test_name);
fhexdump(0, pkt_output, sizeof(pkt_output), stdout);
fprintf(stderr, "%s: tested\n", test_name);
printf("\n");
}
int main (int argc, char * argv[]) {
char *test_name = "environment";
unsigned char key[32];
unsigned char pkt_input[32];
memset(pkt_input, 0, 31);
pkt_input[31] = 9;
memset(key, 0x55, 32);
printf("%s: input\n", test_name);
fhexdump(0, pkt_input, sizeof(pkt_input), stdout);
printf("%s: key\n", test_name);
fhexdump(0, key, sizeof(key), stdout);
printf("\n");
test_curve25519(pkt_input, key);
return 0;
}