Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F178055428
D61007.1795863173.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
18 KB
Referenced Files
None
Subscribers
None
D61007.1795863173.diff
View Options
diff --git a/lib/libsecureboot/Makefile.inc b/lib/libsecureboot/Makefile.inc
--- a/lib/libsecureboot/Makefile.inc
+++ b/lib/libsecureboot/Makefile.inc
@@ -1,3 +1,5 @@
+# See README.rst for details on what we are doing here
+
.if empty(BEARSSL)
.include "../libbearssl/Makefile.inc"
.endif
@@ -7,12 +9,13 @@
libsecureboot_src:= ${.PARSEDIR}
-CFLAGS+= -I${libsecureboot_src}/h
-
-CFLAGS+= -DHAVE_BR_X509_TIME_CHECK
-
.PATH: ${.PARSEDIR}
+CFLAGS+= -I. \
+ -I${libsecureboot_src}/h \
+ -DHAVE_BR_X509_TIME_CHECK \
+ ${XCFLAGS.${.TARGET:T:R}:U}
+
SRCS+= \
readfile.c \
brf.c \
@@ -23,8 +26,6 @@
SRCS+= veta.c
.endif
-CFLAGS+= ${XCFLAGS.${.TARGET:T:R}:U}
-
# we use a couple of files from ${BEARSSL}/tools
BRSSL_CFLAGS+= -I${BEARSSL}/tools
BRSSL_SRCS+= \
@@ -57,28 +58,44 @@
sed -n "`grep -n .-BEGIN ${.ALLSRC:M*.pem} | tail -2 | \
sed 's,:.*,,' | xargs | (read a b; echo $$a,$$(($$b - 1)))`p" ${.ALLSRC:M*.pem} > ${.TARGET}
+# Suppress duplicate entries in a list
+# without changing the order
+M_unique ?= @x@$${"${.$$x}":?:$$x${.$$x::=1}}@
+
# rules to populate the [tv]*.pem files we use to generate ta.h
-# and can add/alter VE_*_LIST as desired.
+# and VE_*_LIST as desired.
+# At minimum we expect this to populate VE_SIGNATURE_LIST with tuples of
+# sig/method/hash/flags in order of preference.
+# The / separator makes it easy to use combinations of :H and :T to
+# extract elements.
+# XXXX change the format of VE_SIGNATURE_LIST and *lots* of :H
+# expressions below need to change.
.-include "local.trust.mk"
-# list of hashes we support
-VE_HASH_LIST?= SHA256
-
# list of signatures we support
-# some people don't trust ECDSA
-VE_SIGNATURE_LIST?= RSA
-
+# Each entry defines an sig/method/hash/flags
# this list controls our search for signatures so will not be sorted
# note: for X509 signatures we assume we can replace the trailing
# "sig" with "certs" to find the certificate chain
# eg. for manifest.esig we use manifest.ecerts
-VE_SIGNATURE_EXT_LIST?= sig
+VE_SIGNATURE_LIST?= sig/RSA/sha256/0
+
+.if ${VE_SIGNATURE_LIST:M*OPENPGP*} != ""
+.include "openpgp/Makefile.inc"
+.endif
+
+VE_SIGNATURE_LIST:= ${VE_SIGNATURE_LIST:${M_unique}}
+
+# list of hashes we support (2nd last element of each tuple)
+VE_HASH_LIST+= ${VE_SIGNATURE_LIST:H:T}
+VE_HASH_LIST:= ${VE_HASH_LIST:tu:O:u}
+
+# sig(ext) is first (4th last) element of each tuple
+VE_SIGNATURE_EXT_LIST?= ${VE_SIGNATURE_LIST:H:H:H}
# needs to be yes for FIPS 140-2 compliance
VE_SELF_TESTS?= no
-CFLAGS+= -I.
-
.if ${VE_SIGNATURE_EXT_LIST:M*sig} != ""
# this is what we use as our trust anchor
CFLAGS+= -DTRUST_ANCHOR_STR=ta_PEM
@@ -88,17 +105,21 @@
.endif
.endif
-# clean these up
-VE_HASH_LIST:= ${VE_HASH_LIST:tu:O:u}
-VE_SIGNATURE_LIST:= ${VE_SIGNATURE_LIST:tu:O:u}
+# method is 3rd last element of each tuple
+VE_SUPPORT_LIST+= ${VE_HASH_LIST} ${VE_SIGNATURE_LIST:H:H:T}
+# make sure we have the canonical names for the signature methods
+# we support. eg. VE_SIGNATURE_LIST might have RSA3K etc,
+# and we need RSA.
+.for x in ECDSA RSA OPENPGP
+.if ${VE_SUPPORT_LIST:tu:M*$x*} != ""
+VE_SUPPORT_LIST+= $x
+.endif
+.endfor
+# clean that up
+VE_SUPPORT_LIST:= ${VE_SUPPORT_LIST:tu:O:u}
# define what we are supporting
-CFLAGS+= ${VE_HASH_LIST:@H@-DVE_$H_SUPPORT@} \
- ${VE_SIGNATURE_LIST:@S@-DVE_$S_SUPPORT@}
-
-.if ${VE_SIGNATURE_LIST:MOPENPGP} != ""
-.include "openpgp/Makefile.inc"
-.endif
+CFLAGS+= ${VE_SUPPORT_LIST:@H@-DVE_$H_SUPPORT@}
.if ${VE_SELF_TESTS} != "no"
# The input used for hash KATs
@@ -117,8 +138,8 @@
XCFLAGS.vets+= -DVE_HASH_KAT_STRLEN=${VE_HASH_KAT_STRLEN}
.endif
-# this should be updated occassionally this is 2019-01-01Z
-SOURCE_DATE_EPOCH?= 1546329600
+# this should be updated occassionally this is 2026-04-01Z
+SOURCE_DATE_EPOCH?= 1775001600
.if ${MK_REPRODUCIBLE_BUILD} == "yes"
BUILD_UTC?= ${SOURCE_DATE_EPOCH}
.endif
@@ -143,6 +164,9 @@
# using each supported hash method
# to use as a Known Answer Test (needed for FIPS 140-2)
#
+# We also populate signature_info_list describing the signatures
+# we support.
+#
TA_PEM_LIST ?= ${.ALLSRC:N*crl*:Mt*.pem}
VC_PEM_LIST ?= ${.ALLSRC:N*crl*:Mv*.pem}
vets.o vets.po vets.pico: ta.h
@@ -157,15 +181,23 @@
.endif
echo '#define BUILD_UTC ${BUILD_UTC}' >> ${.TARGET} ${.OODATE:MNOMETA_CMP}
+# This header contains signature info needed by verify_sig et al
+${.SUFFIXES:M*o:S,^,vets,}: vsi.h
+vsi.h:
+ @( echo '/* Autogenerated - DO NOT EDIT!!! */'; echo; \
+ echo 'static signature_info signature_info_list[] = {'; \
+ echo -e '${VE_SIGNATURE_LIST:@x@\t{ "${x:H:H:H}", "${x:H:H:T}", br_${x:H:T:tl}_ID, ${x:T} },${.newline}@}'; \
+ echo -e '\t{ NULL, NULL, 0, 0 },'; \
+ echo '};'; ) > ${.TARGET}
+
# This header records our preference for signature extensions.
-vesigned.o vesigned.po vesigned.pico: vse.h
+${.SUFFIXES:M*o:S,^,vesigned,}: vse.h
vse.h:
@( echo '/* Autogenerated - DO NOT EDIT!!! */'; echo; \
- echo "static const char *signature_exts[] = {"; \
- echo '${VE_SIGNATURE_EXT_LIST:O:u:@e@"$e",${.newline}@}'; \
+ echo "static const char *signature_ext_list[] = {"; \
+ echo '${VE_SIGNATURE_EXT_LIST:@e@"$e",${.newline}@}'; \
echo 'NULL };' ) > ${.TARGET}
-
.for s in ${BRSSL_SRCS} ${BRSSL_DEPS}
.ifdef BRSSL_SED
$s: brssl.h
diff --git a/lib/libsecureboot/README.rst b/lib/libsecureboot/README.rst
--- a/lib/libsecureboot/README.rst
+++ b/lib/libsecureboot/README.rst
@@ -3,6 +3,7 @@
This library depends one way or another on verifying detached digital
signatures.
+
To do that, the necessary trust anchors need to be available.
The simplest (and most attractive for an embedded system) is to
@@ -12,17 +13,57 @@
The file provided is just an example and depends on the environment
here at Juniper.
-Within Juniper we use signing servers, which apart from signing things
+We expect ``local.trust.mk`` to set ``VE_SIGNATURE_LIST`` to a set of
+tuples as below, in order of preference.
+Each entry contains sig/alg/hash/flags:
+
+ r3sig/RSA/sha384/0
+ esig/ECDSA/sha256/1
+ acc/OPENPGP/sha256/0
+
+If using a signing server (such as that referenced below), it
+may instead define ``VE_SIGN_URL_LIST`` which is the same
+as the above, but with an extra element for the url to
+contact. Thus, ``VE_SIGNATURE_LIST`` can be derrived from
+``${VE_SIGN_URL_LIST:H}``.
+
+From ``VE_SIGNATURE_LIST`` we derrive:
+
+``VE_SUPPORTED_LIST``
+
+ a list of hash and signature methods to support.
+ Each results in ``-DVE_<thing>_SUPPORT`` being added to ``CFLAGS``.
+
+``VE_SIGNATURE_EXT_LIST``
+
+ A list of signature extensions in order of preference.
+ This is used to populate ``signature_ext_list`` used by
+ ``verify_signed()`` to find the most preferred signature
+ available.
+
+Finally use ``VE_SIGNATURE_LIST`` to populate ``signature_info_list``
+used by ``verify_sig()`` to lookup the ``signature_info``,
+which provides the hash to use and whether the hash should be hashed
+again.
+
+Within Juniper/HPE we use signing servers, which apart from signing things
provide access to the necessary trust anchors.
That signing server is freely available - see
http://www.crufty.net/sjg/docs/signing-server.htm
+The entry above for ``esig`` has non-zero ``flags`` to indicate
+that the hash needs to re-hashed.
+This is to deal with a quirk of our orignal ECDSA signature. Since
+the signing sever expects to receive a hash, and the signature methods
+insist on hashing the input, the data is actually hashed twice. Since
+then, I added a FakeHash class to avoid that.
+
X.509 certificate chains offer a lot of flexibility over time and are
a great solution for an embedded vendor like Juniper or even
FreeBSD.org, but are probably overkill for personal or small site use.
-Setting up a CA for this is rather involved so I'll just provide a
-link below to suitable tutorial below.
+Setting up a CA for this is rather involved, so I'll just provide a
+link to a suitable tutorial below.
Using OpenPGP is much simpler.
diff --git a/lib/libsecureboot/libsecureboot-priv.h b/lib/libsecureboot/libsecureboot-priv.h
--- a/lib/libsecureboot/libsecureboot-priv.h
+++ b/lib/libsecureboot/libsecureboot-priv.h
@@ -37,6 +37,24 @@
size_t hash_size;
} hash_data;
+/*
+ * When supporting multiple signature formats
+ * we need a mapping from sig (ext) to hash_id
+ * and a clue about the method doesn't hurt.
+ * flags can indicate whether we need to hash the hash
+ * (to match a potential use of signing server; to-date
+ * only our original use of ECDSA requires this).
+ */
+typedef struct {
+ const char *sig; /* extension */
+ const char *method; /* ECDSA,RSA */
+ int hash_id; /* br_<hash>_ID */
+ int flags;
+} signature_info;
+
+/* signature_info flags */
+#define SIF_HASH_TWICE 1
+
int ve_check_hash(br_hash_compat_context *, const br_hash_class *,
const char *, const char *, size_t);
diff --git a/lib/libsecureboot/local.trust.mk b/lib/libsecureboot/local.trust.mk
--- a/lib/libsecureboot/local.trust.mk
+++ b/lib/libsecureboot/local.trust.mk
@@ -11,7 +11,8 @@
#VE_DEBUG_LEVEL?=3
#VE_VERBOSE_DEFAULT?=2
-VE_HASH_LIST?= \
+# just to be sure
+VE_HASH_LIST+= \
SHA256 \
SHA384 \
@@ -21,57 +22,63 @@
SIGNER?= /opt/sigs/sign.py
.if exists(${SIGNER})
-OPENPGP_SIGNER?= ${SIGNER:H}/openpgp-sign.py
-OPENPGP_SIGN_FLAGS= -a
-OPENPGP_SIGN_HOST?= localhost
+SIGNER_asc?= ${SIGNER:H}/openpgp-sign.py
+SIGN_FLAGS_asc= -a
+SIGN_HOST_asc?= localhost
SIGN_HOST ?= localhost
-# A list of name/ext/url tuples.
-# name should be one of ECDSA, OPENPGP or RSA, they can be repeated
+# A list of ext/method/hash/flags/url tuples.
+# method should include one of ECDSA, OPENPGP or RSA, they can be repeated
# Order of ext list implies runtime preference so do not sort!
VE_SIGN_URL_LIST?= \
- ECDSA/esig/${SIGN_HOST}:${133%y:L:localtime} \
- RSA/rsig/${SIGN_HOST}:${163%y:L:localtime} \
- OPENPGP/asc/${OPENPGP_SIGN_HOST}:1234 \
+ esig/ECDSA/sha256/1/${SIGN_HOST}:${133%y:L:localtime} \
+ rsig/RSA/sha256/0/${SIGN_HOST}:${163%y:L:localtime} \
+ asc/OPENPGP/sha256/0/${SIGN_HOST_asc}:1234 \
-.for sig ext url in ${VE_SIGN_URL_LIST:@x@${x:H:H} ${x:H:T} ${x:T}@}
-SIGN_${sig}:= ${PYTHON} ${${sig}_SIGNER:U${SIGNER}} -u ${url} ${${sig}_SIGN_FLAGS:U-h sha256}
+# Same as VE_SIGN_URL_LIST minus the url
+VE_SIGNATURE_LIST += ${VE_SIGN_URL_LIST:H}
-VE_SIGNATURE_LIST+= ${sig}
-VE_SIGNATURE_EXT_LIST+= ${ext}
+.if !target(_SIGN_USE)
+_SIGN_USE: .USE
+ @${SIGN_${.TARGET:E}} -o ${.TARGET} ${.ALLSRC:M*${.TARGET:T:R}:u}
+.endif
-_SIGN_${sig}_USE: .USE
- ${SIGN_${sig}} ${.ALLSRC}
+.if !target(_TA_USE)
+_TA_USE: .USE
+ @if test ${.TARGET:E} = pem; then \
+ ${SIGN_${.TARGET:R:S,certs,sig,}} -C ${.TARGET}; \
+ else \
+ ${SIGN_${.TARGET:E}} -C ${.TARGET}; \
+ fi
+.endif
-_TA_${sig}_USE: .USE
- ${SIGN_${sig}} -C ${.TARGET}
+# we define SIGN_esig etc for use by _SIGN_USE and _TA_USE
+.for sig method hash flags url in ${VE_SIGN_URL_LIST:S,/, ,g}
+SIGN_${sig}?= ${PYTHON} ${SIGNER_${sig}:U${SIGNER}} -h ${hash} -u ${url} ${SIGN_FLAGS_${sig}:U}
-.if ${sig} == "OPENPGP"
-ta_${sig:tl}.${ext}: _TA_${sig}_USE
-ta_${ext}.h: ta_${sig:tl}.${ext}
+.if ${sig} == "asc"
+ta_${method:tl}.${sig}: _TA_USE
+ta_${sig}.h: ta_${method:tl}.${sig}
.else
-${ext:S/sig/certs/}.pem: _TA_${sig}_USE
+${sig:S/sig/certs/}.pem: _TA_USE
# the last cert in the chain is the one we want
-ta_${ext}.pem: ${ext:S/sig/certs/}.pem _LAST_PEM_USE
-ta.h: ta_${ext}.pem
+ta_${sig}.pem: ${sig:S/sig/certs/}.pem _LAST_PEM_USE
+ta.h: ta_${sig}.pem
.if ${VE_SELF_TESTS} != "no"
# we use the 2nd last cert to test verification
-vc_${ext}.pem: ${ext:S/sig/certs/}.pem _2ndLAST_PEM_USE
-ta.h: vc_${ext}.pem
+vc_${sig}.pem: ${sig:S/sig/certs/}.pem _2ndLAST_PEM_USE
+ta.h: vc_${sig}.pem
.endif
.endif
.endfor
-# cleanup duplicates
-VE_SIGNATURE_LIST:= ${VE_SIGNATURE_LIST:O:u}
-
.if target(ta_asc.h)
XCFLAGS.opgp_key+= -DHAVE_TA_ASC_H
.if ${VE_SELF_TESTS} != "no"
# for self test
vc_openpgp.asc: ta_openpgp.asc
- ${SIGN_OPENPGP} ${.ALLSRC:M*.asc}
+ ${SIGN_asc} ${.ALLSRC:M*.asc}
mv ta_openpgp.asc.asc ${.TARGET}
ta_asc.h: vc_openpgp.asc
@@ -79,7 +86,6 @@
.endif
.else
-VE_SIGNATURE_LIST?= RSA
# you need to provide t*.pem or t*.asc files for each trust anchor
# below assumes they are named ta_${ext}.pem eg ta_esig.pem for ECDSA
@@ -93,14 +99,10 @@
.if ${TRUST_ANCHORS:T:Mt*.pem} != ""
ta.h: ${TRUST_ANCHORS:M*.pem}
VE_SIGNATURE_EXT_LIST?= ${TRUST_ANCHORS:T:Mt*.pem:R:S/ta_//}
-.if ${VE_SIGNATURE_EXT_LIST:Mesig} != ""
-VE_SIGNATURE_LIST+= ECDSA
-.endif
.endif
.if ${TRUST_ANCHORS:T:Mt*.asc} != ""
-VE_SIGNATURE_LIST+= OPENPGP
-VE_SIGNATURE_EXT_LIST+= asc
+VE_SIGNATURE_LIST+= asc/OPENPGP/sha256/0
ta_asc.h: ${TRUST_ANCHORS:M*.asc}
.endif
# we take the mtime of this as our baseline time
diff --git a/lib/libsecureboot/openpgp/Makefile.inc b/lib/libsecureboot/openpgp/Makefile.inc
--- a/lib/libsecureboot/openpgp/Makefile.inc
+++ b/lib/libsecureboot/openpgp/Makefile.inc
@@ -26,7 +26,7 @@
VC_ASC_LIST ?= ${.ALLSRC:Mv*.asc}
ta_asc.h:
-.if ${VE_SIGNATURE_LIST:MOPENPGP} != ""
+.if ${VE_SIGNATURE_LIST:M*OPENPGP*} != ""
@( echo '/* Autogenerated - DO NOT EDIT!!! */'; echo; \
echo "#define HAVE_TA_ASC 1"; \
set -- ${TA_ASC_LIST:@f@$f ${f:T:R}@}; \
diff --git a/lib/libsecureboot/vesigned.c b/lib/libsecureboot/vesigned.c
--- a/lib/libsecureboot/vesigned.c
+++ b/lib/libsecureboot/vesigned.c
@@ -44,15 +44,11 @@
char buf[MAXPATHLEN];
const char **se;
- for (se = signature_exts; *se; se++) {
+ for (se = signature_ext_list; *se; se++) {
snprintf(buf, sizeof(buf), "%s.%s", filename, *se);
if (stat(buf, &st) < 0 || !S_ISREG(st.st_mode))
continue;
DEBUG_PRINTF(5, ("verify_signed: %s\n", buf));
-#ifdef VE_OPENPGP_SUPPORT
- if (strncmp(*se, "asc", 3) == 0)
- return (verify_asc(buf, flags));
-#endif
return (verify_sig(buf, flags));
}
return (NULL);
diff --git a/lib/libsecureboot/vets.c b/lib/libsecureboot/vets.c
--- a/lib/libsecureboot/vets.c
+++ b/lib/libsecureboot/vets.c
@@ -36,6 +36,7 @@
#include "libsecureboot-priv.h"
#include <brssl.h>
#include <ta.h>
+#include <vsi.h>
#ifndef TRUST_ANCHOR_STR
# define TRUST_ANCHOR_STR ta_PEM
@@ -779,15 +780,15 @@
*/
#ifdef VE_ECDSA_SUPPORT
static unsigned char *
-verify_ec(br_x509_pkey *pk, const char *file, const char *sigfile)
+verify_ec(br_x509_pkey *pk, const char *file, const char *sigfile,
+ signature_info *sip)
{
-#ifdef VE_ECDSA_HASH_AGAIN
char *hex, hexbuf[br_sha512_SIZE * 2 + 2];
-#endif
unsigned char rhbuf[br_sha512_SIZE];
- br_sha256_context ctx;
+ const br_hash_class *md;
+ br_hash_compat_context mctx;
unsigned char *fcp, *scp;
- size_t flen, slen, plen;
+ size_t flen, hlen, plen, slen;
pem_object *po;
const br_ec_impl *ec;
br_ecdsa_vrfy vrfy;
@@ -803,21 +804,39 @@
free(scp);
return (NULL);
}
- br_sha256_init(&ctx);
- br_sha256_update(&ctx, fcp, flen);
- br_sha256_out(&ctx, rhbuf);
-#ifdef VE_ECDSA_HASH_AGAIN
- hex = hexdigest(hexbuf, sizeof(hexbuf), rhbuf, br_sha256_SIZE);
- /* now hash that */
- if (hex) {
- br_sha256_init(&ctx);
- br_sha256_update(&ctx, hex, strlen(hex));
- br_sha256_out(&ctx, rhbuf);
+ switch (sip->hash_id) {
+ case br_sha256_ID:
+ md = &br_sha256_vtable;
+ hlen = br_sha256_SIZE;
+ break;
+ case br_sha384_ID:
+ md = &br_sha384_vtable;
+ hlen = br_sha384_SIZE;
+ break;
+ case br_sha512_ID:
+ md = &br_sha512_vtable;
+ hlen = br_sha512_SIZE;
+ break;
+ default:
+ free(fcp);
+ free(scp);
+ return (NULL);
+ }
+ md->init(&mctx.vtable);
+ md->update(&mctx.vtable, fcp, flen);
+ md->out(&mctx.vtable, rhbuf);
+ if ((sip->flags & SIF_HASH_TWICE) != 0) {
+ hex = hexdigest(hexbuf, sizeof(hexbuf), rhbuf, hlen);
+ /* now hash that */
+ if (hex) {
+ md->init(&mctx.vtable);
+ md->update(&mctx.vtable, hex, strlen(hex));
+ md->out(&mctx.vtable, rhbuf);
+ }
}
-#endif
ec = br_ec_get_default();
vrfy = br_ecdsa_vrfy_asn1_get_default();
- if (!vrfy(ec, rhbuf, br_sha256_SIZE, &pk->key.ec, po->data,
+ if (!vrfy(ec, rhbuf, hlen, &pk->key.ec, po->data,
po->data_len)) {
free(fcp);
fcp = NULL;
@@ -877,8 +896,10 @@
*/
#ifdef VE_RSA_SUPPORT
static unsigned char *
-verify_rsa(br_x509_pkey *pk, const char *file, const char *sigfile)
+verify_rsa(br_x509_pkey *pk, const char *file, const char *sigfile,
+ signature_info *sip)
{
+ char *hex, hexbuf[br_sha512_SIZE * 2 + 2];
unsigned char rhbuf[br_sha512_SIZE];
const unsigned char *hash_oid;
const br_hash_class *md;
@@ -899,24 +920,46 @@
return (NULL);
}
- switch (po->data_len) {
-#if defined(UNIT_TEST) && defined(VE_DEPRECATED_RSA_SHA1_SUPPORT)
- case 256:
- // this is our old deprecated sig method
+ switch (sip->hash_id) {
+#ifdef VE_SHA1_SUPPORT /* deprecated */
+ case br_sha1_ID:
md = &br_sha1_vtable;
hlen = br_sha1_SIZE;
hash_oid = BR_HASH_OID_SHA1;
break;
#endif
- default:
+ case br_sha256_ID:
md = &br_sha256_vtable;
hlen = br_sha256_SIZE;
hash_oid = BR_HASH_OID_SHA256;
break;
+ case br_sha384_ID:
+ md = &br_sha384_vtable;
+ hlen = br_sha384_SIZE;
+ hash_oid = BR_HASH_OID_SHA384;
+ break;
+ case br_sha512_ID:
+ md = &br_sha512_vtable;
+ hlen = br_sha512_SIZE;
+ hash_oid = BR_HASH_OID_SHA512;
+ break;
+ default:
+ free(fcp);
+ free(scp);
+ return (NULL);
}
md->init(&mctx.vtable);
md->update(&mctx.vtable, fcp, flen);
md->out(&mctx.vtable, rhbuf);
+ if ((sip->flags & SIF_HASH_TWICE) != 0) {
+ hex = hexdigest(hexbuf, sizeof(hexbuf), rhbuf, hlen);
+ /* now hash that */
+ if (hex) {
+ md->init(&mctx.vtable);
+ md->update(&mctx.vtable, hex, strlen(hex));
+ md->out(&mctx.vtable, rhbuf);
+ }
+ }
if (!verify_rsa_digest(&pk->key.rsa, hash_oid,
rhbuf, hlen, po->data, po->data_len)) {
free(fcp);
@@ -951,9 +994,31 @@
char pbuf[MAXPATHLEN];
char *cp;
unsigned char *ucp;
+ signature_info *sip;
+ const char *sig;
size_t n;
DEBUG_PRINTF(5, ("verify_sig: %s\n", sigfile));
+
+ /* find the signature_info for this signature ext */
+ if ((sig = strrchr(sigfile, '.')) != NULL) {
+ sig++;
+
+ for (sip = signature_info_list; sip->sig != NULL; sip++) {
+ if (strcmp(sig, sip->sig) == 0)
+ break;
+ }
+ } else
+ sip = NULL;
+
+ if (sip == NULL || sip->sig == NULL)
+ return NULL; /* not valid */
+ if (strcmp(sig, "asc") == 0)
+#ifdef VE_OPENPGP_SUPPORT
+ return verify_asc(sigfile, flags);
+#else
+ return NULL; /* we shouldn't get here */
+#endif
n = strlcpy(pbuf, sigfile, sizeof(pbuf));
if (n > (sizeof(pbuf) - 5) || strcmp(&sigfile[n - 3], "sig") != 0)
return (NULL);
@@ -984,12 +1049,12 @@
switch (pk->key_type) {
#ifdef VE_ECDSA_SUPPORT
case BR_KEYTYPE_EC:
- ucp = verify_ec(pk, pbuf, sigfile);
+ ucp = verify_ec(pk, pbuf, sigfile, sip);
break;
#endif
#ifdef VE_RSA_SUPPORT
case BR_KEYTYPE_RSA:
- ucp = verify_rsa(pk, pbuf, sigfile);
+ ucp = verify_rsa(pk, pbuf, sigfile, sip);
break;
#endif
default:
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 28, 10:52 AM (21 h, 15 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
42063171
Default Alt Text
D61007.1795863173.diff (18 KB)
Attached To
Mode
D61007: libsecureboot: add support for more signatures
Attached
Detach File
Event Timeline