summaryrefslogtreecommitdiff
path: root/firmware/2lib/2rsa.c
diff options
context:
space:
mode:
authorJulius Werner <jwerner@chromium.org>2020-03-10 23:27:10 -0700
committerCommit Bot <commit-bot@chromium.org>2020-04-06 18:54:38 +0000
commitb1c6ef3892c4e36a1375249ce4494959d2457011 (patch)
tree2c584a236674c6d57c8064aec663d728e31812d6 /firmware/2lib/2rsa.c
parent509a887c5a89530e9748241625ad3cb25f5de3c5 (diff)
downloadvboot-b1c6ef3892c4e36a1375249ce4494959d2457011.tar.gz
Rewrite algorithm type parsers and make them globally available
There is some code strewn around between futility and the vb21-specific part of hostlib to allow parsing of textual algorithm names to vboot enums, but it is somewhat disorganized and not written in a super efficient way. This patch rewrites it and centralizes all the algorithm mapping stuff under 2crypto.c so it can be a single source of truth for all of vboot. (String parsing routines still need to stay in hostlib since not all firmware targets support things like stroul() and strcasecmp().) BRANCH=None BUG=None TEST=make runtests Signed-off-by: Julius Werner <jwerner@chromium.org> Change-Id: I719b2499992a6e4395a29231bc8b9a7680c5b174 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2099447 Reviewed-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org>
Diffstat (limited to 'firmware/2lib/2rsa.c')
-rw-r--r--firmware/2lib/2rsa.c39
1 files changed, 0 insertions, 39 deletions
diff --git a/firmware/2lib/2rsa.c b/firmware/2lib/2rsa.c
index 54b00b63..1a23d023 100644
--- a/firmware/2lib/2rsa.c
+++ b/firmware/2lib/2rsa.c
@@ -182,45 +182,6 @@ static void modpow(const struct vb2_public_key *key, uint8_t *inout,
}
}
-
-static const uint8_t crypto_to_sig[] = {
- VB2_SIG_RSA1024,
- VB2_SIG_RSA1024,
- VB2_SIG_RSA1024,
- VB2_SIG_RSA2048,
- VB2_SIG_RSA2048,
- VB2_SIG_RSA2048,
- VB2_SIG_RSA4096,
- VB2_SIG_RSA4096,
- VB2_SIG_RSA4096,
- VB2_SIG_RSA8192,
- VB2_SIG_RSA8192,
- VB2_SIG_RSA8192,
- VB2_SIG_RSA2048_EXP3,
- VB2_SIG_RSA2048_EXP3,
- VB2_SIG_RSA2048_EXP3,
- VB2_SIG_RSA3072_EXP3,
- VB2_SIG_RSA3072_EXP3,
- VB2_SIG_RSA3072_EXP3,
-};
-
-/**
- * Convert vb2_crypto_algorithm to vb2_signature_algorithm.
- *
- * @param algorithm Crypto algorithm (vb2_crypto_algorithm)
- *
- * @return The signature algorithm for that crypto algorithm, or
- * VB2_SIG_INVALID if the crypto algorithm or its corresponding signature
- * algorithm is invalid or not supported.
- */
-enum vb2_signature_algorithm vb2_crypto_to_signature(uint32_t algorithm)
-{
- if (algorithm < ARRAY_SIZE(crypto_to_sig))
- return crypto_to_sig[algorithm];
- else
- return VB2_SIG_INVALID;
-}
-
uint32_t vb2_rsa_sig_size(enum vb2_signature_algorithm sig_alg)
{
switch (sig_alg) {