summaryrefslogtreecommitdiffstats
path: root/crypto
AgeCommit message (Collapse)Author
2017-02-21Removed ugly size_t less than zero check.Hikar
CLA: trivial. Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/2674)
2017-02-21Ensure minsize >= sizeof(SH_LIST)Pauli
The sh_add_to_list function will overwrite subsequent slots in the free list for small allocations. This causes a segmentation fault if the writes goes off the end of the secure memory. I've not investigated if this problem can overwrite memory without the segmentation fault, but it seems likely. This fix limits the minsize to the sizeof of the SH_LIST structure (which also has a side effect of properly aligning the pointers). The alternative would be to return an error if minsize is too small. Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/2657)
2017-02-21Implementation of the ARIA cipher as described in RFC 5794.Pauli
This implementation is written in endian agnostic C code. No attempt at providing machine specific assembly code has been made. This implementation expands the evptests by including the test cases from RFC 5794 and ARIA official site rather than providing an individual test case. Support for ARIA has been integrated into the command line applications, but not TLS. Implemented modes are CBC, CFB1, CFB8, CFB128, CTR, ECB and OFB128. Reviewed-by: Andy Polyakov <appro@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/2337)
2017-02-20Don't call memcpy if len is zero.Rich Salz
Prevent undefined behavior in CRYPTO_cbc128_encrypt: calling this function with the 'len' parameter being 0 would result in a memcpy where the source and destination parameters are the same, which is undefined behavior. Do same for AES_ige_encrypt. Reviewed-by: Andy Polyakov <appro@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/2671)
2017-02-20Revert "Use memcmp() instead of CRYPTO_memcmp() when fuzzing"Kurt Roeckx
This reverts commit 3aad8e18707bccaabee5f111de2db0696b45781c. Reviewed-by: Andy Polyakov <appro@openssl.org> GH: #2686
2017-02-19Use memcmp() instead of CRYPTO_memcmp() when fuzzingKurt Roeckx
Reviewed-by: Andy Polyakov <appro@openssl.org> GH: #2633
2017-02-17Fix a slightly confusing if condition in a2i_ASN1_INTEGER.Bernd Edlinger
Reviewed-by: Andy Polyakov <appro@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/2640)
2017-02-17Fix symbol shadowRichard Levitte
Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/2663)
2017-02-17Fix typo in x86_64-mont5.pl CFI directivesDavid Benjamin
Reviewed-by: Kurt Roeckx <kurt@openssl.org> Reviewed-by: Andy Polyakov <appro@openssl.org> (Merged from https://github.com/openssl/openssl/pull/2655)
2017-02-16Use _WIN32 over WIN32 for preprocessor conditionalBenjamin Kaduk
The intent seems to be that the WIN32 symbol is for things that are a direct byproduct of being a windows-variant configuration and should be used for feature en/disablement on windows systems. Use of the _WIN32 symbol is more widespread, being used to implement platform portability of more generic code. We do define WIN32 in some situations in e_os.h, but that is not included universally. Reviewed-by: Andy Polyakov <appro@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/2642)
2017-02-15Properly zero cipher_data for ChaCha20-Poly1305 on cleanupKazuki Yamaguchi
Fix a typo. Probably this has not been found because EVP_CIPHER_CTX is smaller than EVP_CHACHA_AEAD_CTX and heap overflow does not occur. Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/2294)
2017-02-15crypto/armcap.c: short-circuit processor capability probe in iOS builds.Andy Polyakov
Capability probing by catching SIGILL appears to be problematic on iOS. But since Apple universe is "monocultural", it's actually possible to simply set pre-defined processor capability mask. Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/2617)
2017-02-15ARMv4 assembly pack: harmonize Thumb-ification of iOS build.Andy Polyakov
Three modules were left behind in a285992763f3961f69a8d86bf7dfff020a08cef9. Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/2617)
2017-02-15sha/asm/*-x86_64.pl: add CFI annotations.Andy Polyakov
Reviewed-by: Rich Salz <rsalz@openssl.org>
2017-02-14Fix a few typosFdaSilvaYY
[skip ci] Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/2571)
2017-02-14Remove obsolete commentGuido Vranken
Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1613)
2017-02-14Prevents that OPENSSL_gmtime incorrectly signals success if gmtime_r fails, ↵Guido Vranken
and that struct* tm result's possibly uninitialized content is used Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1613)
2017-02-14Prevent allocations of size 0 in sh_init, which are not possible with the ↵Guido Vranken
default OPENSSL_zalloc, but are possible if the user has installed their own allocator using CRYPTO_set_mem_functions. If the 0-allocations succeeds, the secure heap code will later access (at least) the first byte of that space, which is technically an OOB access. This could lead to problems with some custom allocators that only return a valid pointer for subsequent free()-ing, and do not expect that the pointer is actually dereferenced. Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/2605)
2017-02-14mem leak on error path and error propagation fixYuchi
Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/2559)
2017-02-13aes/asm/*-x86_64.pl: add CFI annotations.Andy Polyakov
Reviewed-by: Rich Salz <rsalz@openssl.org>
2017-02-13perlasm/x86_64-xlate.pl: recognize even offset(%reg) in cfa_expression.Andy Polyakov
This is handy when "offset(%reg)" is a perl variable. Reviewed-by: Rich Salz <rsalz@openssl.org>
2017-02-13ec/asm/ecp_nistz256-x86_64.pl: add CFI directives.Andy Polyakov
Reviewed-by: Rich Salz <rsalz@openssl.org>
2017-02-13ec/asm/ecp_nistz256-x86_64.pl: fix typo-bug in Win64 SE handler.Andy Polyakov
Thanks to Jun Sun for spotting this. Reviewed-by: Rich Salz <rsalz@openssl.org>
2017-02-13Further improvements to ASYNC_WAIT_CTX_clear_fdAndrea Grandi
Remove call to cleanup function Use only one loop to find previous element Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/2581)
2017-02-13Remove fd from the list when the engine clears the wait context before pauseAndrea Grandi
This fixes the num of fds added/removed returned by ASYNC_WAIT_CTX_get_changed_fds Previously, the numbers were not consistent with the fds actually written in the buffers since the fds that have been both added and removed are explicitly ignored in the loop. Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/2581)
2017-02-13{md5,rc4}/asm/*-x86_64.pl: add CFI annotations.Andy Polyakov
Reviewed-by: Rich Salz <rsalz@openssl.org>
2017-02-13modes/asm/*-x86_64.pl: add CFI annotations.Andy Polyakov
Reviewed-by: Rich Salz <rsalz@openssl.org>
2017-02-13DES keys are not 7 days long.Darren Tucker
CLA: trivial Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/2604)
2017-02-11sha/asm/sha1-x86_64.pl: add CFI annotations.Adam Langley
Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Andy Polyakov <appro@openssl.org> (Merged from https://github.com/openssl/openssl/pull/2590)
2017-02-10perlasm/x86_64-xlate.pl: fix pair of typo-bugs in the new cfi_directive.Andy Polyakov
.cfi_{start|end}proc and .cfi_def_cfa were not tracked. Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/2585)
2017-02-10perlasm/x86_64-xlate.pl: typo fix in comment.Adam Langley
CLA: trivial Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Andy Polyakov <appro@openssl.org> (Merged from https://github.com/openssl/openssl/pull/2584)
2017-02-10Fix copy-pasteism in CFI directives.Adam Langley
I don't think this actually affects anything since the cfi_restore directives aren't strictly needed anyway. (The old values are still in memory so either will do.) CLA: trivial Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Andy Polyakov <appro@openssl.org> (Merged from https://github.com/openssl/openssl/pull/2582)
2017-02-10Restore EVP_CIPH_FLAG_LENGTH_BITS working properlyLukasz Pawelczyk
EVP_CIPH_FLAG_LENGTH_BITS flag for CFB1 has been broken with the introduction of the is_partially_overlapping() check that did not take it into the account (treating number of bits passed as bytes). This remedies that and allows this flag to work as intended. Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1942)
2017-02-09bn/asm/x86_64*: add DWARF CFI directives.Andy Polyakov
Reviewed-by: Rich Salz <rsalz@openssl.org>
2017-02-09perlasm/x86_64-xlate.pl: recognize DWARF CFI directives.Andy Polyakov
CFI directives annotate instructions that are significant for stack unwinding procedure. In addition to directives recognized by GNU assembler this module implements three synthetic ones: - .cfi_push annotates push instructions in prologue and translates to .cfi_adjust_cfa_offset (if needed) and .cfi_offset; - .cfi_pop annotates pop instructions in epilogue and translates to .cfi_adjust_cfs_offset (if needed) and .cfi_restore; - .cfi_cfa_expression encodes DW_CFA_def_cfa_expression and passes it to .cfi_escape as byte vector; CFA expression syntax is made up mix of DWARF operator suffixes [subset of] and references to registers with optional bias. Following example describes offloaded original stack pointer at specific offset from current stack pointer: .cfi_cfa_expression %rsp+40,deref,+8 Final +8 has everything to do with the fact that CFA, Canonical Frame Address, is reference to top of caller's stack, and on x86_64 call to subroutine pushes 8-byte return address. Triggered by request from Adam Langley. Reviewed-by: Rich Salz <rsalz@openssl.org>
2017-02-09perlasm/x86_64-xlate.pl: remove obsolete .picmeup synthetic directive.Andy Polyakov
Reviewed-by: Rich Salz <rsalz@openssl.org>
2017-02-09perlasm/x86_64-xlate.pl: minor readability updates.Andy Polyakov
Reviewed-by: Rich Salz <rsalz@openssl.org>
2017-02-09bn/asm/rsaz-avx2.pl: refine Win64 SE handler.Andy Polyakov
Reviewed-by: Rich Salz <rsalz@openssl.org>
2017-02-08Make EVP_*Final work for CCM ciphersDr. Stephen Henson
Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/2550)
2017-02-08Add NID_auth_any and NID_kx_any NIDs.Dr. Stephen Henson
Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/2550)
2017-02-07Fix a crash in EVP_CIPHER_CTX_cleanup due to cipher_data may be NULLBernd Edlinger
or EVP_CTRL_INIT/EVP_CTRL_COPY was not called or failed. If that happens in EVP_CipherInit_ex/EVP_CIPHER_CTX_copy set cipher = NULL, aes_gcm_cleanup should check that gctx != NULL before calling OPENSSL_cleanse. Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/2562)
2017-02-06x86_64 assembly pack: Win64 SEH face-lift.Andy Polyakov
- harmonize handlers with guidelines and themselves; - fix some bugs in handlers; - add missing handlers in chacha and ecp_nistz256 modules; Reviewed-by: Rich Salz <rsalz@openssl.org>
2017-02-06perlasm/x86_64-xlate.pl: clarify SEH coding guidelines.Andy Polyakov
Reviewed-by: Rich Salz <rsalz@openssl.org>
2017-02-05Fix a crash with malformed user notice policy numbersBernd Edlinger
Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/2352)
2017-02-03Combined patch against master branch for the following issues:Bernd Edlinger
Fixed a memory leak in ASN1_digest and ASN1_item_digest. Reworked error handling in asn1_item_embed_new. Fixed error handling in int_ctx_new and EVP_PKEY_CTX_dup. Fixed a memory leak in CRYPTO_free_ex_data. Reworked error handing in x509_name_ex_d2i, x509_name_encode and x509_name_canon. Check for null pointer in tls_process_cert_verify. Fixes #2103 #2104 #2105 #2109 #2111 #2115 Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/2342)
2017-02-03Grouped data declarations [skip ci]Dmitry Kostjuchenko
Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1981)
2017-02-03Removed tab spaces.Dmitry Kostjuchenko
Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1981)
2017-02-03Corrections according the review comments.Dmitry Kostjuchenko
Updated indentations according project rules, renamed file-local define to the shorter version - USE_RWLOCK, fixed declaration after the if statement in CRYPTO_THREAD_lock_new(). Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1981)
2017-02-03Compile fix on platforms with missing pthread_rwlock_t.Dmitry Kostjuchenko
Fix compilation on platforms with missing pthread_rwlock_t implementation by replacing it with pthread_mutex_t. An example of such platform can be Android OS 2.0 - 2.1, API level 5 (Eclair), Android NDK platform - android-5 where pthread_rwlock_t is not implemented and is missing in pthread.h. In case of missing pthread_rwlock_t implementation CRYPTO_RWLOCK will work as exclusive lock in write-only mode of pthread_rwlock_t lock. The implementation based on pthread_mutex_t must be using PTHREAD_MUTEX_RECURSIVE mode to be compatible with recursive behavior of pthread_rwlock_rdlock. Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1981)
2017-02-03crypto/x86_64cpuid.pl: detect if kernel preserves %zmm registers.Andy Polyakov
Reviewed-by: Rich Salz <rsalz@openssl.org>