summaryrefslogtreecommitdiff
path: root/lib/libcrypto/pkcs12
AgeCommit message (Collapse)Author
2024-08-22Remove copy_bag_attr()Theo Buehler
It is no longer possible to set an attribute on an EVP_PKEY, so this code is dead. ok miod
2024-07-15Fix PKCS12_create()Theo Buehler
This tries to copy some microsoft attributes which are not usually present and chokes on the now disabled EVP_PKEY_*attr* API. Instead of reviving about four layers of traps and indirection, just inline the two functions in a way that should be more obvious. found by anton via the ruby-openssl tests ok jsing
2024-07-09Hide global _it symbols in pkcs12.hBob Beck
ok tb@
2024-06-24libcrypto: constify most error string tablesTheo Buehler
These constitute the bulk of the remaining global mutable state in libcrypto. This commit moves most of them into data.rel.ro, leaving out ERR_str_{functs,libraries,reasons} (which require a slightly different approach) and SYS_str_reasons which is populated on startup. The main observation is that if ERR_load_strings() is called with a 0 lib argument, the ERR_STRING_DATA argument is not actually modified. We could use this fact to cast away const on the caller side and be done with it. We can make this cleaner by adding a helper ERR_load_const_strings() which explicitly avoids the assignment to str->error overriding the error code already set in the table. In order for this to work, we need to sprinkle some const in err/err.c. CMS called ERR_load_strings() with non-0 lib argument, but this didn't actually modify the error data since it ored in the value already stored in the table. Annoyingly, we need to cast const away once, namely in the call to lh_insert() in int_err_set_item(). Fixing this would require changing the public API and is going to be tricky since it requires that the LHASH_DOALL_FN_* types adjust. ok jsing
2024-03-24Fix namespace buildTheo Buehler
noticed/ok beck
2024-03-02Remove more PBE stuff from the public APITheo Buehler
This is still needed internally for CMS and its predecessors. This removal will enable disentangling some of its innards. ok jsing
2024-03-02Remove a lot of PKCS12 garbage from the public APITheo Buehler
PKCS12 is a hot mess. Please participate in the survey at the end of https://www.cs.auckland.ac.nz/~pgut001/pubs/pfx.html to increase its credibility and unanimity. ok jsing
2024-02-18Use EVP_CIPHER_CTX_legacy_clear() internallyTheo Buehler
ok jsing
2024-01-27Fold keyivgen functions into evp_pbe.cTheo Buehler
These are only used by the EVP_PBE routines and will become internal in the next major bump.
2024-01-25Plug a few leaks and perform some other code hygieneTheo Buehler
Closing this directory now until the daily Coverity run throws a hissy fit. ok jsing
2024-01-25p12_npas.c: hoist some helpers from the bottom to the top in reverse orderTheo Buehler
2024-01-25p12_npas.c: maclen -> mac_lenTheo Buehler
2024-01-25p12_npas.c: Use slightly less awkward variable namesTheo Buehler
2024-01-25Fix various NULL dereferences in PKCS #12Theo Buehler
The PKCS #7 ContentInfo has a mandatory contentType, but the content itself is OPTIONAL. Various unpacking API assumed presence of the content type is enough to access members of the content, resulting in crashes. Reported by Bahaa Naamneh on libressl-security, many thanks ok jsing
2024-01-25Merge PKCS12_newpass() and newpass_p12()Theo Buehler
With the previous refactoring, newpass_p12() became simple enough that it doesn't require a separate function anymore. Merge the public API into it and move it below (most of) the things it calls. ok jsing
2024-01-25Rename pkcs12_repack_safe() into pkcs12_repack_authsafes()Theo Buehler
discussed with jsing
2024-01-25Rework newpass_p12() a bit moreTheo Buehler
Split the bottom half that repacks the authsafes into a helper function. This simplifies the curly exit path and makes it clearer what is being done. PKCS12_pack_authsafes() is a very inconvenient API and there are some extra dances needed due to it. ok jsing
2024-01-25newpass_p12(): factor for loop body into helpersTheo Buehler
Since newpass_bags() and sk_PKCS7_push() could be shared between two otherwise entirely unrelated code paths, it was decided to dedup the code in about the ugliest possible way. Untangle the spaghetti and split the code paths into helper functions, so we can easily error check and avoid a bunch of leaks. ok jsing
2024-01-25Fix a memleak and a double free in newpass_p12()Theo Buehler
If the allocation of newsafes fails, asafes is leaked. And if the ASN1_OCTET_STRING_new() after the freeing of asafes fails, asafes is freed a second time. ok jsing
2023-02-16libressl *_namespace.h: adjust *_ALIAS() to require a semicolonTheo Buehler
LCRYPTO_ALIAS() and LSSL_ALIAS() contained a trailing semicolon. This does not conform to style(9), breaks editors and ctags and (most importantly) my workflow. Fix this by neutering them with asm("") so that -Wpedantic doesn't complain. There's precedent in libc's namespace.h fix suggested by & ok jsing
2023-01-24Check return value of X509_digestJob Snijders
OK tb@
2022-11-26Make header guards of internal headers consistentTheo Buehler
Not all of them, only those that didn't leak into a public header... Yes.
2022-11-26Make internal header file names consistentTheo Buehler
Libcrypto currently has a mess of *_lcl.h, *_locl.h, and *_local.h names used for internal headers. Move all these headers we inherited from OpenSSL to *_local.h, reserving the name *_internal.h for our own code. Similarly, move dtls_locl.h and ssl_locl.h to dtls_local and ssl_local.h. constant_time_locl.h is moved to constant_time.h since it's special. Adjust all .c files in libcrypto, libssl and regress. The diff is mechanical with the exception of tls13_quic.c, where #include <ssl_locl.h> was fixed manually. discussed with jsing, no objection bcook
2022-11-12Hide symbols in libcrypto/pkcs12Bob Beck
ok jsing@
2022-09-11Make structs in pkcs12.h opaqueTheo Buehler
ok jsing
2022-08-20Add an empty pkcs12_local.h and include it where it will soon be needed.Theo Buehler
2022-08-03Prepare to provide PKCS12 accessorsTheo Buehler
In order to be able to make pkcs12/ opaque, we need an entire family of accessors. These are in a particularly nasty tangle since this was done in about a dozen steps while sprinkling const, renaming functions, etc. The public API also adds backward compat macros for functions that were in the tree for half a day and then renamed. Of course some of them got picked up by some ports. Some of the gruesome hacks in here will go away with the next bump, but that doesn't mean that the pkcs12 directory will be prettier afterward. ok jsing
2022-07-30Eliminate the somewhat pointless Ij variableTheo Buehler
Requested by & ok jsing
2022-07-30Transform two || chains into individually checked functionsTheo Buehler
Requested by and ok jsing
2022-07-25fix indentTheo Buehler
2022-07-24Align PKCS12_key_gen_uni() with OpenSSLTheo Buehler
This is Dr Stephen Henson's rewrite avoiding BIGNUM (OpenSSL 54c68d35). Additionally this pulls in a < vs <= fix by Pauli Dale (OpenSSL 9d868840). There is also some minor cleanup by myself. ok jsing
2022-07-24Minor fixes in PKCS12_parse()Theo Buehler
Pull up clearing of output parameters before first return (OpenSSL 524fdd51 by Bernd Edlinger), explicit comparisons against NULL, '\0', etc. ok jsing
2022-07-24Per RFC 7292, safeContentsBag is a SEQUENCE OF, not a SET OFTheo Buehler
OpenSSL b709babb by Richard Levitte ok jsing
2022-07-24Clear key on exit in PKCS12_gen_mac()Theo Buehler
Also switch to heap-allocated HMAC_CTX and clean a few things up stylistically. loosely based on OpenSSL f5cee414 by Shane Lontis ok jsing
2022-07-24Plug a leak in PKCS12_setup_mac()Theo Buehler
based on OpenSSL 1b8f1937 by Dmitry Belyavskiy ok jsing
2022-07-12Remove mkerr.pl remnants from LibreSSLKlemens Nanni
This script is not used at all and files are edited by hand instead. Thus remove misleading comments incl. the obsolete script/config. Feedback OK jsing tb
2022-05-20Don't pass uninitialized pointer to ASN1_STRING_to_UTF8()Theo Buehler
Exposed by recent rewrite of ASN1_STRING_to_UTF8(). Found via grep after fixing CID 352831. ok jsing
2022-05-09Simplify X509_ATTRIBUTE ASN.1 encoding.Joel Sing
For some unknown historical reason, X509_ATTRIBUTE allows for a single ASN.1 value or an ASN.1 SET OF, rather than requiring an ASN.1 SET OF. Simplify encoding and remove support for single values - this is similar to OpenSSL e20b57270dec. This removes the last use of COMBINE in the ASN.1 decoder. ok tb@
2022-01-20Add check for OBJ_nid2obj return valueKinichiro Inoguchi
input from tb@
2022-01-20Add check for ASN1_INTEGER_setKinichiro Inoguchi
CID 24893 ok jsing@ millert@ tb@
2022-01-14Garbage collect the app_items field of ASN1_ADBTheo Buehler
This is unused and was removed in OpenSSL 5b70372d when it was replaced with an ASN.1 ADB callback (which we don't support). ok inoguchi jsing
2021-12-12Include evp_locl.h where it will be needed once most structs fromTheo Buehler
evp.h will be moved to evp_locl.h in an upcoming bump. ok inoguchi
2021-12-12Add a mostly empty hmac_local.h. HMAC_CTX and a few other thingsTheo Buehler
from hmac.h will be moved there in an umpcoming bump. Include this file where it will be needed. ok inoguchi
2021-11-01Move the now internal X.509-related structs into x509_lcl.h.Theo Buehler
Garbage collect the now unused LIBRESSL_CRYPTO_INTERNAL and LIBRESSL_OPAQUE_X509. Include "x509_lcl.h" where needed and fix a couple of unnecessary reacharounds. ok jsing
2021-07-09KNF: remove whitespace between functions and parenthesesTheo Buehler
2021-04-24Do not leave errors on the error stack on PKCS12_parse() success.Theo Buehler
Fix is the same as OpenSSL commit ffbf304d4832bd51bb0618f8ca5b7c26647ee664 Found by Alex Gaynor with a new pyca cryptography regress test. ok inoguchi
2020-06-05Remove remaining error *_str_functs[]Joel Sing
A number of years ago we dropped the concept of having function names in errors, since it is not that useful and very quickly gets out of sync when refactoring. It would seem that some new ones got imported and some missed the last clean up. ok tb@ beck@ "kill it with fire"
2018-08-24Remove EVP_PKEY2PKCS8_broken() and PKCS8_set_broken()Theo Buehler
Provide PKCS8_pkey_add1_attr_by_NID() and PKCS8_pkey_get0_attrs(). Remove the whole broken code and simplify pkcs8_priv_key_info_st accordingly. Based on OpenSSL commit 54dbf42398e23349b59f258a3dd60387bbc5ba13 plus some const that was added later. tested in a bulk build by sthen ok jsing
2018-05-30Add a const qualifier to the `uni' argument of OPENSSL_uni2asc().Theo Buehler
tested in a bulk build by sthen ok jsing
2018-05-13Add const qualifiers to the X509_SIG * and char * arguments ofTheo Buehler
PKCS8_decrypt(3). tested in a bulk build by sthen ok beck, jsing