1 /* $OpenBSD: x509_issuer_cache.h,v 1.2 2022/09/03 17:47:47 jsing 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 29 struct 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 40 int x509_issuer_cache_set_max(size_t max); 41 int x509_issuer_cache_find(unsigned char *parent_md, unsigned char *child_md); 42 void x509_issuer_cache_add(unsigned char *parent_md, unsigned char *child_md, 43 int valid); 44 void x509_issuer_cache_free(); 45 46 __END_HIDDEN_DECLS 47 48 #endif 49