diff options
author | schwarze <> | 2018-04-07 13:54:46 +0000 |
---|---|---|
committer | schwarze <> | 2018-04-07 13:54:46 +0000 |
commit | 4608af0736dc60b5c3961e69526d193a03fb7f16 (patch) | |
tree | 14abb85d50461bc29c2fc3bc58365dc8a2af5cbb /src | |
parent | 51c043113484c53de869b645bf4515c05a75e519 (diff) | |
download | openbsd-4608af0736dc60b5c3961e69526d193a03fb7f16.tar.gz openbsd-4608af0736dc60b5c3961e69526d193a03fb7f16.tar.bz2 openbsd-4608af0736dc60b5c3961e69526d193a03fb7f16.zip |
test X509_NAME_add_entry_by_txt(3); feedback and OK jsing@
Diffstat (limited to 'src')
-rw-r--r-- | src/regress/lib/libcrypto/Makefile | 5 | ||||
-rw-r--r-- | src/regress/lib/libcrypto/x509/Makefile | 16 | ||||
-rw-r--r-- | src/regress/lib/libcrypto/x509/x509name.c | 59 | ||||
-rw-r--r-- | src/regress/lib/libcrypto/x509/x509name.expected | 3 |
4 files changed, 81 insertions, 2 deletions
diff --git a/src/regress/lib/libcrypto/Makefile b/src/regress/lib/libcrypto/Makefile index f6215fb118..3b3345ee07 100644 --- a/src/regress/lib/libcrypto/Makefile +++ b/src/regress/lib/libcrypto/Makefile | |||
@@ -1,4 +1,4 @@ | |||
1 | # $OpenBSD: Makefile,v 1.29 2018/03/19 14:34:33 beck Exp $ | 1 | # $OpenBSD: Makefile,v 1.30 2018/04/07 13:54:46 schwarze Exp $ |
2 | 2 | ||
3 | SUBDIR= \ | 3 | SUBDIR= \ |
4 | aead \ | 4 | aead \ |
@@ -42,7 +42,8 @@ SUBDIR= \ | |||
42 | sha2 \ | 42 | sha2 \ |
43 | sha256 \ | 43 | sha256 \ |
44 | sha512 \ | 44 | sha512 \ |
45 | utf8 | 45 | utf8 \ |
46 | x509 | ||
46 | 47 | ||
47 | install: | 48 | install: |
48 | 49 | ||
diff --git a/src/regress/lib/libcrypto/x509/Makefile b/src/regress/lib/libcrypto/x509/Makefile new file mode 100644 index 0000000000..106a9f2bf2 --- /dev/null +++ b/src/regress/lib/libcrypto/x509/Makefile | |||
@@ -0,0 +1,16 @@ | |||
1 | # $OpenBSD: Makefile,v 1.1 2018/04/07 13:54:46 schwarze Exp $ | ||
2 | |||
3 | PROG= x509name | ||
4 | LDADD= -lcrypto | ||
5 | DPADD= ${LIBCRYPTO} | ||
6 | WARNINGS= Yes | ||
7 | CFLAGS+= -Wall -Werror | ||
8 | |||
9 | REGRESS_TARGETS=regress-x509name | ||
10 | CLEANFILES+= x509name.result | ||
11 | |||
12 | regress-x509name: ${PROG} | ||
13 | ./${PROG} > x509name.result | ||
14 | diff -u ${.CURDIR}/x509name.expected x509name.result | ||
15 | |||
16 | .include <bsd.regress.mk> | ||
diff --git a/src/regress/lib/libcrypto/x509/x509name.c b/src/regress/lib/libcrypto/x509/x509name.c new file mode 100644 index 0000000000..4ff8ac6908 --- /dev/null +++ b/src/regress/lib/libcrypto/x509/x509name.c | |||
@@ -0,0 +1,59 @@ | |||
1 | /* $OpenBSD: x509name.c,v 1.1 2018/04/07 13:54:46 schwarze Exp $ */ | ||
2 | /* | ||
3 | * Copyright (c) 2018 Ingo Schwarze <schwarze@openbsd.org> | ||
4 | * | ||
5 | * Permission to use, copy, modify, and distribute this software for any | ||
6 | * purpose with or without fee is hereby granted, provided that the above | ||
7 | * copyright notice and this permission notice appear in all copies. | ||
8 | * | ||
9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
16 | */ | ||
17 | |||
18 | #include <err.h> | ||
19 | #include <stdio.h> | ||
20 | |||
21 | #include <openssl/x509.h> | ||
22 | |||
23 | static void debug_print(X509_NAME *); | ||
24 | |||
25 | static void | ||
26 | debug_print(X509_NAME *name) | ||
27 | { | ||
28 | int loc; | ||
29 | |||
30 | for (loc = 0; loc < X509_NAME_entry_count(name); loc++) | ||
31 | printf("%d:", X509_NAME_get_entry(name, loc)->set); | ||
32 | putchar(' '); | ||
33 | X509_NAME_print_ex_fp(stdout, name, 0, XN_FLAG_SEP_CPLUS_SPC); | ||
34 | putchar('\n'); | ||
35 | } | ||
36 | |||
37 | int | ||
38 | main(void) | ||
39 | { | ||
40 | X509_NAME *name; | ||
41 | |||
42 | if ((name = X509_NAME_new()) == NULL) | ||
43 | err(1, NULL); | ||
44 | X509_NAME_add_entry_by_txt(name, "ST", MBSTRING_ASC, | ||
45 | "BaWue", -1, -1, 0); | ||
46 | X509_NAME_add_entry_by_txt(name, "O", MBSTRING_ASC, | ||
47 | "KIT", -1, -1, 0); | ||
48 | debug_print(name); | ||
49 | |||
50 | X509_NAME_add_entry_by_txt(name, "L", MBSTRING_ASC, | ||
51 | "Karlsruhe", -1, 1, 0); | ||
52 | debug_print(name); | ||
53 | |||
54 | X509_NAME_add_entry_by_txt(name, "C", MBSTRING_ASC, | ||
55 | "DE", -1, 0, 1); | ||
56 | debug_print(name); | ||
57 | |||
58 | return 0; | ||
59 | } | ||
diff --git a/src/regress/lib/libcrypto/x509/x509name.expected b/src/regress/lib/libcrypto/x509/x509name.expected new file mode 100644 index 0000000000..6cee7cc435 --- /dev/null +++ b/src/regress/lib/libcrypto/x509/x509name.expected | |||
@@ -0,0 +1,3 @@ | |||
1 | 0:1: ST=BaWue, O=KIT | ||
2 | 0:1:2: ST=BaWue, L=Karlsruhe, O=KIT | ||
3 | 0:0:1:2: C=DE + ST=BaWue, L=Karlsruhe, O=KIT | ||