1
/* crypto.c - support crypto autoload */
3
* GRUB -- GRand Unified Bootloader
4
* Copyright (C) 2009 Free Software Foundation, Inc.
6
* GRUB is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation, either version 3 of the License, or
9
* (at your option) any later version.
11
* GRUB is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
23
#include <grub/misc.h>
24
#include <grub/crypto.h>
25
#include <grub/normal.h>
29
struct load_spec *next;
34
struct load_spec *crypto_specs = NULL;
37
grub_crypto_autoload (const char *name)
39
struct load_spec *cur;
42
for (cur = crypto_specs; cur; cur = cur->next)
43
if (grub_strcasecmp (name, cur->name) == 0)
45
mod = grub_dl_load (cur->modname);
48
grub_errno = GRUB_ERR_NONE;
53
grub_crypto_spec_free (void)
55
struct load_spec *cur, *next;
56
for (cur = crypto_specs; cur; cur = next)
59
grub_free (cur->name);
60
grub_free (cur->modname);
67
/* Read the file crypto.lst for auto-loading. */
69
read_crypto_list (const char *prefix)
77
grub_errno = GRUB_ERR_NONE;
81
filename = grub_xasprintf ("%s/crypto.lst", prefix);
84
grub_errno = GRUB_ERR_NONE;
88
file = grub_file_open (filename);
92
grub_errno = GRUB_ERR_NONE;
96
/* Override previous crypto.lst. */
97
grub_crypto_spec_free ();
99
for (;; grub_free (buf))
102
struct load_spec *cur;
104
buf = grub_file_getline (file);
111
p = grub_strchr (name, ':');
119
cur = grub_malloc (sizeof (*cur));
122
grub_errno = GRUB_ERR_NONE;
126
cur->name = grub_strdup (name);
129
grub_errno = GRUB_ERR_NONE;
134
cur->modname = grub_strdup (p);
137
grub_errno = GRUB_ERR_NONE;
139
grub_free (cur->name);
142
cur->next = crypto_specs;
146
grub_file_close (file);
148
grub_errno = GRUB_ERR_NONE;
150
grub_crypto_autoload_hook = grub_crypto_autoload;