x509.h revision 299742
1/** 2 * \file x509.h 3 * 4 * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine 5 * 6 * Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org> 7 * 8 * All rights reserved. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 14 * * Redistributions of source code must retain the above copyright 15 * notice, this list of conditions and the following disclaimer. 16 * * Redistributions in binary form must reproduce the above copyright 17 * notice, this list of conditions and the following disclaimer in the 18 * documentation and/or other materials provided with the distribution. 19 * * Neither the names of PolarSSL or XySSL nor the names of its contributors 20 * may be used to endorse or promote products derived from this software 21 * without specific prior written permission. 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 27 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 29 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 30 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 31 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 32 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 */ 35#ifndef SVN_LIBSVN_SUBR_X509_H 36#define SVN_LIBSVN_SUBR_X509_H 37 38#include <stddef.h> 39#include <apr_time.h> 40 41#include "svn_x509.h" 42 43/* 44 * DER constants 45 */ 46#define ASN1_BOOLEAN 0x01 47#define ASN1_INTEGER 0x02 48#define ASN1_BIT_STRING 0x03 49#define ASN1_OCTET_STRING 0x04 50#define ASN1_NULL 0x05 51#define ASN1_OID 0x06 52#define ASN1_UTF8_STRING 0x0C 53#define ASN1_SEQUENCE 0x10 54#define ASN1_SET 0x11 55#define ASN1_PRINTABLE_STRING 0x13 56#define ASN1_T61_STRING 0x14 57#define ASN1_IA5_STRING 0x16 58#define ASN1_UTC_TIME 0x17 59#define ASN1_GENERALIZED_TIME 0x18 60#define ASN1_UNIVERSAL_STRING 0x1C 61#define ASN1_BMP_STRING 0x1E 62#define ASN1_PRIMITIVE 0x00 63#define ASN1_CONSTRUCTED 0x20 64#define ASN1_CONTEXT_SPECIFIC 0x80 65 66/* 67 * various object identifiers 68 */ 69#define OID_SUBJECT_ALT_NAME "\x55\x1D\x11" 70 71#ifdef __cplusplus 72extern "C" { 73#endif /* __cplusplus */ 74 75/* 76 * Structures for parsing X.509 certificates 77 */ 78typedef struct _x509_buf { 79 int tag; 80 ptrdiff_t len; 81 const unsigned char *p; 82} x509_buf; 83 84typedef struct _x509_name { 85 x509_buf oid; 86 x509_buf val; 87 struct _x509_name *next; 88} x509_name; 89 90typedef struct _x509_cert { 91 int version; 92 x509_buf serial; 93 x509_buf sig_oid1; 94 95 x509_name issuer; 96 x509_name subject; 97 98 apr_time_t valid_from; 99 apr_time_t valid_to; 100 101 x509_buf issuer_id; 102 x509_buf subject_id; 103 apr_array_header_t *dnsnames; 104 105 x509_buf sig_oid2; 106 x509_buf sig; 107 108} x509_cert; 109 110 111struct svn_x509_name_attr_t { 112 unsigned char *oid; 113 apr_size_t oid_len; 114 const char *utf8_value; 115}; 116 117/* 118 * Certificate info, returned from the parser 119 */ 120struct svn_x509_certinfo_t 121{ 122 apr_array_header_t *issuer; 123 apr_array_header_t *subject; 124 apr_time_t valid_from; 125 apr_time_t valid_to; 126 svn_checksum_t *digest; 127 apr_array_header_t *hostnames; 128}; 129 130#ifdef __cplusplus 131} 132#endif /* __cplusplus */ 133 134#endif /* SVN_LIBSVN_SUBR_X509_H */ 135