1*05442ddfStom /* $OpenBSD: x509.h,v 1.22 2007/08/05 09:43:09 tom Exp $ */ 223d41768Sniklas /* $EOM: x509.h,v 1.11 2000/09/28 12:53:27 niklas Exp $ */ 32040585eSniklas 42040585eSniklas /* 5fb1921ccSniklas * Copyright (c) 1998, 1999 Niels Provos. All rights reserved. 6bdbf6df3Sniklas * Copyright (c) 1999 Angelos D. Keromytis. All rights reserved. 742af7185Sniklas * Copyright (c) 2000, 2001 Niklas Hallqvist. All rights reserved. 82040585eSniklas * 92040585eSniklas * Redistribution and use in source and binary forms, with or without 102040585eSniklas * modification, are permitted provided that the following conditions 112040585eSniklas * are met: 122040585eSniklas * 1. Redistributions of source code must retain the above copyright 132040585eSniklas * notice, this list of conditions and the following disclaimer. 142040585eSniklas * 2. Redistributions in binary form must reproduce the above copyright 152040585eSniklas * notice, this list of conditions and the following disclaimer in the 162040585eSniklas * documentation and/or other materials provided with the distribution. 172040585eSniklas * 182040585eSniklas * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 192040585eSniklas * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 202040585eSniklas * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 212040585eSniklas * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 222040585eSniklas * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 232040585eSniklas * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 242040585eSniklas * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 252040585eSniklas * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 262040585eSniklas * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 272040585eSniklas * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 282040585eSniklas */ 292040585eSniklas 302040585eSniklas /* 312040585eSniklas * This code was written under funding by Ericsson Radio Systems. 322040585eSniklas */ 332040585eSniklas 342040585eSniklas #ifndef _X509_H_ 352040585eSniklas #define _X509_H_ 362040585eSniklas 372f99b248Sniklas #include "libcrypto.h" 382f99b248Sniklas 39fb1921ccSniklas #define X509v3_RFC_NAME 1 40fb1921ccSniklas #define X509v3_DNS_NAME 2 4123d41768Sniklas #define X509v3_IP_ADDR 7 422040585eSniklas 432040585eSniklas struct x509_attribval { 442040585eSniklas char *type; 452040585eSniklas char *val; 462040585eSniklas }; 472040585eSniklas 482040585eSniklas /* 49fb1921ccSniklas * The acceptable certification authority. 50fb1921ccSniklas * XXX We only support two names at the moment, as of ASN this can 51fb1921ccSniklas * be dynamic but we don't care for now. 522040585eSniklas */ 532040585eSniklas struct x509_aca { 542040585eSniklas struct x509_attribval name1; 552040585eSniklas struct x509_attribval name2; 562040585eSniklas }; 572040585eSniklas 58fb1921ccSniklas struct X509; 599e952d08Sho struct X509_STORE; 602040585eSniklas 61fb1921ccSniklas /* Functions provided by cert handler. */ 622040585eSniklas 632040585eSniklas int x509_certreq_validate(u_int8_t *, u_int32_t); 64*05442ddfStom int x509_certreq_decode(void **, u_int8_t *, u_int32_t); 6523d41768Sniklas void x509_cert_free(void *); 6623d41768Sniklas void *x509_cert_get(u_int8_t *, u_int32_t); 67fb1921ccSniklas int x509_cert_get_key(void *, void *); 6823d41768Sniklas int x509_cert_get_subjects(void *, int *, u_int8_t ***, u_int32_t **); 6923d41768Sniklas int x509_cert_init(void); 709dbe9fb4Sho int x509_crl_init(void); 7112f43dabShshoexer int x509_cert_obtain(u_int8_t *, size_t, void *, u_int8_t **, 7212f43dabShshoexer u_int32_t *); 7323d41768Sniklas int x509_cert_validate(void *); 7423d41768Sniklas void x509_free_aca(void *); 75550296f0Sangelos void *x509_cert_dup(void *); 76550296f0Sangelos void x509_serialize(void *, u_int8_t **, u_int32_t *); 77550296f0Sangelos char *x509_printable(void *); 78550296f0Sangelos void *x509_from_printable(char *); 79*05442ddfStom int x509_ca_count(void); 802040585eSniklas 81fb1921ccSniklas /* Misc. X509 certificate functions. */ 822040585eSniklas 837af42284Sniklas char *x509_DN_string(u_int8_t *, size_t); 84ccea4478Sniklas int x509_cert_insert(int, void *); 85fb1921ccSniklas int x509_cert_subjectaltname(X509 * cert, u_char **, u_int *); 86fb1921ccSniklas X509 *x509_from_asn(u_char *, u_int); 876de2d489Sangelos int x509_generate_kn(int, X509 *); 88*05442ddfStom int x509_read_from_dir(X509_STORE *, char *, int, int *); 899dbe9fb4Sho int x509_read_crls_from_dir(X509_STORE *, char *); 9023d41768Sniklas 912040585eSniklas #endif /* _X509_H_ */ 92