aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/asn1/a_int.c
Commit message (Collapse)AuthorAgeFilesLines
* asn1/a_int.c: fix "next negative minimum" corner case in c2i_ibuf.Andy Polyakov2017-04-301-3/+14
| | | | | | | | | | | "Next" refers to negative minimum "next" to one presentable by given number of bytes. For example, -128 is negative minimum presentable by one byte, and -256 is "next" one. Thanks to Kazuki Yamaguchi for report, GH#3339 Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org>
* asn1/a_int.c: clean up asn1_get_int64.Andy Polyakov2017-04-171-9/+20
| | | | | | | | | | | | | Trouble was that integer negation wasn't producing *formally* correct result in platform-neutral sense. Formally correct thing to do is -(int64_t)u, but this triggers undefined behaviour for one value that would still be representable in ASN.1. The trigger was masked with (int64_t)(0-u), but this is formally inappropriate for values other than the problematic one. [Also reorder branches to favour most-likely paths and harmonize asn1_string_set_int64 with asn1_get_int64].] Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/3231)
* asn1/a_int.c: don't write result if returning error.Andy Polyakov2017-04-141-1/+0
| | | | | | Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/3192)
* asn1/a_int.c: simplify asn1_put_uint64.Andy Polyakov2017-04-141-41/+29
| | | | | | Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/3192)
* asn1/a_int.c: remove code duplicate and optimize branches,Andy Polyakov2017-04-141-84/+52
| | | | | | | | i.e. reduce amount of branches and favour likely ones. Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/3192)
* Implement internal ASN.1 types INT32, UINT32, INT64, UINT64Richard Levitte2017-04-041-1/+30
| | | | | | Also Z varieties. Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/3088)
* Fix 0 -> NULL, indentationFdaSilvaYY2017-03-281-1/+1
| | | | | Reviewed-by: Andy Polyakov <appro@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/3066)
* Fix VC warnings about unary minus to an unsigned type.Kurt Roeckx2017-01-151-1/+1
| | | | | Reviewed-by: Andy Polyakov <appro@openssl.org> GH: #2230
* Cast to an unsigned type before negatingKurt Roeckx2016-11-121-1/+1
| | | | | | | | | | | | | llvm's ubsan reported: runtime error: negation of -9223372036854775808 cannot be represented in type 'int64_t' (aka 'long'); cast to an unsigned type to negate this value to itself Found using libfuzzer Reviewed-by: Rich Salz <rsalz@openssl.org> GH: #1908
* Constify ASN1_INTEGER_get, ASN1_ENUMERATED_getFdaSilvaYY2016-08-041-1/+1
| | | | | Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org>
* Avoid creating an illegal pointer.Kurt Roeckx2016-06-211-6/+6
| | | | | | | | Found by tis-interpreter Reviewed-by: Rich Salz <rsalz@openssl.org> GH: #1230
* Avoid creating an illegal pointerKurt Roeckx2016-05-251-4/+4
| | | | | | | | Found by tis-interpreter Reviewed-by: Rich Salz <rsalz@openssl.org> GH: #1122
* Copyright consolidation 09/10Rich Salz2016-05-171-54/+6
| | | | Reviewed-by: Richard Levitte <levitte@openssl.org>
* GH601: Various spelling fixes.FdaSilvaYY2016-02-051-1/+1
| | | | | Signed-off-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Matt Caswell <matt@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>
* RT3993: Fix error found by VS2008David Woodhouse2015-09-081-1/+1
| | | | | | | Cast and then negate, don't negate an unsigned. Signed-off-by: Rich Salz <rsalz@akamai.com> Reviewed-by: Tim Hudson <tjh@openssl.org>
* Encode b == NULL or blen == 0 as zero.Dr. Stephen Henson2015-06-131-2/+2
| | | | | | PR#3904 Reviewed-by: Rich Salz <rsalz@openssl.org>
* Add functions to convert between uint64_t and ASN1_INTEGER.Dr. Stephen Henson2015-05-201-0/+40
| | | | Reviewed-by: Rich Salz <rsalz@openssl.org>
* ASN1 INTEGER refactor.Dr. Stephen Henson2015-05-181-181/+359
| | | | | | | | | | | | | Rewrite and tidy ASN1_INTEGER and ASN1_ENUMERATED handling. Remove code duplication. New functions to convert between int64_t and ASN.1 types without the quirks of the old long conversion functions. Add documentation. 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>
* memset, memcpy, sizeof consistency fixesRich Salz2015-05-051-1/+1
| | | | | | | | Just as with the OPENSSL_malloc calls, consistently use sizeof(*ptr) for memset and memcpy. Remove needless casts for those functions. For memset, replace alternative forms of zero with 0. Reviewed-by: Richard Levitte <levitte@openssl.org>
* free null cleanup finaleRich Salz2015-05-011-6/+3
| | | | | | Don't check for NULL before calling OPENSSL_free Reviewed-by: Richard Levitte <levitte@openssl.org>
* remove malloc castsRich Salz2015-04-281-4/+3
| | | | | | | Following ANSI C rules, remove the casts from calls to OPENSSL_malloc and OPENSSL_realloc. Reviewed-by: Richard Levitte <levitte@openssl.org>
* Fix encoding bug in i2c_ASN1_INTEGERDr. Stephen Henson2015-04-181-2/+4
| | | | | | | | | | 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>
* Move more internal only functions to asn1_locl.hDr. Stephen Henson2015-03-261-0/+1
| | | | Reviewed-by: Matt Caswell <matt@openssl.org>
* free NULL cleanupRich Salz2015-03-241-2/+2
| | | | | | | | Start ensuring all OpenSSL "free" routines allow NULL, and remove any if check before calling them. This gets ASN1_OBJECT_free and ASN1_STRING_free. Reviewed-by: Matt Caswell <matt@openssl.org>
* Remove old ASN.1 code.Dr. Stephen Henson2015-03-231-7/+7
| | | | | | | | | 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>
* Remove obsolete IMPLEMENT_ASN1_SET_OFDr. Stephen Henson2015-02-091-2/+0
| | | | Reviewed-by: Andy Polyakov <appro@openssl.org>
* util/mkstack.pl now generates entire safestack.hRich Salz2015-02-061-2/+0
| | | | | | | | | The mkstack.pl script now generates the entire safestack.h file. It generates output that follows the coding style. Also, removed all instances of the obsolete IMPLEMENT_STACK_OF macro. Reviewed-by: Andy Polyakov <appro@openssl.org>
* Run util/openssl-format-source -v -c .Matt Caswell2015-01-221-356/+359
| | | | Reviewed-by: Tim Hudson <tjh@openssl.org>
* Further comment changes for reformat (master)Matt Caswell2015-01-221-1/+1
| | | | Reviewed-by: Tim Hudson <tjh@openssl.org>
* RT783: Minor optimization to ASN1_INTEGER_setFrédéric Giudicelli2014-08-151-8/+7
| | | | | | Remove local variable and avoid extra assignment. Reviewed-by: Emilia Kasper <emilia@silkandcyanide.net>
* Encode INTEGER correctly.Dr. Stephen Henson2013-03-181-1/+1
| | | | | | If an ASN1_INTEGER structure is allocated but not explicitly set encode it as zero: don't generate an invalid zero length INTEGER. (cherry picked from commit 1643edc63c3e15b6db5a15a728bc288f2cc2bbc7)
* asn1/t_x509.c: fix serial number print, harmonize with a_int.c.Andy Polyakov2012-01-111-2/+2
| | | | | PR: 2675 Submitted by: Annie Yousar
* Fix warnings.Ben Laurie2010-06-121-2/+1
|
* Revert the size_t modifications from HEAD that had led to moreGeoff Thorpe2008-11-121-9/+9
| | | | | | knock-on work than expected - they've been extracted into a patch series that can be completed elsewhere, or in a different branch, before merging back to HEAD.
* size_tification.Ben Laurie2008-11-011-9/+9
|
* make some parameters constNils Larsch2006-03-041-5/+5
|
* Update util/ck_errf.pl script, and have it run automaticallyBodo Möller2005-05-091-1/+1
| | | | | | | | during "make errors" and thus during "make update". Fix lots of bugs that util/ck_errf.pl can detect automatically. Various others of these are still left to fix; that's why "make update" will complain loudly when run now.
* - use BN_set_negative and BN_is_negative instead of BN_set_signNils Larsch2005-04-221-2/+2
| | | | | | and BN_get_sign - implement BN_set_negative as a function - always use "#define BN_is_zero(a) ((a)->top == 0)"
* Make ASN1_INTEGER_cmp() work as expected with negative integers.Dr. Stephen Henson2004-08-101-1/+20
|
* Deprecate the recursive includes of bn.h from various API headers (asn1.h,Geoff Thorpe2004-05-171-0/+1
| | | | | | dh.h, dsa.h, ec.h, ecdh.h, ecdsa.h, rsa.h), as the opaque bignum types are already declared in ossl_typ.h. Add explicit includes for bn.h in those C files that need access to structure internals or API functions+macros.
* Constify d2i, s2i, c2i and r2i functions and other associatedRichard Levitte2004-03-151-4/+6
| | | | | | | | functions and macros. This change has associated tags: LEVITTE_before_const and LEVITTE_after_const. Those will be removed when this change has been properly reviewed.
* A general spring-cleaning (in autumn) to fix up signed/unsigned warnings.Geoff Thorpe2003-10-291-3/+4
| | | | | | | | | | I have tried to convert 'len' type variable declarations to unsigned as a means to address these warnings when appropriate, but when in doubt I have used casts in the comparisons instead. The better solution (that would get us all lynched by API users) would be to go through and convert all the function prototypes and structure definitions to use unsigned variables except when signed is necessary. The proliferation of (signed) "int" for strictly non-negative uses is unfortunate.
* implement and use new macros BN_get_sign(), BN_set_sign()Bodo Möller2002-11-041-2/+4
| | | | Submitted by: Nils Larsch
* Fix warnings.Ben Laurie2002-06-111-1/+1
|
* Check the return values where memory allocation failures may happen.Richard Levitte2002-05-301-1/+10
| | | | PR: 49
* Fixes to various ASN1_INTEGER routines for negative case.Dr. Stephen Henson2001-01-191-0/+6
| | | | Enhance s2i_ASN1_INTEGER().
* Fix typo in OCSP nonce extension.Dr. Stephen Henson2001-01-041-2/+2
| | | | | | | | | | | | Set correct type in ASN1_STRING for INTEGER and ENUMERATED types. Make ASN1_INTEGER_get() and ASN1_ENUMERATED_get() return -1 for invalid type rather than 0 (which is often valid). -1 may also be valid but this is less likely. Load OCSP error strings in ERR_load_crypto_strings().
* Merge from the ASN1 branch of new ASN1 codeDr. Stephen Henson2000-12-081-54/+0
| | | | | | to main trunk. Lets see if the makes it to openssl-cvs :-)