15fff9558SSimon J. Gerraty /*- 25fff9558SSimon J. Gerraty * Copyright (c) 2017, Juniper Networks, Inc. 35fff9558SSimon J. Gerraty * 45fff9558SSimon J. Gerraty * Redistribution and use in source and binary forms, with or without 55fff9558SSimon J. Gerraty * modification, are permitted provided that the following conditions 65fff9558SSimon J. Gerraty * are met: 75fff9558SSimon J. Gerraty * 1. Redistributions of source code must retain the above copyright 85fff9558SSimon J. Gerraty * notice, this list of conditions and the following disclaimer. 95fff9558SSimon J. Gerraty * 2. Redistributions in binary form must reproduce the above copyright 105fff9558SSimon J. Gerraty * notice, this list of conditions and the following disclaimer in the 115fff9558SSimon J. Gerraty * documentation and/or other materials provided with the distribution. 125fff9558SSimon J. Gerraty * 135fff9558SSimon J. Gerraty * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 145fff9558SSimon J. Gerraty * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 155fff9558SSimon J. Gerraty * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 165fff9558SSimon J. Gerraty * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 175fff9558SSimon J. Gerraty * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 185fff9558SSimon J. Gerraty * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 195fff9558SSimon J. Gerraty * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 205fff9558SSimon J. Gerraty * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 215fff9558SSimon J. Gerraty * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 225fff9558SSimon J. Gerraty * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 235fff9558SSimon J. Gerraty * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 245fff9558SSimon J. Gerraty */ 255fff9558SSimon J. Gerraty /* 265fff9558SSimon J. Gerraty */ 275fff9558SSimon J. Gerraty #ifndef _LIBSECUREBOOT_PRIV_H_ 285fff9558SSimon J. Gerraty #define _LIBSECUREBOOT_PRIV_H_ 295fff9558SSimon J. Gerraty 305fff9558SSimon J. Gerraty /* public api */ 315fff9558SSimon J. Gerraty #include "libsecureboot.h" 325fff9558SSimon J. Gerraty 33b0fefb25SMarcin Wojtas struct stat; 34b0fefb25SMarcin Wojtas 3513ea0450SMarcin Wojtas typedef struct { 3613ea0450SMarcin Wojtas unsigned char *data; 3713ea0450SMarcin Wojtas size_t hash_size; 3813ea0450SMarcin Wojtas } hash_data; 3913ea0450SMarcin Wojtas 40*623ecf23SSimon J. Gerraty int ve_check_hash(br_hash_compat_context *, const br_hash_class *, 41*623ecf23SSimon J. Gerraty const char *, const char *, size_t); 42*623ecf23SSimon J. Gerraty 435fff9558SSimon J. Gerraty size_t ve_trust_anchors_add(br_x509_certificate *, size_t); 4413ea0450SMarcin Wojtas size_t ve_forbidden_anchors_add(br_x509_certificate *, size_t); 4513ea0450SMarcin Wojtas void ve_forbidden_digest_add(hash_data *digest, size_t); 465fff9558SSimon J. Gerraty char *fingerprint_info_lookup(int, const char *); 475fff9558SSimon J. Gerraty 485fff9558SSimon J. Gerraty br_x509_certificate * parse_certificates(unsigned char *, size_t, size_t *); 495fff9558SSimon J. Gerraty int certificate_to_trust_anchor_inner(br_x509_trust_anchor *, 505fff9558SSimon J. Gerraty br_x509_certificate *); 515fff9558SSimon J. Gerraty 525fff9558SSimon J. Gerraty int verify_rsa_digest(br_rsa_public_key *pkey, 535fff9558SSimon J. Gerraty const unsigned char *hash_oid, 545fff9558SSimon J. Gerraty unsigned char *mdata, size_t mlen, 555fff9558SSimon J. Gerraty unsigned char *sdata, size_t slen); 565fff9558SSimon J. Gerraty 57b0fefb25SMarcin Wojtas int is_verified(struct stat *stp); 58b0fefb25SMarcin Wojtas void add_verify_status(struct stat *stp, int status); 59b0fefb25SMarcin Wojtas 609bee6a60SSimon J. Gerraty int openpgp_trust_init(void); 61f9510887SSimon J. Gerraty int openpgp_trust_add_buf(unsigned char *, size_t); 62f9510887SSimon J. Gerraty int openpgp_trust_revoke(const char *); 635fff9558SSimon J. Gerraty int openpgp_self_tests(void); 645fff9558SSimon J. Gerraty 6513ea0450SMarcin Wojtas int efi_secure_boot_enabled(void); 6613ea0450SMarcin Wojtas br_x509_certificate* efi_get_trusted_certs(size_t *count); 6713ea0450SMarcin Wojtas br_x509_certificate* efi_get_forbidden_certs(size_t *count); 6813ea0450SMarcin Wojtas hash_data* efi_get_forbidden_digests(size_t *count); 6913ea0450SMarcin Wojtas 705fff9558SSimon J. Gerraty #endif /* _LIBSECUREBOOT_PRIV_H_ */ 71