summaryrefslogtreecommitdiff
path: root/lib/libcrypto/hmac
AgeCommit message (Collapse)Author
2024-08-31Zap HMAC_InitTheo Buehler
Long deprecated, last users have been fixed. ok beck jsing
2024-07-09Add bounded attributes to hmac.hTheo Buehler
ok beck
2024-06-01Remove support for static buffers in HMAC/digestsTheo Buehler
HMAC() and the one-step digests used to support passing a NULL buffer and would return the digest in a static buffer. This design is firmly from the nineties, not thread safe and it saves callers a single line. The few ports that used to rely this were fixed with patches sent to non-hostile (and non-dead) upstreams. It's early enough in the release cycle that remaining uses hidden from the compiler should be caught, at least the ones that matter. There won't be that many since BoringSSL removed this feature in 2017. https://boringssl-review.googlesource.com/14528 Add non-null attributes to the headers and add a few missing bounded attributes. ok beck jsing
2024-03-30Add missing LCRYPTO_ALIAS()Theo Buehler
HMAC_CTX_reset() and HMAC_Init() had missing LCRYPTO_ALIAS(). ok beck jsing
2024-03-26Simplify HMAC_CTX_new()joshua
There is no need to call HMAC_CTX_init() as the memory has already been initialised to zero. ok tb
2024-02-18Use EVP_MD_CTX_legacy_clear() internallyTheo Buehler
ok jsing
2024-01-04Replace .pkey_base_id with a .base_method pointerTheo Buehler
Every EVP_PKEY_ASN1_METHOD is either an ASN.1 method or an alias. As such it resolves to an underlying ASN.1 method (in one step). This information can be stored in a base_method pointer in allusion to the pkey_base_id, which is the name for the nid (aka pkey_id aka type) of the underlying method. For an ASN.1 method, the base method is itself, so the base method is set as a pointer to itself. For an alias it is of course a pointer to the underlying method. Then obviously ameth->pkey_base_id is the same as ameth->base_method->pkey_id, so rework all ASN.1 methods to follow that. ok jsing
2023-12-28Rework and fix pkey_hmac_keygen()Theo Buehler
The usual: single exit, error check all functions even if they can't actually fail. This one was flagged again. ok jsing CID 471706 (false positive)
2023-11-29Ignore ENGINE at the API boundaryTheo Buehler
This removes the remaining ENGINE members from various internal structs and functions. Any ENGINE passed into a public API is now completely ignored functions returning an ENGINE always return NULL. ok jsing
2023-04-25Wire up truncated SHA-2, SHA-3 and related thingsTheo Buehler
from 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
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-19Unindent and check some pointers explicitly against NULLTheo Buehler
2022-11-19Remove HMAC PRIVATE KEY supportTheo Buehler
This is an undocumented feature of openssl genpkey for testing purposes. Emilia removed support for this 'bogus private key format' from OpenSSL in 2017 in commit c26f655fdd18ac19016c1c0496105f5256a1e84d. ok jsing
2022-11-18Check os for NULL before dereferencing itTheo Buehler
Avoids a segfault when both priv == NULL and os == NULL. ok miod
2022-11-18Include bytestring.h directly rather than pulling it in via asn1_locl.hTheo Buehler
2022-11-18Wire up HMAC to raw private key methodsTheo Buehler
Obviously, the brilliant API design kitchen decided that an interface carrying public and private key in its name (so that every sane person thinks of asymmetric cryptography), is also perfectly suitable for MACs. Wire up HMAC since Ruby's OpenSSL gem uses these bindings if the build system detects that EVP_PKEY_new_raw_public_key() is available in evp.h. While there, also add the missing pub_cmp() ameth, which obviously treats two things as equal by returning 1. Reported by jeremy and anton, fixes regress/lib/libssl/openssl-ruby tests ok jsing
2022-11-18Change the pkey.ptr from char * to void *Theo Buehler
Now that EVP_PKEY is opaque, there is no reason to keep the ptr member of the pkey union as a weird char pointer, a void pointer will do. This avoids a few stupid casts and simplifies an upcoming diff. ok jsing
2022-11-11Add support for symbol hiding disabled by default.Bob Beck
Fully explained in libcrypto/README. TL;DR make sure libcrypto and libssl's function calls internally and to each other are via symbol names that won't get overridden by linking other libraries. Mostly work by guenther@, which will currently be gated behind a build setting NAMESPACE=yes. once we convert all the symbols to this method we will do a major bump and pick up the changes. ok tb@ jsing@
2022-05-05Fix HMAC() with NULL keyTheo Buehler
If a NULL key is passed to HMAC_Init_ex(), it tries to reuse the previous key. This makes no sense inside HMAC() since the HMAC_CTX has no key set yet. This is hit by HKDF() with NULL salt() via the EVP API and results in a few Wycheproof test failures. If key is NULL, use a zero length dummy key. This was not hit from wycheproof.go since we pass a []byte with a single NUL from Go. Matches OpenSSL if key is NULL and key_len is 0. If key_len != 0, OpenSSL will still fail by passing a NULL key which makes no sense, so set key_len to 0 instead. ok beck jsing
2022-03-30Avoid segfaults in EVP_PKEY_CTX_free()Theo Buehler
It is possible to call pmeth->cleanup() with an EVP_PKEY_CTX whose data is NULL. If pmeth->init() in int_ctx_new() fails, EVP_PKEY_CTX_free() is called with such a context. This in turn calls pmeth->cleanup(), and thus these cleanup functions must be careful not to use NULL data. Most of them are, but one of GOST's functions and HMAC's aren't. Reported for HMAC by Masaru Masada https://github.com/libressl-portable/openbsd/issues/129 ok bcook jsing
2022-03-30pkey_hmac_init(): use calloc()Theo Buehler
Instead of using malloc() and setting most struct members to 0, simply use calloc(). ok bcook jsing
2022-01-14Remove HMAC_CTX_{init,cleanup}() and HMAC_init from public visibilityTheo Buehler
In OpenSSL commit 32fd54a9a3 HMAC_CTX_cleanup() was integrated into HMAC_CTX_init(), then HMAC_CTX_init() was renamed to HMAC_CTX_reset() in dc0099e1. LibreSSL retained them for API compatibility with OpenSSL 1.0. Not many things use them anymore. In fact, some projects that didn't want to modify their code for OpenSSL 1.1 API compatibility used the removed functions to wrap the OpenSSL 1.1 API. We had to patch some of these and this will now no longer be necessary. Also remove HMAC_cleanup(). Nothing uses this. ok inoguchi jsing
2022-01-14Make structs in evp.h and hmac.h opaqueTheo Buehler
This moves most structs to evp_locl.h and moves HMAC_CTX to hmac_local.h. ok inoguchi jsing
2021-12-12Annotate the structs that will be moved to hmac_local.h and evp_locl.hTheo Buehler
in an upcoming bump. This omits EVP_AEAD_CTX which will be dealt with separately. EVP_CIPHER_INFO internals are still publicly visible in OpenSSL, so it won't be moved. Move typedefs for HMAC_CTX and EVP_ENCODE_CTX to ossl_typ.h. These typedefs will be visible by files including only hmac.h or evp.h since hmac.h includes evp.h and evp.h includes ossl_typ.h. ok inoguchi
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
2018-02-17Provide HMAC_CTX_new(), HMAC_CTX_free(), HMAC_CTX_reset() andJoel Sing
HMAC_CTX_get_md().
2017-05-02use freezero() instead of memset/explicit_bzero + free. SubstantiallyTheo de Raadt
reduces conditional logic (-218, +82). MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH cache alignment calculation bn/bn_exp.c wasn'tt quite right. Two other tricky bits with ASN1_STRING_FLAG_NDEF and BN_FLG_STATIC_DATA where the condition cannot be collapsed completely. Passes regress. ok beck
2017-03-03Ensure MD and key initialized before processing HMACKinichiro Inoguchi
Ensure both MD and key have been initialized before processing HMAC. Releasing HMAC_CTX in error path of HMAC(). In regress test, added test 4,5,6 and cleaned up the code. ok jsing@
2017-01-29Send the function codes from the error functions to the bit bucket,Bob Beck
as was done earlier in libssl. Thanks inoguchi@ for noticing libssl had more reacharounds into this. ok jsing@ inoguchi@
2015-09-10Correct spelling of OPENSSL_cleanse.Joel Sing
ok miod@
2015-07-20Various memory leaks upon error or unchecked allocations.Miod Vallat
ok doug@
2015-02-10Replace assert() and OPENSSL_assert() calls with proper error return paths.Miod Vallat
Careful review, feedback & ok doug@ jsing@
2014-07-11Only import cryptlib.h in the four source files that actually need it.Joel Sing
Remove the openssl public includes from cryptlib.h and add a small number of includes into the source files that actually need them. While here, also sort/group/tidy the includes. ok beck@ miod@
2014-07-10Stop including standard headers via cryptlib.h - pull in the headers thatJoel Sing
are needed in the source files that actually require them. ok beck@ miod@
2014-06-21More KNF.Joel Sing
2014-06-21KNFMiod Vallat
2014-06-12tags as requested by miod and teduTheo de Raadt
2014-04-27Use C99 initializers for the various FOO_METHOD structs. More readable, andMiod Vallat
avoid unreadable/unmaintainable constructs like that: const EVP_PKEY_ASN1_METHOD cmac_asn1_meth = { EVP_PKEY_CMAC, EVP_PKEY_CMAC, 0, "CMAC", "OpenSSL CMAC method", 0,0,0,0, 0,0,0, cmac_size, 0, 0,0,0,0,0,0,0, cmac_key_free, 0, 0,0 }; ok matthew@ deraadt@
2014-04-17Change library to use intrinsic memory allocation functions instead ofBob Beck
OPENSSL_foo wrappers. This changes: OPENSSL_malloc->malloc OPENSSL_free->free OPENSSL_relloc->realloc OPENSSL_freeFunc->free
2014-04-15we don't use these files for buildingTed Unangst
2014-04-15remove FIPS mode support. people who require FIPS can buy something thatTed Unangst
meets their needs, but dumping it in here only penalizes the rest of us. ok beck deraadt
2014-04-15Moved to regress/lib/libcrypto.Miod Vallat
2014-04-15Send the rotIBM stream cipher (ebcdic) to Valhalla to party for eternityBob Beck
with the bearded ones... some API's that nobody should be using will dissapear with this commit.
2014-04-14remove auto-generated dependencies from the old unused build system, soTheo de Raadt
that it is easier to find code pieces. They are getting in the way. ok miod
2012-10-13resolve conflictsDamien Miller
2011-11-03openssl-1.0.0e: resolve conflictsDamien Miller
2010-10-01resolve conflicts, fix local changesDamien Miller
2010-10-01import OpenSSL-1.0.0aDamien Miller