aboutsummaryrefslogtreecommitdiff
path: root/crypto/hmac/hmac.c
AgeCommit message (Collapse)AuthorFilesLines
2019-08-12HMAC: use EVP_MD_flags(), not EVP_MD_meth_get_flags()Richard Levitte1-1/+1
The latter should only be ussed with legacy methods. Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/9391)
2019-03-27Don't allow SHAKE128/SHAKE256 with HMACMatt Caswell1-0/+7
See discussion in github issue #8563 Fixes #8563 Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com> (Merged from https://github.com/openssl/openssl/pull/8584)
2018-12-06Following the license change, modify the boilerplates in crypto/hmac/Richard Levitte1-1/+1
[skip ci] Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/7799)
2018-12-06Refactor the computation of API version limitsRichard Levitte1-1/+1
Previously, the API version limit was indicated with a numeric version number. This was "natural" in the pre-3.0.0 because the version was this simple number. With 3.0.0, the version is divided into three separate numbers, and it's only the major number that counts, but we still need to be able to support pre-3.0.0 version limits. Therefore, we allow OPENSSL_API_COMPAT to be defined with a pre-3.0.0 style numeric version number or with a simple major number, i.e. can be defined like this for any application: -D OPENSSL_API_COMPAT=0x10100000L -D OPENSSL_API_COMPAT=3 Since the pre-3.0.0 numerical version numbers are high, it's easy to distinguish between a simple major number and a pre-3.0.0 numerical version number and to thereby support both forms at the same time. Internally, we define the following macros depending on the value of OPENSSL_API_COMPAT: OPENSSL_API_0_9_8 OPENSSL_API_1_0_0 OPENSSL_API_1_1_0 OPENSSL_API_3 They indicate that functions marked for deprecation in the corresponding major release shall not be built if defined. Reviewed-by: Tim Hudson <tjh@openssl.org> Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/7724)
2018-09-04Fix HMAC SHA3-224 and HMAC SHA3-256.Pauli1-6/+6
Added NIST test cases for these two as well. Additionally deprecate the public definiton of HMAC_MAX_MD_CBLOCK in 1.2.0. Reviewed-by: Tim Hudson <tjh@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/6972)
2018-09-04hmac_init cleanup and fix key zeroization issueShane Lontis1-17/+16
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com> Reviewed-by: Paul Dale <paul.dale@oracle.com> (Merged from https://github.com/openssl/openssl/pull/7092)
2017-08-21Remove OPENSSL_assert() from crypto/hmacMatt Caswell1-1/+2
Reviewed-by: Andy Polyakov <appro@openssl.org> (Merged from https://github.com/openssl/openssl/pull/3740)
2017-04-04PBKDF2 computation speedup (15-40%)Gergely Nagy1-9/+14
This commit contains some optimizations in PKCS5_PBKDF2_HMAC() and HMAC_CTX_copy() functions which together makes PBKDF2 computations faster by 15-40% according to my measurements made on x64 Linux with both asm optimized and no-asm versions of SHA1, SHA256 and SHA512. Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1708)
2016-11-04Fix style issues in HMAC_size()Matt Caswell1-3/+2
Based on review feedback. Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-11-04Ensure HMAC_size() handles errors correctlyMatt Caswell1-1/+4
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-06-24Add a getter to obtain the HMAC_CTX mdMatt Caswell1-0/+5
As a result of opaque HMAC_CTX apps need a getter for the HMAC_CTX md. GitHub Issue #1152 Reviewed-by: Tim Hudson <tjh@openssl.org>
2016-06-09hmac/hmac.c: fix sizeof typo in hmac_ctx_cleanup.Andy Polyakov1-1/+1
Reviewed-by: Matt Caswell <matt@openssl.org>
2016-05-17Copyright consolidation 07/10Rich Salz1-54/+6
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-05-16const correctness: make HMAC_size() take a const *Steffan Karger1-1/+1
CLA: none; trivial Signed-off-by: Kurt Roeckx <kurt@roeckx.be> Reviewed-by: Rich Salz <rsalz@openssl.org> GH: #1070
2016-02-08GH641: Don't care openssl_zmallocRich Salz1-3/+5
Don't cast malloc-family return values. Also found some places where (a) blank line was missing; and (b) the *wrong* return value was checked. Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-02-04RT3095: allow NULL key for single-shot HMACEmilia Kasper1-0/+7
In HMAC_Init_ex, NULL key signals reuse, but in single-shot HMAC, we can allow it to signal an empty key for convenience. Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
2016-01-26Remove /* foo.c */ commentsRich Salz1-1/+0
This was done by the following find . -name '*.[ch]' | /tmp/pl where /tmp/pl is the following three-line script: print unless $. == 1 && m@/\* .*\.[ch] \*/@; close ARGV if eof; # Close file to reset $. And then some hand-editing of other files. Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
2016-01-07Backwards-compatibility subject to OPENSSL_API_COMPATViktor Dukhovni1-1/+2
Provide backwards-compatiblity for functions, macros and include files if OPENSSL_API_COMPAT is either not defined or defined less than the version number of the release in which the feature was deprecated. Reviewed-by: Richard Levitte <levitte@openssl.org>
2015-12-07Cleanup: fix all sources that used HMAC_CTX_initRichard Levitte1-2/+2
Reviewed-by: Rich Salz <rsalz@openssl.org>
2015-12-07Cleanup: rename HMAC_CTX_init to HMAC_CTX_resetRichard Levitte1-2/+2
Reviewed-by: Rich Salz <rsalz@openssl.org>
2015-12-07Cleanup: fix all sources that used EVP_MD_CTX_(create|init|destroy)Richard Levitte1-9/+9
Reviewed-by: Rich Salz <rsalz@openssl.org>
2015-12-07Remove HMAC_CTX_cleanup and combine its functionality into EVP_MD_CTX_initRichard Levitte1-17/+17
This follows the same idea as the combination of EVP_MD_CTX_cleanup and EVP_MD_CTX_init into one function. Reviewed-by: Rich Salz <rsalz@openssl.org>
2015-12-07Make the definition of HMAC_CTX opaqueRichard Levitte1-7/+33
This moves the definition to crypto/hmac/hmac_lcl.h. Constructor and destructor added, and the typedef moved to include/openssl/ossl_typ.h. Reviewed-by: Rich Salz <rsalz@openssl.org>
2015-12-07Adapt HMAC to the EVP_MD_CTX changesRichard Levitte1-29/+50
This change required some special treatment, as HMAC is intertwined with EVP_MD. For now, all local HMAC_CTX variables MUST be initialised with HMAC_CTX_EMPTY, or whatever happens to be on the stack will be mistaken for actual pointers to EVP_MD_CTX. This will change as soon as HMAC_CTX becomes opaque. Also, since HMAC_CTX_init() can fail now, its return type changes from void to int, and it will return 0 on failure, 1 on success. Reviewed-by: Rich Salz <rsalz@openssl.org>
2015-06-12Fix ABI break with HMACMatt Caswell1-12/+8
Recent HMAC changes broke ABI compatibility due to a new field in HMAC_CTX. This backs that change out, and does it a different way. Thanks to Timo Teras for the concept. Reviewed-by: Richard Levitte <levitte@openssl.org>
2015-06-10Fix leak in HMAC error pathMatt Caswell1-0/+1
In the event of an error in the HMAC function, leaks can occur because the HMAC_CTX does not get cleaned up. Thanks to the BoringSSL project for reporting this issue. Reviewed-by: Richard Levitte <levitte@openssl.org>
2015-05-14Identify and move common internal libcrypto header filesRichard Levitte1-1/+1
There are header files in crypto/ that are used by a number of crypto/ submodules. Move those to crypto/include/internal and adapt the affected source code and Makefiles. The header files that got moved are: crypto/cryptolib.h crypto/md32_common.h Reviewed-by: Rich Salz <rsalz@openssl.org>
2015-05-04Use safer sizeof variant in mallocRich Salz1-1/+1
For a local variable: TYPE *p; Allocations like this are "risky": p = OPENSSL_malloc(sizeof(TYPE)); if the type of p changes, and the malloc call isn't updated, you could get memory corruption. Instead do this: p = OPENSSL_malloc(sizeof(*p)); Also fixed a few memset() calls that I noticed while doing this. Reviewed-by: Richard Levitte <levitte@openssl.org>
2015-04-16Code style: space after 'if'Viktor Dukhovni1-6/+6
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-03-25Fix HMAC to pass invalid key len testMatt Caswell1-1/+2
Reviewed-by: Richard Levitte <levitte@openssl.org>
2015-03-25Ensure that both the MD and key have been initialised before attempting toMatt Caswell1-3/+20
create an HMAC Inspired by BoringSSL commit 2fe7f2d0d9a6fcc75b4e594eeec306cc55acd594 Reviewed-by: Richard Levitte <levitte@openssl.org>
2015-02-10HMAC_cleanup, and HMAC_Init are stated as deprecated in the docs and source.Matt Caswell1-1/+3
Mark them as such with OPENSSL_USE_DEPRECATED Reviewed-by: Tim Hudson <tjh@openssl.org>
2015-01-22Run util/openssl-format-source -v -c .Matt Caswell1-143/+135
Reviewed-by: Tim Hudson <tjh@openssl.org>
2014-12-08remove OPENSSL_FIPSAPIDr. Stephen Henson1-1/+1
Reviewed-by: Tim Hudson <tjh@openssl.org>
2011-01-27Change OPENSSL_FIPSEVP to OPENSSL_FIPSAPI as it doesn't just referDr. Stephen Henson1-1/+1
to EVP any more. Move locking #define into fips.h. Set FIPS locking callbacks at same time as OpenSSL locking callbacks.
2011-01-26FIPS HMAC changes:Dr. Stephen Henson1-9/+13
Use EVP macros. Use tiny EVP in FIPS mode.
2010-06-12Fix warnings.Ben Laurie1-3/+0
2010-01-26Add flags functions which were added to 0.9.8 for fips but not 1.0.0 andDr. Stephen Henson1-0/+6
later.
2008-11-12Revert the size_t modifications from HEAD that had led to moreGeoff Thorpe1-3/+3
knock-on work than expected - they've been extracted into a patch series that can be completed elsewhere, or in a different branch, before merging back to HEAD.
2008-11-02Update HMAC functions to return an error where relevant.Dr. Stephen Henson1-27/+56
2008-11-01More size_tification.Ben Laurie1-4/+3
2007-04-11Experimental HMAC support via EVP_PKEY_METHOD.Dr. Stephen Henson1-0/+10
2005-05-17Move cryptlib.h prior bio.h. Actually it makes sense to include cryptlib.hAndy Polyakov1-1/+1
first everywhere in crypto and skip stdio.h and string.h [because it includes them].
2004-07-25Zero key-length for HMAC is apparently OK.Andy Polyakov1-1/+1
2004-07-25Stricter boundary condition check in HMAC_Init_ex.Andy Polyakov1-1/+1
2004-05-15size_t-fication of message digest APIs. We should size_t-fy more APIs...Andy Polyakov1-2/+2
2003-10-29A general spring-cleaning (in autumn) to fix up signed/unsigned warnings.Geoff Thorpe1-2/+2
I have tried to convert 'len' type variable declarations to unsigned as a means to address these warnings when appropriate, but when in doubt I have used casts in the comparisons instead. The better solution (that would get us all lynched by API users) would be to go through and convert all the function prototypes and structure definitions to use unsigned variables except when signed is necessary. The proliferation of (signed) "int" for strictly non-negative uses is unfortunate.
2002-11-13Security fixes brought forward from 0.9.7.Ben Laurie1-0/+3
2002-03-14Initialize cipher context in KRB5Dr. Stephen Henson1-5/+5
("D. Russell" <russelld@aol.net>) Allow HMAC functions to use an alternative ENGINE.
2001-12-09Improve back compatibility.Ben Laurie1-2/+10