// SPDX-License-Identifier: GPL-2.0-or-later /* Instantiate a public key crypto key from an X.509 Certificate * *Copyright(C)2012RedHat,Inc.AllRightsReserved. *WrittenbyDavidHowells(dhowells@redhat.com)
*/
sig->s = kmemdup(cert->raw_sig, cert->raw_sig_size, GFP_KERNEL); if (!sig->s) return -ENOMEM;
sig->s_size = cert->raw_sig_size;
/* Allocate the hashing algorithm we're going to need and find out how *bigthehashoperationaldatawillbe.
*/
tfm = crypto_alloc_shash(sig->hash_algo, 0, 0); if (IS_ERR(tfm)) { if (PTR_ERR(tfm) == -ENOENT) {
cert->unsupported_sig = true; return0;
} return PTR_ERR(tfm);
}
/* *Checkforself-signednessinanX.509certandiffound,checkthesignature *immediatelyifwecan.
*/ int x509_check_for_self_signed(struct x509_certificate *cert)
{ int ret = 0;
if (cert->sig->auth_ids[0] || cert->sig->auth_ids[1]) { /* If the AKID is present it may have one or two parts. If *botharesupplied,bothmustmatch.
*/ bool a = asymmetric_key_id_same(cert->skid, cert->sig->auth_ids[1]); bool b = asymmetric_key_id_same(cert->id, cert->sig->auth_ids[0]);
if (!a && !b) goto not_self_signed;
ret = -EKEYREJECTED; if (((a && !b) || (b && !a)) &&
cert->sig->auth_ids[0] && cert->sig->auth_ids[1]) goto out;
}
if (cert->unsupported_sig) {
ret = 0; goto out;
}
ret = public_key_verify_signature(cert->pub, cert->sig); if (ret < 0) { if (ret == -ENOPKG) {
cert->unsupported_sig = true;
ret = 0;
} goto out;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.