summaryrefslogtreecommitdiffstats
path: root/crypto/asn1
AgeCommit message (Collapse)Author
2016-06-23Fix ASN1_STRING_to_UTF8 could not convert NumericStringMatt Caswell
tag2nbyte had -1 at 18th position, but underlying ASN1_mbstring_copy supports NumericString. tag2nbyte is also used in do_print_ex which will not be broken by setting 1 at 18th position of tag2nbyte Reviewed-by: Stephen Henson <steve@openssl.org> (cherry picked from commit d6079a87db58ad17550b5d00a74512464e6a029e)
2016-06-15Change (!seqtt) to (seqtt == NULL)Richard Levitte
Reviewed-by: Stephen Henson <steve@openssl.org> Reviewed-by: Emilia Käsper <emilia@openssl.org> (cherry picked from commit fdcb499cc2cd57412e496302a4bca8c5d9f1a9c7)
2016-06-15Always check that the value returned by asn1_do_adb() is non-NULLRichard Levitte
Reviewed-by: Stephen Henson <steve@openssl.org> Reviewed-by: Emilia Käsper <emilia@openssl.org> (cherry picked from commit bace847eae24f48adc6a967c6cce7f8d05bbeda3)
2016-06-14Fix omitted selector handling.Dr. Stephen Henson
The selector field could be omitted because it has a DEFAULT value. In this case *sfld == NULL (sfld can never be NULL). This was not noticed because this was never used in existing ASN.1 modules. Reviewed-by: Rich Salz <rsalz@openssl.org> (cherry picked from commit 7c46746bf2958fd2eccc59ecb48039e4e20ce38a)
2016-06-03Fix build with no-cmacDirk Feytons
Add missing ifdefs. Same change is already present in master, see b4a3aeebd9f9280aa7e69a343f5c824e68466d90 Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1155)
2016-05-31Fix some missing initsFdaSilvaYY
Backport of 8e89e85f556f549f05d3b49f5408a217ac5e3700 From PR #1019 / #997 Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1019)
2016-05-20Revert "make update"Richard Levitte
This reverts commit 7229a91a48d706804f790a392b3ad50bc358cdc4. Reviewed-by: Matt Caswell <matt@openssl.org>
2016-05-20Revert "Make it possible to have RFC2254 escapes with ASN1_STRING_print_ex()"Richard Levitte
This reverts commit 87728c682995d0575b52a5a19d69405bb764e76e. Reviewed-by: Matt Caswell <matt@openssl.org>
2016-05-18Refresh seldom used C generating scripts to current C standardRichard Levitte
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-05-18make updateRichard Levitte
RT#1466 Reviewed-by: Rich Salz <rsalz@openssl.org> (cherry picked from commit 0794b6a6a8a9a1dc1c7b0f9cfaf804253af29cdc)
2016-05-18Make it possible to have RFC2254 escapes with ASN1_STRING_print_ex()Richard Levitte
Also adds 'esc_2254' to the possible command line name options RT#1466 Reviewed-by: Rich Salz <rsalz@openssl.org> (cherry picked from commit bc776510982b3768761d32c1160e79cb45a561c3)
2016-05-14RT3513: req doesn't display attributes using utf8stringisnotnick
Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-05-11Fix i2d_X509_AUX and update docsViktor Dukhovni
When *pp is NULL, don't write garbage, return an unexpected pointer or leak memory on error. Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
2016-05-09Add NULL check in i2d_PrivateKey()Richard Levitte
Originally submitted by Kurt Cancemi <kurt@x64architecture.com> Closes RT#4533 Reviewed-by: Matt Caswell <matt@openssl.org> (cherry picked from commit 59a56c4cf02bbf1efeda6c2a5893d5079db78ff3)
2016-05-04Fix name length limit check.Dr. Stephen Henson
The name length limit check in x509_name_ex_d2i() includes the containing structure as well as the actual X509_NAME. This will cause large CRLs to be rejected. Fix by limiting the length passed to ASN1_item_ex_d2i() which will then return an error if the passed X509_NAME exceeds the length. RT#4531 Reviewed-by: Rich Salz <rsalz@openssl.org> (cherry picked from commit 4e0d184ac1dde845ba9574872e2ae5c903c81dff)
2016-05-04Fix double free in d2i_PrivateKey().Dr. Stephen Henson
RT#4527 Reviewed-by: Matt Caswell <matt@openssl.org> (cherry picked from commit 3340e8bb186f689df5720352f65a9c0c42b6046b)
2016-05-03Fix ASN1_INTEGER handling.Dr. Stephen Henson
Only treat an ASN1_ANY type as an integer if it has the V_ASN1_INTEGER tag: V_ASN1_NEG_INTEGER is an internal only value which is never used for on the wire encoding. Thanks to David Benjamin <davidben@google.com> for reporting this bug. This was found using libFuzzer. RT#4364 (part)CVE-2016-2108. Reviewed-by: Emilia Käsper <emilia@openssl.org>
2016-05-02Fix i2d_X509_AUX: pp can be NULL.Dr. Stephen Henson
Reported by David Benjamin Reviewed-by: Emilia Käsper <emilia@openssl.org> (cherry picked from commit 05aef4bbdbc18e7b9490512cdee41e8a608bcc0e)
2016-04-29Don't free ret->data if malloc fails.Dr. Stephen Henson
Issue reported by Guido Vranken. Reviewed-by: Matt Caswell <matt@openssl.org>
2016-04-29Add size limit to X509_NAME structure.Dr. Stephen Henson
This adds an explicit limit to the size of an X509_NAME structure. Some part of OpenSSL (e.g. TLS) already effectively limit the size due to restrictions on certificate size. Reviewed-by: Matt Caswell <matt@openssl.org> (cherry picked from commit 295f3a24919157e2f9021d0b1709353710ad63db)
2016-04-26Ensure we check i2d_X509 return valMatt Caswell
The i2d_X509() function can return a negative value on error. Therefore we should make sure we check it. Issue reported by Yuan Jochen Kang. Reviewed-by: Emilia Käsper <emilia@openssl.org> (cherry picked from commit 446ba8de9af9aa4fa3debc7c76a38f4efed47a62)
2016-04-25Fix a signed/unsigned warningMatt Caswell
This causes a compilation failure when using --strict-warnings in 1.0.2 and 1.0.1 Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
2016-04-23Fix buffer overrun in ASN1_parse().Viktor Dukhovni
Backport of commits: 79c7f74d6cefd5d32fa20e69195ad3de834ce065 bdcd660e33710079b495cf5cc6a1aaa5d2dcd317 from master. Reviewed-by: Matt Caswell <matt@openssl.org>
2016-04-23Harden ASN.1 BIO handling of large amounts of data.Dr. Stephen Henson
If the ASN.1 BIO is presented with a large length field read it in chunks of increasing size checking for EOF on each read. This prevents small files allocating excessive amounts of data. CVE-2016-2109 Thanks to Brian Carpenter for reporting this issue. Reviewed-by: Viktor Dukhovni <viktor@openssl.org> (cherry picked from commit c62981390d6cf9e3d612c489b8b77c2913b25807)
2016-03-07Don't shift serial number into sign bitDr. Stephen Henson
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-02-28Fix invalid freeKurt Roeckx
Also removes an extra initializer, the master branch has a extra field. Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-02-27Fix possible memory leak on BUF_MEM_grow_clean failureFdaSilvaYY
backport of 3eb70c5ebae6f2b5fd6034ed5af14910c8479688 shorter changes Reviewed-by: Kurt Roeckx <kurt@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org>
2015-12-03Fix leak with ASN.1 combine.Dr. Stephen Henson
When parsing a combined structure pass a flag to the decode routine so on error a pointer to the parent structure is not zeroed as this will leak any additional components in the parent. This can leak memory in any application parsing PKCS#7 or CMS structures. CVE-2015-3195. Thanks to Adam Langley (Google/BoringSSL) for discovering this bug using libFuzzer. PR#4131 Reviewed-by: Richard Levitte <levitte@openssl.org>
2015-11-24Fix uninitialised p error.Dr. Stephen Henson
Reviewed-by: Rich Salz <rsalz@openssl.org> (cherry picked from commit 63eb10a07ee29a312e50a227f5b3a290b1ad22b4)
2015-11-24Limit depth of ASN1 parse printing.Dr. Stephen Henson
Thanks to Guido Vranken <guidovranken@gmail.com> for reporting this issue. Reviewed-by: Tim Hudson <tjh@openssl.org> (cherry picked from commit 158e5207a794603f5d64ffa95e0247c7808ab445) Conflicts: crypto/asn1/asn1_par.c
2015-10-03Fix more d2i cases to properly update the input pointerKurt Roeckx
Thanks to David Benjamin <davidben@google.com> for pointing them out. Reviewed-by: Steve Henson <steve@openssl.org> MR #1198 (cherry picked from commit 605236f6a8fe0743af2f63d93239a74c69dae137)
2015-09-15RT4044: Remove .cvsignore files.Rich Salz
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-09-15d2i: don't update input pointer on failureKurt Roeckx
Reviewed-by: Dr. Stephen Henson <steve@openssl.org> MR #1005 (cherry picked from commit a46c9789ce2aecedceef119e9883513c7a49f1ca)
2015-08-31check bn_new return valuemrpre
Slightly modified from the original PR. Signed-off-by: Rich Salz <rsalz@akamai.com> Reviewed-by: Richard Levitte <levitte@openssl.org> (cherry picked from commit a7e974c7be90e2c9673e2ce6215a70f734eb8ad4)
2015-08-28GH354: Memory leak fixesAlessandro Ghedini
Fix more potential leaks in X509_verify_cert() Fix memory leak in ClientHello test Fix memory leak in gost2814789 test Fix potential memory leak in PKCS7_verify() Fix potential memory leaks in X509_add1_reject_object() Refactor to use "goto err" in cleanup. Signed-off-by: Rich Salz <rsalz@akamai.com> Reviewed-by: Emilia Käsper <emilia@openssl.org> (cherry picked from commit 55500ea7c46c27a150a46832e1260891aaad8e52)
2015-06-03Add funtions to set item_sign and item_verifySergey Agievich
PR#3872 Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Stephen Henson <steve@openssl.org>
2015-05-23Fix the update target and remove duplicate file updatesRichard Levitte
We had updates of certain header files in both Makefile.org and the Makefile in the directory the header file lived in. This is error prone and also sometimes generates slightly different results (usually just a comment that differs) depending on which way the update was done. This removes the file update targets from the top level Makefile, adds an update: target in all Makefiles and has it depend on the depend: or local_depend: targets, whichever is appropriate, so we don't get a double run through the whole file tree. Reviewed-by: Rich Salz <rsalz@openssl.org> (cherry picked from commit 0f539dc1a2f45580435c39dada44dd276e79cb88) Conflicts: Makefile.org apps/Makefile test/Makefile
2015-04-18Fix encoding bug in i2c_ASN1_INTEGERDr. Stephen Henson
Fix bug where i2c_ASN1_INTEGER mishandles zero if it is marked as negative. Thanks to Huzaifa Sidhpurwala <huzaifas@redhat.com> and Hanno Böck <hanno@hboeck.de> for reporting this issue. Reviewed-by: Rich Salz <rsalz@openssl.org> (cherry picked from commit a0eed48d37a4b7beea0c966caf09ad46f4a92a44)
2015-04-16Code style: space after 'if'Viktor Dukhovni
Reviewed-by: Matt Caswell <gitlab@openssl.org>
2015-04-16Limit depth of nested sequences when generating ASN.1Dr. Stephen Henson
Reported by Hanno Böck <hanno@hboeck.de> PR#3800 Reviewed-by: Rich Salz <rsalz@openssl.org> (cherry picked from commit c4137b5e828d8fab0b244defb79257619dad8fc7)
2015-04-16Reject empty generation strings.Dr. Stephen Henson
Reported by Hanno Böck <hanno@hboeck.de> Reviewed-by: Rich Salz <rsalz@openssl.org> (cherry picked from commit 111b60bea01d234b5873488c19ff2b9c5d4d58e9)
2015-04-10Don't set *pval to NULL in ASN1_item_ex_new.Dr. Stephen Henson
While *pval is usually a pointer in rare circumstances it can be a long value. One some platforms (e.g. WIN64) where sizeof(long) < sizeof(ASN1_VALUE *) this will write past the field. *pval is initialised correctly in the rest of ASN1_item_ex_new so setting it to NULL is unecessary anyway. Thanks to Julien Kauffmann for reporting this issue. Reviewed-by: Richard Levitte <levitte@openssl.org> (cherry picked from commit f617b4969a9261b9d7d381670aefbe2cf766a2cb) Conflicts: crypto/asn1/tasn_new.c
2015-03-25Fix RAND_(pseudo_)?_bytes returnsMatt Caswell
Ensure all calls to RAND_bytes and RAND_pseudo_bytes have their return value checked correctly Reviewed-by: Richard Levitte <levitte@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-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-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-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> (cherry picked from commit da27006df06853a33b132133699a7aa9d4277920)
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> (cherry picked from commit 5dc1247a7494f50c88ce7492518bbe0ce6f124fa)
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> (cherry picked from commit 34a7ed0c39aa3ab67eea1e106577525eaf0d7a00)
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> (cherry picked from commit 9e488fd6ab2c295941e91a47ab7bcd346b7540c7)