Blame trust/asn1.h

Packit ce73f7
/*
Packit ce73f7
 * Copyright (C) 2012 Red Hat Inc.
Packit ce73f7
 *
Packit ce73f7
 * Redistribution and use in source and binary forms, with or without
Packit ce73f7
 * modification, are permitted provided that the following conditions
Packit ce73f7
 * are met:
Packit ce73f7
 *
Packit ce73f7
 *     * Redistributions of source code must retain the above
Packit ce73f7
 *       copyright notice, this list of conditions and the
Packit ce73f7
 *       following disclaimer.
Packit ce73f7
 *     * Redistributions in binary form must reproduce the
Packit ce73f7
 *       above copyright notice, this list of conditions and
Packit ce73f7
 *       the following disclaimer in the documentation and/or
Packit ce73f7
 *       other materials provided with the distribution.
Packit ce73f7
 *     * The names of contributors to this software may not be
Packit ce73f7
 *       used to endorse or promote products derived from this
Packit ce73f7
 *       software without specific prior written permission.
Packit ce73f7
 *
Packit ce73f7
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
Packit ce73f7
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
Packit ce73f7
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
Packit ce73f7
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
Packit ce73f7
 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
Packit ce73f7
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
Packit ce73f7
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
Packit ce73f7
 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
Packit ce73f7
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Packit ce73f7
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
Packit ce73f7
 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
Packit ce73f7
 * DAMAGE.
Packit ce73f7
 *
Packit ce73f7
 * Author: Stef Walter <stefw@redhat.com>
Packit ce73f7
 */
Packit ce73f7
Packit ce73f7
#include <libtasn1.h>
Packit ce73f7
Packit ce73f7
#include "dict.h"
Packit ce73f7
Packit ce73f7
#ifndef P11_ASN1_H_
Packit ce73f7
#define P11_ASN1_H_
Packit ce73f7
Packit ce73f7
typedef struct _p11_asn1_cache p11_asn1_cache;
Packit ce73f7
Packit ce73f7
p11_dict *       p11_asn1_defs_load                 (void);
Packit ce73f7
Packit ce73f7
node_asn *       p11_asn1_decode                    (p11_dict *asn1_defs,
Packit ce73f7
                                                     const char *struct_name,
Packit ce73f7
                                                     const unsigned char *der,
Packit ce73f7
                                                     size_t der_len,
Packit ce73f7
                                                     char *message);
Packit ce73f7
Packit ce73f7
node_asn *       p11_asn1_create                    (p11_dict *asn1_defs,
Packit ce73f7
                                                     const char *struct_name);
Packit ce73f7
Packit ce73f7
unsigned char *  p11_asn1_encode                    (node_asn *asn,
Packit ce73f7
                                                     size_t *der_len);
Packit ce73f7
Packit ce73f7
void *           p11_asn1_read                      (node_asn *asn,
Packit ce73f7
                                                     const char *field,
Packit ce73f7
                                                     size_t *length);
Packit ce73f7
Packit ce73f7
void             p11_asn1_free                      (void *asn);
Packit ce73f7
Packit ce73f7
ssize_t          p11_asn1_tlv_length                (const unsigned char *data,
Packit ce73f7
                                                     size_t length);
Packit ce73f7
Packit ce73f7
p11_asn1_cache * p11_asn1_cache_new                 (void);
Packit ce73f7
Packit ce73f7
p11_dict *       p11_asn1_cache_defs                (p11_asn1_cache *cache);
Packit ce73f7
Packit ce73f7
node_asn *       p11_asn1_cache_get                 (p11_asn1_cache *cache,
Packit ce73f7
                                                     const char *struct_name,
Packit ce73f7
                                                     const unsigned char *der,
Packit ce73f7
                                                     size_t der_len);
Packit ce73f7
Packit ce73f7
void             p11_asn1_cache_take                (p11_asn1_cache *cache,
Packit ce73f7
                                                     node_asn *node,
Packit ce73f7
                                                     const char *struct_name,
Packit ce73f7
                                                     const unsigned char *der,
Packit ce73f7
                                                     size_t der_len);
Packit ce73f7
Packit ce73f7
void             p11_asn1_cache_flush               (p11_asn1_cache *cache);
Packit ce73f7
Packit ce73f7
void             p11_asn1_cache_free                (p11_asn1_cache *cache);
Packit ce73f7
Packit ce73f7
#endif /* P11_ASN1_H_ */