diff options
author | 2018-04-07 13:54:46 +0000 | |
---|---|---|
committer | 2018-04-07 13:54:46 +0000 | |
commit | 1577660499de1f8e204d398793a4e217df3b7764 (patch) | |
tree | 7f6b043f4be11c56da3f4f2fb0d3ef3384a6056e | |
parent | add arch to Dt line; (diff) | |
download | wireguard-openbsd-1577660499de1f8e204d398793a4e217df3b7764.tar.xz wireguard-openbsd-1577660499de1f8e204d398793a4e217df3b7764.zip |
test X509_NAME_add_entry_by_txt(3); feedback and OK jsing@
-rw-r--r-- | regress/lib/libcrypto/Makefile | 5 | ||||
-rw-r--r-- | regress/lib/libcrypto/x509/Makefile | 16 | ||||
-rw-r--r-- | regress/lib/libcrypto/x509/x509name.c | 59 | ||||
-rw-r--r-- | regress/lib/libcrypto/x509/x509name.expected | 3 |
4 files changed, 81 insertions, 2 deletions
diff --git a/regress/lib/libcrypto/Makefile b/regress/lib/libcrypto/Makefile index f6215fb1181..3b3345ee074 100644 --- a/regress/lib/libcrypto/Makefile +++ b/regress/lib/libcrypto/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.29 2018/03/19 14:34:33 beck Exp $ +# $OpenBSD: Makefile,v 1.30 2018/04/07 13:54:46 schwarze Exp $ SUBDIR= \ aead \ @@ -42,7 +42,8 @@ SUBDIR= \ sha2 \ sha256 \ sha512 \ - utf8 + utf8 \ + x509 install: diff --git a/regress/lib/libcrypto/x509/Makefile b/regress/lib/libcrypto/x509/Makefile new file mode 100644 index 00000000000..106a9f2bf2b --- /dev/null +++ b/regress/lib/libcrypto/x509/Makefile @@ -0,0 +1,16 @@ +# $OpenBSD: Makefile,v 1.1 2018/04/07 13:54:46 schwarze Exp $ + +PROG= x509name +LDADD= -lcrypto +DPADD= ${LIBCRYPTO} +WARNINGS= Yes +CFLAGS+= -Wall -Werror + +REGRESS_TARGETS=regress-x509name +CLEANFILES+= x509name.result + +regress-x509name: ${PROG} + ./${PROG} > x509name.result + diff -u ${.CURDIR}/x509name.expected x509name.result + +.include <bsd.regress.mk> diff --git a/regress/lib/libcrypto/x509/x509name.c b/regress/lib/libcrypto/x509/x509name.c new file mode 100644 index 00000000000..4ff8ac69080 --- /dev/null +++ b/regress/lib/libcrypto/x509/x509name.c @@ -0,0 +1,59 @@ +/* $OpenBSD: x509name.c,v 1.1 2018/04/07 13:54:46 schwarze Exp $ */ +/* + * Copyright (c) 2018 Ingo Schwarze <schwarze@openbsd.org> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include <err.h> +#include <stdio.h> + +#include <openssl/x509.h> + +static void debug_print(X509_NAME *); + +static void +debug_print(X509_NAME *name) +{ + int loc; + + for (loc = 0; loc < X509_NAME_entry_count(name); loc++) + printf("%d:", X509_NAME_get_entry(name, loc)->set); + putchar(' '); + X509_NAME_print_ex_fp(stdout, name, 0, XN_FLAG_SEP_CPLUS_SPC); + putchar('\n'); +} + +int +main(void) +{ + X509_NAME *name; + + if ((name = X509_NAME_new()) == NULL) + err(1, NULL); + X509_NAME_add_entry_by_txt(name, "ST", MBSTRING_ASC, + "BaWue", -1, -1, 0); + X509_NAME_add_entry_by_txt(name, "O", MBSTRING_ASC, + "KIT", -1, -1, 0); + debug_print(name); + + X509_NAME_add_entry_by_txt(name, "L", MBSTRING_ASC, + "Karlsruhe", -1, 1, 0); + debug_print(name); + + X509_NAME_add_entry_by_txt(name, "C", MBSTRING_ASC, + "DE", -1, 0, 1); + debug_print(name); + + return 0; +} diff --git a/regress/lib/libcrypto/x509/x509name.expected b/regress/lib/libcrypto/x509/x509name.expected new file mode 100644 index 00000000000..6cee7cc435a --- /dev/null +++ b/regress/lib/libcrypto/x509/x509name.expected @@ -0,0 +1,3 @@ +0:1: ST=BaWue, O=KIT +0:1:2: ST=BaWue, L=Karlsruhe, O=KIT +0:0:1:2: C=DE + ST=BaWue, L=Karlsruhe, O=KIT |