diff options
author | tb <> | 2023-12-15 22:24:15 +0000 |
---|---|---|
committer | tb <> | 2023-12-15 22:24:15 +0000 |
commit | 4cf0a9d7b82d30cc1eb329cfe63c9b341b58ce76 (patch) | |
tree | 510f26d5b4bb05edd0de282318c0968a78125c85 /src | |
parent | a3587cc63e6e729e456dc5470dbd9083336508d5 (diff) | |
download | openbsd-4cf0a9d7b82d30cc1eb329cfe63c9b341b58ce76.tar.gz openbsd-4cf0a9d7b82d30cc1eb329cfe63c9b341b58ce76.tar.bz2 openbsd-4cf0a9d7b82d30cc1eb329cfe63c9b341b58ce76.zip |
Remove the string_table test
If it wasn't for security/xca, all of the ASN1_STRING_TABLE API would
hit the attic before long. API design by a trained professional...
The table can at least be made immutable, which in turn makes this test
entirely pointless.
Diffstat (limited to 'src')
-rw-r--r-- | src/regress/lib/libcrypto/asn1/Makefile | 3 | ||||
-rw-r--r-- | src/regress/lib/libcrypto/asn1/string_table.c | 128 |
2 files changed, 1 insertions, 130 deletions
diff --git a/src/regress/lib/libcrypto/asn1/Makefile b/src/regress/lib/libcrypto/asn1/Makefile index d00d41a95e..173a51f442 100644 --- a/src/regress/lib/libcrypto/asn1/Makefile +++ b/src/regress/lib/libcrypto/asn1/Makefile | |||
@@ -1,4 +1,4 @@ | |||
1 | # $OpenBSD: Makefile,v 1.25 2023/10/11 12:49:00 tb Exp $ | 1 | # $OpenBSD: Makefile,v 1.26 2023/12/15 22:24:15 tb Exp $ |
2 | 2 | ||
3 | PROGS = \ | 3 | PROGS = \ |
4 | asn1api \ | 4 | asn1api \ |
@@ -12,7 +12,6 @@ PROGS = \ | |||
12 | asn1time \ | 12 | asn1time \ |
13 | asn1x509 \ | 13 | asn1x509 \ |
14 | rfc5280time \ | 14 | rfc5280time \ |
15 | string_table \ | ||
16 | x509_algor | 15 | x509_algor |
17 | 16 | ||
18 | DPADD+= ${LIBCRYPTO} | 17 | DPADD+= ${LIBCRYPTO} |
diff --git a/src/regress/lib/libcrypto/asn1/string_table.c b/src/regress/lib/libcrypto/asn1/string_table.c deleted file mode 100644 index e80cf0f206..0000000000 --- a/src/regress/lib/libcrypto/asn1/string_table.c +++ /dev/null | |||
@@ -1,128 +0,0 @@ | |||
1 | /* $OpenBSD: string_table.c,v 1.1 2021/12/11 22:58:48 schwarze Exp $ */ | ||
2 | /* | ||
3 | * Copyright (c) 2021 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 <stdarg.h> | ||
20 | #include <openssl/asn1.h> | ||
21 | #include <openssl/objects.h> | ||
22 | |||
23 | static int errcount; | ||
24 | |||
25 | static void | ||
26 | report(const char *fmt, ...) | ||
27 | { | ||
28 | va_list ap; | ||
29 | |||
30 | va_start(ap, fmt); | ||
31 | vwarnx(fmt, ap); | ||
32 | va_end(ap); | ||
33 | |||
34 | errcount++; | ||
35 | } | ||
36 | |||
37 | static void | ||
38 | stable_check(const char *testname, ASN1_STRING_TABLE *have, | ||
39 | ASN1_STRING_TABLE *want, unsigned long want_flags) | ||
40 | { | ||
41 | if (have == NULL) { | ||
42 | report("%s returned NULL", testname); | ||
43 | return; | ||
44 | } | ||
45 | if (have->nid != want->nid) | ||
46 | report("%s nid %d, expected %d", testname, | ||
47 | have->nid, want->nid); | ||
48 | if (have->minsize != want->minsize) | ||
49 | report("%s minsize %ld, expected %ld", testname, | ||
50 | have->minsize, want->minsize); | ||
51 | if (have->maxsize != want->maxsize) | ||
52 | report("%s maxsize %ld, expected %ld", testname, | ||
53 | have->maxsize, want->maxsize); | ||
54 | if (have->mask != want->mask) | ||
55 | report("%s mask %lu, expected %lu", testname, | ||
56 | have->mask, want->mask); | ||
57 | if (have->flags != want_flags) | ||
58 | report("%s flags %lu, expected %lu", testname, | ||
59 | have->flags, want_flags); | ||
60 | } | ||
61 | |||
62 | int | ||
63 | main(void) | ||
64 | { | ||
65 | ASN1_STRING_TABLE orig, mine, *have; | ||
66 | int irc; | ||
67 | |||
68 | orig.nid = NID_name; | ||
69 | orig.minsize = 1; | ||
70 | orig.maxsize = ub_name; | ||
71 | orig.mask = DIRSTRING_TYPE; | ||
72 | orig.flags = 0; | ||
73 | |||
74 | mine.nid = NID_name; | ||
75 | mine.minsize = 4; | ||
76 | mine.maxsize = 64; | ||
77 | mine.mask = B_ASN1_PRINTABLESTRING; | ||
78 | mine.flags = STABLE_NO_MASK; | ||
79 | |||
80 | /* Original entry. */ | ||
81 | |||
82 | have = ASN1_STRING_TABLE_get(orig.nid); | ||
83 | stable_check("orig", have, &orig, 0); | ||
84 | |||
85 | /* Copy, but don't really change. */ | ||
86 | |||
87 | irc = ASN1_STRING_TABLE_add(orig.nid, -1, -1, 0, 0); | ||
88 | if (irc != 1) | ||
89 | report("set noop returned %d, expected 1", irc); | ||
90 | have = ASN1_STRING_TABLE_get(orig.nid); | ||
91 | stable_check("noop", have, &orig, STABLE_FLAGS_MALLOC); | ||
92 | |||
93 | /* Change entry. */ | ||
94 | |||
95 | irc = ASN1_STRING_TABLE_add(mine.nid, mine.minsize, mine.maxsize, | ||
96 | mine.mask, mine.flags); | ||
97 | if (irc != 1) | ||
98 | report("set returned %d, expected 1", irc); | ||
99 | have = ASN1_STRING_TABLE_get(mine.nid); | ||
100 | stable_check("set", have, &mine, STABLE_FLAGS_MALLOC | STABLE_NO_MASK); | ||
101 | |||
102 | /* New entry. */ | ||
103 | |||
104 | mine.nid = NID_title; | ||
105 | irc = ASN1_STRING_TABLE_add(mine.nid, mine.minsize, mine.maxsize, | ||
106 | mine.mask, mine.flags); | ||
107 | if (irc != 1) | ||
108 | report("new returned %d, expected 1", irc); | ||
109 | have = ASN1_STRING_TABLE_get(mine.nid); | ||
110 | stable_check("new", have, &mine, STABLE_FLAGS_MALLOC | STABLE_NO_MASK); | ||
111 | |||
112 | /* Back to the initial state. */ | ||
113 | |||
114 | ASN1_STRING_TABLE_cleanup(); | ||
115 | have = ASN1_STRING_TABLE_get(orig.nid); | ||
116 | stable_check("back", have, &orig, 0); | ||
117 | if (ASN1_STRING_TABLE_get(mine.nid) != NULL) | ||
118 | report("deleted entry is not NULL"); | ||
119 | |||
120 | switch (errcount) { | ||
121 | case 0: | ||
122 | return 0; | ||
123 | case 1: | ||
124 | errx(1, "one error"); | ||
125 | default: | ||
126 | errx(1, "%d errors", errcount); | ||
127 | } | ||
128 | } | ||