aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/asn1/tasn_enc.c
Commit message (Collapse)AuthorAgeFilesLines
* Stop raising ERR_R_MALLOC_FAILURE in most placesRichard Levitte2022-10-051-9/+3
| | | | | | | | | | | | | | | | | | | | | | | Since OPENSSL_malloc() and friends report ERR_R_MALLOC_FAILURE, and at least handle the file name and line number they are called from, there's no need to report ERR_R_MALLOC_FAILURE where they are called directly, or when SSLfatal() and RLAYERfatal() is used, the reason `ERR_R_MALLOC_FAILURE` is changed to `ERR_R_CRYPTO_LIB`. There were a number of places where `ERR_R_MALLOC_FAILURE` was reported even though it was a function from a different sub-system that was called. Those places are changed to report ERR_R_{lib}_LIB, where {lib} is the name of that sub-system. Some of them are tricky to get right, as we have a lot of functions that belong in the ASN1 sub-system, and all the `sk_` calls or from the CRYPTO sub-system. Some extra adaptation was necessary where there were custom OPENSSL_malloc() wrappers, and some bugs are fixed alongside these changes. Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Hugo Landau <hlandau@openssl.org> (Merged from https://github.com/openssl/openssl/pull/19301)
* asn.1: fix Coverity 1487104 Logically dead codePauli2021-07-131-4/+5
| | | | | Reviewed-by: Shane Lontis <shane.lontis@oracle.com> (Merged from https://github.com/openssl/openssl/pull/16042)
* ASN.1: Refuse to encode to DER if non-optional items are missingRichard Levitte2021-07-101-9/+20
| | | | | | | Fixes #16026 Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/16036)
* crypto: raise error on malloc failureFdaSilvaYY2021-04-141-7/+12
| | | | | | | | | clean a few style nits. Reviewed-by: Shane Lontis <shane.lontis@oracle.com> Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14806)
* Update copyright yearMatt Caswell2021-04-081-1/+1
| | | | | Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14801)
* Add ossl_asn1 symbolsShane Lontis2021-03-181-10/+10
| | | | | | | Partial fix for #12964 Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14473)
* Complain if we are attempting to encode with an invalid ASN.1 templateMatt Caswell2020-12-081-0/+16
| | | | | | | | | | It never makes sense for multi-string or CHOICE types to have implicit tagging. If we have a template that uses the in this way then we should immediately fail. Thanks to David Benjamin from Google for reporting this issue. Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
* Update copyright yearMatt Caswell2020-11-261-1/+1
| | | | | Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org> (Merged from https://github.com/openssl/openssl/pull/13533)
* Convert all {NAME}err() in crypto/ to their corresponding ERR_raise() callRichard Levitte2020-11-131-1/+1
| | | | | | | | | | This includes error reporting for libcrypto sub-libraries in surprising places. This was done using util/err-to-raise Reviewed-by: Paul Dale <paul.dale@oracle.com> (Merged from https://github.com/openssl/openssl/pull/13318)
* Explicitly test against NULL; do not use !p or similarRich Salz2019-10-091-4/+4
| | | | | | | | Also added blanks lines after declarations in a couple of places. Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org> Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/9916)
* Reorganize local header filesDr. Matthias St. Pierre2019-09-281-1/+1
| | | | | | | | | | | | | Apart from public and internal header files, there is a third type called local header files, which are located next to source files in the source directory. Currently, they have different suffixes like '*_lcl.h', '*_local.h', or '*_int.h' This commit changes the different suffixes to '*_local.h' uniformly. Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/9333)
* Reorganize private crypto header filesDr. Matthias St. Pierre2019-09-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, there are two different directories which contain internal header files of libcrypto which are meant to be shared internally: While header files in 'include/internal' are intended to be shared between libcrypto and libssl, the files in 'crypto/include/internal' are intended to be shared inside libcrypto only. To make things complicated, the include search path is set up in such a way that the directive #include "internal/file.h" could refer to a file in either of these two directoroes. This makes it necessary in some cases to add a '_int.h' suffix to some files to resolve this ambiguity: #include "internal/file.h" # located in 'include/internal' #include "internal/file_int.h" # located in 'crypto/include/internal' This commit moves the private crypto headers from 'crypto/include/internal' to 'include/crypto' As a result, the include directives become unambiguous #include "internal/file.h" # located in 'include/internal' #include "crypto/file.h" # located in 'include/crypto' hence the superfluous '_int.h' suffixes can be stripped. The files 'store_int.h' and 'store.h' need to be treated specially; they are joined into a single file. Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/9333)
* constify *_dup() and *i2d_*() and related functions as far as possible, ↵David von Oheimb2019-03-061-43/+47
| | | | | | | | introducing DECLARE_ASN1_DUP_FUNCTION Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/8029)
* Following the license change, modify the boilerplates in crypto/asn1/Richard Levitte2018-12-061-1/+1
| | | | | Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/7772)
* Set error code on alloc failuresRich Salz2018-04-031-2/+4
| | | | | | | Almost all *alloc failures now set an error code. Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com> (Merged from https://github.com/openssl/openssl/pull/5842)
* Update copyright yearMatt Caswell2018-04-031-1/+1
| | | | | Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/5851)
* Don't write out a bad OIDMatt Caswell2018-03-271-0/+2
| | | | | | | | | | If we don't have OID data for an object then we should fail if we are asked to encode the ASN.1 for that OID. Fixes #5723 Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/5725)
* Check for overlows and error return from ASN1_object_size()Dr. Stephen Henson2016-08-021-9/+16
| | | | Reviewed-by: Richard Levitte <levitte@openssl.org>
* Copyright consolidation 08/10Rich Salz2016-05-171-54/+5
| | | | Reviewed-by: Richard Levitte <levitte@openssl.org>
* Fix ASN1_INTEGER handling.Dr. Stephen Henson2016-05-031-2/+0
| | | | | | | | | | | | | | 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>
* Remove /* foo.c */ commentsRich Salz2016-01-261-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>
* Continue standardising malloc style for libcryptoMatt Caswell2015-11-091-3/+3
| | | | | | | Continuing from previous commit ensure our style is consistent for malloc return checks. Reviewed-by: Kurt Roeckx <kurt@openssl.org>
* New ASN.1 embed macro.Dr. Stephen Henson2015-09-161-0/+10
| | | | | | | | | | | | | | | | | | | New ASN.1 macro ASN1_EMBED. This is the same as ASN1_SIMPLE except the structure is not allocated: it is part of the parent. That is instead of FOO *x; it must be: FOO x; This reduces memory fragmentation and make it impossible to accidentally set a mandatory field to NULL. This currently only works for SEQUENCE and since it is equivalent to ASN1_SIMPLE it cannot be tagged, OPTIONAL, SET OF or SEQUENCE OF. Reviewed-by: Rich Salz <rsalz@openssl.org>
* Identify and move common internal libcrypto header filesRichard Levitte2015-05-141-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>
* Make asn1_ex_i2c, asn1_ex_c2i static.Dr. Stephen Henson2015-03-281-2/+4
| | | | Reviewed-by: Kurt Roeckx <kurt@openssl.org>
* Move more internal only functions to asn1_locl.hDr. Stephen Henson2015-03-261-6/+0
| | | | Reviewed-by: Matt Caswell <matt@openssl.org>
* Move internal only ASN.1 functions to asn1_locl.hDr. Stephen Henson2015-03-251-0/+1
| | | | Reviewed-by: Richard Levitte <levitte@openssl.org>
* make ASN1_OBJECT opaqueDr. Stephen Henson2015-03-241-0/+1
| | | | Reviewed-by: Matt Caswell <matt@openssl.org>
* Remove old style ASN.1 support.Dr. Stephen Henson2015-03-231-16/+0
| | | | | | | | | Remove old ASN.1 COMPAT type. This was meant as a temporary measure so older ASN.1 code (from OpenSSL 0.9.6) still worked. It's a hack which breaks constification and hopefully nothing uses it now, if it ever did. Reviewed-by: Matt Caswell <matt@openssl.org>
* clang on Linux x86_64 complains about unreachable code.Richard Levitte2015-01-291-3/+0
| | | | Reviewed-by: Rich Salz <rsalz@openssl.org>
* Run util/openssl-format-source -v -c .Matt Caswell2015-01-221-594/+559
| | | | Reviewed-by: Tim Hudson <tjh@openssl.org>
* Memory leak and NULL dereference fixes.Dr. Stephen Henson2014-06-271-1/+6
| | | | PR#3403
* Update obsolete email address...Dr. Stephen Henson2008-11-051-1/+1
|
* Avoid warnings.Dr. Stephen Henson2008-02-281-1/+1
|
* Addenum to "Constify obj_dat.[ch]."Andy Polyakov2007-09-181-1/+2
|
* Initial, incomplete support for typesafe macros without using functionDr. Stephen Henson2006-11-161-1/+1
| | | | casts.
* Fixes for BOOL handling: produce errors for invalid string for mini-compiler,Dr. Stephen Henson2006-01-191-5/+8
| | | | correctly encode FALSE for BOOL in ASN1_TYPE.
* "Overload" SunOS 4.x memcmp, which ruins ASN1_OBJECT table lookups.Andy Polyakov2005-09-201-0/+1
| | | | | PR: 1196 Submitted by: Russel Ruby
* Extend callback function to support print customization.Dr. Stephen Henson2005-09-011-4/+4
|
* More ASN1 reformat/tidy.Dr. Stephen Henson2004-04-251-7/+7
|
* Reformat/tidy some of the ASN1 code.Dr. Stephen Henson2004-04-241-118/+188
|
* Fix indefinite length encoding so EOC correctly updatesDr. Stephen Henson2003-02-251-2/+4
| | | | | | | | the buffer pointer. Rename PKCS7_PARTSIGN to PKCS7_STREAM. Guess what that's for :-)
* Oops, remove old comment out debugging printf...Dr. Stephen Henson2002-10-061-3/+5
|
* Please do not use C++ comments in C code.Richard Levitte2002-10-061-1/+3
|
* Preliminary streaming ASN1 encode support.Dr. Stephen Henson2002-10-031-63/+176
|
* gcc can't spot that 'derlst' is not used uninitialised, so appease it.Geoff Thorpe2001-08-261-1/+1
|
* avoid compiler warningBodo Möller2001-03-081-1/+1
|
* Initial support for ASN1_ITEM_FUNCTION option toDr. Stephen Henson2001-02-231-6/+6
| | | | | | | | change the way ASN1 modules are exported. Still needs a bit of work for example the hack which a dummy function prototype to avoid compilers warning about multiple ;s.
* Include string.h so mem* functions get properly declared.Richard Levitte2001-02-201-0/+1
|
* Change the PKCS7 structure to use SEQUENCE OF for theDr. Stephen Henson2000-12-131-1/+12
| | | | | | | | | authenticated attributes: this is used to retain the original encoding and not break signatures. Support for a SET OF which reorders the STACK when encoding a structure. This will be used with the PKCS7 code.