summaryrefslogtreecommitdiffstats
path: root/crypto
AgeCommit message (Collapse)Author
2015-03-23Fix build.Dr. Stephen Henson
Remove x_exten.c and x_exten.o from crypto/asn1/Makefile: they've moved now. Reviewed-by: Matt Caswell <matt@openssl.org>
2015-03-23make X509_EXTENSION opaqueDr. Stephen Henson
Reviewed-by: Rich Salz <rsalz@openssl.org>
2015-03-23Remove deleted functions, update ordinals.Dr. Stephen Henson
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-03-23Remove {i2d,d2i}_ASN1_BOOLEANDr. Stephen Henson
Remove {i2d,d2i}_ASN1_BOOLEAN. Rewrite single occurrence of d2i_ASN1_BOOLEAN in asn1_parse2 Reviewed-by: Rich Salz <rsalz@openssl.org>
2015-03-23Remove old ASN.1 code.Dr. Stephen Henson
Remove old M_ASN1_ macros and replace any occurences with the corresponding function. Remove d2i_ASN1_bytes, d2i_ASN1_SET, i2d_ASN1_SET: no longer used internally. Reviewed-by: Rich Salz <rsalz@openssl.org>
2015-03-23sha/asm/sha256-armv4.pl: adapt for use in Linux kernel context.Andy Polyakov
In cooperation with Ard Biesheuvel (Linaro) and Sami Tolvanen (Google). Reviewed-by: Richard Levitte <levitte@openssl.org>
2015-03-20Add AES unwrap test with invalid key.Dr. Stephen Henson
This tests the unwrap algorithm with an invalid key. The result should be rejected without returning any plaintext. Reviewed-by: Emilia Käsper <emilia@openssl.org>
2015-03-20Fix memory leak.Dr. Stephen Henson
Reviewed-by: Emilia Käsper <emilia@openssl.org>
2015-03-20CRYPTO_128_unwrap(): Fix refactoring damageRichard Godbee
crypto/modes/wrap128.c was heavily refactored to support AES Key Wrap with Padding, and four bugs were introduced into CRYPTO_128_unwrap() at that time: - crypto_128_unwrap_raw()'s return value ('ret') is checked incorrectly, and the function immediately returns 'ret' in (almost) all cases. This makes the IV checking code later in the function unreachable, but callers think the IV check succeeded since CRYPTO_128_unwrap()'s return value is non-zero. FIX: Return 0 (error) if crypto_128_unwrap_raw() returned 0 (error). - crypto_128_unwrap_raw() writes the IV to the 'got_iv' buffer, not to the first 8 bytes of the output buffer ('out') as the IV checking code expects. This makes the IV check fail. FIX: Compare 'iv' to 'got_iv', not 'out'. - The data written to the output buffer ('out') is "cleansed" if the IV check fails, but the code passes OPENSSL_cleanse() the input buffer length ('inlen') instead of the number of bytes that crypto_128_unwrap_raw() wrote to the output buffer ('ret'). This means that OPENSSL_cleanse() could potentially write past the end of 'out'. FIX: Change 'inlen' to 'ret' in the OPENSSL_cleanse() call. - CRYPTO_128_unwrap() is returning the length of the input buffer ('inlen') instead of the number of bytes written to the output buffer ('ret'). This could cause the caller to read past the end of 'out'. FIX: Return 'ret' instead of 'inlen' at the end of the function. PR#3749 Reviewed-by: Stephen Henson <steve@openssl.org> Reviewed-by: Emilia Käsper <emilia@openssl.org>
2015-03-20wrap128.c: Fix Doxygen commentsRichard Godbee
Reviewed-by: Stephen Henson <steve@openssl.org> Reviewed-by: Emilia Käsper <emilia@openssl.org>
2015-03-19Fix a failure to NULL a pointer freed on error.Matt Caswell
Reported by the LibreSSL project as a follow on to CVE-2015-0209 Reviewed-by: Richard Levitte <levitte@openssl.org>
2015-03-19PKCS#7: avoid NULL pointer dereferences with missing contentEmilia Kasper
In PKCS#7, the ASN.1 content component is optional. This typically applies to inner content (detached signatures), however we must also handle unexpected missing outer content correctly. This patch only addresses functions reachable from parsing, decryption and verification, and functions otherwise associated with reading potentially untrusted data. Correcting all low-level API calls requires further work. CVE-2015-0289 Thanks to Michal Zalewski (Google) for reporting this issue. Reviewed-by: Steve Henson <steve@openssl.org>
2015-03-19Fix ASN1_TYPE_cmpDr. Stephen Henson
Fix segmentation violation when ASN1_TYPE_cmp is passed a boolean type. This can be triggered during certificate verification so could be a DoS attack against a client or a server enabling client authentication. CVE-2015-0286 Reviewed-by: Richard Levitte <levitte@openssl.org>
2015-03-19Reject invalid PSS parameters.Dr. Stephen Henson
Fix a bug where invalid PSS parameters are not rejected resulting in a NULL pointer exception. This can be triggered during certificate verification so could be a DoS attack against a client or a server enabling client authentication. Thanks to Brian Carpenter for reporting this issues. CVE-2015-0208 Reviewed-by: Tim Hudson <tjh@openssl.org>
2015-03-19Free up ADB and CHOICE if already initialised.Dr. Stephen Henson
CVE-2015-0287 Reviewed-by: Tim Hudson <tjh@openssl.org> Reviewed-by: Emilia Käsper <emilia@openssl.org>
2015-03-17Remove dead code from cryptoMatt Caswell
Some miscellaneous removal of dead code from lib crypto. Reviewed-by: Richard Levitte <levitte@openssl.org>
2015-03-17Fix probable_prime over large shiftMatt Caswell
In the probable_prime() function we behave slightly different if the number of bits we are interested in is <= BN_BITS2 (the num of bits in a BN_ULONG). As part of the calculation we work out a size_limit as follows: size_limit = (((BN_ULONG)1) << bits) - BN_get_word(rnd) - 1; There is a problem though if bits == BN_BITS2. Shifting by that much causes undefined behaviour. I did some tests. On my system BN_BITS2 == 64. So I set bits to 64 and calculated the result of: (((BN_ULONG)1) << bits) I was expecting to get the result 0. I actually got 1! Strangely this... (((BN_ULONG)0) << BN_BITS2) ...does equal 0! This means that, on my system at least, size_limit will be off by 1 when bits == BN_BITS2. This commit fixes the behaviour so that we always get consistent results. Reviewed-by: Andy Polyakov <appro@openssl.org>
2015-03-17Fix unintended sign extensionMatt Caswell
The function CRYPTO_128_unwrap_pad uses an 8 byte AIV (Alternative Initial Value). The least significant 4 bytes of this is placed into the local variable |ptext_len|. This is done as follows: ptext_len = (aiv[4] << 24) | (aiv[5] << 16) | (aiv[6] << 8) | aiv[7]; aiv[4] is an unsigned char, but (aiv[4] << 24) is promoted to a *signed* int - therefore we could end up shifting into the sign bit and end up with a negative value. |ptext_len| is a size_t (typically 64-bits). If the result of the shifts is negative then the upper bits of |ptext_len| will all be 1. This commit fixes the issue by explicitly casting to an unsigned int. Reviewed-by: Richard Levitte <levitte@openssl.org>
2015-03-17Fix memset call in stack.cMatt Caswell
The function sk_zero is supposed to zero the elements held within a stack. It uses memset to do this. However it calculates the size of each element as being sizeof(char **) instead of sizeof(char *). This probably doesn't make much practical difference in most cases, but isn't a portable assumption. Reviewed-by: Richard Levitte <levitte@openssl.org>
2015-03-16Make X509_ATTRIBUTE opaque.Dr. Stephen Henson
Reviewed-by: Rich Salz <rsalz@openssl.org>
2015-03-15Fix regression in ASN1_UTCTIME_cmp_time_tCarl Jackson
Previously, ASN1_UTCTIME_cmp_time_t would return 1 if s > t, -1 if s < t, and 0 if s == t. This behavior was broken in a refactor [0], resulting in the opposite time comparison behavior. [0]: 904348a4922333106b613754136305db229475ea PR#3706 Reviewed-by: Stephen Henson <steve@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org>
2015-03-15Update ordinals, fix error message.Dr. Stephen Henson
Update error messages to say "EC is disabled" these can then be picked up by mkdef.pl. Update ordinals. Reviewed-by: Kurt Roeckx <kurt@openssl.org>
2015-03-14Avoid reading an unused byte after the bufferAndy Polyakov
Other curves don't have this problem. Reviewed-by: Kurt Roeckx <kurt@roeckx.be> Reviewed-by: Emilia Käsper <emilia@openssl.org>
2015-03-13Fix undefined behaviour in shifts.Emilia Kasper
Td4 and Te4 are arrays of u8. A u8 << int promotes the u8 to an int first then shifts. If the mathematical result of a shift (as modelled by lhs * 2^{rhs}) is not representable in an integer, behaviour is undefined. In other words, you can't shift into the sign bit of a signed integer. Fix this by casting to u32 whenever we're shifting left by 24. (For consistency, cast other shifts, too.) Caught by -fsanitize=shift Submitted by Nick Lewycky (Google) Reviewed-by: Andy Polyakov <appro@openssl.org>
2015-03-13Allocate string types directly.Dr. Stephen Henson
Allocate and free ASN.1 string types directly instead of going through the ASN.1 item code. Reviewed-by: Rich Salz <rsalz@openssl.org>
2015-03-13Fix key wrapping mode with padding to conform to RFC 5649.Petr Spacek
According to RFC 5649 section 4.1 step 1) we should not add padding if plaintext length is multiply of 8 ockets. This matches pseudo-code in http://dx.doi.org/10.6028/NIST.SP.800-38F on page 15, section 6.3 KWP, algorithm 5 KWP-AE, step 2. PR#3675 Reviewed-by: Stephen Henson <steve@openssl.org> Reviewed-by: Andy Polyakov <appro@openssl.org>
2015-03-12Remove obsolete declarations.Dr. Stephen Henson
Remove DECLARE_ASN1_SET_OF and DECLARE_PKCS12_STACK_OF these haven't been used internally in OpenSSL for some time. Reviewed-by: Rich Salz <rsalz@openssl.org>
2015-03-12ASN.1 print fix.Dr. Stephen Henson
When printing out an ASN.1 structure if the type is an item template don't fall thru and attempt to interpret as a primitive type. Reviewed-by: Andy Polyakov <appro@openssl.org>
2015-03-12Fix RSA_X931_derive_exMatt Caswell
In the RSA_X931_derive_ex a call to BN_CTX_new is made. This can return NULL on error. However the return value is not tested until *after* it is derefed! Also at the top of the function a test is made to ensure that |rsa| is not NULL. If it is we go to the "err" label. Unfortunately the error handling code deref's rsa. Reviewed-by: Rich Salz <rsalz@openssl.org>
2015-03-12Fix missing return checks in v3_cpols.cMatt Caswell
Fixed assorted missing return value checks in c3_cpols.c Reviewed-by: Rich Salz <rsalz@openssl.org>
2015-03-12Fix dsa_pub_encodeMatt Caswell
The return value from ASN1_STRING_new() was not being checked which could lead to a NULL deref in the event of a malloc failure. Also fixed a mem leak in the error path. Reviewed-by: Rich Salz <rsalz@openssl.org>
2015-03-12Fix dh_pub_encodeMatt Caswell
The return value from ASN1_STRING_new() was not being checked which could lead to a NULL deref in the event of a malloc failure. Also fixed a mem leak in the error path. Reviewed-by: Rich Salz <rsalz@openssl.org>
2015-03-12Fix asn1_item_print_ctxMatt Caswell
The call to asn1_do_adb can return NULL on error, so we should check the return value before attempting to use it. Reviewed-by: Rich Salz <rsalz@openssl.org>
2015-03-12ASN1_primitive_new NULL param handlingMatt Caswell
ASN1_primitive_new takes an ASN1_ITEM * param |it|. There are a couple of conditional code paths that check whether |it| is NULL or not - but later |it| is deref'd unconditionally. If |it| was ever really NULL then this would seg fault. In practice ASN1_primitive_new is marked as an internal function in the public header file. The only places it is ever used internally always pass a non NULL parameter for |it|. Therefore, change the code to sanity check that |it| is not NULL, and remove the conditional checking. Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Andy Polyakov <appro@openssl.org>
2015-03-12Fix EVP_DigestInit_ex with NULL digestMatt Caswell
Calling EVP_DigestInit_ex which has already had the digest set up for it should be possible. You are supposed to be able to pass NULL for the type. However currently this seg faults. Reviewed-by: Andy Polyakov <appro@openssl.org>
2015-03-12Fix error handling in bn_expMatt Caswell
In the event of an error |rr| could be NULL. Therefore don't assume you can use |rr| in the error handling code. Reviewed-by: Andy Polyakov <appro@openssl.org>
2015-03-11Merge OPENSSL_NO_EC{DH,DSA} into OPENSSL_NO_ECRich Salz
Suggested by John Foley <foleyj@cisco.com>. Reviewed-by: Matt Caswell <matt@openssl.org>
2015-03-11Fix seg fault in ASN1_generate_v3/ASN1_generate_nconfMatt Caswell
Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
2015-03-10BIO_debug_callback: Fix output on 64-bit machinesRichard Godbee
BIO_debug_callback() no longer assumes the hexadecimal representation of a pointer fits in 8 characters. Signed-off-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org>
2015-03-09Fix wrong numbers being passed as string lengthsDmitry-Me
Signed-off-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org>
2015-03-08Cleanse PKCS#8 private key components.Dr. Stephen Henson
New function ASN1_STRING_clear_free which cleanses an ASN1_STRING structure before freeing it. Call ASN1_STRING_clear_free on PKCS#8 private key components. Reviewed-by: Rich Salz <rsalz@openssl.org>
2015-03-08ARMv4 assembly pack: add Cortex-A15 performance data.Andy Polyakov
Reviewed-by: Tim Hudson <tjh@openssl.org>
2015-03-06make errorsMatt Caswell
Run make errors on master Reviewed-by: Richard Levitte <levitte@openssl.org>
2015-03-05Catch up the VMS build.Richard Levitte
crypto/crypto-lib.com - catch up with the OCSP changes test/maketest.com and test/tests.com - catch up with the addition of test_evp_extra Reviewed-by: Rich Salz <rsalz@openssl.org>
2015-03-05Make STACK_OF opaque.Dr. Stephen Henson
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-03-05Make OCSP structures opaque.Dr. Stephen Henson
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-03-05Unchecked malloc fixesMatt Caswell
Miscellaneous unchecked malloc fixes. Also fixed some mem leaks on error paths as I spotted them along the way. Reviewed-by: Tim Hudson <tjh@openssl.org>
2015-03-04add RIPEMD160 whirlpool testsDr. Stephen Henson
Add RIPEMD160 and whirlpool test data. Add Count keyword to repeatedly call EVP_DigestUpate. Reviewed-by: Matt Caswell <matt@openssl.org>
2015-03-02Check public key is not NULL.Dr. Stephen Henson
CVE-2015-0288 PR#3708 Reviewed-by: Matt Caswell <matt@openssl.org>
2015-03-02Fix format script.Dr. Stephen Henson
The format script didn't correctly recognise some ASN.1 macros and didn't reformat some files as a result. Fix script and reformat affected files. Reviewed-by: Tim Hudson <tjh@openssl.org>