summaryrefslogtreecommitdiff
path: root/lib/crypto
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'next'Tom Rini2022-07-111-2/+2
|\
| * spl: Ensure all SPL symbols in Kconfig have some SPL dependencyTom Rini2022-07-071-2/+2
| | | | | | | | | | | | | | | | | | | | | | Tighten up symbol dependencies in a number of places. Ensure that a SPL specific option has at least a direct dependency on SPL. In places where it's clear that we depend on something more specific, use that dependency instead. This means in a very small number of places we can drop redundant dependencies. Reported-by: Pali Rohár <pali@kernel.org> Signed-off-by: Tom Rini <trini@konsulko.com>
* | lib: crypto: add mscode_parserAKASHI Takahiro2022-07-054-0/+184
|/ | | | | | | | | | | | | | | In MS authenticode, pkcs7 should have data in its contentInfo field. This data is tagged with SpcIndirectData type and, for a signed PE image, provides a image's message digest as SpcPeImageData. This parser is used in image authentication to parse the field and retrieve a message digest. Imported from linux v5.19-rc, crypto/asymmetric_keys/mscode*. Checkpatch.pl generates tones of warnings, but those are not fixed for the sake of maintainability (importing from another source). Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
* lib/crypto: support sha384/sha512 in x509/pkcs7Dhananjay Phadke2022-04-112-0/+8
| | | | | | | | | | | | Set digest_size SHA384 and SHA512 algorithms in pkcs7 and x509, (not set by ported linux code, but needed by __UBOOT__ part). EFI_CAPSULE_AUTHENTICATE doesn't select these algos but required for correctness if certificates contain sha384WithRSAEncryption or sha512WithRSAEncryption OIDs. Signed-off-by: Dhananjay Phadke <dphadke@linux.microsoft.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
* Make ASYMMETRIC_KEY_TYPE depend on FIT_SIGNATURESimon Glass2022-04-061-0/+1
| | | | | | | Add this dependency to avoid a build error if FIT_SIGNATURE is not enabled. Signed-off-by: Simon Glass <sjg@chromium.org>
* lib: crypto: allow to build crypyo in SPLPhilippe Reynes2022-03-312-6/+42
| | | | | | | | | | This commit adds the options: - SPL_ASYMMETRIC_KEY_TYPE - SPL_ASYMMETRIC_PUBLIC_KEY_SUBTYPE - SPL_RSA_PUBLIC_KEY_PARSER Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com>
* lib/crypto: Enable more algorithms in cert verificationIlias Apalodimas2022-01-191-19/+16
| | | | | | | | | | | | | Right now the code explicitly limits us to sha1,256 hashes with RSA2048 encryption. But the limitation is artificial since U-Boot supports a wider range of algorithms. The internal image_get_[checksum|crypto]_algo() functions expect an argument in the format of <checksum>,<crypto>. So let's remove the size checking and create the needed string on the fly in order to support more hash/signing combinations. Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
* lib: Rename rsa-checksum.c to hash-checksum.cAlexandru Gagniuc2021-04-142-2/+2
| | | | | | | | | | | rsa-checksum.c sontains the hash_calculate() implementations. Despite the "rsa-" file prefix, this function is useful for other algorithms. To prevent confusion, move this file to lib/, and rename it to hash-checksum.c, to give it a more "generic" feel. Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* crypto: Fix the logic to calculate hash with authattributes setSughosh Ganu2020-12-311-11/+26
| | | | | | | | | | | | | | | RFC 2315 Section 9.3 describes the message digesting process. The digest calculated depends on whether the authenticated attributes are present. In case of a scenario where the authenticated attributes are present, the message digest that gets signed and is part of the pkcs7 message is computed from the auth attributes rather than the contents field. Check if the auth attributes are present, and if set, use the auth attributes to compute the hash that would be compared with the encrypted hash on the pkcs7 message. Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
* lib/crypto: simplify public_key_verify_signatureHeinrich Schuchardt2020-08-081-4/+0
| | | | | | The variable region is filled but never used. Remove it. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* lib: crypto: export and enhance pkcs7_verify_one()AKASHI Takahiro2020-07-221-7/+54
| | | | | | | | | | | | | The function, pkcs7_verify_one(), will be utilized to rework signature verification logic aiming to support intermediate certificates in "chain of trust." To do that, its function interface is expanded, adding an extra argument which is expected to return the last certificate in trusted chain. Then, this last one must further be verified with signature database, db and/or dbx. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
* lib: crypto: add pkcs7_digest()AKASHI Takahiro2020-07-221-3/+89
| | | | | | | | | | | This function was nullified when the file, pkcs7_verify.c, was imported because it calls further linux-specific interfaces inside, hence that could lead to more files being imported from linux. We need this function in pkcs7_verify_one() and so simply re-implement it here instead of re-using the code. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
* lib: crypto: import pkcs7_verify.c from linuxAKASHI Takahiro2020-07-223-0/+528
| | | | | | | | | | | | The file, pkcs7_verify.c, will now be imported from linux code (crypto/asymmetric_keys/pkcs7_verify.c in 5.7) and modified to fit into U-Boot environment. In particular, pkcs7_verify_one() function will be used in a later patch to rework signature verification logic aiming to support intermediate certificates in "chain of trust." Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
* lib: crypto: enable x509_check_for_self_signed()AKASHI Takahiro2020-07-222-10/+25
| | | | | | | | | | | When the file, x509_public_key.c, was imported from linux code in commit b4adf627d5b7 ("lib: crypto: add x509 parser"), x509_check_for_self_signed() was commented out for simplicity. Now it need be enabled in order to make pkcs7_verify_one(), which will be imported in a later patch, functional. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
* lib: crypto: add public_key_verify_signature()AKASHI Takahiro2020-07-221-1/+69
| | | | | | | | | | | | | This function will be called from x509_check_for_self_signed() and pkcs7_verify_one(), which will be imported from linux in a later patch. While it does exist in linux code and has a similar functionality of rsa_verify(), it calls further linux-specific interfaces inside. That could lead to more files being imported from linux. So simply re-implement it here instead of re-using the code. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
* common: Drop linux/bug.h from common headerSimon Glass2020-05-182-0/+2
| | | | | | Move this uncommon header out of the common header. Signed-off-by: Simon Glass <sjg@chromium.org>
* common: Drop log.h from common headerSimon Glass2020-05-183-0/+3
| | | | | | Move this header out of the common header. Signed-off-by: Simon Glass <sjg@chromium.org>
* lib/crypto, efi_loader: move some headers to include/cryptoAKASHI Takahiro2020-05-045-132/+12
| | | | | | | | | | Pkcs7_parse.h and x509_parser.h are used in UEFI subsystem, in particular, secure boot. So move them to include/crypto to avoid relative paths. Suggested-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Don't include include x509_parser.h twice. Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* lib/crypto, efi_loader: avoid multiple inclusions of header filesAKASHI Takahiro2020-05-042-0/+8
| | | | | | | | | | By adding extra symbols, we can now avoid including x509_parser and pkcs7_parser.h files multiple times. Suggested-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Don't include include x509_parser.h twice. Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* dm: core: Create a new header file for 'compat' featuresSimon Glass2020-02-051-0/+1
| | | | | | | | | | | | At present dm/device.h includes the linux-compatible features. This requires including linux/compat.h which in turn includes a lot of headers. One of these is malloc.h which we thus end up including in every file in U-Boot. Apart from the inefficiency of this, it is problematic for sandbox which needs to use the system malloc() in some files. Move the compatibility features into a separate header file. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: core: Require users of devres to include the headerSimon Glass2020-02-055-0/+8
| | | | | | | | | | At present devres.h is included in all files that include dm.h but few make use of it. Also this pulls in linux/compat which adds several more headers. Drop the automatic inclusion and require files to include devres themselves. This provides a good indication of which files use devres. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Anatolij Gustschin <agust@denx.de>
* lib: crypto: add pkcs7 message parserAKASHI Takahiro2019-12-065-0/+914
| | | | | | | | | | Imported from linux kernel v5.3: pkcs7.asn1 without changes pkcs7.h with changes marked as __UBOOT__ pkcs7_parser.h without changes pkcs7_parser.c with changes marked as __UBOOT__ Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
* lib: crypto: add x509 parserAKASHI Takahiro2019-12-067-0/+1170
| | | | | | | | | | | Imported from linux kernel v5.3: x509.asn1 without changes x509_akid.asn1 without changes x509_parser.h without changes x509_cert_parser.c with changes marked as __UBOOT__ x509_public_key.c with changes marked as __UBOOT__ Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
* lib: crypto: add rsa public key parserAKASHI Takahiro2019-12-064-0/+224
| | | | | | | | | Imported from linux kernel v5.3: rsapubkey.asn1 without changes rsa.h without changes rsa_helper.c with changes marked as __UBOOT__ Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
* lib: crypto: add public key utilityAKASHI Takahiro2019-12-064-0/+1073
Imported from linux kernel v5.3: asymmetric-type.h with changes marked as __UBOOT__ asymmetric_type.c with changes marked as __UBOOT__ public_key.h with changes marked as __UBOOT__ public_key.c with changes marked as __UBOOT__ Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>