x509.h revision 1.7
1/* $OpenBSD: x509.h,v 1.7 2000/06/08 20:49:44 niklas Exp $ */ 2/* $EOM: x509.h,v 1.10 2000/05/19 05:47:53 angelos Exp $ */ 3 4/* 5 * Copyright (c) 1998, 1999 Niels Provos. All rights reserved. 6 * Copyright (c) 1999 Angelos D. Keromytis. All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 3. All advertising materials mentioning features or use of this software 17 * must display the following acknowledgement: 18 * This product includes software developed by Ericsson Radio Systems. 19 * 4. The name of the author may not be used to endorse or promote products 20 * derived from this software without specific prior written permission. 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 */ 33 34/* 35 * This code was written under funding by Ericsson Radio Systems. 36 */ 37 38#ifndef _X509_H_ 39#define _X509_H_ 40 41#include "libcrypto.h" 42 43#define X509v3_RFC_NAME 1 44#define X509v3_DNS_NAME 2 45#define X509v3_IPV4_ADDR 7 46 47 48struct x509_attribval { 49 char *type; 50 char *val; 51}; 52 53/* 54 * The acceptable certification authority. 55 * XXX We only support two names at the moment, as of ASN this can 56 * be dynamic but we don't care for now. 57 */ 58 59struct x509_aca { 60 struct x509_attribval name1; 61 struct x509_attribval name2; 62}; 63 64struct X509; 65 66/* Functions provided by cert handler. */ 67 68int x509_cert_init (void); 69void *x509_cert_get (u_int8_t *, u_int32_t); 70int x509_cert_validate (void *); 71void x509_cert_free (void *); 72int x509_certreq_validate (u_int8_t *, u_int32_t); 73void *x509_certreq_decode (u_int8_t *, u_int32_t); 74void x509_free_aca (void *); 75int x509_cert_obtain (u_int8_t *, size_t, void *, u_int8_t **, u_int32_t *); 76int x509_cert_get_key (void *, void *); 77int x509_cert_get_subject (void *, u_int8_t **, u_int32_t *); 78 79/* Misc. X509 certificate functions. */ 80 81int x509_cert_insert (int, void *); 82int x509_read_from_dir (X509_STORE *, char *, int); 83 84int x509_cert_subjectaltname (X509 *cert, u_char **, u_int *); 85int x509_check_subjectaltname (u_char *, u_int, X509 *); 86X509 *x509_from_asn (u_char *, u_int); 87 88int x509_generate_kn(X509 *); 89#endif /* _X509_H_ */ 90