1/* $OpenBSD: x509_issuer_cache.h,v 1.3 2023/12/30 18:06:59 tb Exp $ */ 2/* 3 * Copyright (c) 2020 Bob Beck <beck@openbsd.org> 4 * 5 * Permission to use, copy, modify, and distribute this software for any 6 * purpose with or without fee is hereby granted, provided that the above 7 * copyright notice and this permission notice appear in all copies. 8 * 9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 */ 17 18/* x509_issuer_cache */ 19#ifndef HEADER_X509_ISSUER_CACHE_H 20#define HEADER_X509_ISSUER_CACHE_H 21 22#include <sys/tree.h> 23#include <sys/queue.h> 24 25#include <openssl/x509.h> 26 27__BEGIN_HIDDEN_DECLS 28 29struct x509_issuer { 30 RB_ENTRY(x509_issuer) entry; 31 TAILQ_ENTRY(x509_issuer) queue; /* LRU of entries */ 32 /* parent_md and child_md must point to EVP_MAX_MD_SIZE of memory */ 33 unsigned char *parent_md; 34 unsigned char *child_md; 35 int valid; /* Result of signature validation. */ 36}; 37 38#define X509_ISSUER_CACHE_MAX 40000 /* Approx 7.5 MB, entries 200 bytes */ 39 40int x509_issuer_cache_set_max(size_t max); 41int x509_issuer_cache_find(unsigned char *parent_md, unsigned char *child_md); 42void x509_issuer_cache_add(unsigned char *parent_md, unsigned char *child_md, 43 int valid); 44void x509_issuer_cache_free(void); 45 46__END_HIDDEN_DECLS 47 48#endif 49