x509.h revision 1.2
1/* $OpenBSD: x509.h,v 1.2 1998/11/15 00:44:05 niklas Exp $ */ 2 3/* 4 * Copyright (c) 1998 Niels Provos. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 3. All advertising materials mentioning features or use of this software 15 * must display the following acknowledgement: 16 * This product includes software developed by Ericsson Radio Systems. 17 * 4. The name of the author may not be used to endorse or promote products 18 * derived from this software without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32/* 33 * This code was written under funding by Ericsson Radio Systems. 34 */ 35 36#ifndef _X509_H_ 37#define _X509_H_ 38 39#include "pkcs.h" /* for struct rsa_public_key */ 40 41struct x509_attribval { 42 char *type; 43 char *val; 44}; 45 46/* 47 * The acceptable certification authority 48 * XXX we only support two names at the moment, as of ASN this can 49 * be dynamic but we dont care for now. 50 */ 51 52struct x509_aca { 53 struct x509_attribval name1; 54 struct x509_attribval name2; 55}; 56 57struct exchange; 58 59struct x509_certificate { 60 u_int32_t version; 61 u_int32_t serialnumber; 62 char *signaturetype; 63 struct x509_attribval issuer1; /* At the moment Country */ 64 struct x509_attribval issuer2; /* At the moment Organization */ 65 struct x509_attribval subject1; /* At the moment Country */ 66 struct x509_attribval subject2; /* At the moment Organization */ 67 struct x509_attribval extension; /* Raw Extension */ 68 char *start; /* Certificate Validity Start and End */ 69 char *end; 70 struct rsa_public_key key; 71}; 72 73int x509_certreq_validate (u_int8_t *, u_int32_t); 74void *x509_certreq_decode (u_int8_t *, u_int32_t); 75void x509_free_aca (void *); 76int x509_cert_obtain (struct exchange *, void *, u_int8_t **, u_int32_t *); 77int x509_cert_get_key (u_int8_t *, u_int32_t, void *); 78int x509_cert_get_subject (u_int8_t *, u_int32_t, u_int8_t **, u_int32_t *); 79 80void x509_get_attribval (struct norm_type *, struct x509_attribval *); 81void x509_set_attribval (struct norm_type *, struct x509_attribval *); 82void x509_free_attrbival (struct x509_attribval *); 83 84int x509_validate_signed (u_int8_t *, u_int32_t, struct rsa_public_key *, 85 u_int8_t **, u_int32_t *); 86int x509_create_signed (u_int8_t *, u_int32_t, struct rsa_private_key *, 87 u_int8_t **, u_int32_t *); 88int x509_decode_certificate (u_int8_t *, u_int32_t, struct x509_certificate *); 89int x509_encode_certificate (struct x509_certificate *, u_int8_t **, 90 u_int32_t *); 91void x509_free_certificate (struct x509_certificate *); 92 93int x509_decode_cert_extension (u_int8_t *, u_int32_t, 94 struct x509_certificate *); 95int x509_encode_cert_extension (struct x509_certificate *, u_int8_t **, 96 u_int32_t *); 97 98#endif /* _X509_H_ */ 99