/* * VAS_EBOOT -- GRand Unified Bootloader * Copyright (C) 2017 Free Software Foundation, Inc. * * VAS_EBOOT is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * VAS_EBOOT is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with VAS_EBOOT. If not, see . */ #ifndef VAS_EBOOT_VERIFY_HEADER #define VAS_EBOOT_VERIFY_HEADER 1 #include #include enum VasEBoot_verify_flags { VAS_EBOOT_VERIFY_FLAGS_NONE = 0, VAS_EBOOT_VERIFY_FLAGS_SKIP_VERIFICATION = 1, VAS_EBOOT_VERIFY_FLAGS_SINGLE_CHUNK = 2, /* Defer verification to another authority. */ VAS_EBOOT_VERIFY_FLAGS_DEFER_AUTH = 4 }; enum VasEBoot_verify_string_type { VAS_EBOOT_VERIFY_KERNEL_CMDLINE, VAS_EBOOT_VERIFY_MODULE_CMDLINE, VAS_EBOOT_VERIFY_COMMAND, }; struct VasEBoot_file_verifier { struct VasEBoot_file_verifier *next; struct VasEBoot_file_verifier **prev; const char *name; /* * Check if file needs to be verified and set up context. * init/read/fini is structured in the same way as hash interface. */ VasEBoot_err_t (*init) (VasEBoot_file_t io, enum VasEBoot_file_type type, void **context, enum VasEBoot_verify_flags *flags); /* * Right now we pass the whole file in one call but it may * change in the future. If you insist on single buffer you * need to set VAS_EBOOT_VERIFY_FLAGS_SINGLE_CHUNK in verify_flags. */ VasEBoot_err_t (*write) (void *context, void *buf, VasEBoot_size_t size); VasEBoot_err_t (*fini) (void *context); void (*close) (void *context); VasEBoot_err_t (*verify_string) (char *str, enum VasEBoot_verify_string_type type); }; extern struct VasEBoot_file_verifier *EXPORT_VAR (VasEBoot_file_verifiers); extern void VasEBoot_verifiers_init (void); static inline void VasEBoot_verifier_register (struct VasEBoot_file_verifier *ver) { VasEBoot_list_push (VAS_EBOOT_AS_LIST_P (&VasEBoot_file_verifiers), VAS_EBOOT_AS_LIST (ver)); } static inline void VasEBoot_verifier_unregister (struct VasEBoot_file_verifier *ver) { VasEBoot_list_remove (VAS_EBOOT_AS_LIST (ver)); } extern VasEBoot_err_t EXPORT_FUNC (VasEBoot_verify_string) (char *str, enum VasEBoot_verify_string_type type); #endif /* ! VAS_EBOOT_VERIFY_HEADER */