aboutsummaryrefslogtreecommitdiffstats
path: root/crypto
Commit message (Collapse)AuthorAgeFilesLines
* Remove OPENSSL_assert() usage from crypto/bnMatt Caswell2017-08-212-6/+6
| | | | | Reviewed-by: Andy Polyakov <appro@openssl.org> (Merged from https://github.com/openssl/openssl/pull/3740)
* Remove OPENSSL_assert() from various crypto/bio filesMatt Caswell2017-08-213-14/+21
| | | | | | | bss_dgram.c is deferred until later due to ongoing discussions. Reviewed-by: Andy Polyakov <appro@openssl.org> (Merged from https://github.com/openssl/openssl/pull/3740)
* Remove OPENSSL_assert() from crypto/asn1/bio_asn1.cMatt Caswell2017-08-211-1/+3
| | | | | Reviewed-by: Andy Polyakov <appro@openssl.org> (Merged from https://github.com/openssl/openssl/pull/3740)
* Put thread-fork-init inside a run-once guardRich Salz2017-08-181-2/+11
| | | | | | | Thanks to Christian Heimes for pointing this out. Reviewed-by: Andy Polyakov <appro@openssl.org> (Merged from https://github.com/openssl/openssl/pull/4191)
* err/err.c: improve readability.Andy Polyakov2017-08-181-6/+2
| | | | Reviewed-by: Rich Salz <rsalz@openssl.org>
* err/err.c: fix "wraparound" bug in ERR_set_error_data.Andy Polyakov2017-08-181-2/+0
| | | | Reviewed-by: Rich Salz <rsalz@openssl.org>
* Clear outputs in PKCS12_parse error handling.Bernd Edlinger2017-08-171-8/+13
| | | | | | Reviewed-by: Andy Polyakov <appro@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/4145)
* Fix OCSP_basic_verify() cert chain construction in case bs->certs is NULLDavid von Oheimb2017-08-161-0/+2
| | | | | | | | | | | Now the certs arg is not any more neglected when building the signer cert chain. Added case to test/recipes/80-test_ocsp.t proving fix for 3-level CA hierarchy. See also http://rt.openssl.org/Ticket/Display.html?id=4620 Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/4124)
* sha/asm/keccak1600-armv4.pl: optimize for Thumb-2.Andy Polyakov2017-08-161-144/+242
| | | | | | | Reduce per-round instruction count in Thumb-2 case by 16%. This is achieved by folding ldr/str pairs to their double-word counterparts. Reviewed-by: Rich Salz <rsalz@openssl.org>
* Fix coding style of EVP_PKEY_CTX_ctrl_uint64Johannes Bauer2017-08-151-1/+1
| | | | | | | | | Code review of @dot-asm pointed out style guide violation; this patch fixes it. Reviewed-by: Andy Polyakov <appro@openssl.org> Reviewed-by: Ben Kaduk <kaduk@mit.edu> (Merged from https://github.com/openssl/openssl/pull/4166)
* Revert "Add some casts for %j"Rich Salz2017-08-151-2/+2
| | | | | | | This reverts commit c4d2e483a39176a476c56d35879423fe6e33c0cd. Reviewed-by: Ben Kaduk <kaduk@mit.edu> (Merged from https://github.com/openssl/openssl/pull/4160)
* Clear error stack on successful OSSL_STORE_open()Richard Levitte2017-08-151-5/+16
| | | | | | | | | | | | | | Since OSSL_STORE_open() tries with the 'file' scheme loader first, and then on the loader implied by the URI if the former fails, the former leaves an error on the error stack. This is confusing, so let's clear the error stack on success. The implementation uses ERR_set_mark, ERR_pop_to_mark and ERR_clear_last_mark to make sure caller errors are preserved as much as possible. Fixes #4089 Reviewed-by: Andy Polyakov <appro@openssl.org> (Merged from https://github.com/openssl/openssl/pull/4094)
* Add ERR_clear_last_mark()Richard Levitte2017-08-151-0/+23
| | | | | | | | | This allows callers to set a mark, and then clear it without removing the errors. Useful in case an error is encountered that should be returned up the call stack. Reviewed-by: Andy Polyakov <appro@openssl.org> (Merged from https://github.com/openssl/openssl/pull/4094)
* Rename crypto/evp/scrypt.c to crypto/evp/pbe_scrypt.cRichard Levitte2017-08-152-1/+1
| | | | | | | | | | There already is a scrypt.c in crypto/kdf/, both becoming script.o or script.obj. With some linkers, the same object files name more than once means one of them is dropped, either when building shared libraries or when building executables from static libraries. Reviewed-by: Tim Hudson <tjh@openssl.org> (Merged from https://github.com/openssl/openssl/pull/4164)
* Add some casts for %jRich Salz2017-08-141-2/+2
| | | | | | Reviewed-by: Paul Dale <paul.dale@oracle.com> Reviewed-by: Ben Kaduk <kaduk@mit.edu> (Merged from https://github.com/openssl/openssl/pull/4160)
* Instantiate when RAND_status() checksRich Salz2017-08-131-0/+2
| | | | | Reviewed-by: Kurt Roeckx <kurt@roeckx.be> (Merged from https://github.com/openssl/openssl/pull/4150)
* sha/asm/keccak1600-avx512.pl: fix buglet in SHA3_squeeze tail.Andy Polyakov2017-08-121-1/+1
| | | | Reviewed-by: Rich Salz <rsalz@openssl.org>
* Wire SHAKE to EVP.Andy Polyakov2017-08-122-4/+16
| | | | | Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/4137)
* Add EVP_DigestFinalXOF, interface to extendable-output functions, XOFs.Andy Polyakov2017-08-123-0/+26
| | | | | Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/4137)
* Fix building without scryptJohannes Bauer2017-08-081-0/+4
| | | | | | | | | Building without the scrypt KDF is now possible, the OPENSSL_NO_SCRYPT define is honored in code. Previous this lead to undefined references. Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Stephen Henson <steve@openssl.org> (Merged from https://github.com/openssl/openssl/pull/4116)
* Support CMS decrypt without a certificate for all key typesDr. Stephen Henson2017-08-081-6/+4
| | | | | Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/4115)
* Add interface to the scrypt KDF by means of PKEY_METHODJohannes Bauer2017-08-088-4/+291
| | | | | | | | | Add an interface that allows accessing the scrypt KDF as a PKEY_METHOD. This fixes #4021 (at least for the scrypt portion of the issue). Reviewed-by: Paul Dale <paul.dale@oracle.com> Reviewed-by: Stephen Henson <steve@openssl.org> (Merged from https://github.com/openssl/openssl/pull/4026)
* Various RAND improvementsRich Salz2017-08-073-43/+55
| | | | | | | | | | | | Try to put DRBG and rand_bytes buffers in secure heap Read the TSC fewer times (but it's still not enabled). Short-circuit return in win RAND_poll_ex; other minor tweaks and format-fixes. Use the _bytes version of rdrand/rdseed Fix ia32cap checks. Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de> (Merged from https://github.com/openssl/openssl/pull/4100)
* Avoid surpising password dialog in X509 file lookup.Bernd Edlinger2017-08-071-3/+3
| | | | | Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/4111)
* Make RAND_DRBG fork-safeRich Salz2017-08-075-2/+18
| | | | | | | | Use atfork to count child forks, and reseed DRBG when the counts don't match. Reviewed-by: Paul Dale <paul.dale@oracle.com> (Merged from https://github.com/openssl/openssl/pull/4101)
* Add missing include of cryptlib.hRich Salz2017-08-065-5/+5
| | | | | | | Also use "" not <> for all include cryptlib Reviewed-by: Andy Polyakov <appro@openssl.org> (Merged from https://github.com/openssl/openssl/pull/4082)
* Use passed drbg, not global oneDr. Stephen Henson2017-08-061-2/+2
| | | | | Reviewed-by: Kurt Roeckx <kurt@roeckx.be> (Merged from https://github.com/openssl/openssl/pull/4097)
* Fix typo in files in crypto folderXiaoyin Liu2017-08-054-8/+8
| | | | | | Reviewed-by: Kurt Roeckx <kurt@roeckx.be> Reviewed-by: Andy Polyakov <appro@openssl.org> GH: #4093
* Add entropy sanity checkDr. Stephen Henson2017-08-051-0/+5
| | | | | Reviewed-by: Kurt Roeckx <kurt@roeckx.be> (Merged from https://github.com/openssl/openssl/pull/4092)
* Set randomness buffer pointer in get_entropy calls.Dr. Stephen Henson2017-08-051-0/+2
| | | | | Reviewed-by: Kurt Roeckx <kurt@roeckx.be> (Merged from https://github.com/openssl/openssl/pull/4092)
* Consolidate to a single asn1_time_from_tm() functionTodd Short2017-08-045-163/+154
| | | | | | | | | | | | | | | | Add missing ASN1_TIME functions Do some cleanup of the ASN1_TIME code. Add ASN1_TIME_normalize() to normalize ASN1_TIME structures. Add ASN1_TIME_compare() to compare two ASN1_TIME structures. Add ASN1_TIME_cmp_time_t() to compare an ASN1_TIME to time_t (generic version of ASN1_UTCTIME_cmp_time_t()). Replace '0' .. '9' compares with isdigit() Reviewed-by: Paul Dale <paul.dale@oracle.com> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/2753)
* Add RAND_priv_bytes() for private keysRich Salz2017-08-0314-51/+110
| | | | | | | | | | Add a new global DRBG for private keys used by RAND_priv_bytes. Add BN_priv_rand() and BN_priv_rand_range() which use RAND_priv_bytes(). Change callers to use the appropriate BN_priv... function. Reviewed-by: Paul Dale <paul.dale@oracle.com> (Merged from https://github.com/openssl/openssl/pull/4076)
* Add a DRBG to each SSL objectRich Salz2017-08-031-0/+8
| | | | | | | | | | | Give each SSL object it's own DRBG, chained to the parent global DRBG which is used only as a source of randomness into the per-SSL DRBG. This is used for all session, ticket, and pre-master secret keys. It is NOT used for ECDH key generation which use only the global DRBG. (Doing that without changing the API is tricky, if not impossible.) Reviewed-by: Paul Dale <paul.dale@oracle.com> (Merged from https://github.com/openssl/openssl/pull/4050)
* Switch from ossl_rand to DRBG randRich Salz2017-08-0316-1101/+639
| | | | | | | | | | | | | | | | | | | | | | | | | | | | If RAND_add wraps around, XOR with existing. Add test to drbgtest that does the wrap-around. Re-order seeding and stop after first success. Add RAND_poll_ex() Use the DF and therefore lower RANDOMNESS_NEEDED. Also, for child DRBG's, mix in the address as the personalization bits. Centralize the entropy callbacks, from drbg_lib to rand_lib. (Conceptually, entropy is part of the enclosing application.) Thanks to Dr. Matthias St Pierre for the suggestion. Various code cleanups: -Make state an enum; inline RANDerr calls. -Add RAND_POLL_RETRIES (thanks Pauli for the idea) -Remove most RAND_seed calls from rest of library -Rename DRBG_CTX to RAND_DRBG, etc. -Move some code from drbg_lib to drbg_rand; drbg_lib is now only the implementation of NIST DRBG. -Remove blocklength Reviewed-by: Paul Dale <paul.dale@oracle.com> (Merged from https://github.com/openssl/openssl/pull/4019)
* Move ossl_assertMatt Caswell2017-08-031-82/+0
| | | | | | | | | | Move the definition of ossl_assert() out of e_os.h which is intended for OS specific things. Instead it is moved into internal/cryptlib.h. This also changes the definition to remove the (int) cast. Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/4073)
* Fix indentationJohannes Bauer2017-08-031-1/+1
| | | | | | | | Conform to coding guidelines. Reviewed-by: Paul Dale <paul.dale@oracle.com> Reviewed-by: Stephen Henson <steve@openssl.org> (Merged from https://github.com/openssl/openssl/pull/3989)
* Added differentiation between missing secret and missing seedJohannes Bauer2017-08-033-1/+7
| | | | | | | | This was previously mistakenly handled as a single error code. Reviewed-by: Paul Dale <paul.dale@oracle.com> Reviewed-by: Stephen Henson <steve@openssl.org> (Merged from https://github.com/openssl/openssl/pull/3989)
* Changed use of EVP_PKEY_CTX_md() and more specific error codesJohannes Bauer2017-08-034-12/+22
| | | | | | | | | | Changed HKDF to use EVP_PKEY_CTX_md() (review comment of @snhenson) and introduced more specific error codes (not only indicating *that* some parameter is missing, but actually *which* one it is). Reviewed-by: Paul Dale <paul.dale@oracle.com> Reviewed-by: Stephen Henson <steve@openssl.org> (Merged from https://github.com/openssl/openssl/pull/3989)
* More error handling to HKDF and one more case in TLS1-PRFJohannes Bauer2017-08-034-2/+16
| | | | | | | | | | | | | | HKDF now handles an invalid digest like TLS1-PRF does (i.e., returns KDF_R_INVALID_DIGEST if the passed digest is not known). Both KDFs now set the error code KDF_R_UNKNOWN_PARAMETER_TYPE if a type was passed that is not recognized. This will have the effect of improving debugging output in case a user uses "openssl pkeyutl -kdf ..." in a wrong way and result in an actual error code (instead of just "failure" and an empty error stack). Reviewed-by: Paul Dale <paul.dale@oracle.com> Reviewed-by: Stephen Henson <steve@openssl.org> (Merged from https://github.com/openssl/openssl/pull/3989)
* Set error when HKDF used without parametersJohannes Bauer2017-08-033-1/+5
| | | | | | | | | | | Introduce KDF_F_PKEY_HKDF_DERIVE and return the KDF_R_MISSING_PARAMETER error code when required parameters have not been set. This will make "openssl pkeyutl -kdf HKDF" return a meaningful error message instead of simply "Public Key operation error". Reviewed-by: Paul Dale <paul.dale@oracle.com> Reviewed-by: Stephen Henson <steve@openssl.org> (Merged from https://github.com/openssl/openssl/pull/3989)
* sha/asm/keccak1600-armv4.pl: improve non-NEON performance by ~10%.Andy Polyakov2017-08-021-352/+388
| | | | | | | | | | | | | This is achieved mostly by ~10% reduction of amount of instructions per round thanks to a) switch to KECCAK_2X variant; b) merge of almost 1/2 rotations with logical instructions. Performance is improved on all observed processors except on Cortex-A15. This is because it's capable of exploiting more parallelism and can execute original code for same amount of time. Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de> (Merged from https://github.com/openssl/openssl/pull/4057)
* Adding NID_hmac_sha1 and _md5 to builtin_pbe[]Martin Peylo2017-08-021-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | The OID for {1 3 6 1 5 5 8 1 2} HMAC-SHA1 (NID_hmac_sha1) is explicitly referenced by RFC 2510, RFC 3370, and RFC 4210. This is essential for the common implementations of CMP (Certificate Managing Protocol, RFC4210). HMAC-MD5's OID {1 3 6 1 5 5 8 1 1} (NID_hmac_md5) is in the same branch and it seems to generally exist (-> Internet search), but it is unclear where it is actually defined as it appears not to be referenced by RFCs and practically rather unused. Those OIDs are both duplicates to OIDs from an RSA OID branch, which are already included in builtin_pbe[]: HMAC-SHA1 also has another OID defined in PKCS#5/RFC2898 (NID_hmacWithSHA1). It is also unclear where the other OID for HMAC-MD5 (NID_hmacWithMD5) from the RSA branch is officially specified, as only HMAC-SHA1 from PKCS#5 was found to be defined. Anyway, HMAC-MD5 likely only plays a neglectable role in the future. Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Paul Dale <paul.dale@oracle.com> (Merged from https://github.com/openssl/openssl/pull/3811)
* sha/keccak1600.c: choose more sensible default parameters.Andy Polyakov2017-08-011-11/+21
| | | | | | | "More" refers to the fact that we make active BIT_INTERLEAVE choice in some specific cases. Update commentary correspondingly. Reviewed-by: Rich Salz <rsalz@openssl.org>
* asn1/a_time.c: make handling of 'fractional point' formally correct.Andy Polyakov2017-08-011-17/+20
| | | | | | | | | | | | | Even though tm->length >= 15 && v[14] == '.' works in practice, [because "YYYYMMDDHHMMSS." would be rejected as invalid by asn1_time_to_tm,] formal correctness with respect to buffer overstep in few lines vicinity improves readability. [Also fold one if condition and improve expression readability.] Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/4058)
* Fix an information leak in the RSA padding check code.Bernd Edlinger2017-07-312-4/+4
| | | | | | | | The memory blocks contain secret data and must be cleared before returning to the system heap. Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/4062)
* bn/bn_lcl.h: restore formatting.Andy Polyakov2017-07-311-10/+10
| | | | Reviewed-by: Rich Salz <rsalz@openssl.org>
* bn/bn_lcl.h: use __int128 whenever possible, not only on MIPS.Andy Polyakov2017-07-311-11/+9
| | | | Reviewed-by: Rich Salz <rsalz@openssl.org>
* bn/bn_lcl.h: improve inline assembly coverage on PPC64.Andy Polyakov2017-07-311-7/+7
| | | | | | [And move misplaced macros.] Reviewed-by: Rich Salz <rsalz@openssl.org>
* Fix typo in sha1-thumb.plXiaoyin Liu2017-07-301-1/+1
| | | | | | Reviewed-by: Tim Hudson <tjh@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/4056)
* Refactor ASN1_TIME_print functionsPaul Yang2017-07-303-92/+47
| | | | | | | | | | | | | | Check time string format before parsing Reduce more duplicated code By involving asn1_time_to_tm, we can now get information we mostly need to print a time string. This follows what was discussed at https://github.com/openssl/openssl/pull/4001#discussion_r129092251 Reviewed-by: Paul Dale <paul.dale@oracle.com> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/4039)