1120945Snectar/*
2233294Sstas * Copyright (c) 1999 - 2005 Kungliga Tekniska H��gskolan
3233294Sstas * (Royal Institute of Technology, Stockholm, Sweden).
4233294Sstas * All rights reserved.
5120945Snectar *
6233294Sstas * Portions Copyright (c) 2009 Apple Inc. All rights reserved.
7120945Snectar *
8233294Sstas * Redistribution and use in source and binary forms, with or without
9233294Sstas * modification, are permitted provided that the following conditions
10233294Sstas * are met:
11120945Snectar *
12233294Sstas * 1. Redistributions of source code must retain the above copyright
13233294Sstas *    notice, this list of conditions and the following disclaimer.
14120945Snectar *
15233294Sstas * 2. Redistributions in binary form must reproduce the above copyright
16233294Sstas *    notice, this list of conditions and the following disclaimer in the
17233294Sstas *    documentation and/or other materials provided with the distribution.
18120945Snectar *
19233294Sstas * 3. Neither the name of the Institute nor the names of its contributors
20233294Sstas *    may be used to endorse or promote products derived from this software
21233294Sstas *    without specific prior written permission.
22233294Sstas *
23233294Sstas * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
24233294Sstas * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25233294Sstas * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26233294Sstas * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
27233294Sstas * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28233294Sstas * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29233294Sstas * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30233294Sstas * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31233294Sstas * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32233294Sstas * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33233294Sstas * SUCH DAMAGE.
34120945Snectar */
35120945Snectar
36120945Snectarstruct test_case {
37120945Snectar    void *val;
38120945Snectar    int byte_len;
39178825Sdfr    const char *bytes;
40120945Snectar    char *name;
41120945Snectar};
42120945Snectar
43233294Sstastypedef int (ASN1CALL *generic_encode)(unsigned char *, size_t, void *, size_t *);
44233294Sstastypedef int (ASN1CALL *generic_length)(void *);
45233294Sstastypedef int (ASN1CALL *generic_decode)(unsigned char *, size_t, void *, size_t *);
46233294Sstastypedef int (ASN1CALL *generic_free)(void *);
47233294Sstastypedef int (ASN1CALL *generic_copy)(const void *, void *);
48120945Snectar
49120945Snectarint
50120945Snectargeneric_test (const struct test_case *tests,
51120945Snectar	      unsigned ntests,
52120945Snectar	      size_t data_size,
53233294Sstas	      int (ASN1CALL *encode)(unsigned char *, size_t, void *, size_t *),
54233294Sstas	      int (ASN1CALL *length)(void *),
55233294Sstas	      int (ASN1CALL *decode)(unsigned char *, size_t, void *, size_t *),
56233294Sstas	      int (ASN1CALL *free_data)(void *),
57233294Sstas	      int (*cmp)(void *a, void *b),
58233294Sstas	      int (ASN1CALL *copy)(const void *a, void *b));
59120945Snectar
60178825Sdfrint
61178825Sdfrgeneric_decode_fail(const struct test_case *tests,
62178825Sdfr		    unsigned ntests,
63178825Sdfr		    size_t data_size,
64233294Sstas		    int (ASN1CALL *decode)(unsigned char *, size_t, void *, size_t *));
65178825Sdfr
66178825Sdfr
67178825Sdfrstruct map_page;
68178825Sdfr
69178825Sdfrenum map_type { OVERRUN, UNDERRUN };
70178825Sdfr
71178825Sdfrstruct map_page;
72178825Sdfr
73178825Sdfrvoid *	map_alloc(enum map_type, const void *, size_t, struct map_page **);
74178825Sdfrvoid	map_free(struct map_page *, const char *, const char *);
75