Move asn1_test.c into tests subdirectory and split it in two
The new test-asn1 and test-x509 tools are built using libraries from src/{utils,crypto,tls}. Currently, cross dependencies between crypto and tls are still preventing the test-x509 from being linked properly.
This commit is contained in:
parent
0e574b07f8
commit
ab7ddc74ad
4 changed files with 61 additions and 12 deletions
2
tests/.gitignore
vendored
2
tests/.gitignore
vendored
|
@ -1,4 +1,5 @@
|
|||
test-aes
|
||||
test-asn1
|
||||
test-base64
|
||||
test-md4
|
||||
test-md5
|
||||
|
@ -6,3 +7,4 @@ test-milenage
|
|||
test-ms_funcs
|
||||
test-sha1
|
||||
test-sha256
|
||||
test-x509
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
TESTS=test-base64 test-md4 test-md5 test-milenage test-ms_funcs test-sha1 \
|
||||
test-sha256 test-aes
|
||||
test-sha256 test-aes test-asn1 test-x509
|
||||
|
||||
all: $(TESTS)
|
||||
|
||||
|
@ -19,7 +19,8 @@ CFLAGS += -I../src
|
|||
CFLAGS += -I../src/utils
|
||||
|
||||
LIBS = ../src/utils/libutils.a \
|
||||
../src/crypto/libcrypto.a
|
||||
../src/crypto/libcrypto.a \
|
||||
../src/tls/libtls.a
|
||||
|
||||
../src/utils/libutils.a:
|
||||
$(MAKE) -C ../src/utils
|
||||
|
@ -27,10 +28,16 @@ LIBS = ../src/utils/libutils.a \
|
|||
../src/crypto/libcrypto.a:
|
||||
$(MAKE) -C ../src/crypto
|
||||
|
||||
../src/tls/libtls.a:
|
||||
$(MAKE) -C ../src/tls
|
||||
|
||||
|
||||
test-aes: test-aes.o $(LIBS)
|
||||
$(LDO) $(LDFLAGS) -o $@ $^
|
||||
|
||||
test-asn1: test-asn1.o $(LIBS)
|
||||
$(LDO) $(LDFLAGS) -o $@ $^
|
||||
|
||||
test-base64: test-base64.o $(LIBS)
|
||||
$(LDO) $(LDFLAGS) -o $@ $^
|
||||
|
||||
|
@ -52,6 +59,9 @@ test-sha1: test-sha1.o $(LIBS)
|
|||
test-sha256: test-sha256.o $(LIBS)
|
||||
$(LDO) $(LDFLAGS) -o $@ $^
|
||||
|
||||
test-x509: test-x509.o $(LIBS)
|
||||
$(LDO) $(LDFLAGS) -o $@ $^
|
||||
|
||||
|
||||
run-tests: $(TESTS)
|
||||
./test-aes
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Testing tool for ASN.1/X.509v3 routines
|
||||
* Copyright (c) 2006, Jouni Malinen <j@w1.fi>
|
||||
* Testing tool for ASN.1 routines
|
||||
* Copyright (c) 2006-2009, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
|
@ -15,8 +15,7 @@
|
|||
#include "includes.h"
|
||||
|
||||
#include "common.h"
|
||||
#include "asn1.h"
|
||||
#include "x509v3.h"
|
||||
#include "tls/asn1.h"
|
||||
|
||||
extern int wpa_debug_level;
|
||||
|
||||
|
@ -186,7 +185,6 @@ int main(int argc, char *argv[])
|
|||
FILE *f;
|
||||
u8 buf[3000];
|
||||
size_t len;
|
||||
struct x509_certificate *cert;
|
||||
|
||||
wpa_debug_level = 0;
|
||||
|
||||
|
@ -201,10 +199,5 @@ int main(int argc, char *argv[])
|
|||
|
||||
printf("\n\n");
|
||||
|
||||
cert = x509_certificate_parse(buf, len);
|
||||
if (cert == NULL)
|
||||
printf("Failed to parse X.509 certificate\n");
|
||||
x509_certificate_free(cert);
|
||||
|
||||
return 0;
|
||||
}
|
44
tests/test-x509.c
Normal file
44
tests/test-x509.c
Normal file
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Testing tool for X.509v3 routines
|
||||
* Copyright (c) 2006-2009, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* Alternatively, this software may be distributed under the terms of BSD
|
||||
* license.
|
||||
*
|
||||
* See README and COPYING for more details.
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
|
||||
#include "common.h"
|
||||
#include "tls/x509v3.h"
|
||||
|
||||
extern int wpa_debug_level;
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
FILE *f;
|
||||
u8 buf[3000];
|
||||
size_t len;
|
||||
struct x509_certificate *cert;
|
||||
|
||||
wpa_debug_level = 0;
|
||||
|
||||
f = fopen(argv[1], "rb");
|
||||
if (f == NULL)
|
||||
return -1;
|
||||
len = fread(buf, 1, sizeof(buf), f);
|
||||
fclose(f);
|
||||
|
||||
cert = x509_certificate_parse(buf, len);
|
||||
if (cert == NULL)
|
||||
printf("Failed to parse X.509 certificate\n");
|
||||
x509_certificate_free(cert);
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in a new issue