diff --git a/.gitignore b/.gitignore index 6581dee9d1f8db..50e672fed9b811 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ tags *.pyc doc/api.xml tmp/ +test/tmp*/ node node_g *.swp diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4c3a86b00f30f3..99b9c5ed0d438f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,25 +1,37 @@ # CONTRIBUTING -The node.js project welcomes new contributors. This document will guide you +## ISSUE CONTRIBUTIONS + +When opening new issues or commenting on existing issues on this repository +please make sure discussions are related to concrete technical issues with the +`iojs` software. + +Discussion of non-technical topics including subjects like intellectual +property, trademark and high level project questions should move to the +[node-forward discussion repository][] instead. + +## CODE CONTRIBUTIONS + +The io.js project welcomes new contributors. This document will guide you through the process. ### FORK -Fork the project [on GitHub](https://github.com/joyent/node) and check out +Fork the project [on GitHub](https://github.com/iojs/io.js) and check out your copy. ```sh -$ git clone git@github.com:username/node.git -$ cd node -$ git remote add upstream git://github.com/joyent/node.git +$ git clone git@github.com:username/io.js.git +$ cd io.js +$ git remote add upstream git://github.com/iojs/io.js.git ``` Now decide if you want your feature or bug fix to go into the master branch or the stable branch. As a rule of thumb, bug fixes go into the stable branch while new features go into the master branch. -The stable branch is effectively frozen; patches that change the node.js +The stable branch is effectively frozen; patches that change the io.js API/ABI or affect the run-time behavior of applications get rejected. The rules for the master branch are less strict; consult the @@ -29,7 +41,7 @@ In a nutshell, modules are at varying levels of API stability. Bug fixes are always welcome but API or behavioral changes to modules at stability level 3 and up are off-limits. -Node.js has several bundled dependencies in the deps/ and the tools/ +io.js has several bundled dependencies in the deps/ and the tools/ directories that are not part of the project proper. Any changes to files in those directories or its subdirectories should be sent to their respective projects. Do not send your patch to us, we cannot accept it. @@ -49,10 +61,10 @@ Okay, so you have decided on the proper branch. Create a feature branch and start hacking: ```sh -$ git checkout -b my-feature-branch -t origin/v0.10 +$ git checkout -b my-feature-branch -t origin/v0.12 ``` -(Where v0.10 is the latest stable branch as of this writing.) +(Where v0.12 is the latest stable branch as of this writing.) ### COMMIT @@ -101,7 +113,7 @@ Use `git rebase` (not `git merge`) to sync your work from time to time. ```sh $ git fetch upstream -$ git rebase upstream/v0.10 # or upstream/master +$ git rebase upstream/v0.12 # or upstream/master ``` @@ -138,7 +150,7 @@ node ./test/simple/test-streams2-transform.js $ git push origin my-feature-branch ``` -Go to https://github.com/username/node and select your feature branch. Click +Go to https://github.com/username/io.js and select your feature branch. Click the 'Pull Request' button and fill out the form. Pull requests are usually reviewed within a few days. If there are comments @@ -150,5 +162,321 @@ not send out notifications when you add commits. [stability index page]: https://github.com/joyent/node/blob/master/doc/api/documentation.markdown [issue tracker]: https://github.com/joyent/node/issues [node.js mailing list]: http://groups.google.com/group/nodejs -[IRC]: http://webchat.freenode.net/?channels=node.js +[IRC]: http://webchat.freenode.net/?channels=io.js [project maintainers]: https://github.com/joyent/node/wiki/Project-Organization +[node-forward discussion repository]: https://github.com/node-forward/discussions/issues + +# Contribution Policy + +Individuals making significant and valuable contributions are given +commit-access to the project. These individuals are identified by the +Technical Committee (TC) and discussed during the weekly TC meeting. + +If you make a significant contribution and are not considered for +commit-access log an issue and it will be brought up in the next TC +meeting. + +Internal pull-requests to solicit feedback are required for any other +non-trivial contribution but left to the discretion of the +contributor. + +Pull requests may be approved by any committer with sufficient +expertise to take full responsibility for the change, according to the +"Landing Patches" protocol described below. + +## Landing Patches + +- All bugfixes require a test case which demonstrates the defect. The + test should *fail* before the change, and *pass* after the change. +- Trivial changes (ie, those which fix bugs or improve performance + without affecting API or causing other wide-reaching impact) may be + landed immediately after review by a committer who did not write the + code, provided that no other committers object to the change. +- If you are unsure, or if you are the author, have someone else + review the change. +- For significant changes wait a full 48 hours (72 hours if it spans a + weekend) before merging so that active contributors who are + distributed throughout the world have a chance to weigh in. +- Controversial changes and **very** significant changes should not be + merged until they have been discussed by the TC which will make any + final decisions. +- Always include the `Reviewed-by: Your Name ` in the + commit message. +- In commit messages also include `Fixes:` that either includes the + **full url** (e.g. `https://github.com/iojs/io.js/issues/...`), + and/or the hash and commit message if the commit fixes a bug in a + previous commit. +- PR's should include their full `PR-URL:` so it's easy to trace a + commit back to the conversation that lead up to that change. +- Double check PR's to make sure the person's **full name** and email + address are correct before merging. +- Except when updating dependencies, all commits should be self + contained. Meaning, every commit should pass all tests. This makes + it much easier when bisecting to find a breaking change. + +### Direct instruction + +(Optional) Ensure that you are not in a borked `am`/`rebase` state + +```sh +git am --abort +git rebase --abort +``` + +Checkout proper target branch + +```sh +git checkout v0.12 +``` + +Update the tree + +```sh +git fetch origin +git merge --ff-only origin/v0.12 +``` + +Apply external patches + +```sh +curl https://github.com/iojs/io.js/pull/xxx.patch | git am --whitespace=fix +``` + +Check and re-review the changes + +```sh +git diff origin/v0.12 +``` + +Check number of commits and commit messages + +```sh +git log origin/v0.12...v0.12 +``` + +If there are multiple commits that relate to the same feature or +one with a feature and separate with a test for that feature - +you'll need to squash them (or strictly speaking `fixup`). + +```sh +git rebase -i origin/v0.12 +``` + +This will open a screen like this (in the default shell editor): + +```sh +pick 6928fc1 crypto: add feature A +pick 8120c4c add test for feature A +pick 51759dc feature B +pick 7d6f433 test for feature B + +# Rebase f9456a2..7d6f433 onto f9456a2 +# +# Commands: +# p, pick = use commit +# r, reword = use commit, but edit the commit message +# e, edit = use commit, but stop for amending +# s, squash = use commit, but meld into previous commit +# f, fixup = like "squash", but discard this commit's log message +# x, exec = run command (the rest of the line) using shell +# +# These lines can be re-ordered; they are executed from top to bottom. +# +# If you remove a line here THAT COMMIT WILL BE LOST. +# +# However, if you remove everything, the rebase will be aborted. +# +# Note that empty commits are commented out +``` + +Replace a couple of `pick`s with `fixup` to squash them into a previous commit: + +```sh +pick 6928fc1 crypto: add feature A +fixup 8120c4c add test for feature A +pick 51759dc feature B +fixup 7d6f433 test for feature B +``` + +Replace `pick` with `reword` to change the commit message: + +```sh +reword 6928fc1 crypto: add feature A +fixup 8120c4c add test for feature A +reword 51759dc feature B +fixup 7d6f433 test for feature B +``` + +Save the file and close the editor, you'll be asked to enter new commit message +for that commit, and everything else should go smoothly. Note that this is a +good moment to fix incorrect commit logs, ensure that they are properly +formatted, and add `Reviewed-By` line. + +Time to push it: + +```sh +git push origin v0.12 +``` + +# Governance + +This repository is jointly governed by a technical committee, commonly +referred to as the "TC." + +The TC has final authority over this project including: + +* Technical direction +* Project governance and process (including this policy) +* Contribution policy +* GitHub repository hosting +* Conduct guidelines + +## Membership + +Initial membership invitations to the TC were given to individuals who +had been active contributors to io.js, and who have significant +experience with the management of the io.js project. Membership is +expected to evolve over time according to the needs of the project. + +Current membership is: + +``` +Ben Noordhuis (@bnoordhuis) +Bert Belder (@piscisaureus) +Fedor Indutny (@indutny) +Isaac Z. Schlueter (@isaacs) +Nathan Rajlich (@TooTallNate) +TJ Fontaine (@tjfontaine) +Trevor Norris (@trevnorris) +``` + +TC seats are not time-limited. There is no fixed size of the TC. +However, the expected target is between 6 and 12, to ensure adequate +coverage of important areas of expertise, balanced with the ability to +make decisions efficiently. + +There is no specific set of requirements or qualifications for TC +membership beyond these rules. + +The TC may add contributors to the TC by unanimous consensus. + +A TC member may be removed from the TC by voluntary resignation, or by +unanimous consensus of all other TC members. + +Changes to TC membership should be posted in the agenda, and may be +suggested as any other agenda item (see "TC Meetings" below). + +If an addition or removal is proposed during a meeting, and the full +TC is not in attendance to participate, then the addition or removal +is added to the agenda for the subsequent meeting. This is to ensure +that all members are given the opportunity to participate in all +membership decisions. If a TC member is unable to attend a meeting +where a planned membership decision is being made, then their consent +is assumed. + +No more than 1/3 of the TC members may be affiliated with the same +employer. If removal or resignation of a TC member, or a change of +employment by a TC member, creates a situation where more than 1/3 of +the TC membership shares an employer, then the situation must be +immediately remedied by the resignation or removal of one or more TC +members affiliated with the over-represented employer(s). + +## TC Meetings + +The TC meets weekly on a Google hangout. The meeting is run by a +designated moderator, currently `Mikeal Rogers (@mikeal)`. Each +meeting should be published to Youtube. + +Items are added to the TC agenda which are considered contentious or +are modifications of governance, contribution policy, TC membership, +or release process. The intention of the agenda is not to approve or +review all patches, that should happen continuously on GitHub (see +"Contribution Policy"). + +Any community member or contributor can ask that something be added to +the next meeting's agenda by logging a GitHub Issue. Any TC member or +the moderator can add the item to the agenda by a simple +1. The +moderator and the TC cannot veto or remove items. + +Prior to each TC meeting the moderator will email the Agenda to the +TC. TC members can add any items they like to the agenda at the +beginning of each meeting. The moderator and the TC cannot veto or +remove items. + +TC may invite persons or representatives from certain projects to +participate in a non-voting capacity. These invitees currently are: + +* A representative from [build](https://github.com/node-forward/build) + chosen by that project. + +The moderator is responsible for summarizing the discussion of each +agenda item and send it as a pull request after the meeting. + +## Consensus Seeking Process + +The TC follows a [Consensus +Seeking](http://en.wikipedia.org/wiki/Consensus-seeking_decision-making) +decision making model. + +When an agenda item has appeared to reach a consensus the moderator +will ask "Does anyone object?" as a final call for dissent from the +consensus. + +If an agenda item cannot reach a consensus a TC member can call for +either a closing vote or a vote to table the issue to the next +meeting. The call for a vote must be seconded by a majority of the TC +or else the discussion will continue. Simple majority wins. + +Note that changes to TC membership require unanimous consensus. See +"Membership" above. + +## Caine's requirements + +Hello! + +I am pleased to see your valuable contribution to this project. Would you +please mind answering a couple of questions to help me classify this submission +and/or gather required information for the core team members? + +### Questions: + +* _Issue-only_ Does this issue happen in core, or in some user-space + module from npm or other source? Please ensure that the test case + that reproduces this problem is not using any external dependencies. + If the error is not reproducible with just core modules - it is most + likely not a io.js problem. _Expected: `yes`_ +* Which part of core do you think it might be related to? + _One of: `debugger, http, assert, buffer, child_process, cluster, crypto, + dgram, dns, domain, events, fs, http, https, module, net, os, path, + querystring, readline, repl, smalloc, stream, timers, tls, url, util, vm, + zlib, c++, docs, other`_ (_label_) +* Which versions of io.js do you think are affected by this? + _One of: `v0.10, v0.12, v1.0.0`_ (_label_) +* _PR-only_ Does `make test` pass after applying this Pull Request. + _Expected: `yes`_ +* _PR-only_ Is the commit message properly formatted? (See + CONTRIBUTING.md for more information) + _Expected: `yes`_ + +Please provide the answers in an ordered list like this: + +1. Answer for the first question +2. Answer for the second question +3. ... + +Note that I am just a bot with a limited human-reply parsing abilities, +so please be very careful with numbers and don't skip the questions! + +_In case of success I will say:_ `...summoning the core team devs!`. + +_In case of validation problem I will say:_ `Sorry, but something is not right +here:`. + +Truly yours, +Caine. + +### Responsibilities + +* indutny: crypto, tls, https, child_process, c++ +* trevnorris: buffer, http, https, smalloc +* bnoordhuis: http, cluster, child_process, dgram diff --git a/Makefile b/Makefile index f84c2134499944..b4360326c35512 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,13 @@ DESTDIR ?= SIGN ?= PREFIX ?= /usr/local -NODE ?= ./node +# Determine EXEEXT +EXEEXT := $(shell $(PYTHON) -c \ + "import sys; print('.exe' if sys.platform == 'win32' else '')") + +NODE ?= ./node$(EXEEXT) +NODE_EXE = node$(EXEEXT) +NODE_G_EXE = node_g$(EXEEXT) # Default to verbose builds. # To do quiet/pretty builds, run `make V=` to set V to an empty string, @@ -23,31 +29,31 @@ endif # BUILDTYPE=Debug builds both release and debug builds. If you want to compile # just the debug build, run `make -C out BUILDTYPE=Debug` instead. ifeq ($(BUILDTYPE),Release) -all: out/Makefile node +all: out/Makefile $(NODE_EXE) else -all: out/Makefile node node_g +all: out/Makefile $(NODE_EXE) $(NODE_G_EXE) endif # The .PHONY is needed to ensure that we recursively use the out/Makefile # to check for changes. -.PHONY: node node_g +.PHONY: $(NODE_EXE) $(NODE_G_EXE) ifeq ($(USE_NINJA),1) -node: config.gypi +$(NODE_EXE): config.gypi $(NINJA) -C out/Release/ - ln -fs out/Release/node node + ln -fs out/Release/$(NODE_EXE) $@ -node_g: config.gypi +$(NODE_G_EXE): config.gypi $(NINJA) -C out/Debug/ - ln -fs out/Debug/node $@ + ln -fs out/Debug/$(NODE_EXE) $@ else -node: config.gypi out/Makefile +$(NODE_EXE): config.gypi out/Makefile $(MAKE) -C out BUILDTYPE=Release V=$(V) - ln -fs out/Release/node node + ln -fs out/Release/$(NODE_EXE) $@ -node_g: config.gypi out/Makefile +$(NODE_G_EXE): config.gypi out/Makefile $(MAKE) -C out BUILDTYPE=Debug V=$(V) - ln -fs out/Debug/node $@ + ln -fs out/Debug/$(NODE_EXE) $@ endif out/Makefile: common.gypi deps/uv/uv.gyp deps/http_parser/http_parser.gyp deps/zlib/zlib.gyp deps/v8/build/toolchain.gypi deps/v8/build/features.gypi deps/v8/tools/gyp/v8.gyp node.gyp config.gypi @@ -72,31 +78,34 @@ uninstall: $(PYTHON) tools/install.py $@ '$(DESTDIR)' '$(PREFIX)' clean: - -rm -rf out/Makefile node node_g out/$(BUILDTYPE)/node blog.html email.md - -find out/ -name '*.o' -o -name '*.a' | xargs rm -rf + -rm -rf out/Makefile $(NODE_EXE) $(NODE_G_EXE) out/$(BUILDTYPE)/$(NODE_EXE) blog.html email.md + @if [ -d out ]; then find out/ -name '*.o' -o -name '*.a' | xargs rm -rf; fi -rm -rf node_modules distclean: -rm -rf out -rm -f config.gypi -rm -f config.mk - -rm -rf node node_g blog.html email.md + -rm -rf $(NODE_EXE) $(NODE_G_EXE) blog.html email.md -rm -rf node_modules test: all - $(PYTHON) tools/test.py --mode=release simple message + $(PYTHON) tools/test.py --mode=release message parallel sequential -J $(MAKE) jslint $(MAKE) cpplint +test-parallel: all + $(PYTHON) tools/test.py --mode=release parallel -J + test-http1: all - $(PYTHON) tools/test.py --mode=release --use-http1 simple message + $(PYTHON) tools/test.py --mode=release --use-http1 sequential parallel message test-valgrind: all - $(PYTHON) tools/test.py --mode=release --valgrind simple message + $(PYTHON) tools/test.py --mode=release --valgrind sequential parallel message test/gc/node_modules/weak/build/Release/weakref.node: - @if [ ! -f node ]; then make all; fi - ./node deps/npm/node_modules/node-gyp/bin/node-gyp rebuild \ + @if [ ! -f $(NODE_EXE) ]; then make all; fi + ./$(NODE_EXE) deps/npm/node_modules/node-gyp/bin/node-gyp rebuild \ --directory="$(shell pwd)/test/gc/node_modules/weak" \ --nodedir="$(shell pwd)" @@ -135,7 +144,7 @@ test-message: test-build $(PYTHON) tools/test.py message test-simple: all - $(PYTHON) tools/test.py simple + $(PYTHON) tools/test.py parallel sequential test-pummel: all wrk $(PYTHON) tools/test.py pummel @@ -146,23 +155,23 @@ test-internet: all test-debugger: all $(PYTHON) tools/test.py debugger -test-npm: node +test-npm: $(NODE_EXE) rm -rf npm-cache npm-tmp npm-prefix mkdir npm-cache npm-tmp npm-prefix cd deps/npm ; npm_config_cache="$(shell pwd)/npm-cache" \ npm_config_prefix="$(shell pwd)/npm-prefix" \ npm_config_tmp="$(shell pwd)/npm-tmp" \ - ../../node cli.js install + ../../$(NODE_EXE) cli.js install cd deps/npm ; npm_config_cache="$(shell pwd)/npm-cache" \ npm_config_prefix="$(shell pwd)/npm-prefix" \ npm_config_tmp="$(shell pwd)/npm-tmp" \ - ../../node cli.js run-script test-all && \ - ../../node cli.js prune --prod && \ + ../../$(NODE_EXE) cli.js run-script test-all && \ + ../../$(NODE_EXE) cli.js prune --prod && \ cd ../.. && \ rm -rf npm-cache npm-tmp npm-prefix -test-npm-publish: node - npm_package_config_publishtest=true ./node deps/npm/test/run.js +test-npm-publish: $(NODE_EXE) + npm_package_config_publishtest=true ./$(NODE_EXE) deps/npm/test/run.js test-addons: test-build $(PYTHON) tools/test.py --mode=release addons @@ -186,7 +195,7 @@ website_files = \ out/doc/sh_main.js \ out/doc/sh_javascript.min.js -doc: $(apidoc_dirs) $(website_files) $(apiassets) $(apidocs) tools/doc/ out/doc/changelog.html node +doc: $(apidoc_dirs) $(website_files) $(apiassets) $(apidocs) tools/doc/ out/doc/changelog.html $(NODE_EXE) $(apidoc_dirs): mkdir -p $@ @@ -194,24 +203,24 @@ $(apidoc_dirs): out/doc/api/assets/%: doc/api_assets/% out/doc/api/assets/ cp $< $@ -out/doc/changelog.html: ChangeLog doc/changelog-head.html doc/changelog-foot.html tools/build-changelog.sh node +out/doc/changelog.html: ChangeLog doc/changelog-head.html doc/changelog-foot.html tools/build-changelog.sh $(NODE_EXE) bash tools/build-changelog.sh out/doc/%: doc/% cp -r $< $@ -out/doc/api/%.json: doc/api/%.markdown node - out/Release/node tools/doc/generate.js --format=json $< > $@ +out/doc/api/%.json: doc/api/%.markdown $(NODE_EXE) + out/Release/$(NODE_EXE) tools/doc/generate.js --format=json $< > $@ -out/doc/api/%.html: doc/api/%.markdown node - out/Release/node tools/doc/generate.js --format=html --template=doc/template.html $< > $@ +out/doc/api/%.html: doc/api/%.markdown $(NODE_EXE) + out/Release/$(NODE_EXE) tools/doc/generate.js --format=html --template=doc/template.html $< > $@ email.md: ChangeLog tools/email-footer.md bash tools/changelog-head.sh | sed 's|^\* #|* \\#|g' > $@ cat tools/email-footer.md | sed -e 's|__VERSION__|'$(VERSION)'|g' >> $@ blog.html: email.md - cat $< | ./node tools/doc/node_modules/.bin/marked > $@ + cat $< | ./$(NODE_EXE) tools/doc/node_modules/.bin/marked > $@ website-upload: doc rsync -r out/doc/ node@nodejs.org:~/web/nodejs.org/ @@ -312,7 +321,7 @@ $(PKG): release-only --out $(PKG) SIGN="$(INT_SIGN)" PKG="$(PKG)" bash tools/osx-productsign.sh -$(TARBALL): release-only node doc +$(TARBALL): release-only $(NODE_EXE) doc git archive --format=tar --prefix=$(TARNAME)/ HEAD | tar xf - mkdir -p $(TARNAME)/doc/api cp doc/node.1 $(TARNAME)/doc/node.1 @@ -399,9 +408,9 @@ bench-http-simple: benchmark/http_simple_bench.sh bench-idle: - ./node benchmark/idle_server.js & + ./$(NODE_EXE) benchmark/idle_server.js & sleep 1 - ./node benchmark/idle_clients.js & + ./$(NODE_EXE) benchmark/idle_clients.js & jslintfix: PYTHONPATH=tools/closure_linter/ $(PYTHON) tools/closure_linter/closure_linter/fixjsstyle.py --strict --nojsdoc -r lib/ -r src/ --exclude_files lib/punycode.js diff --git a/Makefile.build b/Makefile.build new file mode 100644 index 00000000000000..dad86cb517a9e6 --- /dev/null +++ b/Makefile.build @@ -0,0 +1,499 @@ +# Copyright 2012 the V8 project authors. All rights reserved. +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following +# disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +# Variable default definitions. Override them by exporting them in your shell. +CXX ?= g++ +LINK ?= g++ +OUTDIR ?= out +TESTJOBS ?= +# TODO(bnoordhuis) Make i18n support configurable. +GYPFLAGS ?= -Dv8_enable_i18n_support=0 +TESTFLAGS ?= +ANDROID_NDK_ROOT ?= +ANDROID_NDK_HOST_ARCH ?= +ANDROID_TOOLCHAIN ?= +ANDROID_V8 ?= /data/local/tmp/v8 +NACL_SDK_ROOT ?= + +# Special build flags. Use them like this: "make library=shared" + +# library=shared || component=shared_library +ifeq ($(library), shared) + GYPFLAGS += -Dcomponent=shared_library +endif +ifdef component + GYPFLAGS += -Dcomponent=$(component) +endif +# console=readline +ifdef console + GYPFLAGS += -Dconsole=$(console) +endif +# disassembler=on +ifeq ($(disassembler), on) + GYPFLAGS += -Dv8_enable_disassembler=1 +endif +# objectprint=on +ifeq ($(objectprint), on) + GYPFLAGS += -Dv8_object_print=1 +endif +# verifyheap=on +ifeq ($(verifyheap), on) + GYPFLAGS += -Dv8_enable_verify_heap=1 +endif +# backtrace=off +ifeq ($(backtrace), off) + GYPFLAGS += -Dv8_enable_backtrace=0 +else + GYPFLAGS += -Dv8_enable_backtrace=1 +endif +# verifypredictable=on +ifeq ($(verifypredictable), on) + GYPFLAGS += -Dv8_enable_verify_predictable=1 +endif +# snapshot=off +ifeq ($(snapshot), off) + GYPFLAGS += -Dv8_use_snapshot='false' +endif +# extrachecks=on/off +ifeq ($(extrachecks), on) + GYPFLAGS += -Dv8_enable_extra_checks=1 -Dv8_enable_handle_zapping=1 +endif +ifeq ($(extrachecks), off) + GYPFLAGS += -Dv8_enable_extra_checks=0 -Dv8_enable_handle_zapping=0 +endif +# gdbjit=on/off +ifeq ($(gdbjit), on) + GYPFLAGS += -Dv8_enable_gdbjit=1 +endif +ifeq ($(gdbjit), off) + GYPFLAGS += -Dv8_enable_gdbjit=0 +endif +# vtunejit=on +ifeq ($(vtunejit), on) + GYPFLAGS += -Dv8_enable_vtunejit=1 +endif +# optdebug=on +ifeq ($(optdebug), on) + GYPFLAGS += -Dv8_optimized_debug=2 +endif +# unalignedaccess=on +ifeq ($(unalignedaccess), on) + GYPFLAGS += -Dv8_can_use_unaligned_accesses=true +endif +# randomseed=12345, disable random seed via randomseed=0 +ifdef randomseed + GYPFLAGS += -Dv8_random_seed=$(randomseed) +endif +# soname_version=1.2.3 +ifdef soname_version + GYPFLAGS += -Dsoname_version=$(soname_version) +endif +# werror=no +ifeq ($(werror), no) + GYPFLAGS += -Dwerror='' +endif +# presubmit=no +ifeq ($(presubmit), no) + TESTFLAGS += --no-presubmit +endif +# strictaliasing=off (workaround for GCC-4.5) +ifeq ($(strictaliasing), off) + GYPFLAGS += -Dv8_no_strict_aliasing=1 +endif +# regexp=interpreted +ifeq ($(regexp), interpreted) + GYPFLAGS += -Dv8_interpreted_regexp=1 +endif +# i18nsupport=off +ifeq ($(i18nsupport), off) + GYPFLAGS += -Dv8_enable_i18n_support=0 + TESTFLAGS += --noi18n +endif +# deprecation_warnings=on +ifeq ($(deprecationwarnings), on) + GYPFLAGS += -Dv8_deprecation_warnings=1 +endif +# asan=/path/to/clang++ +ifneq ($(strip $(asan)),) + GYPFLAGS += -Dasan=1 + export CXX=$(asan) + export CXX_host=$(asan) + export LINK=$(asan) + export ASAN_SYMBOLIZER_PATH="$(dir $(asan))llvm-symbolizer" +endif + +# arm specific flags. +# arm_version= +ifneq ($(strip $(arm_version)),) + GYPFLAGS += -Darm_version=$(arm_version) +else +# Deprecated (use arm_version instead): armv7=false/true +ifeq ($(armv7), false) + GYPFLAGS += -Darm_version=6 +else +ifeq ($(armv7), true) + GYPFLAGS += -Darm_version=7 +endif +endif +endif +# hardfp=on/off. Deprecated, use armfloatabi +ifeq ($(hardfp),on) + GYPFLAGS += -Darm_float_abi=hard +else +ifeq ($(hardfp),off) + GYPFLAGS += -Darm_float_abi=softfp +endif +endif +# fpu: armfpu=xxx +# xxx: vfp, vfpv3-d16, vfpv3, neon. +ifeq ($(armfpu),) + GYPFLAGS += -Darm_fpu=default +else + GYPFLAGS += -Darm_fpu=$(armfpu) +endif +# float abi: armfloatabi=softfp/hard +ifeq ($(armfloatabi),) +ifeq ($(hardfp),) + GYPFLAGS += -Darm_float_abi=default +endif +else + GYPFLAGS += -Darm_float_abi=$(armfloatabi) +endif +# armthumb=on/off +ifeq ($(armthumb), off) + GYPFLAGS += -Darm_thumb=0 +else +ifeq ($(armthumb), on) + GYPFLAGS += -Darm_thumb=1 +endif +endif +# arm_test_noprobe=on +# With this flag set, by default v8 will only use features implied +# by the compiler (no probe). This is done by modifying the default +# values of enable_armv7, enable_vfp3, enable_32dregs and enable_neon. +# Modifying these flags when launching v8 will enable the probing for +# the specified values. +ifeq ($(arm_test_noprobe), on) + GYPFLAGS += -Darm_test_noprobe=on +endif + +# ----------------- available targets: -------------------- +# - "builddeps": pulls in external dependencies for building +# - "dependencies": pulls in all external dependencies +# - "grokdump": rebuilds heap constants lists used by grokdump +# - any arch listed in ARCHES (see below) +# - any mode listed in MODES +# - every combination ., e.g. "ia32.release" +# - "native": current host's architecture, release mode +# - any of the above with .check appended, e.g. "ia32.release.check" +# - "android": cross-compile for Android/ARM +# - "nacl" : cross-compile for Native Client (ia32 and x64) +# - default (no target specified): build all DEFAULT_ARCHES and MODES +# - "check": build all targets and run all tests +# - ".clean" for any in ARCHES +# - "clean": clean all ARCHES + +# ----------------- internal stuff ------------------------ + +# Architectures and modes to be compiled. Consider these to be internal +# variables, don't override them (use the targets instead). +ARCHES = ia32 x64 x32 arm arm64 mips mipsel mips64el x87 +DEFAULT_ARCHES = ia32 x64 arm +MODES = release debug optdebug +DEFAULT_MODES = release debug +ANDROID_ARCHES = android_ia32 android_arm android_arm64 android_mipsel android_x87 +NACL_ARCHES = nacl_ia32 nacl_x64 + +# List of files that trigger Makefile regeneration: +GYPFILES = \ + common.gypi \ + deps/cares/cares.gyp \ + deps/http_parser/http_parser.gyp \ + deps/openssl/openssl.gyp \ + deps/uv/uv.gyp \ + deps/v8/tools/gyp/v8.gyp \ + deps/zlib/zlib.gyp \ + node.gyp \ + +# If vtunejit=on, the v8vtune.gyp will be appended. +ifeq ($(vtunejit), on) + GYPFILES += src/third_party/vtune/v8vtune.gyp +endif +# Generates all combinations of ARCHES and MODES, e.g. "ia32.release". +BUILDS = $(foreach mode,$(MODES),$(addsuffix .$(mode),$(ARCHES))) +ANDROID_BUILDS = $(foreach mode,$(MODES), \ + $(addsuffix .$(mode),$(ANDROID_ARCHES))) +NACL_BUILDS = $(foreach mode,$(MODES), \ + $(addsuffix .$(mode),$(NACL_ARCHES))) +# Generates corresponding test targets, e.g. "ia32.release.check". +CHECKS = $(addsuffix .check,$(BUILDS)) +QUICKCHECKS = $(addsuffix .quickcheck,$(BUILDS)) +ANDROID_CHECKS = $(addsuffix .check,$(ANDROID_BUILDS)) +NACL_CHECKS = $(addsuffix .check,$(NACL_BUILDS)) +# File where previously used GYPFLAGS are stored. +ENVFILE = $(OUTDIR)/environment + +.PHONY: all check clean builddeps dependencies $(ENVFILE).new native \ + qc quickcheck $(QUICKCHECKS) \ + $(addsuffix .quickcheck,$(MODES)) $(addsuffix .quickcheck,$(ARCHES)) \ + $(ARCHES) $(MODES) $(BUILDS) $(CHECKS) $(addsuffix .clean,$(ARCHES)) \ + $(addsuffix .check,$(MODES)) $(addsuffix .check,$(ARCHES)) \ + $(ANDROID_ARCHES) $(ANDROID_BUILDS) $(ANDROID_CHECKS) \ + must-set-ANDROID_NDK_ROOT_OR_TOOLCHAIN \ + $(NACL_ARCHES) $(NACL_BUILDS) $(NACL_CHECKS) \ + must-set-NACL_SDK_ROOT + +# Target definitions. "all" is the default. +all: $(DEFAULT_MODES) + +# Special target for the buildbots to use. Depends on $(OUTDIR)/Makefile +# having been created before. +buildbot: + $(MAKE) -C "$(OUTDIR)" BUILDTYPE=$(BUILDTYPE) \ + builddir="$(abspath $(OUTDIR))/$(BUILDTYPE)" + +# Compile targets. MODES and ARCHES are convenience targets. +.SECONDEXPANSION: +$(MODES): $(addsuffix .$$@,$(DEFAULT_ARCHES)) + +$(ARCHES): $(addprefix $$@.,$(DEFAULT_MODES)) + +# Defines how to build a particular target (e.g. ia32.release). +$(BUILDS): $(OUTDIR)/Makefile.$$@ + @$(MAKE) -C "$(OUTDIR)" -f Makefile.$@ \ + CXX="$(CXX)" LINK="$(LINK)" \ + BUILDTYPE=$(shell echo $(subst .,,$(suffix $@)) | \ + python -c "print \ + raw_input().replace('opt', '').capitalize()") \ + builddir="$(shell pwd)/$(OUTDIR)/$@" + +native: $(OUTDIR)/Makefile.native + @$(MAKE) -C "$(OUTDIR)" -f Makefile.native \ + CXX="$(CXX)" LINK="$(LINK)" BUILDTYPE=Release \ + builddir="$(shell pwd)/$(OUTDIR)/$@" + +$(ANDROID_ARCHES): $(addprefix $$@.,$(MODES)) + +$(ANDROID_BUILDS): $(GYPFILES) $(ENVFILE) build/android.gypi \ + must-set-ANDROID_NDK_ROOT_OR_TOOLCHAIN Makefile.android + @$(MAKE) -f Makefile.android $@ \ + ARCH="$(basename $@)" \ + MODE="$(subst .,,$(suffix $@))" \ + OUTDIR="$(OUTDIR)" \ + GYPFLAGS="$(GYPFLAGS)" + +$(NACL_ARCHES): $(addprefix $$@.,$(MODES)) + +$(NACL_BUILDS): $(GYPFILES) $(ENVFILE) \ + Makefile.nacl must-set-NACL_SDK_ROOT + @$(MAKE) -f Makefile.nacl $@ \ + ARCH="$(basename $@)" \ + MODE="$(subst .,,$(suffix $@))" \ + OUTDIR="$(OUTDIR)" \ + GYPFLAGS="$(GYPFLAGS)" + +# Test targets. +check: all + @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \ + --arch=$(shell echo $(DEFAULT_ARCHES) | sed -e 's/ /,/g') \ + $(TESTFLAGS) + +$(addsuffix .check,$(MODES)): $$(basename $$@) + @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \ + --mode=$(basename $@) $(TESTFLAGS) + +$(addsuffix .check,$(ARCHES)): $$(basename $$@) + @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \ + --arch=$(basename $@) $(TESTFLAGS) + +$(CHECKS): $$(basename $$@) + @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \ + --arch-and-mode=$(basename $@) $(TESTFLAGS) + +$(addsuffix .quickcheck,$(MODES)): $$(basename $$@) + @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \ + --mode=$(basename $@) $(TESTFLAGS) --quickcheck + +$(addsuffix .quickcheck,$(ARCHES)): $$(basename $$@) + @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \ + --arch=$(basename $@) $(TESTFLAGS) --quickcheck + +$(QUICKCHECKS): $$(basename $$@) + @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \ + --arch-and-mode=$(basename $@) $(TESTFLAGS) --quickcheck + +$(addsuffix .sync, $(ANDROID_BUILDS)): $$(basename $$@) + @tools/android-sync.sh $(basename $@) $(OUTDIR) \ + $(shell pwd) $(ANDROID_V8) + +$(addsuffix .check, $(ANDROID_BUILDS)): $$(basename $$@).sync + @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \ + --arch-and-mode=$(basename $@) \ + --timeout=600 \ + --command-prefix="tools/android-run.py" $(TESTFLAGS) + +$(addsuffix .check, $(ANDROID_ARCHES)): \ + $(addprefix $$(basename $$@).,$(MODES)).check + +$(addsuffix .check, $(NACL_BUILDS)): $$(basename $$@) + @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \ + --arch-and-mode=$(basename $@) \ + --timeout=600 --nopresubmit --noi18n \ + --command-prefix="tools/nacl-run.py" + +$(addsuffix .check, $(NACL_ARCHES)): \ + $(addprefix $$(basename $$@).,$(MODES)).check + +native.check: native + @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR)/native \ + --arch-and-mode=. $(TESTFLAGS) + +SUPERFASTTESTMODES = ia32.release +FASTTESTMODES = $(SUPERFASTTESTMODES),x64.release,ia32.optdebug,x64.optdebug,arm.optdebug,arm64.release +FASTCOMPILEMODES = $(FASTTESTMODES),arm64.optdebug + +COMMA = , +EMPTY = +SPACE = $(EMPTY) $(EMPTY) +quickcheck: $(subst $(COMMA),$(SPACE),$(FASTCOMPILEMODES)) + tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \ + --arch-and-mode=$(SUPERFASTTESTMODES) $(TESTFLAGS) --quickcheck \ + --download-data mozilla webkit + tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \ + --arch-and-mode=$(FASTTESTMODES) $(TESTFLAGS) --quickcheck +qc: quickcheck + +# Clean targets. You can clean each architecture individually, or everything. +$(addsuffix .clean, $(ARCHES) $(ANDROID_ARCHES) $(NACL_ARCHES)): + rm -f $(OUTDIR)/Makefile.$(basename $@)* + rm -rf $(OUTDIR)/$(basename $@).release + rm -rf $(OUTDIR)/$(basename $@).debug + rm -rf $(OUTDIR)/$(basename $@).optdebug + find $(OUTDIR) -regex '.*\(host\|target\)\.$(basename $@).*\.mk' -delete + +native.clean: + rm -f $(OUTDIR)/Makefile.native + rm -rf $(OUTDIR)/native + find $(OUTDIR) -regex '.*\(host\|target\)\.native\.mk' -delete + +clean: $(addsuffix .clean, $(ARCHES) $(ANDROID_ARCHES) $(NACL_ARCHES)) native.clean gtags.clean + +# GYP file generation targets. +OUT_MAKEFILES = $(addprefix $(OUTDIR)/Makefile.,$(BUILDS)) +$(OUT_MAKEFILES): $(GYPFILES) $(ENVFILE) + $(eval CXX_TARGET_ARCH:=$(shell $(CXX) -v 2>&1 | grep ^Target: | \ + cut -f 2 -d " " | cut -f 1 -d "-" )) + $(eval CXX_TARGET_ARCH:=$(subst aarch64,arm64,$(CXX_TARGET_ARCH))) + $(eval V8_TARGET_ARCH:=$(subst .,,$(suffix $(basename $@)))) + GYP_GENERATORS=make \ + tools/gyp/gyp --generator-output="$(OUTDIR)" node.gyp \ + -Icommon.gypi --depth=. \ + -Dtarget_arch=$(V8_TARGET_ARCH) \ + -Dv8_target_arch=$(V8_TARGET_ARCH) \ + $(if $(findstring $(CXX_TARGET_ARCH),$(V8_TARGET_ARCH)), \ + -Dtarget_arch=$(V8_TARGET_ARCH),) \ + $(if $(findstring optdebug,$@),-Dv8_optimized_debug=2,) \ + -S$(suffix $(basename $@))$(suffix $@) $(GYPFLAGS) + +$(OUTDIR)/Makefile.native: $(GYPFILES) $(ENVFILE) + GYP_GENERATORS=make \ + tools/gyp/gyp --generator-output="$(OUTDIR)" node.gyp \ + -Icommon.gypi --depth=. -S.native $(GYPFLAGS) + +must-set-ANDROID_NDK_ROOT_OR_TOOLCHAIN: +ifndef ANDROID_NDK_ROOT +ifndef ANDROID_TOOLCHAIN + $(error ANDROID_NDK_ROOT or ANDROID_TOOLCHAIN must be set)) +endif +endif + +# Note that NACL_SDK_ROOT must be set to point to an appropriate +# Native Client SDK before using this makefile. You can download +# an SDK here: +# https://developers.google.com/native-client/sdk/download +# The path indicated by NACL_SDK_ROOT will typically end with +# a folder for a pepper version such as "pepper_25" that should +# have "tools" and "toolchain" subdirectories. +must-set-NACL_SDK_ROOT: +ifndef NACL_SDK_ROOT + $(error NACL_SDK_ROOT must be set) +endif + +# Replaces the old with the new environment file if they're different, which +# will trigger GYP to regenerate Makefiles. +$(ENVFILE): $(ENVFILE).new + @if test -r $(ENVFILE) && cmp $(ENVFILE).new $(ENVFILE) > /dev/null; \ + then rm $(ENVFILE).new; \ + else mv $(ENVFILE).new $(ENVFILE); fi + +# Stores current GYPFLAGS in a file. +$(ENVFILE).new: + @mkdir -p $(OUTDIR); echo "GYPFLAGS=$(GYPFLAGS)" > $(ENVFILE).new; \ + echo "CXX=$(CXX)" >> $(ENVFILE).new + +# Heap constants for grokdump. +DUMP_FILE = tools/v8heapconst.py +grokdump: ia32.release + @cat $(DUMP_FILE).tmpl > $(DUMP_FILE) + @$(OUTDIR)/ia32.release/d8 --dump-heap-constants >> $(DUMP_FILE) + +# Support for the GNU GLOBAL Source Code Tag System. +gtags.files: $(GYPFILES) $(ENVFILE) + @find include src test -name '*.h' -o -name '*.cc' -o -name '*.c' > $@ + +# We need to manually set the stack limit here, to work around bugs in +# gmake-3.81 and global-5.7.1 on recent 64-bit Linux systems. +GPATH GRTAGS GSYMS GTAGS: gtags.files $(shell cat gtags.files 2> /dev/null) + @bash -c 'ulimit -s 10240 && GTAGSFORCECPP=yes gtags -i -q -f $<' + +gtags.clean: + rm -f gtags.files GPATH GRTAGS GSYMS GTAGS + +# Dependencies. "builddeps" are dependencies required solely for building, +# "dependencies" includes also dependencies required for development. +# Remember to keep these in sync with the DEPS file. +builddeps: + svn checkout --force http://gyp.googlecode.com/svn/trunk build/gyp \ + --revision 1831 + if svn info third_party/icu 2>&1 | grep -q icu46 ; then \ + svn switch --force \ + https://src.chromium.org/chrome/trunk/deps/third_party/icu52 \ + third_party/icu --revision 277999 ; \ + else \ + svn checkout --force \ + https://src.chromium.org/chrome/trunk/deps/third_party/icu52 \ + third_party/icu --revision 277999 ; \ + fi + svn checkout --force http://googletest.googlecode.com/svn/trunk \ + testing/gtest --revision 692 + svn checkout --force http://googlemock.googlecode.com/svn/trunk \ + testing/gmock --revision 485 + +dependencies: builddeps + # The spec is a copy of the hooks in v8's DEPS file. + gclient sync -r fb782d4369d5ae04f17a2fceef7de5a63e50f07b --spec="solutions = [{u'managed': False, u'name': u'buildtools', u'url': u'https://chromium.googlesource.com/chromium/buildtools.git', u'custom_deps': {}, u'custom_hooks': [{u'name': u'clang_format_win',u'pattern': u'.',u'action': [u'download_from_google_storage',u'--no_resume',u'--platform=win32',u'--no_auth',u'--bucket',u'chromium-clang-format',u'-s',u'buildtools/win/clang-format.exe.sha1']},{u'name': u'clang_format_mac',u'pattern': u'.',u'action': [u'download_from_google_storage',u'--no_resume',u'--platform=darwin',u'--no_auth',u'--bucket',u'chromium-clang-format',u'-s',u'buildtools/mac/clang-format.sha1']},{u'name': u'clang_format_linux',u'pattern': u'.',u'action': [u'download_from_google_storage',u'--no_resume',u'--platform=linux*',u'--no_auth',u'--bucket',u'chromium-clang-format',u'-s',u'buildtools/linux64/clang-format.sha1']}],u'deps_file': u'.DEPS.git', u'safesync_url': u''}]" diff --git a/README.md b/README.md index 0032c63c0730c9..abc8adf85ba536 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,30 @@ -Evented I/O for V8 javascript. +io.js === +[![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/iojs/io.js?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) + +This repository began as a GitHub fork of +[joyent/node](https://github.com/joyent/node). +io.js contributions, releases, and contributorship are under an +[open governance model](./CONTRIBUTING.md#governance). +We intend to land, with increasing regularity, releases which are +compatible with the npm ecosystem that has been built to date for node.js. + +### Is it io.js or IO.js or iojs or IOjs or iOjS? + +The official name is **io.js**, which should never be capitalized, +especially not at the start of a sentence, unless it is being +displayed in a location that is customarily all-caps (such as +the title of man pages.) ### To build: Prerequisites (Unix only): - * GCC 4.2 or newer - * G++ 4.2 or newer - * Python 2.6 or 2.7 - * GNU Make 3.81 or newer - * libexecinfo (FreeBSD and OpenBSD only) +* `gcc` and `g++` 4.8 or newer, or +* `clang` and `clang++` 3.3 or newer +* Python 2.6 or 2.7 +* GNU Make 3.81 or newer +* libexecinfo (FreeBSD and OpenBSD only) Unix/Macintosh: @@ -31,8 +46,9 @@ make install Prerequisites (Windows only): - * Python 2.6 or 2.7 - * Visual Studio 2010 or 2012 +* Python 2.6 or 2.7 +* Visual Studio 2013 for Windows Desktop, or +* Visual Studio Express 2013 for Windows Desktop Windows: @@ -121,7 +137,7 @@ Resources for Newcomers - [searching the npm registry](http://npmjs.org/) - [list of companies and projects using node](https://github.com/joyent/node/wiki/Projects,-Applications,-and-Companies-Using-Node) - [node.js mailing list](http://groups.google.com/group/nodejs) - - irc chatroom, [#node.js on freenode.net](http://webchat.freenode.net?channels=node.js&uio=d4) + - irc chatroom, [#io.js on freenode.net](http://webchat.freenode.net?channels=io.js&uio=d4) - [community](https://github.com/joyent/node/wiki/Community) - [contributing](https://github.com/joyent/node/wiki/Contributing) - [big list of all the helpful wiki pages](https://github.com/joyent/node/wiki/_pages) diff --git a/benchmark/common.js b/benchmark/common.js index ff54f2ea495ef5..7d1730c373d8ae 100644 --- a/benchmark/common.js +++ b/benchmark/common.js @@ -187,7 +187,7 @@ Benchmark.prototype.end = function(operations) { Benchmark.prototype.report = function(value) { var heading = this.getHeading(); if (!silent) - console.log('%s: %s', heading, value.toPrecision(5)); + console.log('%s: %s', heading, value.toFixed(0)); process.exit(0); }; diff --git a/benchmark/events/ee-add-remove.js b/benchmark/events/ee-add-remove.js new file mode 100644 index 00000000000000..cd9fe3cb7de057 --- /dev/null +++ b/benchmark/events/ee-add-remove.js @@ -0,0 +1,23 @@ +var common = require('../common.js'); +var events = require('events'); + +var bench = common.createBenchmark(main, {n: [25e4]}); + +function main(conf) { + var n = conf.n | 0; + + var ee = new events.EventEmitter(); + var listeners = []; + + for (var k = 0; k < 10; k += 1) + listeners.push(function() {}); + + bench.start(); + for (var i = 0; i < n; i += 1) { + for (var k = listeners.length; --k >= 0; /* empty */) + ee.on('dummy', listeners[k]); + for (var k = listeners.length; --k >= 0; /* empty */) + ee.removeListener('dummy', listeners[k]); + } + bench.end(n); +} diff --git a/benchmark/misc/domain-fn-args.js b/benchmark/misc/domain-fn-args.js new file mode 100644 index 00000000000000..36e9e900299bb2 --- /dev/null +++ b/benchmark/misc/domain-fn-args.js @@ -0,0 +1,43 @@ +var common = require('../common.js'); +var domain = require('domain'); + +var bench = common.createBenchmark(main, { + arguments: [0, 1, 2, 3], + n: [10] +}); + +var bdomain = domain.create(); +var gargs = [1, 2, 3]; + +function main(conf) { + + var args, ret, n = +conf.n; + var arguments = gargs.slice(0, conf.arguments); + bench.start(); + + bdomain.enter(); + for (var i = 0; i < n; i++) { + if (arguments.length >= 2) { + args = Array.prototype.slice.call(arguments, 1); + ret = fn.apply(this, args); + } else { + ret = fn.call(this); + } + } + bdomain.exit(); + + bench.end(n); +} + +function fn(a, b, c) { + if (!a) + a = 1; + + if (!b) + b = 2; + + if (!c) + c = 3; + + return a + b + c; +} \ No newline at end of file diff --git a/benchmark/misc/module-loader.js b/benchmark/misc/module-loader.js index 96f8e7df1ead60..00a9369650d103 100644 --- a/benchmark/misc/module-loader.js +++ b/benchmark/misc/module-loader.js @@ -56,7 +56,7 @@ function measure(n) { } function rmrf(location) { - if (fs.existsSync(location)) { + try { var things = fs.readdirSync(location); things.forEach(function(thing) { var cur = path.join(location, thing), @@ -68,5 +68,7 @@ function rmrf(location) { fs.unlinkSync(cur); }); fs.rmdirSync(location); + } catch (err) { + // Ignore error } } diff --git a/benchmark/url/url-parse.js b/benchmark/url/url-parse.js new file mode 100644 index 00000000000000..ffa47c4ccd6105 --- /dev/null +++ b/benchmark/url/url-parse.js @@ -0,0 +1,36 @@ +var common = require('../common.js'); +var url = require('url'); +var v8 = require('v8'); + +var bench = common.createBenchmark(main, { + type: 'one two three four five six'.split(' '), + n: [25e4] +}); + +function main(conf) { + var type = conf.type; + var n = conf.n | 0; + + var inputs = { + one: 'http://nodejs.org/docs/latest/api/url.html#url_url_format_urlobj', + two: 'http://blog.nodejs.org/', + three: 'https://encrypted.google.com/search?q=url&q=site:npmjs.org&hl=en', + four: 'javascript:alert("node is awesome");', + five: 'some.ran/dom/url.thing?oh=yes#whoo', + six: 'https://user:pass@example.com/', + }; + var input = inputs[type] || ''; + + // Force-optimize url.parse() so that the benchmark doesn't get + // disrupted by the optimizer kicking in halfway through. + for (var name in inputs) + url.parse(inputs[name]); + + v8.setFlagsFromString('--allow_natives_syntax'); + eval('%OptimizeFunctionOnNextCall(url.parse)'); + + bench.start(); + for (var i = 0; i < n; i += 1) + url.parse(input); + bench.end(n); +} diff --git a/benchmark/url/url-resolve.js b/benchmark/url/url-resolve.js new file mode 100644 index 00000000000000..5f6c1f7600ce4e --- /dev/null +++ b/benchmark/url/url-resolve.js @@ -0,0 +1,31 @@ +var common = require('../common.js'); +var url = require('url'); +var v8 = require('v8'); + +var bench = common.createBenchmark(main, { + type: ['one'], + n: [1e5], +}); + +function main(conf) { + var type = conf.type; + var n = conf.n | 0; + + var inputs = { + one: ['http://example.com/', '../../../../../etc/passwd'], + }; + var input = inputs[type] || []; + + // Force-optimize url.resolve() so that the benchmark doesn't get + // disrupted by the optimizer kicking in halfway through. + for (var name in inputs) + url.resolve(inputs[name][0], inputs[name][1]); + + v8.setFlagsFromString('--allow_natives_syntax'); + eval('%OptimizeFunctionOnNextCall(url.resolve)'); + + bench.start(); + for (var i = 0; i < n; i += 1) + url.resolve(input[0], input[1]); + bench.end(n); +} diff --git a/common.gypi b/common.gypi index 8886b743927d03..fabb3751730a3e 100644 --- a/common.gypi +++ b/common.gypi @@ -1,5 +1,6 @@ { 'variables': { + 'asan%': 0, 'werror': '', # Turn off -Werror in V8 build. 'visibility%': 'hidden', # V8's visibility setting 'target_arch%': 'ia32', # set v8's target architecture @@ -12,6 +13,12 @@ 'clang%': 0, 'python%': 'python', + 'node_tag%': '', + 'uv_library%': 'static_library', + + # Default to -O0 for debug builds. + 'v8_optimized_debug%': 0, + # Enable disassembler for `--print-code` v8 options 'v8_enable_disassembler': 1, @@ -77,12 +84,6 @@ # pull in V8's postmortem metadata 'ldflags': [ '-Wl,-z,allextract' ] }], - ['clang == 0 and gcc_version >= 40', { - 'cflags': [ '-fno-tree-vrp' ], # Work around compiler bug. - }], - ['clang == 0 and gcc_version <= 44', { - 'cflags': [ '-fno-tree-sink' ], # Work around compiler bug. - }], ['OS!="mac" and OS!="win"', { 'cflags': [ '-fno-omit-frame-pointer' ], }], @@ -153,6 +154,16 @@ }, 'msvs_disabled_warnings': [4351, 4355, 4800], 'conditions': [ + ['asan != 0', { + 'cflags+': [ + '-fno-omit-frame-pointer', + '-fsanitize=address', + '-w', # http://crbug.com/162783 + ], + 'cflags_cc+': [ '-gline-tables-only' ], + 'cflags!': [ '-fomit-frame-pointer' ], + 'ldflags': [ '-fsanitize=address' ], + }], ['OS == "win"', { 'msvs_cygwin_shell': 0, # prevent actions from trying to use cygwin 'defines': [ @@ -173,7 +184,7 @@ }], [ 'OS in "linux freebsd openbsd solaris android"', { 'cflags': [ '-Wall', '-Wextra', '-Wno-unused-parameter', ], - 'cflags_cc': [ '-fno-rtti', '-fno-exceptions' ], + 'cflags_cc': [ '-fno-rtti', '-fno-exceptions', '-std=gnu++0x' ], 'ldflags': [ '-rdynamic' ], 'target_conditions': [ ['_type=="static_library"', { @@ -185,6 +196,10 @@ 'cflags': [ '-m32' ], 'ldflags': [ '-m32' ], }], + [ 'target_arch=="x32"', { + 'cflags': [ '-mx32' ], + 'ldflags': [ '-mx32' ], + }], [ 'target_arch=="x64"', { 'cflags': [ '-m64' ], 'ldflags': [ '-m64' ], @@ -237,6 +252,12 @@ ['target_arch=="x64"', { 'xcode_settings': {'ARCHS': ['x86_64']}, }], + ['clang==1', { + 'xcode_settings': { + 'GCC_VERSION': 'com.apple.compilers.llvm.clang.1_0', + 'CLANG_CXX_LANGUAGE_STANDARD': 'gnu++0x', # -std=gnu++0x + }, + }], ], }], ['OS=="freebsd" and node_use_dtrace=="true"', { diff --git a/configure b/configure index c558f7f8dd797d..128aa27348ffef 100755 --- a/configure +++ b/configure @@ -31,7 +31,7 @@ parser.add_option('--debug', parser.add_option('--dest-cpu', action='store', dest='dest_cpu', - help='CPU architecture to build for. Valid values are: arm, ia32, x64') + help='CPU architecture to build for. Valid values are: arm, ia32, x32, x64') parser.add_option('--dest-os', action='store', @@ -83,26 +83,6 @@ parser.add_option('--openssl-use-sys', dest='shared_openssl', help=optparse.SUPPRESS_HELP) -parser.add_option('--shared-cares', - action='store_true', - dest='shared_cares', - help='link to a shared cares DLL instead of static linking') - -parser.add_option('--shared-cares-includes', - action='store', - dest='shared_cares_includes', - help='directory containing cares header files') - -parser.add_option('--shared-cares-libname', - action='store', - dest='shared_cares_libname', - help='alternative lib name to link to (default: \'cares\')') - -parser.add_option('--shared-cares-libpath', - action='store', - dest='shared_cares_libpath', - help='a directory to search for the shared cares DLL') - parser.add_option('--shared-http-parser', action='store_true', dest='shared_http_parser', @@ -376,28 +356,8 @@ def is_arm_hard_float_abi(): # the Floating Point ABI used (PCS stands for Procedure Call Standard). # We use these as well as a couple of other defines to statically determine # what FP ABI used. - # GCC versions 4.4 and below don't support hard-fp. - # GCC versions 4.5 may support hard-fp without defining __ARM_PCS or - # __ARM_PCS_VFP. - - if compiler_version() >= (4, 6, 0): - return '__ARM_PCS_VFP' in cc_macros() - elif compiler_version() < (4, 5, 0): - return False - elif '__ARM_PCS_VFP' in cc_macros(): - return True - elif ('__ARM_PCS' in cc_macros() or - '__SOFTFP' in cc_macros() or - not '__VFP_FP__' in cc_macros()): - return False - else: - print '''Node.js configure error: Your version of GCC does not report - the Floating-Point ABI to compile for your hardware - Please manually specify which floating-point ABI to use with the - --with-arm-float-abi option. - ''' - sys.exit() + return '__ARM_PCS_VFP' in cc_macros() def host_arch_cc(): @@ -501,10 +461,6 @@ def configure_node(o): if not is_clang and cc_version != 0: o['variables']['gcc_version'] = 10 * cc_version[0] + cc_version[1] - # clang has always supported -fvisibility=hidden, right? - if not is_clang and cc_version < (4,0,0): - o['variables']['visibility'] = '' - if flavor in ('solaris', 'mac', 'linux', 'freebsd'): use_dtrace = not options.without_dtrace # Don't enable by default on linux and freebsd @@ -586,20 +542,6 @@ def configure_http_parser(o): o['include_dirs'] += [options.shared_http_parser_includes] -def configure_cares(o): - o['variables']['node_shared_cares'] = b(options.shared_cares) - - # assume shared cares if one of these is set? - if options.shared_cares_libpath: - o['libraries'] += ['-L%s' % options.shared_cares_libpath] - if options.shared_cares_libname: - o['libraries'] += ['-l%s' % options.shared_cares_libname] - elif options.shared_cares: - o['libraries'] += ['-lcares'] - if options.shared_cares_includes: - o['include_dirs'] += [options.shared_cares_includes] - - def configure_libuv(o): o['variables']['node_shared_libuv'] = b(options.shared_libuv) @@ -863,7 +805,6 @@ output = { configure_node(output) configure_libz(output) configure_http_parser(output) -configure_cares(output) configure_libuv(output) configure_v8(output) configure_openssl(output) @@ -905,11 +846,11 @@ if options.use_ninja: gyp_args += ['-f', 'ninja-' + flavor] elif options.use_xcode: gyp_args += ['-f', 'xcode'] -elif flavor == 'win': +elif flavor == 'win' and sys.platform != 'msys': gyp_args += ['-f', 'msvs', '-G', 'msvs_version=auto'] else: gyp_args += ['-f', 'make-' + flavor] gyp_args += args -subprocess.call(gyp_args) +sys.exit(subprocess.call(gyp_args)) diff --git a/deps/debugger-agent/debugger-agent.gyp b/deps/debugger-agent/debugger-agent.gyp deleted file mode 100644 index e98206849ab1aa..00000000000000 --- a/deps/debugger-agent/debugger-agent.gyp +++ /dev/null @@ -1,24 +0,0 @@ -{ - "targets": [{ - "target_name": "debugger-agent", - "type": "<(library)", - "include_dirs": [ - "src", - "include", - "../v8/include", - "../uv/include", - - # Private node.js folder and stuff needed to include from it - "../../src", - "../cares/include", - ], - "direct_dependent_settings": { - "include_dirs": [ - "include", - ], - }, - "sources": [ - "src/agent.cc", - ], - }], -} diff --git a/deps/debugger-agent/include/debugger-agent.h b/deps/debugger-agent/include/debugger-agent.h deleted file mode 100644 index 762a687a0a071c..00000000000000 --- a/deps/debugger-agent/include/debugger-agent.h +++ /dev/null @@ -1,109 +0,0 @@ -// Copyright Fedor Indutny and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -#ifndef DEPS_DEBUGGER_AGENT_INCLUDE_DEBUGGER_AGENT_H_ -#define DEPS_DEBUGGER_AGENT_INCLUDE_DEBUGGER_AGENT_H_ - -#include "uv.h" -#include "v8.h" -#include "v8-debug.h" - -namespace node { - -// Forward declaration -class Environment; - -namespace debugger { - -// Forward declaration -class AgentMessage; - -class Agent { - public: - explicit Agent(node::Environment* env); - ~Agent(); - - typedef void (*DispatchHandler)(node::Environment* env); - - // Start the debugger agent thread - bool Start(int port, bool wait); - // Listen for debug events - void Enable(); - // Stop the debugger agent - void Stop(); - - inline void set_dispatch_handler(DispatchHandler handler) { - dispatch_handler_ = handler; - } - - inline node::Environment* parent_env() const { return parent_env_; } - inline node::Environment* child_env() const { return child_env_; } - - protected: - void InitAdaptor(Environment* env); - - // Worker body - void WorkerRun(); - - static void ThreadCb(Agent* agent); - static void ParentSignalCb(uv_async_t* signal); - static void ChildSignalCb(uv_async_t* signal); - static void MessageHandler(const v8::Debug::Message& message); - - // V8 API - static Agent* Unwrap(const v8::FunctionCallbackInfo& args); - static void NotifyListen(const v8::FunctionCallbackInfo& args); - static void NotifyWait(const v8::FunctionCallbackInfo& args); - static void SendCommand(const v8::FunctionCallbackInfo& args); - - void EnqueueMessage(AgentMessage* message); - - enum State { - kNone, - kRunning - }; - - // TODO(indutny): Verify that there are no races - State state_; - - int port_; - bool wait_; - - uv_sem_t start_sem_; - uv_mutex_t message_mutex_; - uv_async_t child_signal_; - - uv_thread_t thread_; - node::Environment* parent_env_; - node::Environment* child_env_; - uv_loop_t child_loop_; - v8::Persistent api_; - - // QUEUE - void* messages_[2]; - - DispatchHandler dispatch_handler_; -}; - -} // namespace debugger -} // namespace node - -#endif // DEPS_DEBUGGER_AGENT_INCLUDE_DEBUGGER_AGENT_H_ diff --git a/deps/debugger-agent/lib/_debugger_agent.js b/deps/debugger-agent/lib/_debugger_agent.js deleted file mode 100644 index 680c5e95c4982f..00000000000000 --- a/deps/debugger-agent/lib/_debugger_agent.js +++ /dev/null @@ -1,191 +0,0 @@ -var assert = require('assert'); -var net = require('net'); -var util = require('util'); -var Buffer = require('buffer').Buffer; - -var Transform = require('stream').Transform; - -exports.start = function start() { - var agent = new Agent(); - - // Do not let `agent.listen()` request listening from cluster master - var cluster = require('cluster'); - cluster.isWorker = false; - cluster.isMaster = true; - - agent.on('error', function(err) { - process._rawDebug(err.stack || err); - }); - - agent.listen(process._debugAPI.port, function() { - var addr = this.address(); - process._rawDebug('Debugger listening on port %d', addr.port); - process._debugAPI.notifyListen(); - }); - - // Just to spin-off events - // TODO(indutny): Figure out why node.cc isn't doing this - setImmediate(function() { - }); - - process._debugAPI.onclose = function() { - // We don't care about it, but it prevents loop from cleaning up gently - // NOTE: removeAllListeners won't work, as it doesn't call `removeListener` - process.listeners('SIGWINCH').forEach(function(fn) { - process.removeListener('SIGWINCH', fn); - }); - - agent.close(); - }; - - // Not used now, but anyway - return agent; -}; - -function Agent() { - net.Server.call(this, this.onConnection); - - this.first = true; - this.binding = process._debugAPI; - - var self = this; - this.binding.onmessage = function(msg) { - self.clients.forEach(function(client) { - client.send({}, msg); - }); - }; - - this.clients = []; - assert(this.binding, 'Debugger agent running without bindings!'); -} -util.inherits(Agent, net.Server); - -Agent.prototype.onConnection = function onConnection(socket) { - var c = new Client(this, socket); - - c.start(); - this.clients.push(c); - - var self = this; - c.once('close', function() { - var index = self.clients.indexOf(c); - assert(index !== -1); - self.clients.splice(index, 1); - }); -}; - -Agent.prototype.notifyWait = function notifyWait() { - if (this.first) - this.binding.notifyWait(); - this.first = false; -}; - -function Client(agent, socket) { - Transform.call(this); - this._readableState.objectMode = true; - - this.agent = agent; - this.binding = this.agent.binding; - this.socket = socket; - - // Parse incoming data - this.state = 'headers'; - this.headers = {}; - this.buffer = ''; - socket.pipe(this); - - this.on('data', this.onCommand); - - var self = this; - this.socket.on('close', function() { - self.destroy(); - }); -} -util.inherits(Client, Transform); - -Client.prototype.destroy = function destroy(msg) { - this.socket.destroy(); - - this.emit('close'); -}; - -Client.prototype._transform = function _transform(data, enc, cb) { - cb(); - - this.buffer += data; - - while (true) { - if (this.state === 'headers') { - // Not enough data - if (!/\r\n/.test(this.buffer)) - break; - - if (/^\r\n/.test(this.buffer)) { - this.buffer = this.buffer.slice(2); - this.state = 'body'; - continue; - } - - // Match: - // Header-name: header-value\r\n - var match = this.buffer.match(/^([^:\s\r\n]+)\s*:\s*([^\s\r\n]+)\r\n/); - if (!match) - return this.destroy('Expected header, but failed to parse it'); - - this.headers[match[1].toLowerCase()] = match[2]; - - this.buffer = this.buffer.slice(match[0].length); - } else { - var len = this.headers['content-length']; - if (len === undefined) - return this.destroy('Expected content-length'); - - len = len | 0; - if (Buffer.byteLength(this.buffer) < len) - break; - - this.push(new Command(this.headers, this.buffer.slice(0, len))); - this.state = 'headers'; - this.buffer = this.buffer.slice(len); - this.headers = {}; - } - } -}; - -Client.prototype.send = function send(headers, data) { - if (!data) - data = ''; - - var out = []; - Object.keys(headers).forEach(function(key) { - out.push(key + ': ' + headers[key]); - }); - out.push('Content-Length: ' + Buffer.byteLength(data), ''); - - this.socket.cork(); - this.socket.write(out.join('\r\n') + '\r\n'); - - if (data.length > 0) - this.socket.write(data); - this.socket.uncork(); -}; - -Client.prototype.start = function start() { - this.send({ - Type: 'connect', - 'V8-Version': process.versions.v8, - 'Protocol-Version': 1, - 'Embedding-Host': 'node ' + process.version - }); -}; - -Client.prototype.onCommand = function onCommand(cmd) { - this.binding.sendCommand(cmd.body); - - this.agent.notifyWait(); -}; - -function Command(headers, body) { - this.headers = headers; - this.body = body; -} diff --git a/deps/debugger-agent/src/agent.cc b/deps/debugger-agent/src/agent.cc deleted file mode 100644 index 335737ffe9e33f..00000000000000 --- a/deps/debugger-agent/src/agent.cc +++ /dev/null @@ -1,347 +0,0 @@ -// Copyright Fedor Indutny and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -#include "agent.h" -#include "debugger-agent.h" - -#include "node.h" -#include "node_internals.h" // ARRAY_SIZE -#include "env.h" -#include "env-inl.h" -#include "v8.h" -#include "v8-debug.h" -#include "util.h" -#include "util-inl.h" -#include "queue.h" - -#include - -namespace node { -namespace debugger { - -using v8::Context; -using v8::Function; -using v8::FunctionCallbackInfo; -using v8::FunctionTemplate; -using v8::Handle; -using v8::HandleScope; -using v8::Integer; -using v8::Isolate; -using v8::Local; -using v8::Locker; -using v8::Object; -using v8::String; -using v8::Value; - - -Agent::Agent(Environment* env) : state_(kNone), - port_(5858), - wait_(false), - parent_env_(env), - child_env_(NULL), - dispatch_handler_(NULL) { - int err; - - err = uv_sem_init(&start_sem_, 0); - CHECK_EQ(err, 0); - - err = uv_mutex_init(&message_mutex_); - CHECK_EQ(err, 0); - - QUEUE_INIT(&messages_); -} - - -Agent::~Agent() { - Stop(); - - uv_sem_destroy(&start_sem_); - uv_mutex_destroy(&message_mutex_); - - // Clean-up messages - while (!QUEUE_EMPTY(&messages_)) { - QUEUE* q = QUEUE_HEAD(&messages_); - QUEUE_REMOVE(q); - AgentMessage* msg = ContainerOf(&AgentMessage::member, q); - delete msg; - } -} - - -bool Agent::Start(int port, bool wait) { - int err; - - if (state_ == kRunning) - return false; - - err = uv_loop_init(&child_loop_); - if (err != 0) - goto loop_init_failed; - - // Interruption signal handler - err = uv_async_init(&child_loop_, &child_signal_, ChildSignalCb); - if (err != 0) - goto async_init_failed; - uv_unref(reinterpret_cast(&child_signal_)); - - port_ = port; - wait_ = wait; - - err = uv_thread_create(&thread_, - reinterpret_cast(ThreadCb), - this); - if (err != 0) - goto thread_create_failed; - - uv_sem_wait(&start_sem_); - - state_ = kRunning; - - return true; - - thread_create_failed: - uv_close(reinterpret_cast(&child_signal_), NULL); - - async_init_failed: - err = uv_loop_close(&child_loop_); - CHECK_EQ(err, 0); - - loop_init_failed: - return false; -} - - -void Agent::Enable() { - v8::Debug::SetMessageHandler(MessageHandler); - - // Assign environment to the debugger's context - // NOTE: The debugger context is created after `SetMessageHandler()` call - parent_env()->AssignToContext(v8::Debug::GetDebugContext()); -} - - -void Agent::Stop() { - int err; - - if (state_ != kRunning) { - return; - } - - v8::Debug::SetMessageHandler(NULL); - - // Send empty message to terminate things - EnqueueMessage(new AgentMessage(NULL, 0)); - - // Signal worker thread to make it stop - err = uv_async_send(&child_signal_); - CHECK_EQ(err, 0); - - err = uv_thread_join(&thread_); - CHECK_EQ(err, 0); - - uv_close(reinterpret_cast(&child_signal_), NULL); - uv_run(&child_loop_, UV_RUN_NOWAIT); - - err = uv_loop_close(&child_loop_); - CHECK_EQ(err, 0); - - state_ = kNone; -} - - -void Agent::WorkerRun() { - static const char* argv[] = { "node", "--debug-agent" }; - Isolate* isolate = Isolate::New(); - { - Locker locker(isolate); - Isolate::Scope isolate_scope(isolate); - - HandleScope handle_scope(isolate); - Local context = Context::New(isolate); - - Context::Scope context_scope(context); - Environment* env = CreateEnvironment( - isolate, - &child_loop_, - context, - ARRAY_SIZE(argv), - argv, - ARRAY_SIZE(argv), - argv); - - child_env_ = env; - - // Expose API - InitAdaptor(env); - LoadEnvironment(env); - - CHECK_EQ(&child_loop_, env->event_loop()); - uv_run(&child_loop_, UV_RUN_DEFAULT); - - // Clean-up peristent - api_.Reset(); - - // Clean-up all running handles - env->CleanupHandles(); - - env->Dispose(); - env = NULL; - } - isolate->Dispose(); -} - - -void Agent::InitAdaptor(Environment* env) { - Isolate* isolate = env->isolate(); - HandleScope scope(isolate); - - // Create API adaptor - Local t = FunctionTemplate::New(isolate); - t->InstanceTemplate()->SetInternalFieldCount(1); - t->SetClassName(String::NewFromUtf8(isolate, "DebugAPI")); - - NODE_SET_PROTOTYPE_METHOD(t, "notifyListen", NotifyListen); - NODE_SET_PROTOTYPE_METHOD(t, "notifyWait", NotifyWait); - NODE_SET_PROTOTYPE_METHOD(t, "sendCommand", SendCommand); - - Local api = t->GetFunction()->NewInstance(); - api->SetAlignedPointerInInternalField(0, this); - - api->Set(String::NewFromUtf8(isolate, "port"), Integer::New(isolate, port_)); - - env->process_object()->Set(String::NewFromUtf8(isolate, "_debugAPI"), api); - api_.Reset(env->isolate(), api); -} - - -Agent* Agent::Unwrap(const v8::FunctionCallbackInfo& args) { - void* ptr = args.Holder()->GetAlignedPointerFromInternalField(0); - return reinterpret_cast(ptr); -} - - -void Agent::NotifyListen(const FunctionCallbackInfo& args) { - Agent* a = Unwrap(args); - - // Notify other thread that we are ready to process events - uv_sem_post(&a->start_sem_); -} - - -void Agent::NotifyWait(const FunctionCallbackInfo& args) { - Agent* a = Unwrap(args); - - a->wait_ = false; - - int err = uv_async_send(&a->child_signal_); - CHECK_EQ(err, 0); -} - - -void Agent::SendCommand(const FunctionCallbackInfo& args) { - Agent* a = Unwrap(args); - Environment* env = a->child_env(); - HandleScope scope(env->isolate()); - - String::Value v(args[0]); - - v8::Debug::SendCommand(a->parent_env()->isolate(), *v, v.length()); - if (a->dispatch_handler_ != NULL) - a->dispatch_handler_(a->parent_env()); -} - - -void Agent::ThreadCb(Agent* agent) { - agent->WorkerRun(); -} - - -void Agent::ChildSignalCb(uv_async_t* signal) { - Agent* a = ContainerOf(&Agent::child_signal_, signal); - Isolate* isolate = a->child_env()->isolate(); - - HandleScope scope(isolate); - Local api = PersistentToLocal(isolate, a->api_); - - uv_mutex_lock(&a->message_mutex_); - while (!QUEUE_EMPTY(&a->messages_)) { - QUEUE* q = QUEUE_HEAD(&a->messages_); - AgentMessage* msg = ContainerOf(&AgentMessage::member, q); - - // Time to close everything - if (msg->data() == NULL) { - QUEUE_REMOVE(q); - delete msg; - - MakeCallback(isolate, api, "onclose", 0, NULL); - break; - } - - // Waiting for client, do not send anything just yet - // TODO(indutny): move this to js-land - if (a->wait_) - break; - - QUEUE_REMOVE(q); - Local argv[] = { - String::NewFromTwoByte(isolate, - msg->data(), - String::kNormalString, - msg->length()) - }; - - // Emit message - MakeCallback(isolate, - api, - "onmessage", - ARRAY_SIZE(argv), - argv); - delete msg; - } - uv_mutex_unlock(&a->message_mutex_); -} - - -void Agent::EnqueueMessage(AgentMessage* message) { - uv_mutex_lock(&message_mutex_); - QUEUE_INSERT_TAIL(&messages_, &message->member); - uv_mutex_unlock(&message_mutex_); - uv_async_send(&child_signal_); -} - - -void Agent::MessageHandler(const v8::Debug::Message& message) { - Isolate* isolate = message.GetIsolate(); - Environment* env = Environment::GetCurrent(isolate); - Agent* a = env->debugger_agent(); - CHECK_NE(a, NULL); - CHECK_EQ(isolate, a->parent_env()->isolate()); - - HandleScope scope(isolate); - Local json = message.GetJSON(); - String::Value v(json); - - AgentMessage* msg = new AgentMessage(*v, v.length()); - a->EnqueueMessage(msg); -} - -} // namespace debugger -} // namespace node diff --git a/deps/debugger-agent/src/agent.h b/deps/debugger-agent/src/agent.h deleted file mode 100644 index 82db5e5e181d6a..00000000000000 --- a/deps/debugger-agent/src/agent.h +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright Fedor Indutny and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -#ifndef DEPS_DEBUGGER_AGENT_SRC_AGENT_H_ -#define DEPS_DEBUGGER_AGENT_SRC_AGENT_H_ - -#include "v8.h" -#include "v8-debug.h" -#include "queue.h" - -#include -#include - -namespace node { -namespace debugger { - -class AgentMessage { - public: - AgentMessage(uint16_t* val, int length) : length_(length) { - if (val == NULL) { - data_ = val; - } else { - data_ = new uint16_t[length]; - memcpy(data_, val, length * sizeof(*data_)); - } - } - - ~AgentMessage() { - delete[] data_; - data_ = NULL; - } - - inline const uint16_t* data() const { return data_; } - inline int length() const { return length_; } - - QUEUE member; - - private: - uint16_t* data_; - int length_; -}; - -} // namespace debugger -} // namespace node - -#endif // DEPS_DEBUGGER_AGENT_SRC_AGENT_H_ diff --git a/deps/openssl/asm/x64-win32-masm/aes/aesni-x86_64.asm b/deps/openssl/asm/x64-win32-masm/aes/aesni-x86_64.asm index 9d5a6260712165..e114c5eb1f5e59 100644 --- a/deps/openssl/asm/x64-win32-masm/aes/aesni-x86_64.asm +++ b/deps/openssl/asm/x64-win32-masm/aes/aesni-x86_64.asm @@ -454,6 +454,12 @@ $L$SEH_begin_aesni_ecb_encrypt:: mov r8,QWORD PTR[40+rsp] + lea rsp,QWORD PTR[((-88))+rsp] + movaps XMMWORD PTR[rsp],xmm6 + movaps XMMWORD PTR[16+rsp],xmm7 + movaps XMMWORD PTR[32+rsp],xmm8 + movaps XMMWORD PTR[48+rsp],xmm9 +$L$ecb_enc_body:: and rdx,-16 jz $L$ecb_ret @@ -752,6 +758,12 @@ $L$ecb_dec_six:: movups XMMWORD PTR[80+rsi],xmm7 $L$ecb_ret:: + movaps xmm6,XMMWORD PTR[rsp] + movaps xmm7,XMMWORD PTR[16+rsp] + movaps xmm8,XMMWORD PTR[32+rsp] + movaps xmm9,XMMWORD PTR[48+rsp] + lea rsp,QWORD PTR[88+rsp] +$L$ecb_enc_ret:: mov rdi,QWORD PTR[8+rsp] ;WIN64 epilogue mov rsi,QWORD PTR[16+rsp] DB 0F3h,0C3h ;repret @@ -2766,26 +2778,7 @@ ALIGN 64 EXTERN __imp_RtlVirtualUnwind:NEAR ALIGN 16 -ecb_se_handler PROC PRIVATE - push rsi - push rdi - push rbx - push rbp - push r12 - push r13 - push r14 - push r15 - pushfq - sub rsp,64 - - mov rax,QWORD PTR[152+r8] - - jmp $L$common_seh_tail -ecb_se_handler ENDP - - -ALIGN 16 -ccm64_se_handler PROC PRIVATE +ecb_ccm64_se_handler PROC PRIVATE push rsi push rdi push rbx @@ -2823,7 +2816,7 @@ ccm64_se_handler PROC PRIVATE lea rax,QWORD PTR[88+rax] jmp $L$common_seh_tail -ccm64_se_handler ENDP +ecb_ccm64_se_handler ENDP ALIGN 16 @@ -3026,15 +3019,17 @@ ALIGN 4 ALIGN 8 $L$SEH_info_ecb:: DB 9,0,0,0 - DD imagerel ecb_se_handler + DD imagerel ecb_ccm64_se_handler + DD imagerel $L$ecb_enc_body,imagerel $L$ecb_enc_ret + $L$SEH_info_ccm64_enc:: DB 9,0,0,0 - DD imagerel ccm64_se_handler + DD imagerel ecb_ccm64_se_handler DD imagerel $L$ccm64_enc_body,imagerel $L$ccm64_enc_ret $L$SEH_info_ccm64_dec:: DB 9,0,0,0 - DD imagerel ccm64_se_handler + DD imagerel ecb_ccm64_se_handler DD imagerel $L$ccm64_dec_body,imagerel $L$ccm64_dec_ret $L$SEH_info_ctr32:: diff --git a/deps/openssl/config/opensslconf.h b/deps/openssl/config/opensslconf.h index 9bf23692d64f4b..2e7732b926260d 100644 --- a/deps/openssl/config/opensslconf.h +++ b/deps/openssl/config/opensslconf.h @@ -190,10 +190,8 @@ * boundary. See crypto/rc4/rc4_enc.c for further details. */ # undef RC4_CHUNK -# if (defined(_M_X64) || defined(__x86_64__)) && defined(_WIN32) +# if defined(_M_X64) || defined(__x86_64__) # define RC4_CHUNK unsigned long long -# elif (defined(_M_X64) || defined(__x86_64__)) && !defined(_WIN32) -# define RC4_CHUNK unsigned long # elif defined(__arm__) # define RC4_CHUNK unsigned long # else @@ -205,21 +203,12 @@ /* If this is set to 'unsigned int' on a DEC Alpha, this gives about a * %20 speed up (longs are 8 bytes, int's are 4). */ # undef DES_LONG -# if defined(_M_X64) || defined(__x86_64__) || defined(__arm__) || defined(__mips__) -# define DES_LONG unsigned int -# elif defined(_M_IX86) || defined(__i386__) -# define DES_LONG unsigned long -# endif +# define DES_LONG unsigned int #endif #if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H) # define CONFIG_HEADER_BN_H -# undef BL_LLONG -# if defined(_M_IX86) || defined(__i386__) || defined(__arm__) -# define BL_LLONG -# endif - /* Should we define BN_DIV2W here? */ /* Only one for the following should be defined */ @@ -231,10 +220,12 @@ # undef THIRTY_TWO_BIT # undef SIXTEEN_BIT # undef EIGHT_BIT -# if (defined(_M_X64) || defined(__x86_64__)) && defined(_WIN32) -# define SIXTY_FOUR_BIT -# elif (defined(_M_X64) || defined(__x86_64__)) && !defined(_WIN32) -# define SIXTY_FOUR_BIT_LONG +# if defined(_M_X64) || defined(__x86_64__) +# if defined(_LP64) +# define SIXTY_FOUR_BIT_LONG +# else +# define SIXTY_FOUR_BIT +# endif # elif defined(_M_IX86) || defined(__i386__) || defined(__arm__) || defined(__mips__) # define THIRTY_TWO_BIT # endif diff --git a/deps/openssl/openssl/CHANGES b/deps/openssl/openssl/CHANGES index 064c1d9ded481d..277b46f17c0dcd 100644 --- a/deps/openssl/openssl/CHANGES +++ b/deps/openssl/openssl/CHANGES @@ -2,6 +2,57 @@ OpenSSL CHANGES _______________ + Changes between 1.0.1i and 1.0.1j [15 Oct 2014] + + *) SRTP Memory Leak. + + A flaw in the DTLS SRTP extension parsing code allows an attacker, who + sends a carefully crafted handshake message, to cause OpenSSL to fail + to free up to 64k of memory causing a memory leak. This could be + exploited in a Denial Of Service attack. This issue affects OpenSSL + 1.0.1 server implementations for both SSL/TLS and DTLS regardless of + whether SRTP is used or configured. Implementations of OpenSSL that + have been compiled with OPENSSL_NO_SRTP defined are not affected. + + The fix was developed by the OpenSSL team. + (CVE-2014-3513) + [OpenSSL team] + + *) Session Ticket Memory Leak. + + When an OpenSSL SSL/TLS/DTLS server receives a session ticket the + integrity of that ticket is first verified. In the event of a session + ticket integrity check failing, OpenSSL will fail to free memory + causing a memory leak. By sending a large number of invalid session + tickets an attacker could exploit this issue in a Denial Of Service + attack. + (CVE-2014-3567) + [Steve Henson] + + *) Build option no-ssl3 is incomplete. + + When OpenSSL is configured with "no-ssl3" as a build option, servers + could accept and complete a SSL 3.0 handshake, and clients could be + configured to send them. + (CVE-2014-3568) + [Akamai and the OpenSSL team] + + *) Add support for TLS_FALLBACK_SCSV. + Client applications doing fallback retries should call + SSL_set_mode(s, SSL_MODE_SEND_FALLBACK_SCSV). + (CVE-2014-3566) + [Adam Langley, Bodo Moeller] + + *) Add additional DigestInfo checks. + + Reencode DigestInto in DER and check against the original when + verifying RSA signature: this will reject any improperly encoded + DigestInfo structures. + + Note: this is a precautionary measure and no attacks are currently known. + + [Steve Henson] + Changes between 1.0.1h and 1.0.1i [6 Aug 2014] *) Fix SRP buffer overrun vulnerability. Invalid parameters passed to the diff --git a/deps/openssl/openssl/Configure b/deps/openssl/openssl/Configure index 36844b7b2f7a50..6f0da761b66644 100755 --- a/deps/openssl/openssl/Configure +++ b/deps/openssl/openssl/Configure @@ -1767,6 +1767,9 @@ open(OUT,'>crypto/opensslconf.h.new') || die "unable to create crypto/opensslcon print OUT "/* opensslconf.h */\n"; print OUT "/* WARNING: Generated automatically from opensslconf.h.in by Configure. */\n\n"; +print OUT "#ifdef __cplusplus\n"; +print OUT "extern \"C\" {\n"; +print OUT "#endif\n"; print OUT "/* OpenSSL was configured with the following options: */\n"; my $openssl_algorithm_defines_trans = $openssl_algorithm_defines; $openssl_experimental_defines =~ s/^\s*#\s*define\s+OPENSSL_NO_(.*)/#ifndef OPENSSL_EXPERIMENTAL_$1\n# ifndef OPENSSL_NO_$1\n# define OPENSSL_NO_$1\n# endif\n#endif/mg; @@ -1871,6 +1874,9 @@ while () { print OUT $_; } } close(IN); +print OUT "#ifdef __cplusplus\n"; +print OUT "}\n"; +print OUT "#endif\n"; close(OUT); rename("crypto/opensslconf.h","crypto/opensslconf.h.bak") || die "unable to rename crypto/opensslconf.h\n" if -e "crypto/opensslconf.h"; rename("crypto/opensslconf.h.new","crypto/opensslconf.h") || die "unable to rename crypto/opensslconf.h.new\n"; diff --git a/deps/openssl/openssl/Makefile b/deps/openssl/openssl/Makefile index 998c032004d9d4..d475c12d46944c 100644 --- a/deps/openssl/openssl/Makefile +++ b/deps/openssl/openssl/Makefile @@ -4,7 +4,7 @@ ## Makefile for OpenSSL ## -VERSION=1.0.1i +VERSION=1.0.1j MAJOR=1 MINOR=0.1 SHLIB_VERSION_NUMBER=1.0.0 diff --git a/deps/openssl/openssl/Makefile.bak b/deps/openssl/openssl/Makefile.bak index fecd36d3f0ef55..a90fb0854b2256 100644 --- a/deps/openssl/openssl/Makefile.bak +++ b/deps/openssl/openssl/Makefile.bak @@ -4,7 +4,7 @@ ## Makefile for OpenSSL ## -VERSION=1.0.1i-dev +VERSION=1.0.1j-dev MAJOR=1 MINOR=0.1 SHLIB_VERSION_NUMBER=1.0.0 diff --git a/deps/openssl/openssl/NEWS b/deps/openssl/openssl/NEWS index 8b2be4bb2474ed..512a667ff42416 100644 --- a/deps/openssl/openssl/NEWS +++ b/deps/openssl/openssl/NEWS @@ -5,6 +5,13 @@ This file gives a brief overview of the major changes between each OpenSSL release. For more details please read the CHANGES file. + Major changes between OpenSSL 1.0.1i and OpenSSL 1.0.1j [15 Oct 2014] + + o Fix for CVE-2014-3513 + o Fix for CVE-2014-3567 + o Mitigation for CVE-2014-3566 (SSL protocol vulnerability) + o Fix for CVE-2014-3568 + Major changes between OpenSSL 1.0.1h and OpenSSL 1.0.1i [6 Aug 2014] o Fix for CVE-2014-3512 diff --git a/deps/openssl/openssl/README b/deps/openssl/openssl/README index b2cf1ce1b49c7f..cb90c9f4028dc4 100644 --- a/deps/openssl/openssl/README +++ b/deps/openssl/openssl/README @@ -1,5 +1,5 @@ - OpenSSL 1.0.1i 6 Aug 2014 + OpenSSL 1.0.1j 15 Oct 2014 Copyright (c) 1998-2011 The OpenSSL Project Copyright (c) 1995-1998 Eric A. Young, Tim J. Hudson diff --git a/deps/openssl/openssl/apps/makeapps.com b/deps/openssl/openssl/apps/makeapps.com index efc213c8eed066..71a333674473c8 100644 --- a/deps/openssl/openssl/apps/makeapps.com +++ b/deps/openssl/openssl/apps/makeapps.com @@ -773,9 +773,12 @@ $ CCDEFS = "MONOLITH" $ IF F$TYPE(USER_CCDEFS) .NES. "" THEN CCDEFS = CCDEFS + "," + USER_CCDEFS $ CCEXTRAFLAGS = "" $ IF F$TYPE(USER_CCFLAGS) .NES. "" THEN CCEXTRAFLAGS = USER_CCFLAGS -$ CCDISABLEWARNINGS = "" !!! "LONGLONGTYPE,LONGLONGSUFX,FOUNDCR" -$ IF F$TYPE(USER_CCDISABLEWARNINGS) .NES. "" THEN - - CCDISABLEWARNINGS = CCDISABLEWARNINGS + "," + USER_CCDISABLEWARNINGS +$ CCDISABLEWARNINGS = "" !!! "MAYLOSEDATA3" !!! "LONGLONGTYPE,LONGLONGSUFX,FOUNDCR" +$ IF F$TYPE(USER_CCDISABLEWARNINGS) .NES. "" +$ THEN +$ IF CCDISABLEWARNINGS .NES. "" THEN CCDISABLEWARNINGS = CCDISABLEWARNINGS + "," +$ CCDISABLEWARNINGS = CCDISABLEWARNINGS + USER_CCDISABLEWARNINGS +$ ENDIF $! $! Check To See If We Have A ZLIB Option. $! @@ -1064,6 +1067,18 @@ $! Finish up the definition of CC. $! $ IF COMPILER .EQS. "DECC" $ THEN +$! Not all compiler versions support MAYLOSEDATA3. +$ OPT_TEST = "MAYLOSEDATA3" +$ DEFINE /USER_MODE SYS$ERROR NL: +$ DEFINE /USER_MODE SYS$OUTPUT NL: +$ 'CC' /NOCROSS_REFERENCE /NOLIST /NOOBJECT - + /WARNINGS = DISABLE = ('OPT_TEST', EMPTYFILE) NL: +$ IF ($SEVERITY) +$ THEN +$ IF CCDISABLEWARNINGS .NES. "" THEN - + CCDISABLEWARNINGS = CCDISABLEWARNINGS+ "," +$ CCDISABLEWARNINGS = CCDISABLEWARNINGS+ OPT_TEST +$ ENDIF $ IF CCDISABLEWARNINGS .NES. "" $ THEN $ CCDISABLEWARNINGS = " /WARNING=(DISABLE=(" + CCDISABLEWARNINGS + "))" diff --git a/deps/openssl/openssl/apps/s_client.c b/deps/openssl/openssl/apps/s_client.c index 973e58e160ab1a..61ba7205718217 100644 --- a/deps/openssl/openssl/apps/s_client.c +++ b/deps/openssl/openssl/apps/s_client.c @@ -344,6 +344,7 @@ static void sc_usage(void) BIO_printf(bio_err," -tls1_1 - just use TLSv1.1\n"); BIO_printf(bio_err," -tls1 - just use TLSv1\n"); BIO_printf(bio_err," -dtls1 - just use DTLSv1\n"); + BIO_printf(bio_err," -fallback_scsv - send TLS_FALLBACK_SCSV\n"); BIO_printf(bio_err," -mtu - set the link layer MTU\n"); BIO_printf(bio_err," -no_tls1_2/-no_tls1_1/-no_tls1/-no_ssl3/-no_ssl2 - turn off that protocol\n"); BIO_printf(bio_err," -bugs - Switch on all SSL implementation bug workarounds\n"); @@ -624,6 +625,7 @@ int MAIN(int argc, char **argv) char *sess_out = NULL; struct sockaddr peer; int peerlen = sizeof(peer); + int fallback_scsv = 0; int enable_timeouts = 0 ; long socket_mtu = 0; #ifndef OPENSSL_NO_JPAKE @@ -830,6 +832,10 @@ int MAIN(int argc, char **argv) meth=DTLSv1_client_method(); socket_type=SOCK_DGRAM; } + else if (strcmp(*argv,"-fallback_scsv") == 0) + { + fallback_scsv = 1; + } else if (strcmp(*argv,"-timeout") == 0) enable_timeouts=1; else if (strcmp(*argv,"-mtu") == 0) @@ -1242,6 +1248,10 @@ int MAIN(int argc, char **argv) SSL_set_session(con, sess); SSL_SESSION_free(sess); } + + if (fallback_scsv) + SSL_set_mode(con, SSL_MODE_SEND_FALLBACK_SCSV); + #ifndef OPENSSL_NO_TLSEXT if (servername != NULL) { diff --git a/deps/openssl/openssl/crypto/LPdir_vms.c b/deps/openssl/openssl/crypto/LPdir_vms.c index 7613bd254e7cfb..3582fa6f01c86e 100644 --- a/deps/openssl/openssl/crypto/LPdir_vms.c +++ b/deps/openssl/openssl/crypto/LPdir_vms.c @@ -1,4 +1,3 @@ -/* $LP: LPlib/source/LPdir_vms.c,v 1.20 2004/08/26 13:36:05 _cvs_levitte Exp $ */ /* * Copyright (c) 2004, Richard Levitte * All rights reserved. @@ -88,6 +87,12 @@ const char *LP_find_file(LP_DIR_CTX **ctx, const char *directory) size_t filespeclen = strlen(directory); char *filespec = NULL; + if (filespeclen == 0) + { + errno = ENOENT; + return 0; + } + /* MUST be a VMS directory specification! Let's estimate if it is. */ if (directory[filespeclen-1] != ']' && directory[filespeclen-1] != '>' diff --git a/deps/openssl/openssl/crypto/LPdir_win.c b/deps/openssl/openssl/crypto/LPdir_win.c index 702dbc730f62ff..d5b5e2c900db9e 100644 --- a/deps/openssl/openssl/crypto/LPdir_win.c +++ b/deps/openssl/openssl/crypto/LPdir_win.c @@ -1,4 +1,3 @@ -/* $LP: LPlib/source/LPdir_win.c,v 1.10 2004/08/26 13:36:05 _cvs_levitte Exp $ */ /* * Copyright (c) 2004, Richard Levitte * All rights reserved. @@ -63,6 +62,16 @@ const char *LP_find_file(LP_DIR_CTX **ctx, const char *directory) errno = 0; if (*ctx == NULL) { + const char *extdir = directory; + char *extdirbuf = NULL; + size_t dirlen = strlen (directory); + + if (dirlen == 0) + { + errno = ENOENT; + return 0; + } + *ctx = (LP_DIR_CTX *)malloc(sizeof(LP_DIR_CTX)); if (*ctx == NULL) { @@ -71,15 +80,35 @@ const char *LP_find_file(LP_DIR_CTX **ctx, const char *directory) } memset(*ctx, '\0', sizeof(LP_DIR_CTX)); + if (directory[dirlen-1] != '*') + { + extdirbuf = (char *)malloc(dirlen + 3); + if (extdirbuf == NULL) + { + free(*ctx); + *ctx = NULL; + errno = ENOMEM; + return 0; + } + if (directory[dirlen-1] != '/' && directory[dirlen-1] != '\\') + extdir = strcat(strcpy (extdirbuf,directory),"/*"); + else + extdir = strcat(strcpy (extdirbuf,directory),"*"); + } + if (sizeof(TCHAR) != sizeof(char)) { TCHAR *wdir = NULL; /* len_0 denotes string length *with* trailing 0 */ - size_t index = 0,len_0 = strlen(directory) + 1; + size_t index = 0,len_0 = strlen(extdir) + 1; - wdir = (TCHAR *)malloc(len_0 * sizeof(TCHAR)); + wdir = (TCHAR *)calloc(len_0, sizeof(TCHAR)); if (wdir == NULL) { + if (extdirbuf != NULL) + { + free (extdirbuf); + } free(*ctx); *ctx = NULL; errno = ENOMEM; @@ -87,17 +116,23 @@ const char *LP_find_file(LP_DIR_CTX **ctx, const char *directory) } #ifdef LP_MULTIBYTE_AVAILABLE - if (!MultiByteToWideChar(CP_ACP, 0, directory, len_0, (WCHAR *)wdir, len_0)) + if (!MultiByteToWideChar(CP_ACP, 0, extdir, len_0, (WCHAR *)wdir, len_0)) #endif for (index = 0; index < len_0; index++) - wdir[index] = (TCHAR)directory[index]; + wdir[index] = (TCHAR)extdir[index]; (*ctx)->handle = FindFirstFile(wdir, &(*ctx)->ctx); free(wdir); } else - (*ctx)->handle = FindFirstFile((TCHAR *)directory, &(*ctx)->ctx); + { + (*ctx)->handle = FindFirstFile((TCHAR *)extdir, &(*ctx)->ctx); + } + if (extdirbuf != NULL) + { + free (extdirbuf); + } if ((*ctx)->handle == INVALID_HANDLE_VALUE) { @@ -114,7 +149,6 @@ const char *LP_find_file(LP_DIR_CTX **ctx, const char *directory) return 0; } } - if (sizeof(TCHAR) != sizeof(char)) { TCHAR *wdir = (*ctx)->ctx.cFileName; diff --git a/deps/openssl/openssl/crypto/Makefile b/deps/openssl/openssl/crypto/Makefile index a90809b2b83333..ee5bfbda82bcec 100644 --- a/deps/openssl/openssl/crypto/Makefile +++ b/deps/openssl/openssl/crypto/Makefile @@ -31,6 +31,7 @@ CPUID_OBJ=mem_clr.o LIBS= GENERAL=Makefile README crypto-lib.com install.com +TEST=constant_time_test.c LIB= $(TOP)/libcrypto.a SHARED_LIB= libcrypto$(SHLIB_EXT) @@ -43,7 +44,8 @@ SRC= $(LIBSRC) EXHEADER= crypto.h opensslv.h opensslconf.h ebcdic.h symhacks.h \ ossl_typ.h -HEADER= cryptlib.h buildinf.h md32_common.h o_time.h o_str.h o_dir.h $(EXHEADER) +HEADER= cryptlib.h buildinf.h md32_common.h o_time.h o_str.h o_dir.h \ + constant_time_locl.h $(EXHEADER) ALL= $(GENERAL) $(SRC) $(HEADER) diff --git a/deps/openssl/openssl/crypto/aes/asm/aesni-x86_64.pl b/deps/openssl/openssl/crypto/aes/asm/aesni-x86_64.pl index 0dbb194b8d7489..c9270dfddc182d 100644 --- a/deps/openssl/openssl/crypto/aes/asm/aesni-x86_64.pl +++ b/deps/openssl/openssl/crypto/aes/asm/aesni-x86_64.pl @@ -525,6 +525,16 @@ sub aesni_generate8 { .type aesni_ecb_encrypt,\@function,5 .align 16 aesni_ecb_encrypt: +___ +$code.=<<___ if ($win64); + lea -0x58(%rsp),%rsp + movaps %xmm6,(%rsp) + movaps %xmm7,0x10(%rsp) + movaps %xmm8,0x20(%rsp) + movaps %xmm9,0x30(%rsp) +.Lecb_enc_body: +___ +$code.=<<___; and \$-16,$len jz .Lecb_ret @@ -805,6 +815,16 @@ sub aesni_generate8 { movups $inout5,0x50($out) .Lecb_ret: +___ +$code.=<<___ if ($win64); + movaps (%rsp),%xmm6 + movaps 0x10(%rsp),%xmm7 + movaps 0x20(%rsp),%xmm8 + movaps 0x30(%rsp),%xmm9 + lea 0x58(%rsp),%rsp +.Lecb_enc_ret: +___ +$code.=<<___; ret .size aesni_ecb_encrypt,.-aesni_ecb_encrypt ___ @@ -2730,28 +2750,9 @@ sub aesni_generate8 { .extern __imp_RtlVirtualUnwind ___ $code.=<<___ if ($PREFIX eq "aesni"); -.type ecb_se_handler,\@abi-omnipotent -.align 16 -ecb_se_handler: - push %rsi - push %rdi - push %rbx - push %rbp - push %r12 - push %r13 - push %r14 - push %r15 - pushfq - sub \$64,%rsp - - mov 152($context),%rax # pull context->Rsp - - jmp .Lcommon_seh_tail -.size ecb_se_handler,.-ecb_se_handler - -.type ccm64_se_handler,\@abi-omnipotent +.type ecb_ccm64_se_handler,\@abi-omnipotent .align 16 -ccm64_se_handler: +ecb_ccm64_se_handler: push %rsi push %rdi push %rbx @@ -2788,7 +2789,7 @@ sub aesni_generate8 { lea 0x58(%rax),%rax # adjust stack pointer jmp .Lcommon_seh_tail -.size ccm64_se_handler,.-ccm64_se_handler +.size ecb_ccm64_se_handler,.-ecb_ccm64_se_handler .type ctr32_se_handler,\@abi-omnipotent .align 16 @@ -2993,14 +2994,15 @@ sub aesni_generate8 { $code.=<<___ if ($PREFIX eq "aesni"); .LSEH_info_ecb: .byte 9,0,0,0 - .rva ecb_se_handler + .rva ecb_ccm64_se_handler + .rva .Lecb_enc_body,.Lecb_enc_ret # HandlerData[] .LSEH_info_ccm64_enc: .byte 9,0,0,0 - .rva ccm64_se_handler + .rva ecb_ccm64_se_handler .rva .Lccm64_enc_body,.Lccm64_enc_ret # HandlerData[] .LSEH_info_ccm64_dec: .byte 9,0,0,0 - .rva ccm64_se_handler + .rva ecb_ccm64_se_handler .rva .Lccm64_dec_body,.Lccm64_dec_ret # HandlerData[] .LSEH_info_ctr32: .byte 9,0,0,0 diff --git a/deps/openssl/openssl/crypto/asn1/a_strex.c b/deps/openssl/openssl/crypto/asn1/a_strex.c index ead37ac32582cd..8fb4193bc0b299 100644 --- a/deps/openssl/openssl/crypto/asn1/a_strex.c +++ b/deps/openssl/openssl/crypto/asn1/a_strex.c @@ -568,6 +568,7 @@ int ASN1_STRING_to_UTF8(unsigned char **out, ASN1_STRING *in) mbflag |= MBSTRING_FLAG; stmp.data = NULL; stmp.length = 0; + stmp.flags = 0; ret = ASN1_mbstring_copy(&str, in->data, in->length, mbflag, B_ASN1_UTF8STRING); if(ret < 0) return ret; *out = stmp.data; diff --git a/deps/openssl/openssl/crypto/bn/asm/x86_64-gcc.c b/deps/openssl/openssl/crypto/bn/asm/x86_64-gcc.c index acb0b401181e32..31476abebfb79b 100644 --- a/deps/openssl/openssl/crypto/bn/asm/x86_64-gcc.c +++ b/deps/openssl/openssl/crypto/bn/asm/x86_64-gcc.c @@ -189,7 +189,7 @@ BN_ULONG bn_add_words (BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,int if (n <= 0) return 0; - asm ( + asm volatile ( " subq %2,%2 \n" ".p2align 4 \n" "1: movq (%4,%2,8),%0 \n" @@ -200,7 +200,7 @@ BN_ULONG bn_add_words (BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,int " sbbq %0,%0 \n" : "=&a"(ret),"+c"(n),"=&r"(i) : "r"(rp),"r"(ap),"r"(bp) - : "cc" + : "cc", "memory" ); return ret&1; @@ -212,7 +212,7 @@ BN_ULONG bn_sub_words (BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,int if (n <= 0) return 0; - asm ( + asm volatile ( " subq %2,%2 \n" ".p2align 4 \n" "1: movq (%4,%2,8),%0 \n" @@ -223,7 +223,7 @@ BN_ULONG bn_sub_words (BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,int " sbbq %0,%0 \n" : "=&a"(ret),"+c"(n),"=&r"(i) : "r"(rp),"r"(ap),"r"(bp) - : "cc" + : "cc", "memory" ); return ret&1; diff --git a/deps/openssl/openssl/crypto/bn/bn_exp.c b/deps/openssl/openssl/crypto/bn/bn_exp.c index 5e7eb3373ffd17..611fa3262bed91 100644 --- a/deps/openssl/openssl/crypto/bn/bn_exp.c +++ b/deps/openssl/openssl/crypto/bn/bn_exp.c @@ -874,7 +874,14 @@ int BN_mod_exp_mont_word(BIGNUM *rr, BN_ULONG a, const BIGNUM *p, bits = BN_num_bits(p); if (bits == 0) { - ret = BN_one(rr); + /* x**0 mod 1 is still zero. */ + if (BN_is_one(m)) + { + ret = 1; + BN_zero(rr); + } + else + ret = BN_one(rr); return ret; } if (a == 0) diff --git a/deps/openssl/openssl/crypto/bn/bn_nist.c b/deps/openssl/openssl/crypto/bn/bn_nist.c index e22968d4a33bd3..abb1570853ec2c 100644 --- a/deps/openssl/openssl/crypto/bn/bn_nist.c +++ b/deps/openssl/openssl/crypto/bn/bn_nist.c @@ -1088,9 +1088,9 @@ int BN_nist_mod_521(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, /* ... and right shift */ for (val=t_d[0],i=0; i>BN_NIST_521_RSHIFT; - val = t_d[i+1]; - t_d[i] = (tmp | val<>BN_NIST_521_RSHIFT | + (tmp=t_d[i+1])<>BN_NIST_521_RSHIFT; /* lower 521 bits */ diff --git a/deps/openssl/openssl/crypto/bn/exptest.c b/deps/openssl/openssl/crypto/bn/exptest.c index 074a8e882a8eb5..5fa02a1229e88c 100644 --- a/deps/openssl/openssl/crypto/bn/exptest.c +++ b/deps/openssl/openssl/crypto/bn/exptest.c @@ -71,6 +71,43 @@ static const char rnd_seed[] = "string to make the random number generator think it has entropy"; +/* test_exp_mod_zero tests that x**0 mod 1 == 0. It returns zero on success. */ +static int test_exp_mod_zero() { + BIGNUM a, p, m; + BIGNUM r; + BN_CTX *ctx = BN_CTX_new(); + int ret = 1; + + BN_init(&m); + BN_one(&m); + + BN_init(&a); + BN_one(&a); + + BN_init(&p); + BN_zero(&p); + + BN_init(&r); + BN_mod_exp(&r, &a, &p, &m, ctx); + BN_CTX_free(ctx); + + if (BN_is_zero(&r)) + ret = 0; + else + { + printf("1**0 mod 1 = "); + BN_print_fp(stdout, &r); + printf(", should be 0\n"); + } + + BN_free(&r); + BN_free(&a); + BN_free(&p); + BN_free(&m); + + return ret; +} + int main(int argc, char *argv[]) { BN_CTX *ctx; @@ -190,7 +227,13 @@ int main(int argc, char *argv[]) ERR_remove_thread_state(NULL); CRYPTO_mem_leaks(out); BIO_free(out); - printf(" done\n"); + printf("\n"); + + if (test_exp_mod_zero() != 0) + goto err; + + printf("done\n"); + EXIT(0); err: ERR_load_crypto_strings(); diff --git a/deps/openssl/openssl/crypto/constant_time_locl.h b/deps/openssl/openssl/crypto/constant_time_locl.h new file mode 100644 index 00000000000000..c0483939fe3dbb --- /dev/null +++ b/deps/openssl/openssl/crypto/constant_time_locl.h @@ -0,0 +1,216 @@ +/* crypto/constant_time_locl.h */ +/* + * Utilities for constant-time cryptography. + * + * Author: Emilia Kasper (emilia@openssl.org) + * Based on previous work by Bodo Moeller, Emilia Kasper, Adam Langley + * (Google). + * ==================================================================== + * Copyright (c) 2014 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_CONSTANT_TIME_LOCL_H +#define HEADER_CONSTANT_TIME_LOCL_H + +#include "e_os.h" /* For 'inline' */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The boolean methods return a bitmask of all ones (0xff...f) for true + * and 0 for false. This is useful for choosing a value based on the result + * of a conditional in constant time. For example, + * + * if (a < b) { + * c = a; + * } else { + * c = b; + * } + * + * can be written as + * + * unsigned int lt = constant_time_lt(a, b); + * c = constant_time_select(lt, a, b); + */ + +/* + * Returns the given value with the MSB copied to all the other + * bits. Uses the fact that arithmetic shift shifts-in the sign bit. + * However, this is not ensured by the C standard so you may need to + * replace this with something else on odd CPUs. + */ +static inline unsigned int constant_time_msb(unsigned int a); + +/* + * Returns 0xff..f if a < b and 0 otherwise. + */ +static inline unsigned int constant_time_lt(unsigned int a, unsigned int b); +/* Convenience method for getting an 8-bit mask. */ +static inline unsigned char constant_time_lt_8(unsigned int a, unsigned int b); + +/* + * Returns 0xff..f if a >= b and 0 otherwise. + */ +static inline unsigned int constant_time_ge(unsigned int a, unsigned int b); +/* Convenience method for getting an 8-bit mask. */ +static inline unsigned char constant_time_ge_8(unsigned int a, unsigned int b); + +/* + * Returns 0xff..f if a == 0 and 0 otherwise. + */ +static inline unsigned int constant_time_is_zero(unsigned int a); +/* Convenience method for getting an 8-bit mask. */ +static inline unsigned char constant_time_is_zero_8(unsigned int a); + + +/* + * Returns 0xff..f if a == b and 0 otherwise. + */ +static inline unsigned int constant_time_eq(unsigned int a, unsigned int b); +/* Convenience method for getting an 8-bit mask. */ +static inline unsigned char constant_time_eq_8(unsigned int a, unsigned int b); +/* Signed integers. */ +static inline unsigned int constant_time_eq_int(int a, int b); +/* Convenience method for getting an 8-bit mask. */ +static inline unsigned char constant_time_eq_int_8(int a, int b); + + +/* + * Returns (mask & a) | (~mask & b). + * + * When |mask| is all 1s or all 0s (as returned by the methods above), + * the select methods return either |a| (if |mask| is nonzero) or |b| + * (if |mask| is zero). + */ +static inline unsigned int constant_time_select(unsigned int mask, + unsigned int a, unsigned int b); +/* Convenience method for unsigned chars. */ +static inline unsigned char constant_time_select_8(unsigned char mask, + unsigned char a, unsigned char b); +/* Convenience method for signed integers. */ +static inline int constant_time_select_int(unsigned int mask, int a, int b); + +static inline unsigned int constant_time_msb(unsigned int a) + { + return (unsigned int)((int)(a) >> (sizeof(int) * 8 - 1)); + } + +static inline unsigned int constant_time_lt(unsigned int a, unsigned int b) + { + unsigned int lt; + /* Case 1: msb(a) == msb(b). a < b iff the MSB of a - b is set.*/ + lt = ~(a ^ b) & (a - b); + /* Case 2: msb(a) != msb(b). a < b iff the MSB of b is set. */ + lt |= ~a & b; + return constant_time_msb(lt); + } + +static inline unsigned char constant_time_lt_8(unsigned int a, unsigned int b) + { + return (unsigned char)(constant_time_lt(a, b)); + } + +static inline unsigned int constant_time_ge(unsigned int a, unsigned int b) + { + unsigned int ge; + /* Case 1: msb(a) == msb(b). a >= b iff the MSB of a - b is not set.*/ + ge = ~((a ^ b) | (a - b)); + /* Case 2: msb(a) != msb(b). a >= b iff the MSB of a is set. */ + ge |= a & ~b; + return constant_time_msb(ge); + } + +static inline unsigned char constant_time_ge_8(unsigned int a, unsigned int b) + { + return (unsigned char)(constant_time_ge(a, b)); + } + +static inline unsigned int constant_time_is_zero(unsigned int a) + { + return constant_time_msb(~a & (a - 1)); + } + +static inline unsigned char constant_time_is_zero_8(unsigned int a) + { + return (unsigned char)(constant_time_is_zero(a)); + } + +static inline unsigned int constant_time_eq(unsigned int a, unsigned int b) + { + return constant_time_is_zero(a ^ b); + } + +static inline unsigned char constant_time_eq_8(unsigned int a, unsigned int b) + { + return (unsigned char)(constant_time_eq(a, b)); + } + +static inline unsigned int constant_time_eq_int(int a, int b) + { + return constant_time_eq((unsigned)(a), (unsigned)(b)); + } + +static inline unsigned char constant_time_eq_int_8(int a, int b) + { + return constant_time_eq_8((unsigned)(a), (unsigned)(b)); + } + +static inline unsigned int constant_time_select(unsigned int mask, + unsigned int a, unsigned int b) + { + return (mask & a) | (~mask & b); + } + +static inline unsigned char constant_time_select_8(unsigned char mask, + unsigned char a, unsigned char b) + { + return (unsigned char)(constant_time_select(mask, a, b)); + } + +inline int constant_time_select_int(unsigned int mask, int a, int b) + { + return (int)(constant_time_select(mask, (unsigned)(a), (unsigned)(b))); + } + +#ifdef __cplusplus +} +#endif + +#endif /* HEADER_CONSTANT_TIME_LOCL_H */ diff --git a/deps/openssl/openssl/crypto/constant_time_test.c b/deps/openssl/openssl/crypto/constant_time_test.c new file mode 100644 index 00000000000000..d9c6a44aed055d --- /dev/null +++ b/deps/openssl/openssl/crypto/constant_time_test.c @@ -0,0 +1,330 @@ +/* crypto/constant_time_test.c */ +/* + * Utilities for constant-time cryptography. + * + * Author: Emilia Kasper (emilia@openssl.org) + * Based on previous work by Bodo Moeller, Emilia Kasper, Adam Langley + * (Google). + * ==================================================================== + * Copyright (c) 2014 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include "../crypto/constant_time_locl.h" + +#include +#include +#include + +static const unsigned int CONSTTIME_TRUE = (unsigned)(~0); +static const unsigned int CONSTTIME_FALSE = 0; +static const unsigned char CONSTTIME_TRUE_8 = 0xff; +static const unsigned char CONSTTIME_FALSE_8 = 0; + +static int test_binary_op(unsigned int (*op)(unsigned int a, unsigned int b), + const char* op_name, unsigned int a, unsigned int b, int is_true) + { + unsigned c = op(a, b); + if (is_true && c != CONSTTIME_TRUE) + { + fprintf(stderr, "Test failed for %s(%du, %du): expected %du " + "(TRUE), got %du\n", op_name, a, b, CONSTTIME_TRUE, c); + return 1; + } + else if (!is_true && c != CONSTTIME_FALSE) + { + fprintf(stderr, "Test failed for %s(%du, %du): expected %du " + "(FALSE), got %du\n", op_name, a, b, CONSTTIME_FALSE, + c); + return 1; + } + return 0; + } + +static int test_binary_op_8(unsigned char (*op)(unsigned int a, unsigned int b), + const char* op_name, unsigned int a, unsigned int b, int is_true) + { + unsigned char c = op(a, b); + if (is_true && c != CONSTTIME_TRUE_8) + { + fprintf(stderr, "Test failed for %s(%du, %du): expected %u " + "(TRUE), got %u\n", op_name, a, b, CONSTTIME_TRUE_8, c); + return 1; + } + else if (!is_true && c != CONSTTIME_FALSE_8) + { + fprintf(stderr, "Test failed for %s(%du, %du): expected %u " + "(FALSE), got %u\n", op_name, a, b, CONSTTIME_FALSE_8, + c); + return 1; + } + return 0; + } + +static int test_is_zero(unsigned int a) + { + unsigned int c = constant_time_is_zero(a); + if (a == 0 && c != CONSTTIME_TRUE) + { + fprintf(stderr, "Test failed for constant_time_is_zero(%du): " + "expected %du (TRUE), got %du\n", a, CONSTTIME_TRUE, c); + return 1; + } + else if (a != 0 && c != CONSTTIME_FALSE) + { + fprintf(stderr, "Test failed for constant_time_is_zero(%du): " + "expected %du (FALSE), got %du\n", a, CONSTTIME_FALSE, + c); + return 1; + } + return 0; + } + +static int test_is_zero_8(unsigned int a) + { + unsigned char c = constant_time_is_zero_8(a); + if (a == 0 && c != CONSTTIME_TRUE_8) + { + fprintf(stderr, "Test failed for constant_time_is_zero(%du): " + "expected %u (TRUE), got %u\n", a, CONSTTIME_TRUE_8, c); + return 1; + } + else if (a != 0 && c != CONSTTIME_FALSE) + { + fprintf(stderr, "Test failed for constant_time_is_zero(%du): " + "expected %u (FALSE), got %u\n", a, CONSTTIME_FALSE_8, + c); + return 1; + } + return 0; + } + +static int test_select(unsigned int a, unsigned int b) + { + unsigned int selected = constant_time_select(CONSTTIME_TRUE, a, b); + if (selected != a) + { + fprintf(stderr, "Test failed for constant_time_select(%du, %du," + "%du): expected %du(first value), got %du\n", + CONSTTIME_TRUE, a, b, a, selected); + return 1; + } + selected = constant_time_select(CONSTTIME_FALSE, a, b); + if (selected != b) + { + fprintf(stderr, "Test failed for constant_time_select(%du, %du," + "%du): expected %du(second value), got %du\n", + CONSTTIME_FALSE, a, b, b, selected); + return 1; + } + return 0; + } + +static int test_select_8(unsigned char a, unsigned char b) + { + unsigned char selected = constant_time_select_8(CONSTTIME_TRUE_8, a, b); + if (selected != a) + { + fprintf(stderr, "Test failed for constant_time_select(%u, %u," + "%u): expected %u(first value), got %u\n", + CONSTTIME_TRUE, a, b, a, selected); + return 1; + } + selected = constant_time_select_8(CONSTTIME_FALSE_8, a, b); + if (selected != b) + { + fprintf(stderr, "Test failed for constant_time_select(%u, %u," + "%u): expected %u(second value), got %u\n", + CONSTTIME_FALSE, a, b, b, selected); + return 1; + } + return 0; + } + +static int test_select_int(int a, int b) + { + int selected = constant_time_select_int(CONSTTIME_TRUE, a, b); + if (selected != a) + { + fprintf(stderr, "Test failed for constant_time_select(%du, %d," + "%d): expected %d(first value), got %d\n", + CONSTTIME_TRUE, a, b, a, selected); + return 1; + } + selected = constant_time_select_int(CONSTTIME_FALSE, a, b); + if (selected != b) + { + fprintf(stderr, "Test failed for constant_time_select(%du, %d," + "%d): expected %d(second value), got %d\n", + CONSTTIME_FALSE, a, b, b, selected); + return 1; + } + return 0; + } + +static int test_eq_int(int a, int b) + { + unsigned int equal = constant_time_eq_int(a, b); + if (a == b && equal != CONSTTIME_TRUE) + { + fprintf(stderr, "Test failed for constant_time_eq_int(%d, %d): " + "expected %du(TRUE), got %du\n", + a, b, CONSTTIME_TRUE, equal); + return 1; + } + else if (a != b && equal != CONSTTIME_FALSE) + { + fprintf(stderr, "Test failed for constant_time_eq_int(%d, %d): " + "expected %du(FALSE), got %du\n", + a, b, CONSTTIME_FALSE, equal); + return 1; + } + return 0; + } + +static int test_eq_int_8(int a, int b) + { + unsigned char equal = constant_time_eq_int_8(a, b); + if (a == b && equal != CONSTTIME_TRUE_8) + { + fprintf(stderr, "Test failed for constant_time_eq_int_8(%d, %d): " + "expected %u(TRUE), got %u\n", + a, b, CONSTTIME_TRUE_8, equal); + return 1; + } + else if (a != b && equal != CONSTTIME_FALSE_8) + { + fprintf(stderr, "Test failed for constant_time_eq_int_8(%d, %d): " + "expected %u(FALSE), got %u\n", + a, b, CONSTTIME_FALSE_8, equal); + return 1; + } + return 0; + } + +static unsigned int test_values[] = {0, 1, 1024, 12345, 32000, UINT_MAX/2-1, + UINT_MAX/2, UINT_MAX/2+1, UINT_MAX-1, + UINT_MAX}; + +static unsigned char test_values_8[] = {0, 1, 2, 20, 32, 127, 128, 129, 255}; + +static int signed_test_values[] = {0, 1, -1, 1024, -1024, 12345, -12345, + 32000, -32000, INT_MAX, INT_MIN, INT_MAX-1, + INT_MIN+1}; + + +int main(int argc, char *argv[]) + { + unsigned int a, b, i, j; + int c, d; + unsigned char e, f; + int num_failed = 0, num_all = 0; + fprintf(stdout, "Testing constant time operations...\n"); + + for (i = 0; i < sizeof(test_values)/sizeof(int); ++i) + { + a = test_values[i]; + num_failed += test_is_zero(a); + num_failed += test_is_zero_8(a); + num_all += 2; + for (j = 0; j < sizeof(test_values)/sizeof(int); ++j) + { + b = test_values[j]; + num_failed += test_binary_op(&constant_time_lt, + "constant_time_lt", a, b, a < b); + num_failed += test_binary_op_8(&constant_time_lt_8, + "constant_time_lt_8", a, b, a < b); + num_failed += test_binary_op(&constant_time_lt, + "constant_time_lt_8", b, a, b < a); + num_failed += test_binary_op_8(&constant_time_lt_8, + "constant_time_lt_8", b, a, b < a); + num_failed += test_binary_op(&constant_time_ge, + "constant_time_ge", a, b, a >= b); + num_failed += test_binary_op_8(&constant_time_ge_8, + "constant_time_ge_8", a, b, a >= b); + num_failed += test_binary_op(&constant_time_ge, + "constant_time_ge", b, a, b >= a); + num_failed += test_binary_op_8(&constant_time_ge_8, + "constant_time_ge_8", b, a, b >= a); + num_failed += test_binary_op(&constant_time_eq, + "constant_time_eq", a, b, a == b); + num_failed += test_binary_op_8(&constant_time_eq_8, + "constant_time_eq_8", a, b, a == b); + num_failed += test_binary_op(&constant_time_eq, + "constant_time_eq", b, a, b == a); + num_failed += test_binary_op_8(&constant_time_eq_8, + "constant_time_eq_8", b, a, b == a); + num_failed += test_select(a, b); + num_all += 13; + } + } + + for (i = 0; i < sizeof(signed_test_values)/sizeof(int); ++i) + { + c = signed_test_values[i]; + for (j = 0; j < sizeof(signed_test_values)/sizeof(int); ++j) + { + d = signed_test_values[j]; + num_failed += test_select_int(c, d); + num_failed += test_eq_int(c, d); + num_failed += test_eq_int_8(c, d); + num_all += 3; + } + } + + for (i = 0; i < sizeof(test_values_8); ++i) + { + e = test_values_8[i]; + for (j = 0; j < sizeof(test_values_8); ++j) + { + f = test_values_8[j]; + num_failed += test_select_8(e, f); + num_all += 1; + } + } + + if (!num_failed) + { + fprintf(stdout, "ok (ran %d tests)\n", num_all); + return EXIT_SUCCESS; + } + else + { + fprintf(stdout, "%d of %d tests failed!\n", num_failed, num_all); + return EXIT_FAILURE; + } + } diff --git a/deps/openssl/openssl/crypto/crypto-lib.com b/deps/openssl/openssl/crypto/crypto-lib.com index dc8a8c174c1304..a136f4b0b64b94 100644 --- a/deps/openssl/openssl/crypto/crypto-lib.com +++ b/deps/openssl/openssl/crypto/crypto-lib.com @@ -111,8 +111,8 @@ $ ET_WHIRLPOOL = "WHRLPOOL" $ IF ARCH .EQS. "VAX" THEN ET_WHIRLPOOL = "" $ ENCRYPT_TYPES = "Basic,"+ - "OBJECTS,"+ - - "MD2,MD4,MD5,SHA,MDC2,HMAC,RIPEMD,"+ET_WHIRLPOOL+","+ - - "DES,AES,RC2,RC4,RC5,IDEA,BF,CAST,CAMELLIA,SEED,MODES,"+ - + "MD4,MD5,SHA,MDC2,HMAC,RIPEMD,"+ET_WHIRLPOOL+","+ - + "DES,AES,RC2,RC4,IDEA,BF,CAST,CAMELLIA,SEED,MODES,"+ - "BN,EC,RSA,DSA,ECDSA,DH,ECDH,DSO,ENGINE,"+ - "BUFFER,BIO,STACK,LHASH,RAND,ERR,"+ - "EVP,EVP_2,EVP_3,ASN1,ASN1_2,PEM,X509,X509V3,"+ - @@ -204,11 +204,18 @@ $ GOSUB CHECK_OPT_FILE $! $! Define The Different Encryption "library" Strings. $! -$ APPS_DES = "DES/DES,CBC3_ENC" -$ APPS_PKCS7 = "ENC/ENC;DEC/DEC;SIGN/SIGN;VERIFY/VERIFY,EXAMPLE" +$!!! Test apps disabled, as they aren't supported at all, +$!!! not even in the unix build +$!!! APPS_DES = "DES/DES,CBC3_ENC" +$!!! APPS_PKCS7 = "ENC/ENC;DEC/DEC;SIGN/SIGN;VERIFY/VERIFY,EXAMPLE" $ -$ LIB_ = "cryptlib,mem,mem_clr,mem_dbg,cversion,ex_data,cpt_err,"+ - - "ebcdic,uid,o_time,o_str,o_dir,o_fips.c,o_init,fips_ers" +$! These variables are ordered as the SDIRS variable from the top Makefile.org +$! The contents of these variables are copied from the LIBOBJ variable in the +$! corresponding Makefile from each corresponding subdirectory, with .o stripped +$! and spaces replaced with commas. +$ LIB_ = "cryptlib,mem,mem_dbg,cversion,ex_data,cpt_err,ebcdic,"+ - + "uid,o_time,o_str,o_dir,o_fips.c,o_init,fips_ers,mem_clr" +$ LIB_OBJECTS = "o_names,obj_dat,obj_lib,obj_err,obj_xref" $ LIB_MD2 = "md2_dgst,md2_one" $ LIB_MD4 = "md4_dgst,md4_one" $ LIB_MD5 = "md5_dgst,md5_one" @@ -225,13 +232,13 @@ $ LIB_DES = "set_key,ecb_enc,cbc_enc,"+ - "fcrypt,xcbc_enc,rpc_enc,cbc_cksm,"+ - "ede_cbcm_enc,des_old,des_old2,read2pwd" $ LIB_RC2 = "rc2_ecb,rc2_skey,rc2_cbc,rc2cfb64,rc2ofb64" -$ LIB_RC4 = "rc4_skey,rc4_enc,rc4_utl" +$ LIB_RC4 = "rc4_enc,rc4_skey,rc4_utl" $ LIB_RC5 = "rc5_skey,rc5_ecb,rc5_enc,rc5cfb64,rc5ofb64" $ LIB_IDEA = "i_cbc,i_cfb64,i_ofb64,i_ecb,i_skey" $ LIB_BF = "bf_skey,bf_ecb,bf_enc,bf_cfb64,bf_ofb64" $ LIB_CAST = "c_skey,c_ecb,c_enc,c_cfb64,c_ofb64" -$ LIB_CAMELLIA = "camellia,cmll_misc,cmll_ecb,cmll_cbc,cmll_ofb,"+ - - "cmll_cfb,cmll_ctr,cmll_utl" +$ LIB_CAMELLIA = "cmll_ecb,cmll_ofb,cmll_cfb,cmll_ctr,cmll_utl,"+ - + "camellia,cmll_misc,cmll_cbc" $ LIB_SEED = "seed,seed_ecb,seed_cbc,seed_cfb,seed_ofb" $ LIB_MODES = "cbc128,ctr128,cts128,cfb128,ofb128,gcm128,"+ - "ccm128,xts128" @@ -264,24 +271,23 @@ $ LIB_ENGINE = "eng_err,eng_lib,eng_list,eng_init,eng_ctrl,"+ - "eng_table,eng_pkey,eng_fat,eng_all,"+ - "tb_rsa,tb_dsa,tb_ecdsa,tb_dh,tb_ecdh,tb_rand,tb_store,"+ - "tb_cipher,tb_digest,tb_pkmeth,tb_asnmth,"+ - - "eng_openssl,eng_dyn,eng_cnf,eng_cryptodev,"+ - + "eng_openssl,eng_cnf,eng_dyn,eng_cryptodev,"+ - "eng_rsax,eng_rdrand" -$ LIB_AES = "aes_core,aes_misc,aes_ecb,aes_cbc,aes_cfb,aes_ofb,aes_ctr,"+ - - "aes_ige,aes_wrap" +$ LIB_AES = "aes_misc,aes_ecb,aes_cfb,aes_ofb,aes_ctr,aes_ige,aes_wrap,"+ - + "aes_core,aes_cbc" $ LIB_BUFFER = "buffer,buf_str,buf_err" $ LIB_BIO = "bio_lib,bio_cb,bio_err,"+ - "bss_mem,bss_null,bss_fd,"+ - "bss_file,bss_sock,bss_conn,"+ - "bf_null,bf_buff,b_print,b_dump,"+ - - "b_sock,bss_acpt,bf_nbio,bss_rtcp,bss_bio,bss_log,"+ - + "b_sock,bss_acpt,bf_nbio,bss_log,bss_bio,"+ - "bss_dgram,"+ - - "bf_lbuf" + "bf_lbuf,bss_rtcp" ! The last two are VMS specific $ LIB_STACK = "stack" $ LIB_LHASH = "lhash,lh_stats" $ LIB_RAND = "md_rand,randfile,rand_lib,rand_err,rand_egd,"+ - - "rand_vms" + "rand_vms" ! The last one is VMS specific $ LIB_ERR = "err,err_all,err_prn" -$ LIB_OBJECTS = "o_names,obj_dat,obj_lib,obj_err,obj_xref" $ LIB_EVP = "encode,digest,evp_enc,evp_key,evp_acnf,evp_cnf,"+ - "e_des,e_bf,e_idea,e_des3,e_camellia,"+ - "e_rc4,e_aes,names,e_seed,"+ - @@ -345,7 +351,7 @@ $ LIB_TS = "ts_err,ts_req_utils,ts_req_print,ts_rsp_utils,ts_rsp_print,"+ - $ LIB_JPAKE = "jpake,jpake_err" $ LIB_SRP = "srp_lib,srp_vfy" $ LIB_STORE = "str_err,str_lib,str_meth,str_mem" -$ LIB_CMAC = "cmac,cm_ameth.c,cm_pmeth" +$ LIB_CMAC = "cmac,cm_ameth,cm_pmeth" $! $! Setup exceptional compilations $! @@ -381,7 +387,7 @@ $ MODULE_NEXT: $! $! Extract The Module Name From The Encryption List. $! -$ MODULE_NAME = F$ELEMENT(MODULE_COUNTER,",",ENCRYPT_TYPES) +$ MODULE_NAME = F$EDIT(F$ELEMENT(MODULE_COUNTER,",",ENCRYPT_TYPES),"COLLAPSE") $ IF MODULE_NAME.EQS."Basic" THEN MODULE_NAME = "" $ MODULE_NAME1 = MODULE_NAME $! @@ -465,7 +471,7 @@ $ THEN $! $! O.K, Extract The File Name From The File List. $! -$ FILE_NAME = F$ELEMENT(FILE_COUNTER,",",'LIB_MODULE') +$ FILE_NAME = F$EDIT(F$ELEMENT(FILE_COUNTER,",",'LIB_MODULE'),"COLLAPSE") $! $! else $! @@ -492,7 +498,7 @@ $! SHOW SYMBOL APPLICATION* $! $ IF APPLICATION .NES. ";" $ THEN -$ FILE_NAME = F$ELEMENT(FILE_COUNTER,",",APPLICATION_OBJECTS) +$ FILE_NAME = F$EDIT(F$ELEMENT(FILE_COUNTER,",",APPLICATION_OBJECTS),"COLLAPSE") $ IF FILE_NAME .EQS. "," $ THEN $ APPLICATION = "" @@ -1132,9 +1138,12 @@ $ CCDEFS = "TCPIP_TYPE_''P4',DSO_VMS" $ IF F$TYPE(USER_CCDEFS) .NES. "" THEN CCDEFS = CCDEFS + "," + USER_CCDEFS $ CCEXTRAFLAGS = "" $ IF F$TYPE(USER_CCFLAGS) .NES. "" THEN CCEXTRAFLAGS = USER_CCFLAGS -$ CCDISABLEWARNINGS = "" !!! "LONGLONGTYPE,LONGLONGSUFX,FOUNDCR" -$ IF F$TYPE(USER_CCDISABLEWARNINGS) .NES. "" THEN - - CCDISABLEWARNINGS = CCDISABLEWARNINGS + "," + USER_CCDISABLEWARNINGS +$ CCDISABLEWARNINGS = "" !!! "MAYLOSEDATA3" !!! "LONGLONGTYPE,LONGLONGSUFX,FOUNDCR" +$ IF F$TYPE(USER_CCDISABLEWARNINGS) .NES. "" +$ THEN +$ IF CCDISABLEWARNINGS .NES. "" THEN CCDISABLEWARNINGS = CCDISABLEWARNINGS + "," +$ CCDISABLEWARNINGS = CCDISABLEWARNINGS + USER_CCDISABLEWARNINGS +$ ENDIF $! $! Check To See If We Have A ZLIB Option. $! @@ -1299,6 +1308,18 @@ $! Finish up the definition of CC. $! $ IF COMPILER .EQS. "DECC" $ THEN +$! Not all compiler versions support MAYLOSEDATA3. +$ OPT_TEST = "MAYLOSEDATA3" +$ DEFINE /USER_MODE SYS$ERROR NL: +$ DEFINE /USER_MODE SYS$OUTPUT NL: +$ 'CC' /NOCROSS_REFERENCE /NOLIST /NOOBJECT - + /WARNINGS = DISABLE = ('OPT_TEST', EMPTYFILE) NL: +$ IF ($SEVERITY) +$ THEN +$ IF CCDISABLEWARNINGS .NES. "" THEN - + CCDISABLEWARNINGS = CCDISABLEWARNINGS+ "," +$ CCDISABLEWARNINGS = CCDISABLEWARNINGS+ OPT_TEST +$ ENDIF $ IF CCDISABLEWARNINGS .EQS. "" $ THEN $ CC4DISABLEWARNINGS = "DOLLARID" diff --git a/deps/openssl/openssl/crypto/dsa/dsa_ameth.c b/deps/openssl/openssl/crypto/dsa/dsa_ameth.c index 376156ec5ef3a6..5af76eade59ab1 100644 --- a/deps/openssl/openssl/crypto/dsa/dsa_ameth.c +++ b/deps/openssl/openssl/crypto/dsa/dsa_ameth.c @@ -307,6 +307,12 @@ static int dsa_priv_encode(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pkey) unsigned char *dp = NULL; int dplen; + if (!pkey->pkey.dsa || !pkey->pkey.dsa->priv_key) + { + DSAerr(DSA_F_DSA_PRIV_ENCODE,DSA_R_MISSING_PARAMETERS); + goto err; + } + params = ASN1_STRING_new(); if (!params) @@ -701,4 +707,3 @@ const EVP_PKEY_ASN1_METHOD dsa_asn1_meths[] = old_dsa_priv_encode } }; - diff --git a/deps/openssl/openssl/crypto/ebcdic.h b/deps/openssl/openssl/crypto/ebcdic.h index 6d65afcf9e7522..85f3cf7f66b94b 100644 --- a/deps/openssl/openssl/crypto/ebcdic.h +++ b/deps/openssl/openssl/crypto/ebcdic.h @@ -5,6 +5,10 @@ #include +#ifdef __cplusplus +extern "C" { +#endif + /* Avoid name clashes with other applications */ #define os_toascii _openssl_os_toascii #define os_toebcdic _openssl_os_toebcdic @@ -16,4 +20,7 @@ extern const unsigned char os_toebcdic[256]; void *ebcdic2ascii(void *dest, const void *srce, size_t count); void *ascii2ebcdic(void *dest, const void *srce, size_t count); +#ifdef __cplusplus +} +#endif #endif diff --git a/deps/openssl/openssl/crypto/ec/ec.h b/deps/openssl/openssl/crypto/ec/ec.h index dfe8710d330954..572111f16cd143 100644 --- a/deps/openssl/openssl/crypto/ec/ec.h +++ b/deps/openssl/openssl/crypto/ec/ec.h @@ -629,7 +629,7 @@ int EC_POINT_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b, BN int EC_POINT_make_affine(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx); int EC_POINTs_make_affine(const EC_GROUP *group, size_t num, EC_POINT *points[], BN_CTX *ctx); -/** Computes r = generator * n sum_{i=0}^num p[i] * m[i] +/** Computes r = generator * n sum_{i=0}^{num-1} p[i] * m[i] * \param group underlying EC_GROUP object * \param r EC_POINT object for the result * \param n BIGNUM with the multiplier for the group generator (optional) diff --git a/deps/openssl/openssl/crypto/ec/ec2_smpl.c b/deps/openssl/openssl/crypto/ec/ec2_smpl.c index e0e59c7d8299b0..62223cbb01f2f0 100644 --- a/deps/openssl/openssl/crypto/ec/ec2_smpl.c +++ b/deps/openssl/openssl/crypto/ec/ec2_smpl.c @@ -80,9 +80,6 @@ const EC_METHOD *EC_GF2m_simple_method(void) { -#ifdef OPENSSL_FIPS - return fips_ec_gf2m_simple_method(); -#else static const EC_METHOD ret = { EC_FLAGS_DEFAULT_OCT, NID_X9_62_characteristic_two_field, @@ -125,8 +122,12 @@ const EC_METHOD *EC_GF2m_simple_method(void) 0 /* field_decode */, 0 /* field_set_to_one */ }; - return &ret; +#ifdef OPENSSL_FIPS + if (FIPS_mode()) + return fips_ec_gf2m_simple_method(); #endif + + return &ret; } diff --git a/deps/openssl/openssl/crypto/ec/ec_ameth.c b/deps/openssl/openssl/crypto/ec/ec_ameth.c index f715a238a6fc1a..11283769b9399c 100644 --- a/deps/openssl/openssl/crypto/ec/ec_ameth.c +++ b/deps/openssl/openssl/crypto/ec/ec_ameth.c @@ -453,14 +453,16 @@ static int do_EC_KEY_print(BIO *bp, const EC_KEY *x, int off, int ktype) if (ktype > 0) { public_key = EC_KEY_get0_public_key(x); - if ((pub_key = EC_POINT_point2bn(group, public_key, - EC_KEY_get_conv_form(x), NULL, ctx)) == NULL) + if (public_key != NULL) { - reason = ERR_R_EC_LIB; - goto err; - } - if (pub_key) + if ((pub_key = EC_POINT_point2bn(group, public_key, + EC_KEY_get_conv_form(x), NULL, ctx)) == NULL) + { + reason = ERR_R_EC_LIB; + goto err; + } buf_len = (size_t)BN_num_bytes(pub_key); + } } if (ktype == 2) diff --git a/deps/openssl/openssl/crypto/ec/ec_asn1.c b/deps/openssl/openssl/crypto/ec/ec_asn1.c index e94f34e11b7ca3..52d31c2f9642d0 100644 --- a/deps/openssl/openssl/crypto/ec/ec_asn1.c +++ b/deps/openssl/openssl/crypto/ec/ec_asn1.c @@ -1183,29 +1183,46 @@ EC_KEY *d2i_ECPrivateKey(EC_KEY **a, const unsigned char **in, long len) goto err; } + if (ret->pub_key) + EC_POINT_clear_free(ret->pub_key); + ret->pub_key = EC_POINT_new(ret->group); + if (ret->pub_key == NULL) + { + ECerr(EC_F_D2I_ECPRIVATEKEY, ERR_R_EC_LIB); + goto err; + } + if (priv_key->publicKey) { const unsigned char *pub_oct; - size_t pub_oct_len; + int pub_oct_len; - if (ret->pub_key) - EC_POINT_clear_free(ret->pub_key); - ret->pub_key = EC_POINT_new(ret->group); - if (ret->pub_key == NULL) + pub_oct = M_ASN1_STRING_data(priv_key->publicKey); + pub_oct_len = M_ASN1_STRING_length(priv_key->publicKey); + /* The first byte - point conversion form - must be present. */ + if (pub_oct_len <= 0) { - ECerr(EC_F_D2I_ECPRIVATEKEY, ERR_R_EC_LIB); + ECerr(EC_F_D2I_ECPRIVATEKEY, EC_R_BUFFER_TOO_SMALL); goto err; } - pub_oct = M_ASN1_STRING_data(priv_key->publicKey); - pub_oct_len = M_ASN1_STRING_length(priv_key->publicKey); - /* save the point conversion form */ + /* Save the point conversion form. */ ret->conv_form = (point_conversion_form_t)(pub_oct[0] & ~0x01); if (!EC_POINT_oct2point(ret->group, ret->pub_key, - pub_oct, pub_oct_len, NULL)) + pub_oct, (size_t)(pub_oct_len), NULL)) + { + ECerr(EC_F_D2I_ECPRIVATEKEY, ERR_R_EC_LIB); + goto err; + } + } + else + { + if (!EC_POINT_mul(ret->group, ret->pub_key, ret->priv_key, NULL, NULL, NULL)) { ECerr(EC_F_D2I_ECPRIVATEKEY, ERR_R_EC_LIB); goto err; } + /* Remember the original private-key-only encoding. */ + ret->enc_flag |= EC_PKEY_NO_PUBKEY; } ok = 1; @@ -1230,7 +1247,8 @@ int i2d_ECPrivateKey(EC_KEY *a, unsigned char **out) size_t buf_len=0, tmp_len; EC_PRIVATEKEY *priv_key=NULL; - if (a == NULL || a->group == NULL || a->priv_key == NULL) + if (a == NULL || a->group == NULL || a->priv_key == NULL || + (!(a->enc_flag & EC_PKEY_NO_PUBKEY) && a->pub_key == NULL)) { ECerr(EC_F_I2D_ECPRIVATEKEY, ERR_R_PASSED_NULL_PARAMETER); diff --git a/deps/openssl/openssl/crypto/ec/ecp_mont.c b/deps/openssl/openssl/crypto/ec/ecp_mont.c index f04f132c7ad689..3c5ec1965ac829 100644 --- a/deps/openssl/openssl/crypto/ec/ecp_mont.c +++ b/deps/openssl/openssl/crypto/ec/ecp_mont.c @@ -72,9 +72,6 @@ const EC_METHOD *EC_GFp_mont_method(void) { -#ifdef OPENSSL_FIPS - return fips_ec_gfp_mont_method(); -#else static const EC_METHOD ret = { EC_FLAGS_DEFAULT_OCT, NID_X9_62_prime_field, @@ -114,8 +111,12 @@ const EC_METHOD *EC_GFp_mont_method(void) ec_GFp_mont_field_decode, ec_GFp_mont_field_set_to_one }; - return &ret; +#ifdef OPENSSL_FIPS + if (FIPS_mode()) + return fips_ec_gfp_mont_method(); #endif + + return &ret; } diff --git a/deps/openssl/openssl/crypto/ec/ecp_nist.c b/deps/openssl/openssl/crypto/ec/ecp_nist.c index aad2d5f44389ad..db3b99e06a5fa9 100644 --- a/deps/openssl/openssl/crypto/ec/ecp_nist.c +++ b/deps/openssl/openssl/crypto/ec/ecp_nist.c @@ -73,9 +73,6 @@ const EC_METHOD *EC_GFp_nist_method(void) { -#ifdef OPENSSL_FIPS - return fips_ec_gfp_nist_method(); -#else static const EC_METHOD ret = { EC_FLAGS_DEFAULT_OCT, NID_X9_62_prime_field, @@ -115,8 +112,12 @@ const EC_METHOD *EC_GFp_nist_method(void) 0 /* field_decode */, 0 /* field_set_to_one */ }; - return &ret; +#ifdef OPENSSL_FIPS + if (FIPS_mode()) + return fips_ec_gfp_nist_method(); #endif + + return &ret; } int ec_GFp_nist_group_copy(EC_GROUP *dest, const EC_GROUP *src) diff --git a/deps/openssl/openssl/crypto/ec/ecp_smpl.c b/deps/openssl/openssl/crypto/ec/ecp_smpl.c index ef5285477a2a9f..2d1f35768623f1 100644 --- a/deps/openssl/openssl/crypto/ec/ecp_smpl.c +++ b/deps/openssl/openssl/crypto/ec/ecp_smpl.c @@ -73,9 +73,6 @@ const EC_METHOD *EC_GFp_simple_method(void) { -#ifdef OPENSSL_FIPS - return fips_ec_gfp_simple_method(); -#else static const EC_METHOD ret = { EC_FLAGS_DEFAULT_OCT, NID_X9_62_prime_field, @@ -115,8 +112,12 @@ const EC_METHOD *EC_GFp_simple_method(void) 0 /* field_decode */, 0 /* field_set_to_one */ }; - return &ret; +#ifdef OPENSSL_FIPS + if (FIPS_mode()) + return fips_ec_gfp_simple_method(); #endif + + return &ret; } @@ -1317,8 +1318,8 @@ int ec_GFp_simple_points_make_affine(const EC_GROUP *group, size_t num, EC_POINT { for (i = 0; i < num; i++) { - if (prod_Z[i] != NULL) - BN_clear_free(prod_Z[i]); + if (prod_Z[i] == NULL) break; + BN_clear_free(prod_Z[i]); } OPENSSL_free(prod_Z); } diff --git a/deps/openssl/openssl/crypto/ec/ectest.c b/deps/openssl/openssl/crypto/ec/ectest.c index 82c8c8bfb119c6..d1bf980599c8ac 100644 --- a/deps/openssl/openssl/crypto/ec/ectest.c +++ b/deps/openssl/openssl/crypto/ec/ectest.c @@ -251,14 +251,15 @@ static void group_order_tests(EC_GROUP *group) if (!EC_POINT_is_at_infinity(group, Q)) ABORT; /* Exercise EC_POINTs_mul, including corner cases. */ + if (EC_POINT_is_at_infinity(group, P)) ABORT; scalars[0] = n1; points[0] = Q; /* => infinity */ scalars[1] = n2; points[1] = P; /* => -P */ scalars[2] = n1; points[2] = Q; /* => infinity */ scalars[3] = n2; points[3] = Q; /* => infinity */ scalars[4] = n1; points[4] = P; /* => P */ scalars[5] = n2; points[5] = Q; /* => infinity */ - if (!EC_POINTs_mul(group, Q, NULL, 5, points, scalars, ctx)) ABORT; - if (!EC_POINT_is_at_infinity(group, Q)) ABORT; + if (!EC_POINTs_mul(group, P, NULL, 6, points, scalars, ctx)) ABORT; + if (!EC_POINT_is_at_infinity(group, P)) ABORT; } fprintf(stdout, "ok\n"); diff --git a/deps/openssl/openssl/crypto/err/openssl.ec b/deps/openssl/openssl/crypto/err/openssl.ec index e0554b4342e10c..bafbc35d3065ea 100644 --- a/deps/openssl/openssl/crypto/err/openssl.ec +++ b/deps/openssl/openssl/crypto/err/openssl.ec @@ -71,6 +71,7 @@ R SSL_R_TLSV1_ALERT_EXPORT_RESTRICTION 1060 R SSL_R_TLSV1_ALERT_PROTOCOL_VERSION 1070 R SSL_R_TLSV1_ALERT_INSUFFICIENT_SECURITY 1071 R SSL_R_TLSV1_ALERT_INTERNAL_ERROR 1080 +R SSL_R_TLSV1_ALERT_INAPPROPRIATE_FALLBACK 1086 R SSL_R_TLSV1_ALERT_USER_CANCELLED 1090 R SSL_R_TLSV1_ALERT_NO_RENEGOTIATION 1100 R SSL_R_TLSV1_UNSUPPORTED_EXTENSION 1110 diff --git a/deps/openssl/openssl/crypto/evp/Makefile b/deps/openssl/openssl/crypto/evp/Makefile index 5d0c6b7db4c9a1..fa25bff6b5cab3 100644 --- a/deps/openssl/openssl/crypto/evp/Makefile +++ b/deps/openssl/openssl/crypto/evp/Makefile @@ -383,7 +383,7 @@ evp_enc.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h evp_enc.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h evp_enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h evp_enc.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h -evp_enc.o: ../cryptlib.h evp_enc.c evp_locl.h +evp_enc.o: ../constant_time_locl.h ../cryptlib.h evp_enc.c evp_locl.h evp_err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h evp_err.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h evp_err.o: ../../include/openssl/err.h ../../include/openssl/evp.h diff --git a/deps/openssl/openssl/crypto/evp/e_aes.c b/deps/openssl/openssl/crypto/evp/e_aes.c index 07bf83a608d87a..dc3c2a162a5e29 100644 --- a/deps/openssl/openssl/crypto/evp/e_aes.c +++ b/deps/openssl/openssl/crypto/evp/e_aes.c @@ -166,7 +166,7 @@ extern unsigned int OPENSSL_ia32cap_P[2]; #define VPAES_CAPABLE (OPENSSL_ia32cap_P[1]&(1<<(41-32))) #endif #ifdef BSAES_ASM -#define BSAES_CAPABLE VPAES_CAPABLE +#define BSAES_CAPABLE (OPENSSL_ia32cap_P[1]&(1<<(41-32))) #endif /* * AES-NI section diff --git a/deps/openssl/openssl/crypto/evp/evp_enc.c b/deps/openssl/openssl/crypto/evp/evp_enc.c index 0c54f05e6ef511..7b1842a52a6dac 100644 --- a/deps/openssl/openssl/crypto/evp/evp_enc.c +++ b/deps/openssl/openssl/crypto/evp/evp_enc.c @@ -67,6 +67,7 @@ #ifdef OPENSSL_FIPS #include #endif +#include "constant_time_locl.h" #include "evp_locl.h" #ifdef OPENSSL_FIPS @@ -500,21 +501,21 @@ int EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl) int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl) { - int i,n; - unsigned int b; + unsigned int i, b; + unsigned char pad, padding_good; *outl=0; if (ctx->cipher->flags & EVP_CIPH_FLAG_CUSTOM_CIPHER) { - i = M_do_cipher(ctx, out, NULL, 0); - if (i < 0) + int ret = M_do_cipher(ctx, out, NULL, 0); + if (ret < 0) return 0; else - *outl = i; + *outl = ret; return 1; } - b=ctx->cipher->block_size; + b=(unsigned int)(ctx->cipher->block_size); if (ctx->flags & EVP_CIPH_NO_PADDING) { if(ctx->buf_len) @@ -533,28 +534,34 @@ int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl) return(0); } OPENSSL_assert(b <= sizeof ctx->final); - n=ctx->final[b-1]; - if (n == 0 || n > (int)b) - { - EVPerr(EVP_F_EVP_DECRYPTFINAL_EX,EVP_R_BAD_DECRYPT); - return(0); - } - for (i=0; ifinal[b-1]; + + padding_good = (unsigned char)(~constant_time_is_zero_8(pad)); + padding_good &= constant_time_ge_8(b, pad); + + for (i = 1; i < b; ++i) { - if (ctx->final[--b] != n) - { - EVPerr(EVP_F_EVP_DECRYPTFINAL_EX,EVP_R_BAD_DECRYPT); - return(0); - } + unsigned char is_pad_index = constant_time_lt_8(i, pad); + unsigned char pad_byte_good = constant_time_eq_8(ctx->final[b-i-1], pad); + padding_good &= constant_time_select_8(is_pad_index, pad_byte_good, 0xff); } - n=ctx->cipher->block_size-n; - for (i=0; ifinal[i]; - *outl=n; + + /* + * At least 1 byte is always padding, so we always write b - 1 + * bytes to avoid a timing leak. The caller is required to have |b| + * bytes space in |out| by the API contract. + */ + for (i = 0; i < b - 1; ++i) + out[i] = ctx->final[i] & padding_good; + /* Safe cast: for a good padding, EVP_MAX_IV_LENGTH >= b >= pad */ + *outl = padding_good & ((unsigned char)(b - pad)); + return padding_good & 1; } else - *outl=0; - return(1); + { + *outl = 0; + return 1; + } } void EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *ctx) @@ -678,4 +685,3 @@ int EVP_CIPHER_CTX_copy(EVP_CIPHER_CTX *out, const EVP_CIPHER_CTX *in) return in->cipher->ctrl((EVP_CIPHER_CTX *)in, EVP_CTRL_COPY, 0, out); return 1; } - diff --git a/deps/openssl/openssl/crypto/install-crypto.com b/deps/openssl/openssl/crypto/install-crypto.com index 85b3d583cf6fbf..d19081d4df094d 100755 --- a/deps/openssl/openssl/crypto/install-crypto.com +++ b/deps/openssl/openssl/crypto/install-crypto.com @@ -75,13 +75,13 @@ $! $ sdirs := , - 'archd', - objects, - - md2, md4, md5, sha, mdc2, hmac, ripemd, whrlpool, - - des, aes, rc2, rc4, rc5, idea, bf, cast, camellia, seed, - + md4, md5, sha, mdc2, hmac, ripemd, whrlpool, - + des, aes, rc2, rc4, idea, bf, cast, camellia, seed, - bn, ec, rsa, dsa, ecdsa, dh, ecdh, dso, engine, - buffer, bio, stack, lhash, rand, err, - evp, asn1, pem, x509, x509v3, conf, txt_db, pkcs7, pkcs12, comp, ocsp, - ui, krb5, - - store, cms, pqueue, ts, jpake + cms, pqueue, ts, jpake, srp, store, cmac $! $ exheader_ := crypto.h, opensslv.h, ebcdic.h, symhacks.h, ossl_typ.h $ exheader_'archd' := opensslconf.h @@ -139,6 +139,9 @@ $ exheader_cms := cms.h $ exheader_pqueue := pqueue.h $ exheader_ts := ts.h $ exheader_jpake := jpake.h +$ exheader_srp := srp.h +$ exheader_store := store.h +$ exheader_cmac := cmac.h $ libs := ssl_libcrypto $! $ exe_dir := [-.'archd'.exe.crypto] diff --git a/deps/openssl/openssl/crypto/md5/asm/md5-x86_64.pl b/deps/openssl/openssl/crypto/md5/asm/md5-x86_64.pl index f11224d1722012..381bf77e1c6bbd 100755 --- a/deps/openssl/openssl/crypto/md5/asm/md5-x86_64.pl +++ b/deps/openssl/openssl/crypto/md5/asm/md5-x86_64.pl @@ -108,6 +108,7 @@ sub round4_step EOF } +no warnings qw(uninitialized); my $flavour = shift; my $output = shift; if ($flavour =~ /\./) { $output = $flavour; undef $flavour; } @@ -119,7 +120,6 @@ sub round4_step ( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or die "can't locate x86_64-xlate.pl"; -no warnings qw(uninitialized); open OUT,"| \"$^X\" $xlate $flavour $output"; *STDOUT=*OUT; diff --git a/deps/openssl/openssl/crypto/modes/modes.h b/deps/openssl/openssl/crypto/modes/modes.h index f18215bb2b25e2..7773c2542e5c84 100644 --- a/deps/openssl/openssl/crypto/modes/modes.h +++ b/deps/openssl/openssl/crypto/modes/modes.h @@ -7,6 +7,9 @@ #include +#ifdef __cplusplus +extern "C" { +#endif typedef void (*block128_f)(const unsigned char in[16], unsigned char out[16], const void *key); @@ -133,3 +136,6 @@ typedef struct xts128_context XTS128_CONTEXT; int CRYPTO_xts128_encrypt(const XTS128_CONTEXT *ctx, const unsigned char iv[16], const unsigned char *inp, unsigned char *out, size_t len, int enc); +#ifdef __cplusplus +} +#endif diff --git a/deps/openssl/openssl/crypto/ocsp/ocsp_vfy.c b/deps/openssl/openssl/crypto/ocsp/ocsp_vfy.c index 276718304dd211..fc0d4cc0f5f785 100644 --- a/deps/openssl/openssl/crypto/ocsp/ocsp_vfy.c +++ b/deps/openssl/openssl/crypto/ocsp/ocsp_vfy.c @@ -436,8 +436,11 @@ static int ocsp_req_find_signer(X509 **psigner, OCSP_REQUEST *req, X509_NAME *nm if(!(flags & OCSP_NOINTERN)) { signer = X509_find_by_subject(req->optionalSignature->certs, nm); - *psigner = signer; - return 1; + if (signer) + { + *psigner = signer; + return 1; + } } signer = X509_find_by_subject(certs, nm); diff --git a/deps/openssl/openssl/crypto/opensslv.h b/deps/openssl/openssl/crypto/opensslv.h index 241150530038d8..f375967ef9132a 100644 --- a/deps/openssl/openssl/crypto/opensslv.h +++ b/deps/openssl/openssl/crypto/opensslv.h @@ -1,6 +1,10 @@ #ifndef HEADER_OPENSSLV_H #define HEADER_OPENSSLV_H +#ifdef __cplusplus +extern "C" { +#endif + /* Numeric release version identifier: * MNNFFPPS: major minor fix patch status * The status nibble has one of the values 0 for development, 1 to e for betas @@ -25,11 +29,11 @@ * (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for * major minor fix final patch/beta) */ -#define OPENSSL_VERSION_NUMBER 0x1000109fL +#define OPENSSL_VERSION_NUMBER 0x100010afL #ifdef OPENSSL_FIPS -#define OPENSSL_VERSION_TEXT "OpenSSL 1.0.1i-fips 6 Aug 2014" +#define OPENSSL_VERSION_TEXT "OpenSSL 1.0.1j-fips 15 Oct 2014" #else -#define OPENSSL_VERSION_TEXT "OpenSSL 1.0.1i 6 Aug 2014" +#define OPENSSL_VERSION_TEXT "OpenSSL 1.0.1j 15 Oct 2014" #endif #define OPENSSL_VERSION_PTEXT " part of " OPENSSL_VERSION_TEXT @@ -86,4 +90,7 @@ #define SHLIB_VERSION_NUMBER "1.0.0" +#ifdef __cplusplus +} +#endif #endif /* HEADER_OPENSSLV_H */ diff --git a/deps/openssl/openssl/crypto/ossl_typ.h b/deps/openssl/openssl/crypto/ossl_typ.h index ea9227f6f95a88..12cdd43be9dc6d 100644 --- a/deps/openssl/openssl/crypto/ossl_typ.h +++ b/deps/openssl/openssl/crypto/ossl_typ.h @@ -55,6 +55,10 @@ #ifndef HEADER_OPENSSL_TYPES_H #define HEADER_OPENSSL_TYPES_H +#ifdef __cplusplus +extern "C" { +#endif + #include #ifdef NO_ASN1_TYPEDEFS @@ -199,4 +203,7 @@ typedef struct ocsp_req_ctx_st OCSP_REQ_CTX; typedef struct ocsp_response_st OCSP_RESPONSE; typedef struct ocsp_responder_id_st OCSP_RESPID; +#ifdef __cplusplus +} +#endif #endif /* def HEADER_OPENSSL_TYPES_H */ diff --git a/deps/openssl/openssl/crypto/pkcs7/pkcs7.h b/deps/openssl/openssl/crypto/pkcs7/pkcs7.h index 04f60379fb6d2f..5d54c4ac2723b9 100644 --- a/deps/openssl/openssl/crypto/pkcs7/pkcs7.h +++ b/deps/openssl/openssl/crypto/pkcs7/pkcs7.h @@ -233,10 +233,6 @@ DECLARE_PKCS12_STACK_OF(PKCS7) (OBJ_obj2nid((a)->type) == NID_pkcs7_signedAndEnveloped) #define PKCS7_type_is_data(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_data) #define PKCS7_type_is_digest(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_digest) -#define PKCS7_type_is_encrypted(a) \ - (OBJ_obj2nid((a)->type) == NID_pkcs7_encrypted) - -#define PKCS7_type_is_digest(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_digest) #define PKCS7_set_detached(p,v) \ PKCS7_ctrl(p,PKCS7_OP_SET_DETACHED_SIGNATURE,v,NULL) diff --git a/deps/openssl/openssl/crypto/pqueue/pqueue.h b/deps/openssl/openssl/crypto/pqueue/pqueue.h index 87fc9037c8f3af..26b5348089005e 100644 --- a/deps/openssl/openssl/crypto/pqueue/pqueue.h +++ b/deps/openssl/openssl/crypto/pqueue/pqueue.h @@ -64,6 +64,9 @@ #include #include +#ifdef __cplusplus +extern "C" { +#endif typedef struct _pqueue *pqueue; typedef struct _pitem @@ -91,4 +94,7 @@ pitem *pqueue_next(piterator *iter); void pqueue_print(pqueue pq); int pqueue_size(pqueue pq); +#ifdef __cplusplus +} +#endif #endif /* ! HEADER_PQUEUE_H */ diff --git a/deps/openssl/openssl/crypto/rsa/Makefile b/deps/openssl/openssl/crypto/rsa/Makefile index f798d2f7493290..e8121a49675063 100644 --- a/deps/openssl/openssl/crypto/rsa/Makefile +++ b/deps/openssl/openssl/crypto/rsa/Makefile @@ -212,7 +212,7 @@ rsa_oaep.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h rsa_oaep.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h rsa_oaep.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h rsa_oaep.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h -rsa_oaep.o: ../cryptlib.h rsa_oaep.c +rsa_oaep.o: ../constant_time_locl.h ../cryptlib.h rsa_oaep.c rsa_pk1.o: ../../e_os.h ../../include/openssl/asn1.h rsa_pk1.o: ../../include/openssl/bio.h ../../include/openssl/bn.h rsa_pk1.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h @@ -221,7 +221,8 @@ rsa_pk1.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h rsa_pk1.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h rsa_pk1.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h rsa_pk1.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h -rsa_pk1.o: ../../include/openssl/symhacks.h ../cryptlib.h rsa_pk1.c +rsa_pk1.o: ../../include/openssl/symhacks.h ../constant_time_locl.h +rsa_pk1.o: ../cryptlib.h rsa_pk1.c rsa_pmeth.o: ../../e_os.h ../../include/openssl/asn1.h rsa_pmeth.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h rsa_pmeth.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h diff --git a/deps/openssl/openssl/crypto/rsa/rsa.h b/deps/openssl/openssl/crypto/rsa/rsa.h index 5f269e577af498..11853fee5fe402 100644 --- a/deps/openssl/openssl/crypto/rsa/rsa.h +++ b/deps/openssl/openssl/crypto/rsa/rsa.h @@ -559,6 +559,7 @@ void ERR_load_RSA_strings(void); #define RSA_R_OPERATION_NOT_ALLOWED_IN_FIPS_MODE 158 #define RSA_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE 148 #define RSA_R_PADDING_CHECK_FAILED 114 +#define RSA_R_PKCS_DECODING_ERROR 159 #define RSA_R_P_NOT_PRIME 128 #define RSA_R_Q_NOT_PRIME 129 #define RSA_R_RSA_OPERATIONS_NOT_SUPPORTED 130 diff --git a/deps/openssl/openssl/crypto/rsa/rsa_err.c b/deps/openssl/openssl/crypto/rsa/rsa_err.c index 46e0bf99806c63..9da79d920ee9d1 100644 --- a/deps/openssl/openssl/crypto/rsa/rsa_err.c +++ b/deps/openssl/openssl/crypto/rsa/rsa_err.c @@ -175,6 +175,7 @@ static ERR_STRING_DATA RSA_str_reasons[]= {ERR_REASON(RSA_R_OPERATION_NOT_ALLOWED_IN_FIPS_MODE),"operation not allowed in fips mode"}, {ERR_REASON(RSA_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE),"operation not supported for this keytype"}, {ERR_REASON(RSA_R_PADDING_CHECK_FAILED) ,"padding check failed"}, +{ERR_REASON(RSA_R_PKCS_DECODING_ERROR) ,"pkcs decoding error"}, {ERR_REASON(RSA_R_P_NOT_PRIME) ,"p not prime"}, {ERR_REASON(RSA_R_Q_NOT_PRIME) ,"q not prime"}, {ERR_REASON(RSA_R_RSA_OPERATIONS_NOT_SUPPORTED),"rsa operations not supported"}, diff --git a/deps/openssl/openssl/crypto/rsa/rsa_oaep.c b/deps/openssl/openssl/crypto/rsa/rsa_oaep.c index af4d24a56ef591..c363331992e0c7 100644 --- a/deps/openssl/openssl/crypto/rsa/rsa_oaep.c +++ b/deps/openssl/openssl/crypto/rsa/rsa_oaep.c @@ -18,6 +18,7 @@ * an equivalent notion. */ +#include "constant_time_locl.h" #if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_SHA1) #include @@ -95,92 +96,117 @@ int RSA_padding_check_PKCS1_OAEP(unsigned char *to, int tlen, const unsigned char *from, int flen, int num, const unsigned char *param, int plen) { - int i, dblen, mlen = -1; - const unsigned char *maskeddb; - int lzero; - unsigned char *db = NULL, seed[SHA_DIGEST_LENGTH], phash[SHA_DIGEST_LENGTH]; - unsigned char *padded_from; - int bad = 0; - - if (--num < 2 * SHA_DIGEST_LENGTH + 1) - /* 'num' is the length of the modulus, i.e. does not depend on the - * particular ciphertext. */ - goto decoding_err; + int i, dblen, mlen = -1, one_index = 0, msg_index; + unsigned int good, found_one_byte; + const unsigned char *maskedseed, *maskeddb; + /* |em| is the encoded message, zero-padded to exactly |num| bytes: + * em = Y || maskedSeed || maskedDB */ + unsigned char *db = NULL, *em = NULL, seed[EVP_MAX_MD_SIZE], + phash[EVP_MAX_MD_SIZE]; - lzero = num - flen; - if (lzero < 0) - { - /* signalling this error immediately after detection might allow - * for side-channel attacks (e.g. timing if 'plen' is huge - * -- cf. James H. Manger, "A Chosen Ciphertext Attack on RSA Optimal - * Asymmetric Encryption Padding (OAEP) [...]", CRYPTO 2001), - * so we use a 'bad' flag */ - bad = 1; - lzero = 0; - flen = num; /* don't overflow the memcpy to padded_from */ - } + if (tlen <= 0 || flen <= 0) + return -1; - dblen = num - SHA_DIGEST_LENGTH; - db = OPENSSL_malloc(dblen + num); - if (db == NULL) + /* + * |num| is the length of the modulus; |flen| is the length of the + * encoded message. Therefore, for any |from| that was obtained by + * decrypting a ciphertext, we must have |flen| <= |num|. Similarly, + * num < 2 * SHA_DIGEST_LENGTH + 2 must hold for the modulus + * irrespective of the ciphertext, see PKCS #1 v2.2, section 7.1.2. + * This does not leak any side-channel information. + */ + if (num < flen || num < 2 * SHA_DIGEST_LENGTH + 2) + goto decoding_err; + + dblen = num - SHA_DIGEST_LENGTH - 1; + db = OPENSSL_malloc(dblen); + em = OPENSSL_malloc(num); + if (db == NULL || em == NULL) { RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP, ERR_R_MALLOC_FAILURE); - return -1; + goto cleanup; } - /* Always do this zero-padding copy (even when lzero == 0) - * to avoid leaking timing info about the value of lzero. */ - padded_from = db + dblen; - memset(padded_from, 0, lzero); - memcpy(padded_from + lzero, from, flen); + /* + * Always do this zero-padding copy (even when num == flen) to avoid + * leaking that information. The copy still leaks some side-channel + * information, but it's impossible to have a fixed memory access + * pattern since we can't read out of the bounds of |from|. + * + * TODO(emilia): Consider porting BN_bn2bin_padded from BoringSSL. + */ + memset(em, 0, num); + memcpy(em + num - flen, from, flen); - maskeddb = padded_from + SHA_DIGEST_LENGTH; + /* + * The first byte must be zero, however we must not leak if this is + * true. See James H. Manger, "A Chosen Ciphertext Attack on RSA + * Optimal Asymmetric Encryption Padding (OAEP) [...]", CRYPTO 2001). + */ + good = constant_time_is_zero(em[0]); + + maskedseed = em + 1; + maskeddb = em + 1 + SHA_DIGEST_LENGTH; if (MGF1(seed, SHA_DIGEST_LENGTH, maskeddb, dblen)) - return -1; + goto cleanup; for (i = 0; i < SHA_DIGEST_LENGTH; i++) - seed[i] ^= padded_from[i]; - + seed[i] ^= maskedseed[i]; + if (MGF1(db, dblen, seed, SHA_DIGEST_LENGTH)) - return -1; + goto cleanup; for (i = 0; i < dblen; i++) db[i] ^= maskeddb[i]; if (!EVP_Digest((void *)param, plen, phash, NULL, EVP_sha1(), NULL)) - return -1; + goto cleanup; + + good &= constant_time_is_zero(CRYPTO_memcmp(db, phash, SHA_DIGEST_LENGTH)); - if (CRYPTO_memcmp(db, phash, SHA_DIGEST_LENGTH) != 0 || bad) + found_one_byte = 0; + for (i = SHA_DIGEST_LENGTH; i < dblen; i++) + { + /* Padding consists of a number of 0-bytes, followed by a 1. */ + unsigned int equals1 = constant_time_eq(db[i], 1); + unsigned int equals0 = constant_time_is_zero(db[i]); + one_index = constant_time_select_int(~found_one_byte & equals1, + i, one_index); + found_one_byte |= equals1; + good &= (found_one_byte | equals0); + } + + good &= found_one_byte; + + /* + * At this point |good| is zero unless the plaintext was valid, + * so plaintext-awareness ensures timing side-channels are no longer a + * concern. + */ + if (!good) goto decoding_err; + + msg_index = one_index + 1; + mlen = dblen - msg_index; + + if (tlen < mlen) + { + RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP, RSA_R_DATA_TOO_LARGE); + mlen = -1; + } else { - for (i = SHA_DIGEST_LENGTH; i < dblen; i++) - if (db[i] != 0x00) - break; - if (i == dblen || db[i] != 0x01) - goto decoding_err; - else - { - /* everything looks OK */ - - mlen = dblen - ++i; - if (tlen < mlen) - { - RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP, RSA_R_DATA_TOO_LARGE); - mlen = -1; - } - else - memcpy(to, db + i, mlen); - } + memcpy(to, db + msg_index, mlen); + goto cleanup; } - OPENSSL_free(db); - return mlen; decoding_err: - /* to avoid chosen ciphertext attacks, the error message should not reveal - * which kind of decoding error happened */ + /* To avoid chosen ciphertext attacks, the error message should not reveal + * which kind of decoding error happened. */ RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP, RSA_R_OAEP_DECODING_ERROR); +cleanup: if (db != NULL) OPENSSL_free(db); - return -1; + if (em != NULL) OPENSSL_free(em); + return mlen; } int PKCS1_MGF1(unsigned char *mask, long len, diff --git a/deps/openssl/openssl/crypto/rsa/rsa_pk1.c b/deps/openssl/openssl/crypto/rsa/rsa_pk1.c index 8560755f1d12d8..c2da56f6cad8f1 100644 --- a/deps/openssl/openssl/crypto/rsa/rsa_pk1.c +++ b/deps/openssl/openssl/crypto/rsa/rsa_pk1.c @@ -56,6 +56,8 @@ * [including the GNU Public Licence.] */ +#include "constant_time_locl.h" + #include #include "cryptlib.h" #include @@ -181,44 +183,87 @@ int RSA_padding_add_PKCS1_type_2(unsigned char *to, int tlen, int RSA_padding_check_PKCS1_type_2(unsigned char *to, int tlen, const unsigned char *from, int flen, int num) { - int i,j; - const unsigned char *p; + int i; + /* |em| is the encoded message, zero-padded to exactly |num| bytes */ + unsigned char *em = NULL; + unsigned int good, found_zero_byte; + int zero_index = 0, msg_index, mlen = -1; - p=from; - if ((num != (flen+1)) || (*(p++) != 02)) - { - RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_2,RSA_R_BLOCK_TYPE_IS_NOT_02); - return(-1); - } -#ifdef PKCS1_CHECK - return(num-11); -#endif + if (tlen < 0 || flen < 0) + return -1; - /* scan over padding data */ - j=flen-1; /* one for type. */ - for (i=0; i num) + goto err; + + if (num < 11) + goto err; + + em = OPENSSL_malloc(num); + if (em == NULL) { - RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_2,RSA_R_NULL_BEFORE_BLOCK_MISSING); - return(-1); + RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_2, ERR_R_MALLOC_FAILURE); + return -1; } + memset(em, 0, num); + /* + * Always do this zero-padding copy (even when num == flen) to avoid + * leaking that information. The copy still leaks some side-channel + * information, but it's impossible to have a fixed memory access + * pattern since we can't read out of the bounds of |from|. + * + * TODO(emilia): Consider porting BN_bn2bin_padded from BoringSSL. + */ + memcpy(em + num - flen, from, flen); - if (i < 8) + good = constant_time_is_zero(em[0]); + good &= constant_time_eq(em[1], 2); + + found_zero_byte = 0; + for (i = 2; i < num; i++) { - RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_2,RSA_R_BAD_PAD_BYTE_COUNT); - return(-1); + unsigned int equals0 = constant_time_is_zero(em[i]); + zero_index = constant_time_select_int(~found_zero_byte & equals0, i, zero_index); + found_zero_byte |= equals0; } - i++; /* Skip over the '\0' */ - j-=i; - if (j > tlen) + + /* + * PS must be at least 8 bytes long, and it starts two bytes into |em|. + * If we never found a 0-byte, then |zero_index| is 0 and the check + * also fails. + */ + good &= constant_time_ge((unsigned int)(zero_index), 2 + 8); + + /* Skip the zero byte. This is incorrect if we never found a zero-byte + * but in this case we also do not copy the message out. */ + msg_index = zero_index + 1; + mlen = num - msg_index; + + /* For good measure, do this check in constant time as well; it could + * leak something if |tlen| was assuming valid padding. */ + good &= constant_time_ge((unsigned int)(tlen), (unsigned int)(mlen)); + + /* + * We can't continue in constant-time because we need to copy the result + * and we cannot fake its length. This unavoidably leaks timing + * information at the API boundary. + * TODO(emilia): this could be addressed at the call site, + * see BoringSSL commit 0aa0767340baf925bda4804882aab0cb974b2d26. + */ + if (!good) { - RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_2,RSA_R_DATA_TOO_LARGE); - return(-1); + mlen = -1; + goto err; } - memcpy(to,p,(unsigned int)j); - return(j); - } + memcpy(to, em + msg_index, mlen); +err: + if (em != NULL) + OPENSSL_free(em); + if (mlen == -1) + RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_2, RSA_R_PKCS_DECODING_ERROR); + return mlen; + } diff --git a/deps/openssl/openssl/crypto/rsa/rsa_sign.c b/deps/openssl/openssl/crypto/rsa/rsa_sign.c index b6f6037ae002df..225bcfe2dcabee 100644 --- a/deps/openssl/openssl/crypto/rsa/rsa_sign.c +++ b/deps/openssl/openssl/crypto/rsa/rsa_sign.c @@ -151,6 +151,25 @@ int RSA_sign(int type, const unsigned char *m, unsigned int m_len, return(ret); } +/* + * Check DigestInfo structure does not contain extraneous data by reencoding + * using DER and checking encoding against original. + */ +static int rsa_check_digestinfo(X509_SIG *sig, const unsigned char *dinfo, int dinfolen) + { + unsigned char *der = NULL; + int derlen; + int ret = 0; + derlen = i2d_X509_SIG(sig, &der); + if (derlen <= 0) + return 0; + if (derlen == dinfolen && !memcmp(dinfo, der, derlen)) + ret = 1; + OPENSSL_cleanse(der, derlen); + OPENSSL_free(der); + return ret; + } + int int_rsa_verify(int dtype, const unsigned char *m, unsigned int m_len, unsigned char *rm, size_t *prm_len, @@ -228,7 +247,7 @@ int int_rsa_verify(int dtype, const unsigned char *m, if (sig == NULL) goto err; /* Excess data can be used to create forgeries */ - if(p != s+i) + if(p != s+i || !rsa_check_digestinfo(sig, s, i)) { RSAerr(RSA_F_INT_RSA_VERIFY,RSA_R_BAD_SIGNATURE); goto err; diff --git a/deps/openssl/openssl/crypto/stack/safestack.h b/deps/openssl/openssl/crypto/stack/safestack.h index ea3aa0d800ecec..bc194cb2681761 100644 --- a/deps/openssl/openssl/crypto/stack/safestack.h +++ b/deps/openssl/openssl/crypto/stack/safestack.h @@ -57,6 +57,10 @@ #include +#ifdef __cplusplus +extern "C" { +#endif + #ifndef CHECKED_PTR_OF #define CHECKED_PTR_OF(type, p) \ ((void*) (1 ? p : (type*)0)) @@ -2660,4 +2664,8 @@ DECLARE_SPECIAL_STACK_OF(OPENSSL_BLOCK, void) #define lh_SSL_SESSION_free(lh) LHM_lh_free(SSL_SESSION,lh) /* End of util/mkstack.pl block, you may now edit :-) */ + +#ifdef __cplusplus +} +#endif #endif /* !defined HEADER_SAFESTACK_H */ diff --git a/deps/openssl/openssl/doc/apps/c_rehash.pod b/deps/openssl/openssl/doc/apps/c_rehash.pod new file mode 100644 index 00000000000000..c564e86315529a --- /dev/null +++ b/deps/openssl/openssl/doc/apps/c_rehash.pod @@ -0,0 +1,81 @@ +=pod + +=for comment +Original text by James Westby, contributed under the OpenSSL license. + +=head1 NAME + +c_rehash - Create symbolic links to files named by the hash values + +=head1 SYNOPSIS + +B +[ I...] + +=head1 DESCRIPTION + +B scans directories and calculates a hash value of each C<.pem> +file in the specified directory list and creates symbolic links +for each file, where the name of the link is the hash value. +This utility is useful as many programs that use OpenSSL require +directories to be set up like this in order to find certificates. + +If any directories are named on the command line, then those are +processed in turn. If not, then the B environment variable +is consulted; this shold be a colon-separated list of directories, +like the Unix B variable. +If that is not set then the default directory (installation-specific +but often B) is processed. + +In order for a directory to be processed, the user must have write +permissions on that directory, otherwise it will be skipped. +The links created are of the form C, where each B +is a hexadecimal character and B is a single decimal digit. +When processing a directory, B will first remove all links +that have a name in that syntax. If you have links in that format +used for other purposes, they will be removed. +Hashes for CRL's look similar except the letter B appears after +the period, like this: C. + +Multiple objects may have the same hash; they will be indicated by +incrementing the B value. Duplicates are found by comparing the +full SHA-1 fingerprint. A warning will be displayed if a duplicate +is found. + +A warning will also be displayed if there are B<.pem> files that +cannot be parsed as either a certificate or a CRL. + +The program uses the B program to compute the hashes and +fingerprints. If not found in the user's B, then set the +B environment variable to the full pathname. +Any program can be used, it will be invoked as follows for either +a certificate or CRL: + + $OPENSSL x509 -hash -fingerprint -noout -in FFFFFF + $OPENSSL crl -hash -fingerprint -noout -in FFFFFF + +where B is the filename. It must output the hash of the +file on the first line, and the fingerprint on the second, +optionally prefixed with some text and an equals sign. + +=head1 ENVIRONMENT + +=over + +=item B + +The path to an executable to use to generate hashes and +fingerprints (see above). + +=item B + +Colon separated list of directories to operate on. +Ignored if directories are listed on the command line. + +=back + +=head1 SEE ALSO + +L, +L. +L. diff --git a/deps/openssl/openssl/doc/apps/dgst.pod b/deps/openssl/openssl/doc/apps/dgst.pod index b035edf08e0fb2..2414c533777847 100644 --- a/deps/openssl/openssl/doc/apps/dgst.pod +++ b/deps/openssl/openssl/doc/apps/dgst.pod @@ -2,16 +2,17 @@ =head1 NAME -dgst, md5, md4, md2, sha1, sha, mdc2, ripemd160 - message digests +dgst, sha, sha1, mdc2, ripemd160, sha224, sha256, sha384, sha512, md2, md4, md5, dss1 - message digests =head1 SYNOPSIS B B -[B<-md5|-md4|-md2|-sha1|-sha|-mdc2|-ripemd160|-dss1>] +[B<-sha|-sha1|-mdc2|-ripemd160|-sha224|-sha256|-sha384|-sha512|-md2|-md4|-md5|-dss1>] [B<-c>] [B<-d>] [B<-hex>] [B<-binary>] +[B<-r>] [B<-out filename>] [B<-sign filename>] [B<-keyform arg>] @@ -20,17 +21,19 @@ B B [B<-prverify filename>] [B<-signature filename>] [B<-hmac key>] +[B<-non-fips-allow>] +[B<-fips-fingerprint>] [B] -[B] -[B<-c>] -[B<-d>] -[B] +B +[I] +[B<...>] =head1 DESCRIPTION The digest functions output the message digest of a supplied file or files -in hexadecimal form. They can also be used for digital signing and verification. +in hexadecimal. The digest functions also generate and verify digital +signatures using message digests. =head1 OPTIONS @@ -48,12 +51,17 @@ print out BIO debugging information. =item B<-hex> digest is to be output as a hex dump. This is the default case for a "normal" -digest as opposed to a digital signature. +digest as opposed to a digital signature. See NOTES below for digital +signatures using B<-hex>. =item B<-binary> output the digest or signature in binary form. +=item B<-r> + +output the digest in the "coreutils" format used by programs like B. + =item B<-out filename> filename to output to, or standard output by default. @@ -64,8 +72,8 @@ digitally sign the digest using the private key in "filename". =item B<-keyform arg> -Specifies the key format to sign digest with. Only PEM and ENGINE -formats are supported by the B command. +Specifies the key format to sign digest with. The DER, PEM, P12, +and ENGINE formats are supported. =item B<-engine id> @@ -117,7 +125,7 @@ Following options are supported by both by B and B: =over 8 =item B - + Specifies MAC key as alphnumeric string (use if key contain printable characters only). String length must conform to any restrictions of the MAC algorithm for example exactly 32 chars for gost-mac. @@ -138,6 +146,15 @@ Multiple files can be specified separated by a OS-dependent character. The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for all others. +=item B<-non-fips-allow> + +enable use of non-FIPS algorithms such as MD5 even in FIPS mode. + +=item B<-fips-fingerprint> + +compute HMAC using a specific key +for certain OpenSSL-FIPS operations. + =item B file or files to digest. If no files are specified then standard input is @@ -145,18 +162,41 @@ used. =back + +=head1 EXAMPLES + +To create a hex-encoded message digest of a file: + openssl dgst -md5 -hex file.txt + +To sign a file using SHA-256 with binary file output: + openssl dgst -sha256 -sign privatekey.pem -out signature.sign file.txt + +To verify a signature: + openssl dgst -sha256 -verify publickey.pem \ + -signature signature.sign \ + file.txt + + =head1 NOTES The digest of choice for all new applications is SHA1. Other digests are however still widely used. -If you wish to sign or verify data using the DSA algorithm then the dss1 -digest must be used. +When signing a file, B will automatically determine the algorithm +(RSA, ECC, etc) to use for signing based on the private key's ASN.1 info. +When verifying signatures, it only handles the RSA, DSA, or ECDSA signature +itself, not the related data to identify the signer and algorithm used in +formats such as x.509, CMS, and S/MIME. A source of random numbers is required for certain signing algorithms, in -particular DSA. +particular ECDSA and DSA. The signing and verify options should only be used if a single file is being signed or verified. +Hex signatures cannot be verified using B. Instead, use "xxd -r" +or similar program to transform the hex signature into a binary signature +prior to verification. + + =cut diff --git a/deps/openssl/openssl/doc/crypto/BIO_s_accept.pod b/deps/openssl/openssl/doc/crypto/BIO_s_accept.pod index 7b63e4621b6600..b80b6ae488363b 100644 --- a/deps/openssl/openssl/doc/crypto/BIO_s_accept.pod +++ b/deps/openssl/openssl/doc/crypto/BIO_s_accept.pod @@ -59,8 +59,8 @@ the accept socket. See L BIO_set_accept_port() uses the string B to set the accept port. The port is represented as a string of the form "host:port", where "host" is the interface to use and "port" is the port. -Either or both values can be "*" which is interpreted as meaning -any interface or port respectively. "port" has the same syntax +The host can be can be "*" which is interpreted as meaning +any interface; "port" has the same syntax as the port specified in BIO_set_conn_port() for connect BIOs, that is it can be a numerical port string or a string to lookup using getservbyname() and a string table. diff --git a/deps/openssl/openssl/doc/crypto/CMS_add1_signer.pod b/deps/openssl/openssl/doc/crypto/CMS_add1_signer.pod new file mode 100644 index 00000000000000..a055b82695aee8 --- /dev/null +++ b/deps/openssl/openssl/doc/crypto/CMS_add1_signer.pod @@ -0,0 +1,101 @@ +=pod + +=head1 NAME + + CMS_add1_signer, CMS_SignerInfo_sign - add a signer to a CMS_ContentInfo signed data structure. + +=head1 SYNOPSIS + + #include + + CMS_SignerInfo *CMS_add1_signer(CMS_ContentInfo *cms, X509 *signcert, EVP_PKEY *pkey, const EVP_MD *md, unsigned int flags); + + int CMS_SignerInfo_sign(CMS_SignerInfo *si); + + +=head1 DESCRIPTION + +CMS_add1_signer() adds a signer with certificate B and private +key B using message digest B to CMS_ContentInfo SignedData +structure B. + +The CMS_ContentInfo structure should be obtained from an initial call to +CMS_sign() with the flag B set or in the case or re-signing a +valid CMS_ContentInfo SignedData structure. + +If the B parameter is B then the default digest for the public +key algorithm will be used. + +Unless the B flag is set the returned CMS_ContentInfo +structure is not complete and must be finalized either by streaming (if +applicable) or a call to CMS_final(). + +The CMS_SignerInfo_sign() function will explicitly sign a CMS_SignerInfo +structure, its main use is when B and B flags +are both set. + +=head1 NOTES + +The main purpose of CMS_add1_signer() is to provide finer control +over a CMS signed data structure where the simpler CMS_sign() function defaults +are not appropriate. For example if multiple signers or non default digest +algorithms are needed. New attributes can also be added using the returned +CMS_SignerInfo structure and the CMS attribute utility functions or the +CMS signed receipt request functions. + +Any of the following flags (ored together) can be passed in the B +parameter. + +If B is set then an attempt is made to copy the content +digest value from the CMS_ContentInfo structure: to add a signer to an existing +structure. An error occurs if a matching digest value cannot be found to copy. +The returned CMS_ContentInfo structure will be valid and finalized when this +flag is set. + +If B is set in addition to B then the +CMS_SignerInfo structure will not be finalized so additional attributes +can be added. In this case an explicit call to CMS_SignerInfo_sign() is +needed to finalize it. + +If B is set the signer's certificate will not be included in the +CMS_ContentInfo structure, the signer's certificate must still be supplied in +the B parameter though. This can reduce the size of the signature if +the signers certificate can be obtained by other means: for example a +previously signed message. + +The SignedData structure includes several CMS signedAttributes including the +signing time, the CMS content type and the supported list of ciphers in an +SMIMECapabilities attribute. If B is set then no signedAttributes +will be used. If B is set then just the SMIMECapabilities are +omitted. + +OpenSSL will by default identify signing certificates using issuer name +and serial number. If B is set it will use the subject key +identifier value instead. An error occurs if the signing certificate does not +have a subject key identifier extension. + +If present the SMIMECapabilities attribute indicates support for the following +algorithms in preference order: 256 bit AES, Gost R3411-94, Gost 28147-89, 192 +bit AES, 128 bit AES, triple DES, 128 bit RC2, 64 bit RC2, DES and 40 bit RC2. +If any of these algorithms is not available then it will not be included: for example the GOST algorithms will not be included if the GOST ENGINE is +not loaded. + +CMS_add1_signer() returns an internal pointer to the CMS_SignerInfo +structure just added, this can be used to set additional attributes +before it is finalized. + +=head1 RETURN VALUES + +CMS_add1_signer() returns an internal pointer to the CMS_SignerInfo +structure just added or NULL if an error occurs. + +=head1 SEE ALSO + +L, L, +L, + +=head1 HISTORY + +CMS_add1_signer() was added to OpenSSL 0.9.8 + +=cut diff --git a/deps/openssl/openssl/doc/crypto/CMS_sign_add1_signer.pod b/deps/openssl/openssl/doc/crypto/CMS_sign_add1_signer.pod deleted file mode 100644 index bda3ca2adbd1c1..00000000000000 --- a/deps/openssl/openssl/doc/crypto/CMS_sign_add1_signer.pod +++ /dev/null @@ -1,101 +0,0 @@ -=pod - -=head1 NAME - - CMS_sign_add1_signer, CMS_SignerInfo_sign - add a signer to a CMS_ContentInfo signed data structure. - -=head1 SYNOPSIS - - #include - - CMS_SignerInfo *CMS_sign_add1_signer(CMS_ContentInfo *cms, X509 *signcert, EVP_PKEY *pkey, const EVP_MD *md, unsigned int flags); - - int CMS_SignerInfo_sign(CMS_SignerInfo *si); - - -=head1 DESCRIPTION - -CMS_sign_add1_signer() adds a signer with certificate B and private -key B using message digest B to CMS_ContentInfo SignedData -structure B. - -The CMS_ContentInfo structure should be obtained from an initial call to -CMS_sign() with the flag B set or in the case or re-signing a -valid CMS_ContentInfo SignedData structure. - -If the B parameter is B then the default digest for the public -key algorithm will be used. - -Unless the B flag is set the returned CMS_ContentInfo -structure is not complete and must be finalized either by streaming (if -applicable) or a call to CMS_final(). - -The CMS_SignerInfo_sign() function will explicitly sign a CMS_SignerInfo -structure, its main use is when B and B flags -are both set. - -=head1 NOTES - -The main purpose of CMS_sign_add1_signer() is to provide finer control -over a CMS signed data structure where the simpler CMS_sign() function defaults -are not appropriate. For example if multiple signers or non default digest -algorithms are needed. New attributes can also be added using the returned -CMS_SignerInfo structure and the CMS attribute utility functions or the -CMS signed receipt request functions. - -Any of the following flags (ored together) can be passed in the B -parameter. - -If B is set then an attempt is made to copy the content -digest value from the CMS_ContentInfo structure: to add a signer to an existing -structure. An error occurs if a matching digest value cannot be found to copy. -The returned CMS_ContentInfo structure will be valid and finalized when this -flag is set. - -If B is set in addition to B then the -CMS_SignerInfo structure will not be finalized so additional attributes -can be added. In this case an explicit call to CMS_SignerInfo_sign() is -needed to finalize it. - -If B is set the signer's certificate will not be included in the -CMS_ContentInfo structure, the signer's certificate must still be supplied in -the B parameter though. This can reduce the size of the signature if -the signers certificate can be obtained by other means: for example a -previously signed message. - -The SignedData structure includes several CMS signedAttributes including the -signing time, the CMS content type and the supported list of ciphers in an -SMIMECapabilities attribute. If B is set then no signedAttributes -will be used. If B is set then just the SMIMECapabilities are -omitted. - -OpenSSL will by default identify signing certificates using issuer name -and serial number. If B is set it will use the subject key -identifier value instead. An error occurs if the signing certificate does not -have a subject key identifier extension. - -If present the SMIMECapabilities attribute indicates support for the following -algorithms in preference order: 256 bit AES, Gost R3411-94, Gost 28147-89, 192 -bit AES, 128 bit AES, triple DES, 128 bit RC2, 64 bit RC2, DES and 40 bit RC2. -If any of these algorithms is not available then it will not be included: for example the GOST algorithms will not be included if the GOST ENGINE is -not loaded. - -CMS_sign_add1_signer() returns an internal pointer to the CMS_SignerInfo -structure just added, this can be used to set additional attributes -before it is finalized. - -=head1 RETURN VALUES - -CMS_sign1_add_signers() returns an internal pointer to the CMS_SignerInfo -structure just added or NULL if an error occurs. - -=head1 SEE ALSO - -L, L, -L, - -=head1 HISTORY - -CMS_sign_add1_signer() was added to OpenSSL 0.9.8 - -=cut diff --git a/deps/openssl/openssl/doc/crypto/EVP_DigestInit.pod b/deps/openssl/openssl/doc/crypto/EVP_DigestInit.pod index 310c65eb370577..ac526bb6dbcb71 100644 --- a/deps/openssl/openssl/doc/crypto/EVP_DigestInit.pod +++ b/deps/openssl/openssl/doc/crypto/EVP_DigestInit.pod @@ -26,13 +26,13 @@ EVP digest routines int EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx); void EVP_MD_CTX_destroy(EVP_MD_CTX *ctx); - int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out,const EVP_MD_CTX *in); + int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out,const EVP_MD_CTX *in); int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type); int EVP_DigestFinal(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *s); - int EVP_MD_CTX_copy(EVP_MD_CTX *out,EVP_MD_CTX *in); + int EVP_MD_CTX_copy(EVP_MD_CTX *out,EVP_MD_CTX *in); #define EVP_MAX_MD_SIZE 64 /* SHA512 */ @@ -136,10 +136,10 @@ reasons. EVP_md2(), EVP_md5(), EVP_sha(), EVP_sha1(), EVP_sha224(), EVP_sha256(), EVP_sha384(), EVP_sha512(), EVP_mdc2() and EVP_ripemd160() return B structures for the MD2, MD5, SHA, SHA1, SHA224, SHA256, SHA384, SHA512, MDC2 -and RIPEMD160 digest algorithms respectively. +and RIPEMD160 digest algorithms respectively. EVP_dss() and EVP_dss1() return B structures for SHA and SHA1 digest -algorithms but using DSS (DSA) for the signature algorithm. Note: there is +algorithms but using DSS (DSA) for the signature algorithm. Note: there is no need to use these pseudo-digests in OpenSSL 1.0.0 and later, they are however retained for compatibility. @@ -177,21 +177,21 @@ The B interface to message digests should almost always be used in preference to the low level interfaces. This is because the code then becomes transparent to the digest used and much more flexible. -New applications should use the SHA2 digest algorithms such as SHA256. +New applications should use the SHA2 digest algorithms such as SHA256. The other digest algorithms are still in common use. For most applications the B parameter to EVP_DigestInit_ex() will be set to NULL to use the default digest implementation. -The functions EVP_DigestInit(), EVP_DigestFinal() and EVP_MD_CTX_copy() are +The functions EVP_DigestInit(), EVP_DigestFinal() and EVP_MD_CTX_copy() are obsolete but are retained to maintain compatibility with existing code. New -applications should use EVP_DigestInit_ex(), EVP_DigestFinal_ex() and +applications should use EVP_DigestInit_ex(), EVP_DigestFinal_ex() and EVP_MD_CTX_copy_ex() because they can efficiently reuse a digest context instead of initializing and cleaning it up on each call and allow non default implementations of digests to be specified. In OpenSSL 0.9.7 and later if digest contexts are not cleaned up after use -memory leaks will occur. +memory leaks will occur. Stack allocation of EVP_MD_CTX structures is common, for example: @@ -245,15 +245,19 @@ digest name passed on the command line. EVP_MD_CTX_destroy(mdctx); printf("Digest is: "); - for(i = 0; i < md_len; i++) printf("%02x", md_value[i]); + for(i = 0; i < md_len; i++) + printf("%02x", md_value[i]); printf("\n"); + + /* Call this once before exit. */ + EVP_cleanup(); + exit(0); } =head1 SEE ALSO -L, L, L, -L, L, L, -L, L +L, +L =head1 HISTORY @@ -269,7 +273,7 @@ EVP_dss(), EVP_dss1(), EVP_mdc2() and EVP_ripemd160() were changed to return truely const EVP_MD * in OpenSSL 0.9.7. The link between digests and signing algorithms was fixed in OpenSSL 1.0 and -later, so now EVP_sha1() can be used with RSA and DSA, there is no need to +later, so now EVP_sha1() can be used with RSA and DSA; there is no need to use EVP_dss1() any more. OpenSSL 1.0 and later does not include the MD2 digest algorithm in the diff --git a/deps/openssl/openssl/doc/crypto/EVP_DigestVerifyInit.pod b/deps/openssl/openssl/doc/crypto/EVP_DigestVerifyInit.pod index f22448897839ba..cfeccd96effcfb 100644 --- a/deps/openssl/openssl/doc/crypto/EVP_DigestVerifyInit.pod +++ b/deps/openssl/openssl/doc/crypto/EVP_DigestVerifyInit.pod @@ -38,7 +38,7 @@ or a negative value for failure. In particular a return value of -2 indicates the operation is not supported by the public key algorithm. Unlike other functions the return value 0 from EVP_DigestVerifyFinal() only -indicates that the signature did not not verify successfully (that is tbs did +indicates that the signature did not verify successfully (that is tbs did not match the original data or the signature was of invalid form) it is not an indication of a more serious error. @@ -59,7 +59,7 @@ For some key types and parameters the random number generator must be seeded or the operation will fail. The call to EVP_DigestVerifyFinal() internally finalizes a copy of the digest -context. This means that calls to EVP_VerifyUpdate() and EVP_VerifyFinal() can +context. This means that EVP_VerifyUpdate() and EVP_VerifyFinal() can be called later to digest and verify additional data. Since only a copy of the digest context is ever finalized the context must diff --git a/deps/openssl/openssl/doc/crypto/EVP_EncryptInit.pod b/deps/openssl/openssl/doc/crypto/EVP_EncryptInit.pod index d11e054e48b3be..4e22edcd679bfb 100644 --- a/deps/openssl/openssl/doc/crypto/EVP_EncryptInit.pod +++ b/deps/openssl/openssl/doc/crypto/EVP_EncryptInit.pod @@ -387,27 +387,7 @@ for certain common S/MIME ciphers (RC2, DES, triple DES) in CBC mode. =head1 EXAMPLES -Get the number of rounds used in RC5: - - int nrounds; - EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GET_RC5_ROUNDS, 0, &nrounds); - -Get the RC2 effective key length: - - int key_bits; - EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GET_RC2_KEY_BITS, 0, &key_bits); - -Set the number of rounds used in RC5: - - int nrounds; - EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_SET_RC5_ROUNDS, nrounds, NULL); - -Set the effective key length used in RC2: - - int key_bits; - EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_SET_RC2_KEY_BITS, key_bits, NULL); - -Encrypt a string using blowfish: +Encrypt a string using IDEA: int do_crypt(char *outfile) { @@ -421,8 +401,9 @@ Encrypt a string using blowfish: char intext[] = "Some Crypto Text"; EVP_CIPHER_CTX ctx; FILE *out; + EVP_CIPHER_CTX_init(&ctx); - EVP_EncryptInit_ex(&ctx, EVP_bf_cbc(), NULL, key, iv); + EVP_EncryptInit_ex(&ctx, EVP_idea_cbc(), NULL, key, iv); if(!EVP_EncryptUpdate(&ctx, outbuf, &outlen, intext, strlen(intext))) { @@ -451,28 +432,34 @@ Encrypt a string using blowfish: } The ciphertext from the above example can be decrypted using the B -utility with the command line: +utility with the command line (shown on two lines for clarity): - S + openssl idea -d or B if the key is not of the correct type. -EVP_PKEY_assign_RSA() EVP_PKEY_assign_DSA(), EVP_PKEY_assign_DH() +EVP_PKEY_assign_RSA(), EVP_PKEY_assign_DSA(), EVP_PKEY_assign_DH() and EVP_PKEY_assign_EC_KEY() also set the referenced key to B however these use the supplied B internally and so B will be freed when the parent B is freed. @@ -54,8 +54,8 @@ In accordance with the OpenSSL naming convention the key obtained from or assigned to the B using the B<1> functions must be freed as well as B. -EVP_PKEY_assign_RSA() EVP_PKEY_assign_DSA(), EVP_PKEY_assign_DH() -EVP_PKEY_assign_EC_KEY() are implemented as macros. +EVP_PKEY_assign_RSA(), EVP_PKEY_assign_DSA(), EVP_PKEY_assign_DH() +and EVP_PKEY_assign_EC_KEY() are implemented as macros. =head1 RETURN VALUES @@ -66,7 +66,7 @@ EVP_PKEY_get1_RSA(), EVP_PKEY_get1_DSA(), EVP_PKEY_get1_DH() and EVP_PKEY_get1_EC_KEY() return the referenced key or B if an error occurred. -EVP_PKEY_assign_RSA() EVP_PKEY_assign_DSA(), EVP_PKEY_assign_DH() +EVP_PKEY_assign_RSA(), EVP_PKEY_assign_DSA(), EVP_PKEY_assign_DH() and EVP_PKEY_assign_EC_KEY() return 1 for success and 0 for failure. =head1 SEE ALSO diff --git a/deps/openssl/openssl/doc/crypto/EVP_PKEY_sign.pod b/deps/openssl/openssl/doc/crypto/EVP_PKEY_sign.pod index a044f2c13127fa..21974b4b1a9cf3 100644 --- a/deps/openssl/openssl/doc/crypto/EVP_PKEY_sign.pod +++ b/deps/openssl/openssl/doc/crypto/EVP_PKEY_sign.pod @@ -28,9 +28,14 @@ B and the amount of data written to B. =head1 NOTES +EVP_PKEY_sign() does not hash the data to be signed, and therefore is +normally used to sign digests. For signing arbitrary messages, see the +L and +L signing interfaces instead. + After the call to EVP_PKEY_sign_init() algorithm specific control operations can be performed to set any appropriate parameters for the -operation. +operation (see L). The function EVP_PKEY_sign() can be called more than once on the same context if several operations are performed using the same parameters. @@ -49,13 +54,17 @@ Sign data using RSA with PKCS#1 padding and SHA256 digest: #include EVP_PKEY_CTX *ctx; + /* md is a SHA-256 digest in this example. */ unsigned char *md, *sig; - size_t mdlen, siglen; + size_t mdlen = 32, siglen; EVP_PKEY *signing_key; - /* NB: assumes signing_key, md and mdlen are already set up - * and that signing_key is an RSA private key + + /* + * NB: assumes signing_key and md are set up before the next + * step. signing_key must be an RSA private key and md must + * point to the SHA-256 digest to be signed. */ - ctx = EVP_PKEY_CTX_new(signing_key); + ctx = EVP_PKEY_CTX_new(signing_key, NULL /* no engine */); if (!ctx) /* Error occurred */ if (EVP_PKEY_sign_init(ctx) <= 0) @@ -83,6 +92,7 @@ Sign data using RSA with PKCS#1 padding and SHA256 digest: =head1 SEE ALSO L, +L, L, L, L, diff --git a/deps/openssl/openssl/doc/ssl/SSL_CTX_set_tmp_dh_callback.pod b/deps/openssl/openssl/doc/ssl/SSL_CTX_set_tmp_dh_callback.pod index b34c68aba34363..7a27eef50b173d 100644 --- a/deps/openssl/openssl/doc/ssl/SSL_CTX_set_tmp_dh_callback.pod +++ b/deps/openssl/openssl/doc/ssl/SSL_CTX_set_tmp_dh_callback.pod @@ -48,12 +48,13 @@ even if he gets hold of the normal (certified) key, as this key was only used for signing. In order to perform a DH key exchange the server must use a DH group -(DH parameters) and generate a DH key. The server will always generate a new -DH key during the negotiation, when the DH parameters are supplied via -callback and/or when the SSL_OP_SINGLE_DH_USE option of -L is set. It will -immediately create a DH key, when DH parameters are supplied via -SSL_CTX_set_tmp_dh() and SSL_OP_SINGLE_DH_USE is not set. In this case, +(DH parameters) and generate a DH key. +The server will always generate a new DH key during the negotiation +if either the DH parameters are supplied via callback or the +SSL_OP_SINGLE_DH_USE option of SSL_CTX_set_options(3) is set (or both). +It will immediately create a DH key if DH parameters are supplied via +SSL_CTX_set_tmp_dh() and SSL_OP_SINGLE_DH_USE is not set. +In this case, it may happen that a key is generated on initialization without later being needed, while on the other hand the computer time during the negotiation is being saved. @@ -139,7 +140,7 @@ partly left out.) dh_tmp = dh_512; break; case 1024: - if (!dh_1024) + if (!dh_1024) dh_1024 = get_dh1024(); dh_tmp = dh_1024; break; diff --git a/deps/openssl/openssl/e_os.h b/deps/openssl/openssl/e_os.h index 6a0aad1de72f1c..733155e48df816 100644 --- a/deps/openssl/openssl/e_os.h +++ b/deps/openssl/openssl/e_os.h @@ -373,7 +373,16 @@ static unsigned int _strlen31(const char *str) # define check_winnt() (1) #else # define check_winnt() (GetVersion() < 0x80000000) -#endif +#endif + +/* + * Visual Studio: inline is available in C++ only, however + * __inline is available for C, see + * http://msdn.microsoft.com/en-us/library/z8y1yy88.aspx + */ +#if defined(_MSC_VER) && !defined(__cplusplus) && !defined(inline) +# define inline __inline +#endif #else /* The non-microsoft world */ @@ -738,4 +747,3 @@ struct servent *getservbyname(const char *name, const char *proto); #endif #endif - diff --git a/deps/openssl/openssl/engines/makeengines.com b/deps/openssl/openssl/engines/makeengines.com index 6329fbbf03a1a3..4838e389afa192 100644 --- a/deps/openssl/openssl/engines/makeengines.com +++ b/deps/openssl/openssl/engines/makeengines.com @@ -155,7 +155,7 @@ $ ENGINE_ = "engine_vector.mar" $ TV_OBJ_NAME = OBJ_DIR + F$PARSE(ENGINE_,,,"NAME","SYNTAX_ONLY") + ".OBJ" $ TV_OBJ = ",''TV_OBJ_NAME'" $ ENDIF -$ ENGINE_4758CCA = "e_4758cca" +$ ENGINE_4758cca = "e_4758cca" $ ENGINE_aep = "e_aep" $ ENGINE_atalla = "e_atalla" $ ENGINE_cswift = "e_cswift" @@ -756,9 +756,12 @@ $ CCDEFS = "TCPIP_TYPE_''OPT_TCPIP_LIB',DSO_VMS" $ IF F$TYPE(USER_CCDEFS) .NES. "" THEN CCDEFS = CCDEFS + "," + USER_CCDEFS $ CCEXTRAFLAGS = "" $ IF F$TYPE(USER_CCFLAGS) .NES. "" THEN CCEXTRAFLAGS = USER_CCFLAGS -$ CCDISABLEWARNINGS = "" !!! "LONGLONGTYPE,LONGLONGSUFX" -$ IF F$TYPE(USER_CCDISABLEWARNINGS) .NES. "" THEN - - CCDISABLEWARNINGS = CCDISABLEWARNINGS + "," + USER_CCDISABLEWARNINGS +$ CCDISABLEWARNINGS = "" !!! "MAYLOSEDATA3" !!! "LONGLONGTYPE,LONGLONGSUFX" +$ IF F$TYPE(USER_CCDISABLEWARNINGS) .NES. "" +$ THEN +$ IF CCDISABLEWARNINGS .NES. "" THEN CCDISABLEWARNINGS = CCDISABLEWARNINGS + "," +$ CCDISABLEWARNINGS = CCDISABLEWARNINGS + USER_CCDISABLEWARNINGS +$ ENDIF $! $! Check To See If We Have A ZLIB Option. $! @@ -922,6 +925,18 @@ $! Finish up the definition of CC. $! $ IF COMPILER .EQS. "DECC" $ THEN +$! Not all compiler versions support MAYLOSEDATA3. +$ OPT_TEST = "MAYLOSEDATA3" +$ DEFINE /USER_MODE SYS$ERROR NL: +$ DEFINE /USER_MODE SYS$OUTPUT NL: +$ 'CC' /NOCROSS_REFERENCE /NOLIST /NOOBJECT - + /WARNINGS = DISABLE = ('OPT_TEST', EMPTYFILE) NL: +$ IF ($SEVERITY) +$ THEN +$ IF CCDISABLEWARNINGS .NES. "" THEN - + CCDISABLEWARNINGS = CCDISABLEWARNINGS+ "," +$ CCDISABLEWARNINGS = CCDISABLEWARNINGS+ OPT_TEST +$ ENDIF $ IF CCDISABLEWARNINGS .NES. "" $ THEN $ CCDISABLEWARNINGS = " /WARNING=(DISABLE=(" + CCDISABLEWARNINGS + "))" diff --git a/deps/openssl/openssl/makevms.com b/deps/openssl/openssl/makevms.com index de1dbd9058a1f0..11db2f16e4ef1e 100755 --- a/deps/openssl/openssl/makevms.com +++ b/deps/openssl/openssl/makevms.com @@ -283,6 +283,7 @@ $ CONFIG_LOGICALS := AES,- MD4,- MD5,- MDC2,- + NEXTPROTONEG,- OCSP,- PSK,- RC2,- @@ -340,7 +341,12 @@ $ CONFIG_DISABLE_RULES := RIJNDAEL/AES;- DH/GOST;- /STATIC_ENGINE;- /KRB5;- - /EC_NISTP_64_GCC_128 + /EC_NISTP_64_GCC_128;- + /GMP;- + /MD2;- + /RC5;- + /RFC3779;- + /SCTP $ CONFIG_ENABLE_RULES := ZLIB_DYNAMIC/ZLIB;- /THREADS $ @@ -706,8 +712,8 @@ $! $ SDIRS := , - 'ARCHD', - OBJECTS, - - MD2, MD4, MD5, SHA, MDC2, HMAC, RIPEMD, WHRLPOOL, - - DES, AES, RC2, RC4, RC5, IDEA, BF, CAST, CAMELLIA, SEED, MODES, - + MD4, MD5, SHA, MDC2, HMAC, RIPEMD, WHRLPOOL, - + DES, AES, RC2, RC4, IDEA, BF, CAST, CAMELLIA, SEED, MODES, - BN, EC, RSA, DSA, ECDSA, DH, ECDH, DSO, ENGINE, - BUFFER, BIO, STACK, LHASH, RAND, ERR, - EVP, ASN1, PEM, X509, X509V3, CONF, TXT_DB, PKCS7, PKCS12, - @@ -819,8 +825,9 @@ $ @CRYPTO-LIB LIBRARY 'DEBUGGER' "''COMPILER'" "''TCPIP_TYPE'" - $! $! Build The [.xxx.EXE.CRYPTO]*.EXE Test Applications. $! -$ @CRYPTO-LIB APPS 'DEBUGGER' "''COMPILER'" "''TCPIP_TYPE'" - - "''ISSEVEN'" "''BUILDPART'" "''POINTER_SIZE'" "''ZLIB'" +$!!! DISABLED, as these test programs lack any support +$!!!$ @CRYPTO-LIB APPS 'DEBUGGER' "''COMPILER'" "''TCPIP_TYPE'" - +$!!! "''ISSEVEN'" "''BUILDPART'" "''POINTER_SIZE'" "''ZLIB'" $! $! Go Back To The Main Directory. $! diff --git a/deps/openssl/openssl/openssl.spec b/deps/openssl/openssl/openssl.spec index a7e277650bea6e..706fb5d239901f 100644 --- a/deps/openssl/openssl/openssl.spec +++ b/deps/openssl/openssl/openssl.spec @@ -7,7 +7,7 @@ Release: 1 Summary: Secure Sockets Layer and cryptography libraries and tools Name: openssl #Version: %{libmaj}.%{libmin}.%{librel} -Version: 1.0.1i +Version: 1.0.1j Source0: ftp://ftp.openssl.org/source/%{name}-%{version}.tar.gz License: OpenSSL Group: System Environment/Libraries diff --git a/deps/openssl/openssl/ssl/Makefile b/deps/openssl/openssl/ssl/Makefile index bffd928f515395..8dd390e67f9903 100644 --- a/deps/openssl/openssl/ssl/Makefile +++ b/deps/openssl/openssl/ssl/Makefile @@ -547,26 +547,27 @@ s3_both.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h s3_both.o: ../include/openssl/stack.h ../include/openssl/symhacks.h s3_both.o: ../include/openssl/tls1.h ../include/openssl/x509.h s3_both.o: ../include/openssl/x509_vfy.h s3_both.c ssl_locl.h -s3_cbc.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h -s3_cbc.o: ../include/openssl/buffer.h ../include/openssl/comp.h -s3_cbc.o: ../include/openssl/crypto.h ../include/openssl/dsa.h -s3_cbc.o: ../include/openssl/dtls1.h ../include/openssl/e_os2.h -s3_cbc.o: ../include/openssl/ec.h ../include/openssl/ecdh.h -s3_cbc.o: ../include/openssl/ecdsa.h ../include/openssl/err.h -s3_cbc.o: ../include/openssl/evp.h ../include/openssl/hmac.h -s3_cbc.o: ../include/openssl/kssl.h ../include/openssl/lhash.h -s3_cbc.o: ../include/openssl/md5.h ../include/openssl/obj_mac.h -s3_cbc.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h -s3_cbc.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h -s3_cbc.o: ../include/openssl/pem.h ../include/openssl/pem2.h -s3_cbc.o: ../include/openssl/pkcs7.h ../include/openssl/pqueue.h -s3_cbc.o: ../include/openssl/rsa.h ../include/openssl/safestack.h -s3_cbc.o: ../include/openssl/sha.h ../include/openssl/srtp.h -s3_cbc.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h -s3_cbc.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h -s3_cbc.o: ../include/openssl/stack.h ../include/openssl/symhacks.h -s3_cbc.o: ../include/openssl/tls1.h ../include/openssl/x509.h -s3_cbc.o: ../include/openssl/x509_vfy.h s3_cbc.c ssl_locl.h +s3_cbc.o: ../crypto/constant_time_locl.h ../e_os.h ../include/openssl/asn1.h +s3_cbc.o: ../include/openssl/bio.h ../include/openssl/buffer.h +s3_cbc.o: ../include/openssl/comp.h ../include/openssl/crypto.h +s3_cbc.o: ../include/openssl/dsa.h ../include/openssl/dtls1.h +s3_cbc.o: ../include/openssl/e_os2.h ../include/openssl/ec.h +s3_cbc.o: ../include/openssl/ecdh.h ../include/openssl/ecdsa.h +s3_cbc.o: ../include/openssl/err.h ../include/openssl/evp.h +s3_cbc.o: ../include/openssl/hmac.h ../include/openssl/kssl.h +s3_cbc.o: ../include/openssl/lhash.h ../include/openssl/md5.h +s3_cbc.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h +s3_cbc.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h +s3_cbc.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h +s3_cbc.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h +s3_cbc.o: ../include/openssl/pqueue.h ../include/openssl/rsa.h +s3_cbc.o: ../include/openssl/safestack.h ../include/openssl/sha.h +s3_cbc.o: ../include/openssl/srtp.h ../include/openssl/ssl.h +s3_cbc.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h +s3_cbc.o: ../include/openssl/ssl3.h ../include/openssl/stack.h +s3_cbc.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h +s3_cbc.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h s3_cbc.c +s3_cbc.o: ssl_locl.h s3_clnt.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h s3_clnt.o: ../include/openssl/bn.h ../include/openssl/buffer.h s3_clnt.o: ../include/openssl/comp.h ../include/openssl/crypto.h @@ -671,28 +672,29 @@ s3_pkt.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h s3_pkt.o: ../include/openssl/stack.h ../include/openssl/symhacks.h s3_pkt.o: ../include/openssl/tls1.h ../include/openssl/x509.h s3_pkt.o: ../include/openssl/x509_vfy.h s3_pkt.c ssl_locl.h -s3_srvr.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h -s3_srvr.o: ../include/openssl/bn.h ../include/openssl/buffer.h -s3_srvr.o: ../include/openssl/comp.h ../include/openssl/crypto.h -s3_srvr.o: ../include/openssl/dh.h ../include/openssl/dsa.h -s3_srvr.o: ../include/openssl/dtls1.h ../include/openssl/e_os2.h -s3_srvr.o: ../include/openssl/ec.h ../include/openssl/ecdh.h -s3_srvr.o: ../include/openssl/ecdsa.h ../include/openssl/err.h -s3_srvr.o: ../include/openssl/evp.h ../include/openssl/hmac.h -s3_srvr.o: ../include/openssl/krb5_asn.h ../include/openssl/kssl.h -s3_srvr.o: ../include/openssl/lhash.h ../include/openssl/md5.h -s3_srvr.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h -s3_srvr.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h -s3_srvr.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h -s3_srvr.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h -s3_srvr.o: ../include/openssl/pqueue.h ../include/openssl/rand.h -s3_srvr.o: ../include/openssl/rsa.h ../include/openssl/safestack.h -s3_srvr.o: ../include/openssl/sha.h ../include/openssl/srtp.h -s3_srvr.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h -s3_srvr.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h -s3_srvr.o: ../include/openssl/stack.h ../include/openssl/symhacks.h -s3_srvr.o: ../include/openssl/tls1.h ../include/openssl/x509.h -s3_srvr.o: ../include/openssl/x509_vfy.h kssl_lcl.h s3_srvr.c ssl_locl.h +s3_srvr.o: ../crypto/constant_time_locl.h ../e_os.h ../include/openssl/asn1.h +s3_srvr.o: ../include/openssl/bio.h ../include/openssl/bn.h +s3_srvr.o: ../include/openssl/buffer.h ../include/openssl/comp.h +s3_srvr.o: ../include/openssl/crypto.h ../include/openssl/dh.h +s3_srvr.o: ../include/openssl/dsa.h ../include/openssl/dtls1.h +s3_srvr.o: ../include/openssl/e_os2.h ../include/openssl/ec.h +s3_srvr.o: ../include/openssl/ecdh.h ../include/openssl/ecdsa.h +s3_srvr.o: ../include/openssl/err.h ../include/openssl/evp.h +s3_srvr.o: ../include/openssl/hmac.h ../include/openssl/krb5_asn.h +s3_srvr.o: ../include/openssl/kssl.h ../include/openssl/lhash.h +s3_srvr.o: ../include/openssl/md5.h ../include/openssl/obj_mac.h +s3_srvr.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h +s3_srvr.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h +s3_srvr.o: ../include/openssl/pem.h ../include/openssl/pem2.h +s3_srvr.o: ../include/openssl/pkcs7.h ../include/openssl/pqueue.h +s3_srvr.o: ../include/openssl/rand.h ../include/openssl/rsa.h +s3_srvr.o: ../include/openssl/safestack.h ../include/openssl/sha.h +s3_srvr.o: ../include/openssl/srtp.h ../include/openssl/ssl.h +s3_srvr.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h +s3_srvr.o: ../include/openssl/ssl3.h ../include/openssl/stack.h +s3_srvr.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h +s3_srvr.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h kssl_lcl.h +s3_srvr.o: s3_srvr.c ssl_locl.h ssl_algs.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h ssl_algs.o: ../include/openssl/buffer.h ../include/openssl/comp.h ssl_algs.o: ../include/openssl/crypto.h ../include/openssl/dsa.h diff --git a/deps/openssl/openssl/ssl/d1_both.c b/deps/openssl/openssl/ssl/d1_both.c index 89cdca806480b6..2e4250fcfecfd4 100644 --- a/deps/openssl/openssl/ssl/d1_both.c +++ b/deps/openssl/openssl/ssl/d1_both.c @@ -1492,6 +1492,9 @@ dtls1_process_heartbeat(SSL *s) /* Read type and payload length first */ if (1 + 2 + 16 > s->s3->rrec.length) return 0; /* silently discard */ + if (s->s3->rrec.length > SSL3_RT_MAX_PLAIN_LENGTH) + return 0; /* silently discard per RFC 6520 sec. 4 */ + hbtype = *p++; n2s(p, payload); if (1 + 2 + payload + 16 > s->s3->rrec.length) diff --git a/deps/openssl/openssl/ssl/d1_lib.c b/deps/openssl/openssl/ssl/d1_lib.c index 6bde16fa212c98..82ca653920630e 100644 --- a/deps/openssl/openssl/ssl/d1_lib.c +++ b/deps/openssl/openssl/ssl/d1_lib.c @@ -266,6 +266,16 @@ long dtls1_ctrl(SSL *s, int cmd, long larg, void *parg) case DTLS_CTRL_LISTEN: ret = dtls1_listen(s, parg); break; + case SSL_CTRL_CHECK_PROTO_VERSION: + /* For library-internal use; checks that the current protocol + * is the highest enabled version (according to s->ctx->method, + * as version negotiation may have changed s->method). */ +#if DTLS_MAX_VERSION != DTLS1_VERSION +# error Code needs update for DTLS_method() support beyond DTLS1_VERSION. +#endif + /* Just one protocol version is supported so far; + * fail closed if the version is not as expected. */ + return s->version == DTLS_MAX_VERSION; default: ret = ssl3_ctrl(s, cmd, larg, parg); diff --git a/deps/openssl/openssl/ssl/d1_srtp.c b/deps/openssl/openssl/ssl/d1_srtp.c index ab9c41922c46ad..535539ba3b50c0 100644 --- a/deps/openssl/openssl/ssl/d1_srtp.c +++ b/deps/openssl/openssl/ssl/d1_srtp.c @@ -168,25 +168,6 @@ static int find_profile_by_name(char *profile_name, return 1; } -static int find_profile_by_num(unsigned profile_num, - SRTP_PROTECTION_PROFILE **pptr) - { - SRTP_PROTECTION_PROFILE *p; - - p=srtp_known_profiles; - while(p->name) - { - if(p->id == profile_num) - { - *pptr=p; - return 0; - } - p++; - } - - return 1; - } - static int ssl_ctx_make_profiles(const char *profiles_string,STACK_OF(SRTP_PROTECTION_PROFILE) **out) { STACK_OF(SRTP_PROTECTION_PROFILE) *profiles; @@ -209,11 +190,19 @@ static int ssl_ctx_make_profiles(const char *profiles_string,STACK_OF(SRTP_PROTE if(!find_profile_by_name(ptr,&p, col ? col-ptr : (int)strlen(ptr))) { + if (sk_SRTP_PROTECTION_PROFILE_find(profiles,p) >= 0) + { + SSLerr(SSL_F_SSL_CTX_MAKE_PROFILES,SSL_R_BAD_SRTP_PROTECTION_PROFILE_LIST); + sk_SRTP_PROTECTION_PROFILE_free(profiles); + return 1; + } + sk_SRTP_PROTECTION_PROFILE_push(profiles,p); } else { SSLerr(SSL_F_SSL_CTX_MAKE_PROFILES,SSL_R_SRTP_UNKNOWN_PROTECTION_PROFILE); + sk_SRTP_PROTECTION_PROFILE_free(profiles); return 1; } @@ -305,13 +294,12 @@ int ssl_add_clienthello_use_srtp_ext(SSL *s, unsigned char *p, int *len, int max int ssl_parse_clienthello_use_srtp_ext(SSL *s, unsigned char *d, int len,int *al) { - SRTP_PROTECTION_PROFILE *cprof,*sprof; - STACK_OF(SRTP_PROTECTION_PROFILE) *clnt=0,*srvr; + SRTP_PROTECTION_PROFILE *sprof; + STACK_OF(SRTP_PROTECTION_PROFILE) *srvr; int ct; int mki_len; - int i,j; - int id; - int ret; + int i, srtp_pref; + unsigned int id; /* Length value + the MKI length */ if(len < 3) @@ -341,22 +329,32 @@ int ssl_parse_clienthello_use_srtp_ext(SSL *s, unsigned char *d, int len,int *al return 1; } + srvr=SSL_get_srtp_profiles(s); + s->srtp_profile = NULL; + /* Search all profiles for a match initially */ + srtp_pref = sk_SRTP_PROTECTION_PROFILE_num(srvr); - clnt=sk_SRTP_PROTECTION_PROFILE_new_null(); - while(ct) { n2s(d,id); ct-=2; len-=2; - if(!find_profile_by_num(id,&cprof)) + /* + * Only look for match in profiles of higher preference than + * current match. + * If no profiles have been have been configured then this + * does nothing. + */ + for (i = 0; i < srtp_pref; i++) { - sk_SRTP_PROTECTION_PROFILE_push(clnt,cprof); - } - else - { - ; /* Ignore */ + sprof = sk_SRTP_PROTECTION_PROFILE_value(srvr, i); + if (sprof->id == id) + { + s->srtp_profile = sprof; + srtp_pref = i; + break; + } } } @@ -371,36 +369,7 @@ int ssl_parse_clienthello_use_srtp_ext(SSL *s, unsigned char *d, int len,int *al return 1; } - srvr=SSL_get_srtp_profiles(s); - - /* Pick our most preferred profile. If no profiles have been - configured then the outer loop doesn't run - (sk_SRTP_PROTECTION_PROFILE_num() = -1) - and so we just return without doing anything */ - for(i=0;iid==sprof->id) - { - s->srtp_profile=sprof; - *al=0; - ret=0; - goto done; - } - } - } - - ret=0; - -done: - if(clnt) sk_SRTP_PROTECTION_PROFILE_free(clnt); - - return ret; + return 0; } int ssl_add_serverhello_use_srtp_ext(SSL *s, unsigned char *p, int *len, int maxlen) diff --git a/deps/openssl/openssl/ssl/dtls1.h b/deps/openssl/openssl/ssl/dtls1.h index e65d5011915b45..192c5deff98a0f 100644 --- a/deps/openssl/openssl/ssl/dtls1.h +++ b/deps/openssl/openssl/ssl/dtls1.h @@ -84,6 +84,8 @@ extern "C" { #endif #define DTLS1_VERSION 0xFEFF +#define DTLS_MAX_VERSION DTLS1_VERSION + #define DTLS1_BAD_VER 0x0100 #if 0 @@ -284,4 +286,3 @@ typedef struct dtls1_record_data_st } #endif #endif - diff --git a/deps/openssl/openssl/ssl/s23_clnt.c b/deps/openssl/openssl/ssl/s23_clnt.c index 2b93c639dd2540..86ab3de1c1236e 100644 --- a/deps/openssl/openssl/ssl/s23_clnt.c +++ b/deps/openssl/openssl/ssl/s23_clnt.c @@ -125,9 +125,11 @@ static const SSL_METHOD *ssl23_get_client_method(int ver) if (ver == SSL2_VERSION) return(SSLv2_client_method()); #endif +#ifndef OPENSSL_NO_SSL3 if (ver == SSL3_VERSION) return(SSLv3_client_method()); - else if (ver == TLS1_VERSION) +#endif + if (ver == TLS1_VERSION) return(TLSv1_client_method()); else if (ver == TLS1_1_VERSION) return(TLSv1_1_client_method()); @@ -698,6 +700,7 @@ static int ssl23_get_server_hello(SSL *s) { /* we have sslv3 or tls1 (server hello or alert) */ +#ifndef OPENSSL_NO_SSL3 if ((p[2] == SSL3_VERSION_MINOR) && !(s->options & SSL_OP_NO_SSLv3)) { @@ -712,7 +715,9 @@ static int ssl23_get_server_hello(SSL *s) s->version=SSL3_VERSION; s->method=SSLv3_client_method(); } - else if ((p[2] == TLS1_VERSION_MINOR) && + else +#endif + if ((p[2] == TLS1_VERSION_MINOR) && !(s->options & SSL_OP_NO_TLSv1)) { s->version=TLS1_VERSION; @@ -736,6 +741,9 @@ static int ssl23_get_server_hello(SSL *s) goto err; } + /* ensure that TLS_MAX_VERSION is up-to-date */ + OPENSSL_assert(s->version <= TLS_MAX_VERSION); + if (p[0] == SSL3_RT_ALERT && p[5] != SSL3_AL_WARNING) { /* fatal alert */ diff --git a/deps/openssl/openssl/ssl/s23_srvr.c b/deps/openssl/openssl/ssl/s23_srvr.c index 2901a6bd010402..93ca7d53cda473 100644 --- a/deps/openssl/openssl/ssl/s23_srvr.c +++ b/deps/openssl/openssl/ssl/s23_srvr.c @@ -127,9 +127,11 @@ static const SSL_METHOD *ssl23_get_server_method(int ver) if (ver == SSL2_VERSION) return(SSLv2_server_method()); #endif +#ifndef OPENSSL_NO_SSL3 if (ver == SSL3_VERSION) return(SSLv3_server_method()); - else if (ver == TLS1_VERSION) +#endif + if (ver == TLS1_VERSION) return(TLSv1_server_method()); else if (ver == TLS1_1_VERSION) return(TLSv1_1_server_method()); @@ -421,6 +423,9 @@ int ssl23_get_client_hello(SSL *s) } } + /* ensure that TLS_MAX_VERSION is up-to-date */ + OPENSSL_assert(s->version <= TLS_MAX_VERSION); + #ifdef OPENSSL_FIPS if (FIPS_mode() && (s->version < TLS1_VERSION)) { @@ -597,6 +602,12 @@ int ssl23_get_client_hello(SSL *s) if ((type == 2) || (type == 3)) { /* we have SSLv3/TLSv1 (type 2: SSL2 style, type 3: SSL3/TLS style) */ + s->method = ssl23_get_server_method(s->version); + if (s->method == NULL) + { + SSLerr(SSL_F_SSL23_GET_CLIENT_HELLO,SSL_R_UNSUPPORTED_PROTOCOL); + goto err; + } if (!ssl_init_wbio_buffer(s,1)) goto err; @@ -624,14 +635,6 @@ int ssl23_get_client_hello(SSL *s) s->s3->rbuf.left=0; s->s3->rbuf.offset=0; } - if (s->version == TLS1_2_VERSION) - s->method = TLSv1_2_server_method(); - else if (s->version == TLS1_1_VERSION) - s->method = TLSv1_1_server_method(); - else if (s->version == TLS1_VERSION) - s->method = TLSv1_server_method(); - else - s->method = SSLv3_server_method(); #if 0 /* ssl3_get_client_hello does this */ s->client_version=(v[0]<<8)|v[1]; #endif diff --git a/deps/openssl/openssl/ssl/s2_lib.c b/deps/openssl/openssl/ssl/s2_lib.c index c0bdae549639e2..c63be3052b2863 100644 --- a/deps/openssl/openssl/ssl/s2_lib.c +++ b/deps/openssl/openssl/ssl/s2_lib.c @@ -391,6 +391,8 @@ long ssl2_ctrl(SSL *s, int cmd, long larg, void *parg) case SSL_CTRL_GET_SESSION_REUSED: ret=s->hit; break; + case SSL_CTRL_CHECK_PROTO_VERSION: + return ssl3_ctrl(s, SSL_CTRL_CHECK_PROTO_VERSION, larg, parg); default: break; } @@ -437,7 +439,7 @@ int ssl2_put_cipher_by_char(const SSL_CIPHER *c, unsigned char *p) if (p != NULL) { l=c->id; - if ((l & 0xff000000) != 0x02000000) return(0); + if ((l & 0xff000000) != 0x02000000 && l != SSL3_CK_FALLBACK_SCSV) return(0); p[0]=((unsigned char)(l>>16L))&0xFF; p[1]=((unsigned char)(l>> 8L))&0xFF; p[2]=((unsigned char)(l ))&0xFF; diff --git a/deps/openssl/openssl/ssl/s3_cbc.c b/deps/openssl/openssl/ssl/s3_cbc.c index 443a31e74627bb..11f13adbf7c216 100644 --- a/deps/openssl/openssl/ssl/s3_cbc.c +++ b/deps/openssl/openssl/ssl/s3_cbc.c @@ -53,6 +53,7 @@ * */ +#include "../crypto/constant_time_locl.h" #include "ssl_locl.h" #include @@ -67,37 +68,6 @@ * supported by TLS.) */ #define MAX_HASH_BLOCK_SIZE 128 -/* Some utility functions are needed: - * - * These macros return the given value with the MSB copied to all the other - * bits. They use the fact that arithmetic shift shifts-in the sign bit. - * However, this is not ensured by the C standard so you may need to replace - * them with something else on odd CPUs. */ -#define DUPLICATE_MSB_TO_ALL(x) ( (unsigned)( (int)(x) >> (sizeof(int)*8-1) ) ) -#define DUPLICATE_MSB_TO_ALL_8(x) ((unsigned char)(DUPLICATE_MSB_TO_ALL(x))) - -/* constant_time_lt returns 0xff if a=b and 0x00 otherwise. */ -static unsigned constant_time_ge(unsigned a, unsigned b) - { - a -= b; - return DUPLICATE_MSB_TO_ALL(~a); - } - -/* constant_time_eq_8 returns 0xff if a==b and 0x00 otherwise. */ -static unsigned char constant_time_eq_8(unsigned a, unsigned b) - { - unsigned c = a ^ b; - c--; - return DUPLICATE_MSB_TO_ALL_8(c); - } - /* ssl3_cbc_remove_padding removes padding from the decrypted, SSLv3, CBC * record in |rec| by updating |rec->length| in constant time. * @@ -126,8 +96,8 @@ int ssl3_cbc_remove_padding(const SSL* s, padding_length = good & (padding_length+1); rec->length -= padding_length; rec->type |= padding_length<<8; /* kludge: pass padding length */ - return (int)((good & 1) | (~good & -1)); -} + return constant_time_select_int(good, 1, -1); + } /* tls1_cbc_remove_padding removes the CBC padding from the decrypted, TLS, CBC * record in |rec| in constant time and returns 1 if the padding is valid and @@ -208,7 +178,7 @@ int tls1_cbc_remove_padding(const SSL* s, for (i = 0; i < to_check; i++) { - unsigned char mask = constant_time_ge(padding_length, i); + unsigned char mask = constant_time_ge_8(padding_length, i); unsigned char b = rec->data[rec->length-1-i]; /* The final |padding_length+1| bytes should all have the value * |padding_length|. Therefore the XOR should be zero. */ @@ -216,20 +186,14 @@ int tls1_cbc_remove_padding(const SSL* s, } /* If any of the final |padding_length+1| bytes had the wrong value, - * one or more of the lower eight bits of |good| will be cleared. We - * AND the bottom 8 bits together and duplicate the result to all the - * bits. */ - good &= good >> 4; - good &= good >> 2; - good &= good >> 1; - good <<= sizeof(good)*8-1; - good = DUPLICATE_MSB_TO_ALL(good); - + * one or more of the lower eight bits of |good| will be cleared. + */ + good = constant_time_eq(0xff, good & 0xff); padding_length = good & (padding_length+1); rec->length -= padding_length; rec->type |= padding_length<<8; /* kludge: pass padding length */ - return (int)((good & 1) | (~good & -1)); + return constant_time_select_int(good, 1, -1); } /* ssl3_cbc_copy_mac copies |md_size| bytes from the end of |rec| to |out| in @@ -296,8 +260,8 @@ void ssl3_cbc_copy_mac(unsigned char* out, memset(rotated_mac, 0, md_size); for (i = scan_start, j = 0; i < orig_len; i++) { - unsigned char mac_started = constant_time_ge(i, mac_start); - unsigned char mac_ended = constant_time_ge(i, mac_end); + unsigned char mac_started = constant_time_ge_8(i, mac_start); + unsigned char mac_ended = constant_time_ge_8(i, mac_end); unsigned char b = rec->data[i]; rotated_mac[j++] |= b & mac_started & ~mac_ended; j &= constant_time_lt(j,md_size); @@ -683,12 +647,12 @@ void ssl3_cbc_digest_record( b = data[k-header_length]; k++; - is_past_c = is_block_a & constant_time_ge(j, c); - is_past_cp1 = is_block_a & constant_time_ge(j, c+1); + is_past_c = is_block_a & constant_time_ge_8(j, c); + is_past_cp1 = is_block_a & constant_time_ge_8(j, c+1); /* If this is the block containing the end of the * application data, and we are at the offset for the * 0x80 value, then overwrite b with 0x80. */ - b = (b&~is_past_c) | (0x80&is_past_c); + b = constant_time_select_8(is_past_c, 0x80, b); /* If this the the block containing the end of the * application data and we're past the 0x80 value then * just write zero. */ @@ -704,7 +668,8 @@ void ssl3_cbc_digest_record( if (j >= md_block_size - md_length_size) { /* If this is index_b, write a length byte. */ - b = (b&~is_block_b) | (is_block_b&length_bytes[j-(md_block_size-md_length_size)]); + b = constant_time_select_8( + is_block_b, length_bytes[j-(md_block_size-md_length_size)], b); } block[j] = b; } diff --git a/deps/openssl/openssl/ssl/s3_clnt.c b/deps/openssl/openssl/ssl/s3_clnt.c index ea0c82de479ac9..263e6348c97815 100644 --- a/deps/openssl/openssl/ssl/s3_clnt.c +++ b/deps/openssl/openssl/ssl/s3_clnt.c @@ -326,9 +326,9 @@ int ssl3_connect(SSL *s) break; } #endif - /* Check if it is anon DH/ECDH */ + /* Check if it is anon DH/ECDH, SRP auth */ /* or PSK */ - if (!(s->s3->tmp.new_cipher->algorithm_auth & SSL_aNULL) && + if (!(s->s3->tmp.new_cipher->algorithm_auth & (SSL_aNULL|SSL_aSRP)) && !(s->s3->tmp.new_cipher->algorithm_mkey & SSL_kPSK)) { ret=ssl3_get_server_certificate(s); @@ -1277,8 +1277,8 @@ int ssl3_get_key_exchange(SSL *s) #endif EVP_MD_CTX md_ctx; unsigned char *param,*p; - int al,i,j,param_len,ok; - long n,alg_k,alg_a; + int al,j,ok; + long i,param_len,n,alg_k,alg_a; EVP_PKEY *pkey=NULL; const EVP_MD *md = NULL; #ifndef OPENSSL_NO_RSA @@ -1354,36 +1354,48 @@ int ssl3_get_key_exchange(SSL *s) s->session->sess_cert=ssl_sess_cert_new(); } + /* Total length of the parameters including the length prefix */ param_len=0; + alg_k=s->s3->tmp.new_cipher->algorithm_mkey; alg_a=s->s3->tmp.new_cipher->algorithm_auth; EVP_MD_CTX_init(&md_ctx); + al=SSL_AD_DECODE_ERROR; + #ifndef OPENSSL_NO_PSK if (alg_k & SSL_kPSK) { char tmp_id_hint[PSK_MAX_IDENTITY_LEN+1]; - al=SSL_AD_HANDSHAKE_FAILURE; + param_len = 2; + if (param_len > n) + { + SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, + SSL_R_LENGTH_TOO_SHORT); + goto f_err; + } n2s(p,i); - param_len=i+2; + /* Store PSK identity hint for later use, hint is used * in ssl3_send_client_key_exchange. Assume that the * maximum length of a PSK identity hint can be as * long as the maximum length of a PSK identity. */ if (i > PSK_MAX_IDENTITY_LEN) { + al=SSL_AD_HANDSHAKE_FAILURE; SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_DATA_LENGTH_TOO_LONG); goto f_err; } - if (param_len > n) + if (i > n - param_len) { - al=SSL_AD_DECODE_ERROR; SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_BAD_PSK_IDENTITY_HINT_LENGTH); goto f_err; } + param_len += i; + /* If received PSK identity hint contains NULL * characters, the hint is truncated from the first * NULL. p may not be ending with NULL, so create a @@ -1395,6 +1407,7 @@ int ssl3_get_key_exchange(SSL *s) s->ctx->psk_identity_hint = BUF_strdup(tmp_id_hint); if (s->ctx->psk_identity_hint == NULL) { + al=SSL_AD_HANDSHAKE_FAILURE; SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_MALLOC_FAILURE); goto f_err; } @@ -1407,14 +1420,22 @@ int ssl3_get_key_exchange(SSL *s) #ifndef OPENSSL_NO_SRP if (alg_k & SSL_kSRP) { - n2s(p,i); - param_len=i+2; + param_len = 2; if (param_len > n) { - al=SSL_AD_DECODE_ERROR; + SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, + SSL_R_LENGTH_TOO_SHORT); + goto f_err; + } + n2s(p,i); + + if (i > n - param_len) + { SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,SSL_R_BAD_SRP_N_LENGTH); goto f_err; } + param_len += i; + if (!(s->srp_ctx.N=BN_bin2bn(p,i,NULL))) { SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,ERR_R_BN_LIB); @@ -1422,14 +1443,24 @@ int ssl3_get_key_exchange(SSL *s) } p+=i; + + if (2 > n - param_len) + { + SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, + SSL_R_LENGTH_TOO_SHORT); + goto f_err; + } + param_len += 2; + n2s(p,i); - param_len+=i+2; - if (param_len > n) + + if (i > n - param_len) { - al=SSL_AD_DECODE_ERROR; SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,SSL_R_BAD_SRP_G_LENGTH); goto f_err; } + param_len += i; + if (!(s->srp_ctx.g=BN_bin2bn(p,i,NULL))) { SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,ERR_R_BN_LIB); @@ -1437,15 +1468,25 @@ int ssl3_get_key_exchange(SSL *s) } p+=i; + + if (1 > n - param_len) + { + SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, + SSL_R_LENGTH_TOO_SHORT); + goto f_err; + } + param_len += 1; + i = (unsigned int)(p[0]); p++; - param_len+=i+1; - if (param_len > n) + + if (i > n - param_len) { - al=SSL_AD_DECODE_ERROR; SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,SSL_R_BAD_SRP_S_LENGTH); goto f_err; } + param_len += i; + if (!(s->srp_ctx.s=BN_bin2bn(p,i,NULL))) { SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,ERR_R_BN_LIB); @@ -1453,14 +1494,23 @@ int ssl3_get_key_exchange(SSL *s) } p+=i; + if (2 > n - param_len) + { + SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, + SSL_R_LENGTH_TOO_SHORT); + goto f_err; + } + param_len += 2; + n2s(p,i); - param_len+=i+2; - if (param_len > n) + + if (i > n - param_len) { - al=SSL_AD_DECODE_ERROR; SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,SSL_R_BAD_SRP_B_LENGTH); goto f_err; } + param_len += i; + if (!(s->srp_ctx.B=BN_bin2bn(p,i,NULL))) { SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,ERR_R_BN_LIB); @@ -1498,14 +1548,23 @@ int ssl3_get_key_exchange(SSL *s) SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,ERR_R_MALLOC_FAILURE); goto err; } - n2s(p,i); - param_len=i+2; + + param_len = 2; if (param_len > n) { - al=SSL_AD_DECODE_ERROR; + SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, + SSL_R_LENGTH_TOO_SHORT); + goto f_err; + } + n2s(p,i); + + if (i > n - param_len) + { SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,SSL_R_BAD_RSA_MODULUS_LENGTH); goto f_err; } + param_len += i; + if (!(rsa->n=BN_bin2bn(p,i,rsa->n))) { SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,ERR_R_BN_LIB); @@ -1513,14 +1572,23 @@ int ssl3_get_key_exchange(SSL *s) } p+=i; + if (2 > n - param_len) + { + SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, + SSL_R_LENGTH_TOO_SHORT); + goto f_err; + } + param_len += 2; + n2s(p,i); - param_len+=i+2; - if (param_len > n) + + if (i > n - param_len) { - al=SSL_AD_DECODE_ERROR; SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,SSL_R_BAD_RSA_E_LENGTH); goto f_err; } + param_len += i; + if (!(rsa->e=BN_bin2bn(p,i,rsa->e))) { SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,ERR_R_BN_LIB); @@ -1552,14 +1620,23 @@ int ssl3_get_key_exchange(SSL *s) SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,ERR_R_DH_LIB); goto err; } - n2s(p,i); - param_len=i+2; + + param_len = 2; if (param_len > n) { - al=SSL_AD_DECODE_ERROR; + SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, + SSL_R_LENGTH_TOO_SHORT); + goto f_err; + } + n2s(p,i); + + if (i > n - param_len) + { SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,SSL_R_BAD_DH_P_LENGTH); goto f_err; } + param_len += i; + if (!(dh->p=BN_bin2bn(p,i,NULL))) { SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,ERR_R_BN_LIB); @@ -1567,14 +1644,23 @@ int ssl3_get_key_exchange(SSL *s) } p+=i; + if (2 > n - param_len) + { + SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, + SSL_R_LENGTH_TOO_SHORT); + goto f_err; + } + param_len += 2; + n2s(p,i); - param_len+=i+2; - if (param_len > n) + + if (i > n - param_len) { - al=SSL_AD_DECODE_ERROR; SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,SSL_R_BAD_DH_G_LENGTH); goto f_err; } + param_len += i; + if (!(dh->g=BN_bin2bn(p,i,NULL))) { SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,ERR_R_BN_LIB); @@ -1582,14 +1668,23 @@ int ssl3_get_key_exchange(SSL *s) } p+=i; + if (2 > n - param_len) + { + SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, + SSL_R_LENGTH_TOO_SHORT); + goto f_err; + } + param_len += 2; + n2s(p,i); - param_len+=i+2; - if (param_len > n) + + if (i > n - param_len) { - al=SSL_AD_DECODE_ERROR; SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,SSL_R_BAD_DH_PUB_KEY_LENGTH); goto f_err; } + param_len += i; + if (!(dh->pub_key=BN_bin2bn(p,i,NULL))) { SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,ERR_R_BN_LIB); @@ -1641,12 +1736,19 @@ int ssl3_get_key_exchange(SSL *s) */ /* XXX: For now we only support named (not generic) curves - * and the ECParameters in this case is just three bytes. + * and the ECParameters in this case is just three bytes. We + * also need one byte for the length of the encoded point */ - param_len=3; - if ((param_len > n) || - (*p != NAMED_CURVE_TYPE) || - ((curve_nid = tls1_ec_curve_id2nid(*(p + 2))) == 0)) + param_len=4; + if (param_len > n) + { + SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, + SSL_R_LENGTH_TOO_SHORT); + goto f_err; + } + + if ((*p != NAMED_CURVE_TYPE) || + ((curve_nid = tls1_ec_curve_id2nid(*(p + 2))) == 0)) { al=SSL_AD_INTERNAL_ERROR; SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,SSL_R_UNABLE_TO_FIND_ECDH_PARAMETERS); @@ -1688,15 +1790,15 @@ int ssl3_get_key_exchange(SSL *s) encoded_pt_len = *p; /* length of encoded point */ p+=1; - param_len += (1 + encoded_pt_len); - if ((param_len > n) || + + if ((encoded_pt_len > n - param_len) || (EC_POINT_oct2point(group, srvr_ecpoint, p, encoded_pt_len, bn_ctx) == 0)) { - al=SSL_AD_DECODE_ERROR; SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,SSL_R_BAD_ECPOINT); goto f_err; } + param_len += encoded_pt_len; n-=param_len; p+=encoded_pt_len; @@ -1739,7 +1841,15 @@ int ssl3_get_key_exchange(SSL *s) { if (TLS1_get_version(s) >= TLS1_2_VERSION) { - int sigalg = tls12_get_sigid(pkey); + int sigalg; + if (2 > n) + { + SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, + SSL_R_LENGTH_TOO_SHORT); + goto f_err; + } + + sigalg = tls12_get_sigid(pkey); /* Should never happen */ if (sigalg == -1) { @@ -1757,7 +1867,6 @@ int ssl3_get_key_exchange(SSL *s) if (md == NULL) { SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,SSL_R_UNKNOWN_DIGEST); - al=SSL_AD_DECODE_ERROR; goto f_err; } #ifdef SSL_DEBUG @@ -1768,15 +1877,21 @@ fprintf(stderr, "USING TLSv1.2 HASH %s\n", EVP_MD_name(md)); } else md = EVP_sha1(); - + + if (2 > n) + { + SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, + SSL_R_LENGTH_TOO_SHORT); + goto f_err; + } n2s(p,i); n-=2; j=EVP_PKEY_size(pkey); + /* Check signature length. If n is 0 then signature is empty */ if ((i != n) || (n > j) || (n <= 0)) { /* wrong packet length */ - al=SSL_AD_DECODE_ERROR; SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,SSL_R_WRONG_SIGNATURE_LENGTH); goto f_err; } @@ -1785,6 +1900,7 @@ fprintf(stderr, "USING TLSv1.2 HASH %s\n", EVP_MD_name(md)); if (pkey->type == EVP_PKEY_RSA && TLS1_get_version(s) < TLS1_2_VERSION) { int num; + unsigned int size; j=0; q=md_buf; @@ -1797,9 +1913,9 @@ fprintf(stderr, "USING TLSv1.2 HASH %s\n", EVP_MD_name(md)); EVP_DigestUpdate(&md_ctx,&(s->s3->client_random[0]),SSL3_RANDOM_SIZE); EVP_DigestUpdate(&md_ctx,&(s->s3->server_random[0]),SSL3_RANDOM_SIZE); EVP_DigestUpdate(&md_ctx,param,param_len); - EVP_DigestFinal_ex(&md_ctx,q,(unsigned int *)&i); - q+=i; - j+=i; + EVP_DigestFinal_ex(&md_ctx,q,&size); + q+=size; + j+=size; } i=RSA_verify(NID_md5_sha1, md_buf, j, p, n, pkey->pkey.rsa); @@ -1835,8 +1951,8 @@ fprintf(stderr, "USING TLSv1.2 HASH %s\n", EVP_MD_name(md)); } else { - if (!(alg_a & SSL_aNULL) && !(alg_k & SSL_kPSK)) - /* aNULL or kPSK do not need public keys */ + /* aNULL, aSRP or kPSK do not need public keys */ + if (!(alg_a & (SSL_aNULL|SSL_aSRP)) && !(alg_k & SSL_kPSK)) { SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,ERR_R_INTERNAL_ERROR); goto err; @@ -1844,7 +1960,6 @@ fprintf(stderr, "USING TLSv1.2 HASH %s\n", EVP_MD_name(md)); /* still data left over */ if (n != 0) { - al=SSL_AD_DECODE_ERROR; SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,SSL_R_EXTRA_DATA_IN_MESSAGE); goto f_err; } @@ -2846,7 +2961,11 @@ int ssl3_send_client_key_exchange(SSL *s) #ifndef OPENSSL_NO_PSK else if (alg_k & SSL_kPSK) { - char identity[PSK_MAX_IDENTITY_LEN]; + /* The callback needs PSK_MAX_IDENTITY_LEN + 1 bytes + * to return a \0-terminated identity. The last byte + * is for us for simulating strnlen. */ + char identity[PSK_MAX_IDENTITY_LEN + 2]; + size_t identity_len; unsigned char *t = NULL; unsigned char psk_or_pre_ms[PSK_MAX_PSK_LEN*2+4]; unsigned int pre_ms_len = 0, psk_len = 0; @@ -2860,8 +2979,9 @@ int ssl3_send_client_key_exchange(SSL *s) goto err; } + memset(identity, 0, sizeof(identity)); psk_len = s->psk_client_callback(s, s->ctx->psk_identity_hint, - identity, PSK_MAX_IDENTITY_LEN, + identity, sizeof(identity) - 1, psk_or_pre_ms, sizeof(psk_or_pre_ms)); if (psk_len > PSK_MAX_PSK_LEN) { @@ -2875,7 +2995,14 @@ int ssl3_send_client_key_exchange(SSL *s) SSL_R_PSK_IDENTITY_NOT_FOUND); goto psk_err; } - + identity[PSK_MAX_IDENTITY_LEN + 1] = '\0'; + identity_len = strlen(identity); + if (identity_len > PSK_MAX_IDENTITY_LEN) + { + SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, + ERR_R_INTERNAL_ERROR); + goto psk_err; + } /* create PSK pre_master_secret */ pre_ms_len = 2+psk_len+2+psk_len; t = psk_or_pre_ms; @@ -2909,14 +3036,13 @@ int ssl3_send_client_key_exchange(SSL *s) s->session->master_key_length = s->method->ssl3_enc->generate_master_secret(s, s->session->master_key, - psk_or_pre_ms, pre_ms_len); - n = strlen(identity); - s2n(n, p); - memcpy(p, identity, n); - n+=2; + psk_or_pre_ms, pre_ms_len); + s2n(identity_len, p); + memcpy(p, identity, identity_len); + n = 2 + identity_len; psk_err = 0; psk_err: - OPENSSL_cleanse(identity, PSK_MAX_IDENTITY_LEN); + OPENSSL_cleanse(identity, sizeof(identity)); OPENSSL_cleanse(psk_or_pre_ms, sizeof(psk_or_pre_ms)); if (psk_err != 0) { diff --git a/deps/openssl/openssl/ssl/s3_enc.c b/deps/openssl/openssl/ssl/s3_enc.c index 996267725ebe0d..9db45af7ea7f5a 100644 --- a/deps/openssl/openssl/ssl/s3_enc.c +++ b/deps/openssl/openssl/ssl/s3_enc.c @@ -900,7 +900,7 @@ int ssl3_alert_code(int code) case SSL_AD_BAD_CERTIFICATE_STATUS_RESPONSE: return(SSL3_AD_HANDSHAKE_FAILURE); case SSL_AD_BAD_CERTIFICATE_HASH_VALUE: return(SSL3_AD_HANDSHAKE_FAILURE); case SSL_AD_UNKNOWN_PSK_IDENTITY:return(TLS1_AD_UNKNOWN_PSK_IDENTITY); + case SSL_AD_INAPPROPRIATE_FALLBACK:return(TLS1_AD_INAPPROPRIATE_FALLBACK); default: return(-1); } } - diff --git a/deps/openssl/openssl/ssl/s3_lib.c b/deps/openssl/openssl/ssl/s3_lib.c index 4835bef1a7c6f1..3f1745336b22ea 100644 --- a/deps/openssl/openssl/ssl/s3_lib.c +++ b/deps/openssl/openssl/ssl/s3_lib.c @@ -3355,6 +3355,33 @@ long ssl3_ctrl(SSL *s, int cmd, long larg, void *parg) #endif #endif /* !OPENSSL_NO_TLSEXT */ + + case SSL_CTRL_CHECK_PROTO_VERSION: + /* For library-internal use; checks that the current protocol + * is the highest enabled version (according to s->ctx->method, + * as version negotiation may have changed s->method). */ + if (s->version == s->ctx->method->version) + return 1; + /* Apparently we're using a version-flexible SSL_METHOD + * (not at its highest protocol version). */ + if (s->ctx->method->version == SSLv23_method()->version) + { +#if TLS_MAX_VERSION != TLS1_2_VERSION +# error Code needs update for SSLv23_method() support beyond TLS1_2_VERSION. +#endif + if (!(s->options & SSL_OP_NO_TLSv1_2)) + return s->version == TLS1_2_VERSION; + if (!(s->options & SSL_OP_NO_TLSv1_1)) + return s->version == TLS1_1_VERSION; + if (!(s->options & SSL_OP_NO_TLSv1)) + return s->version == TLS1_VERSION; + if (!(s->options & SSL_OP_NO_SSLv3)) + return s->version == SSL3_VERSION; + if (!(s->options & SSL_OP_NO_SSLv2)) + return s->version == SSL2_VERSION; + } + return 0; /* Unexpected state; fail closed. */ + default: break; } @@ -3714,6 +3741,7 @@ long ssl3_ctx_callback_ctrl(SSL_CTX *ctx, int cmd, void (*fp)(void)) break; #endif #endif + default: return(0); } @@ -3822,10 +3850,15 @@ SSL_CIPHER *ssl3_choose_cipher(SSL *s, STACK_OF(SSL_CIPHER) *clnt, emask_k = cert->export_mask_k; emask_a = cert->export_mask_a; #ifndef OPENSSL_NO_SRP - mask_k=cert->mask_k | s->srp_ctx.srp_Mask; - emask_k=cert->export_mask_k | s->srp_ctx.srp_Mask; + if (s->srp_ctx.srp_Mask & SSL_kSRP) + { + mask_k |= SSL_kSRP; + emask_k |= SSL_kSRP; + mask_a |= SSL_aSRP; + emask_a |= SSL_aSRP; + } #endif - + #ifdef KSSL_DEBUG /* printf("ssl3_choose_cipher %d alg= %lx\n", i,c->algorithms);*/ #endif /* KSSL_DEBUG */ @@ -4291,4 +4324,3 @@ long ssl_get_algorithm2(SSL *s) return SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256; return alg2; } - diff --git a/deps/openssl/openssl/ssl/s3_pkt.c b/deps/openssl/openssl/ssl/s3_pkt.c index eff7356a314820..4c9285f355b264 100644 --- a/deps/openssl/openssl/ssl/s3_pkt.c +++ b/deps/openssl/openssl/ssl/s3_pkt.c @@ -273,6 +273,12 @@ int ssl3_read_n(SSL *s, int n, int max, int extend) return(n); } +/* MAX_EMPTY_RECORDS defines the number of consecutive, empty records that will + * be processed per call to ssl3_get_record. Without this limit an attacker + * could send empty records at a faster rate than we can process and cause + * ssl3_get_record to loop forever. */ +#define MAX_EMPTY_RECORDS 32 + /* Call this to get a new input record. * It will return <= 0 if more data is needed, normally due to an error * or non-blocking IO. @@ -293,6 +299,7 @@ static int ssl3_get_record(SSL *s) short version; unsigned mac_size, orig_len; size_t extra; + unsigned empty_record_count = 0; rr= &(s->s3->rrec); sess=s->session; @@ -523,7 +530,17 @@ printf("\n"); s->packet_length=0; /* just read a 0 length packet */ - if (rr->length == 0) goto again; + if (rr->length == 0) + { + empty_record_count++; + if (empty_record_count > MAX_EMPTY_RECORDS) + { + al=SSL_AD_UNEXPECTED_MESSAGE; + SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_RECORD_TOO_SMALL); + goto f_err; + } + goto again; + } #if 0 fprintf(stderr, "Ultimate Record type=%d, Length=%d\n", rr->type, rr->length); diff --git a/deps/openssl/openssl/ssl/s3_srvr.c b/deps/openssl/openssl/ssl/s3_srvr.c index 2867501287c1e1..c23d9870802923 100644 --- a/deps/openssl/openssl/ssl/s3_srvr.c +++ b/deps/openssl/openssl/ssl/s3_srvr.c @@ -154,6 +154,7 @@ #include #include "ssl_locl.h" #include "kssl_lcl.h" +#include "../crypto/constant_time_locl.h" #include #include #include @@ -410,9 +411,8 @@ int ssl3_accept(SSL *s) case SSL3_ST_SW_CERT_B: /* Check if it is anon DH or anon ECDH, */ /* normal PSK or KRB5 or SRP */ - if (!(s->s3->tmp.new_cipher->algorithm_auth & SSL_aNULL) - && !(s->s3->tmp.new_cipher->algorithm_mkey & SSL_kPSK) - && !(s->s3->tmp.new_cipher->algorithm_auth & SSL_aKRB5)) + if (!(s->s3->tmp.new_cipher->algorithm_auth & (SSL_aNULL|SSL_aKRB5|SSL_aSRP)) + && !(s->s3->tmp.new_cipher->algorithm_mkey & SSL_kPSK)) { ret=ssl3_send_server_certificate(s); if (ret <= 0) goto end; @@ -515,7 +515,9 @@ int ssl3_accept(SSL *s) * (against the specs, but s3_clnt.c accepts this for SSL 3) */ !(s->verify_mode & SSL_VERIFY_FAIL_IF_NO_PEER_CERT)) || /* never request cert in Kerberos ciphersuites */ - (s->s3->tmp.new_cipher->algorithm_auth & SSL_aKRB5) + (s->s3->tmp.new_cipher->algorithm_auth & SSL_aKRB5) || + /* don't request certificate for SRP auth */ + (s->s3->tmp.new_cipher->algorithm_auth & SSL_aSRP) /* With normal PSK Certificates and * Certificate Requests are omitted */ || (s->s3->tmp.new_cipher->algorithm_mkey & SSL_kPSK)) @@ -1846,7 +1848,7 @@ int ssl3_send_server_key_exchange(SSL *s) n+=2+nr[i]; } - if (!(s->s3->tmp.new_cipher->algorithm_auth & SSL_aNULL) + if (!(s->s3->tmp.new_cipher->algorithm_auth & (SSL_aNULL|SSL_aSRP)) && !(s->s3->tmp.new_cipher->algorithm_mkey & SSL_kPSK)) { if ((pkey=ssl_get_sign_pkey(s,s->s3->tmp.new_cipher,&md)) @@ -2166,6 +2168,10 @@ int ssl3_get_client_key_exchange(SSL *s) #ifndef OPENSSL_NO_RSA if (alg_k & SSL_kRSA) { + unsigned char rand_premaster_secret[SSL_MAX_MASTER_KEY_LENGTH]; + int decrypt_len; + unsigned char decrypt_good, version_good; + /* FIX THIS UP EAY EAY EAY EAY */ if (s->s3->tmp.use_rsa_tmp) { @@ -2213,54 +2219,61 @@ int ssl3_get_client_key_exchange(SSL *s) n=i; } - i=RSA_private_decrypt((int)n,p,p,rsa,RSA_PKCS1_PADDING); - - al = -1; - - if (i != SSL_MAX_MASTER_KEY_LENGTH) - { - al=SSL_AD_DECODE_ERROR; - /* SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,SSL_R_BAD_RSA_DECRYPT); */ - } - - if ((al == -1) && !((p[0] == (s->client_version>>8)) && (p[1] == (s->client_version & 0xff)))) - { - /* The premaster secret must contain the same version number as the - * ClientHello to detect version rollback attacks (strangely, the - * protocol does not offer such protection for DH ciphersuites). - * However, buggy clients exist that send the negotiated protocol - * version instead if the server does not support the requested - * protocol version. - * If SSL_OP_TLS_ROLLBACK_BUG is set, tolerate such clients. */ - if (!((s->options & SSL_OP_TLS_ROLLBACK_BUG) && - (p[0] == (s->version>>8)) && (p[1] == (s->version & 0xff)))) - { - al=SSL_AD_DECODE_ERROR; - /* SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,SSL_R_BAD_PROTOCOL_VERSION_NUMBER); */ + /* We must not leak whether a decryption failure occurs because + * of Bleichenbacher's attack on PKCS #1 v1.5 RSA padding (see + * RFC 2246, section 7.4.7.1). The code follows that advice of + * the TLS RFC and generates a random premaster secret for the + * case that the decrypt fails. See + * https://tools.ietf.org/html/rfc5246#section-7.4.7.1 */ - /* The Klima-Pokorny-Rosa extension of Bleichenbacher's attack - * (http://eprint.iacr.org/2003/052/) exploits the version - * number check as a "bad version oracle" -- an alert would - * reveal that the plaintext corresponding to some ciphertext - * made up by the adversary is properly formatted except - * that the version number is wrong. To avoid such attacks, - * we should treat this just like any other decryption error. */ - } + /* should be RAND_bytes, but we cannot work around a failure. */ + if (RAND_pseudo_bytes(rand_premaster_secret, + sizeof(rand_premaster_secret)) <= 0) + goto err; + decrypt_len = RSA_private_decrypt((int)n,p,p,rsa,RSA_PKCS1_PADDING); + ERR_clear_error(); + + /* decrypt_len should be SSL_MAX_MASTER_KEY_LENGTH. + * decrypt_good will be 0xff if so and zero otherwise. */ + decrypt_good = constant_time_eq_int_8(decrypt_len, SSL_MAX_MASTER_KEY_LENGTH); + + /* If the version in the decrypted pre-master secret is correct + * then version_good will be 0xff, otherwise it'll be zero. + * The Klima-Pokorny-Rosa extension of Bleichenbacher's attack + * (http://eprint.iacr.org/2003/052/) exploits the version + * number check as a "bad version oracle". Thus version checks + * are done in constant time and are treated like any other + * decryption error. */ + version_good = constant_time_eq_8(p[0], (unsigned)(s->client_version>>8)); + version_good &= constant_time_eq_8(p[1], (unsigned)(s->client_version&0xff)); + + /* The premaster secret must contain the same version number as + * the ClientHello to detect version rollback attacks + * (strangely, the protocol does not offer such protection for + * DH ciphersuites). However, buggy clients exist that send the + * negotiated protocol version instead if the server does not + * support the requested protocol version. If + * SSL_OP_TLS_ROLLBACK_BUG is set, tolerate such clients. */ + if (s->options & SSL_OP_TLS_ROLLBACK_BUG) + { + unsigned char workaround_good; + workaround_good = constant_time_eq_8(p[0], (unsigned)(s->version>>8)); + workaround_good &= constant_time_eq_8(p[1], (unsigned)(s->version&0xff)); + version_good |= workaround_good; + } + + /* Both decryption and version must be good for decrypt_good + * to remain non-zero (0xff). */ + decrypt_good &= version_good; + + /* Now copy rand_premaster_secret over p using + * decrypt_good_mask. */ + for (i = 0; i < (int) sizeof(rand_premaster_secret); i++) + { + p[i] = constant_time_select_8(decrypt_good, p[i], + rand_premaster_secret[i]); } - if (al != -1) - { - /* Some decryption failure -- use random value instead as countermeasure - * against Bleichenbacher's attack on PKCS #1 v1.5 RSA padding - * (see RFC 2246, section 7.4.7.1). */ - ERR_clear_error(); - i = SSL_MAX_MASTER_KEY_LENGTH; - p[0] = s->client_version >> 8; - p[1] = s->client_version & 0xff; - if (RAND_pseudo_bytes(p+2, i-2) <= 0) /* should be RAND_bytes, but we cannot work around a failure */ - goto err; - } - s->session->master_key_length= s->method->ssl3_enc->generate_master_secret(s, s->session->master_key, diff --git a/deps/openssl/openssl/ssl/srtp.h b/deps/openssl/openssl/ssl/srtp.h index c0cf33ef288c7b..24f23309d7c473 100644 --- a/deps/openssl/openssl/ssl/srtp.h +++ b/deps/openssl/openssl/ssl/srtp.h @@ -130,6 +130,8 @@ extern "C" { #define SRTP_NULL_SHA1_80 0x0005 #define SRTP_NULL_SHA1_32 0x0006 +#ifndef OPENSSL_NO_SRTP + int SSL_CTX_set_tlsext_use_srtp(SSL_CTX *ctx, const char *profiles); int SSL_set_tlsext_use_srtp(SSL *ctx, const char *profiles); SRTP_PROTECTION_PROFILE *SSL_get_selected_srtp_profile(SSL *s); @@ -137,6 +139,8 @@ SRTP_PROTECTION_PROFILE *SSL_get_selected_srtp_profile(SSL *s); STACK_OF(SRTP_PROTECTION_PROFILE) *SSL_get_srtp_profiles(SSL *ssl); SRTP_PROTECTION_PROFILE *SSL_get_selected_srtp_profile(SSL *s); +#endif + #ifdef __cplusplus } #endif diff --git a/deps/openssl/openssl/ssl/ssl-lib.com b/deps/openssl/openssl/ssl/ssl-lib.com index 05bda755b591a3..7303bc4dd1ac47 100644 --- a/deps/openssl/openssl/ssl/ssl-lib.com +++ b/deps/openssl/openssl/ssl/ssl-lib.com @@ -213,16 +213,16 @@ $ ENDIF $! $! Define The Different SSL "library" Files. $! -$ LIB_SSL = "s2_meth,s2_srvr,s2_clnt,s2_lib,s2_enc,s2_pkt,"+ - - "s3_meth,s3_srvr,s3_clnt,s3_lib,s3_enc,s3_pkt,s3_both,s3_cbc,"+ - - "s23_meth,s23_srvr,s23_clnt,s23_lib,s23_pkt,"+ - - "t1_meth,t1_srvr,t1_clnt,t1_lib,t1_enc,"+ - - "d1_meth,d1_srvr,d1_clnt,d1_lib,d1_pkt,"+ - +$ LIB_SSL = "s2_meth, s2_srvr, s2_clnt, s2_lib, s2_enc, s2_pkt,"+ - + "s3_meth, s3_srvr, s3_clnt, s3_lib, s3_enc, s3_pkt, s3_both, s3_cbc,"+ - + "s23_meth,s23_srvr,s23_clnt,s23_lib, s23_pkt,"+ - + "t1_meth, t1_srvr, t1_clnt, t1_lib, t1_enc,"+ - + "d1_meth, d1_srvr, d1_clnt, d1_lib, d1_pkt,"+ - "d1_both,d1_enc,d1_srtp,"+ - "ssl_lib,ssl_err2,ssl_cert,ssl_sess,"+ - "ssl_ciph,ssl_stat,ssl_rsa,"+ - "ssl_asn1,ssl_txt,ssl_algs,"+ - - "bio_ssl,ssl_err,kssl,tls_srp,t1_reneg" + "bio_ssl,ssl_err,kssl,tls_srp,t1_reneg,ssl_utst" $! $ COMPILEWITH_CC5 = "" $! @@ -240,7 +240,7 @@ $ NEXT_FILE: $! $! O.K, Extract The File Name From The File List. $! -$ FILE_NAME = F$ELEMENT(FILE_COUNTER,",",LIB_SSL) +$ FILE_NAME = F$EDIT(F$ELEMENT(FILE_COUNTER,",",LIB_SSL),"COLLAPSE") $! $! Check To See If We Are At The End Of The File List. $! @@ -858,8 +858,11 @@ $ IF F$TYPE(USER_CCDEFS) .NES. "" THEN CCDEFS = CCDEFS + "," + USER_CCDEFS $ CCEXTRAFLAGS = "" $ IF F$TYPE(USER_CCFLAGS) .NES. "" THEN CCEXTRAFLAGS = USER_CCFLAGS $ CCDISABLEWARNINGS = "" !!! "MAYLOSEDATA3" !!! "LONGLONGTYPE,LONGLONGSUFX,FOUNDCR" -$ IF F$TYPE(USER_CCDISABLEWARNINGS) .NES. "" THEN - - CCDISABLEWARNINGS = CCDISABLEWARNINGS + "," + USER_CCDISABLEWARNINGS +$ IF F$TYPE(USER_CCDISABLEWARNINGS) .NES. "" +$ THEN +$ IF CCDISABLEWARNINGS .NES. "" THEN CCDISABLEWARNINGS = CCDISABLEWARNINGS + "," +$ CCDISABLEWARNINGS = CCDISABLEWARNINGS + USER_CCDISABLEWARNINGS +$ ENDIF $! $! Check To See If We Have A ZLIB Option. $! diff --git a/deps/openssl/openssl/ssl/ssl.h b/deps/openssl/openssl/ssl/ssl.h index b73da5ee1e1087..b78a1cce4409f9 100644 --- a/deps/openssl/openssl/ssl/ssl.h +++ b/deps/openssl/openssl/ssl/ssl.h @@ -653,6 +653,10 @@ struct ssl_session_st */ #define SSL_MODE_SEND_CLIENTHELLO_TIME 0x00000020L #define SSL_MODE_SEND_SERVERHELLO_TIME 0x00000040L +/* Send TLS_FALLBACK_SCSV in the ClientHello. + * To be set by applications that reconnect with a downgraded protocol + * version; see draft-ietf-tls-downgrade-scsv-00 for details. */ +#define SSL_MODE_SEND_FALLBACK_SCSV 0x00000080L /* Note: SSL[_CTX]_set_{options,mode} use |= op on the previous value, * they cannot be used to clear bits. */ @@ -1511,6 +1515,7 @@ DECLARE_PEM_rw(SSL_SESSION, SSL_SESSION) #define SSL_AD_BAD_CERTIFICATE_STATUS_RESPONSE TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE #define SSL_AD_BAD_CERTIFICATE_HASH_VALUE TLS1_AD_BAD_CERTIFICATE_HASH_VALUE #define SSL_AD_UNKNOWN_PSK_IDENTITY TLS1_AD_UNKNOWN_PSK_IDENTITY /* fatal */ +#define SSL_AD_INAPPROPRIATE_FALLBACK TLS1_AD_INAPPROPRIATE_FALLBACK /* fatal */ #define SSL_ERROR_NONE 0 #define SSL_ERROR_SSL 1 @@ -1621,6 +1626,8 @@ DECLARE_PEM_rw(SSL_SESSION, SSL_SESSION) #define SSL_CTRL_GET_EXTRA_CHAIN_CERTS 82 #define SSL_CTRL_CLEAR_EXTRA_CHAIN_CERTS 83 +#define SSL_CTRL_CHECK_PROTO_VERSION 119 + #define DTLSv1_get_timeout(ssl, arg) \ SSL_ctrl(ssl,DTLS_CTRL_GET_TIMEOUT,0, (void *)arg) #define DTLSv1_handle_timeout(ssl) \ @@ -2379,6 +2386,7 @@ void ERR_load_SSL_strings(void); #define SSL_R_HTTPS_PROXY_REQUEST 155 #define SSL_R_HTTP_REQUEST 156 #define SSL_R_ILLEGAL_PADDING 283 +#define SSL_R_INAPPROPRIATE_FALLBACK 373 #define SSL_R_INCONSISTENT_COMPRESSION 340 #define SSL_R_INVALID_CHALLENGE_LENGTH 158 #define SSL_R_INVALID_COMMAND 280 @@ -2525,6 +2533,7 @@ void ERR_load_SSL_strings(void); #define SSL_R_TLSV1_ALERT_DECRYPTION_FAILED 1021 #define SSL_R_TLSV1_ALERT_DECRYPT_ERROR 1051 #define SSL_R_TLSV1_ALERT_EXPORT_RESTRICTION 1060 +#define SSL_R_TLSV1_ALERT_INAPPROPRIATE_FALLBACK 1086 #define SSL_R_TLSV1_ALERT_INSUFFICIENT_SECURITY 1071 #define SSL_R_TLSV1_ALERT_INTERNAL_ERROR 1080 #define SSL_R_TLSV1_ALERT_NO_RENEGOTIATION 1100 diff --git a/deps/openssl/openssl/ssl/ssl3.h b/deps/openssl/openssl/ssl/ssl3.h index 37f19e3ab505e3..85f150409d21de 100644 --- a/deps/openssl/openssl/ssl/ssl3.h +++ b/deps/openssl/openssl/ssl/ssl3.h @@ -128,9 +128,14 @@ extern "C" { #endif -/* Signalling cipher suite value: from draft-ietf-tls-renegotiation-03.txt */ +/* Signalling cipher suite value from RFC 5746 + * (TLS_EMPTY_RENEGOTIATION_INFO_SCSV) */ #define SSL3_CK_SCSV 0x030000FF +/* Signalling cipher suite value from draft-ietf-tls-downgrade-scsv-00 + * (TLS_FALLBACK_SCSV) */ +#define SSL3_CK_FALLBACK_SCSV 0x03005600 + #define SSL3_CK_RSA_NULL_MD5 0x03000001 #define SSL3_CK_RSA_NULL_SHA 0x03000002 #define SSL3_CK_RSA_RC4_40_MD5 0x03000003 diff --git a/deps/openssl/openssl/ssl/ssl_err.c b/deps/openssl/openssl/ssl/ssl_err.c index d2f0dec71b3a0a..1b7eb47e15b927 100644 --- a/deps/openssl/openssl/ssl/ssl_err.c +++ b/deps/openssl/openssl/ssl/ssl_err.c @@ -383,6 +383,7 @@ static ERR_STRING_DATA SSL_str_reasons[]= {ERR_REASON(SSL_R_HTTPS_PROXY_REQUEST) ,"https proxy request"}, {ERR_REASON(SSL_R_HTTP_REQUEST) ,"http request"}, {ERR_REASON(SSL_R_ILLEGAL_PADDING) ,"illegal padding"}, +{ERR_REASON(SSL_R_INAPPROPRIATE_FALLBACK),"inappropriate fallback"}, {ERR_REASON(SSL_R_INCONSISTENT_COMPRESSION),"inconsistent compression"}, {ERR_REASON(SSL_R_INVALID_CHALLENGE_LENGTH),"invalid challenge length"}, {ERR_REASON(SSL_R_INVALID_COMMAND) ,"invalid command"}, @@ -529,6 +530,7 @@ static ERR_STRING_DATA SSL_str_reasons[]= {ERR_REASON(SSL_R_TLSV1_ALERT_DECRYPTION_FAILED),"tlsv1 alert decryption failed"}, {ERR_REASON(SSL_R_TLSV1_ALERT_DECRYPT_ERROR),"tlsv1 alert decrypt error"}, {ERR_REASON(SSL_R_TLSV1_ALERT_EXPORT_RESTRICTION),"tlsv1 alert export restriction"}, +{ERR_REASON(SSL_R_TLSV1_ALERT_INAPPROPRIATE_FALLBACK),"tlsv1 alert inappropriate fallback"}, {ERR_REASON(SSL_R_TLSV1_ALERT_INSUFFICIENT_SECURITY),"tlsv1 alert insufficient security"}, {ERR_REASON(SSL_R_TLSV1_ALERT_INTERNAL_ERROR),"tlsv1 alert internal error"}, {ERR_REASON(SSL_R_TLSV1_ALERT_NO_RENEGOTIATION),"tlsv1 alert no renegotiation"}, diff --git a/deps/openssl/openssl/ssl/ssl_lib.c b/deps/openssl/openssl/ssl/ssl_lib.c index 82a2c801292c56..3f66fc061db5a3 100644 --- a/deps/openssl/openssl/ssl/ssl_lib.c +++ b/deps/openssl/openssl/ssl/ssl_lib.c @@ -1387,6 +1387,8 @@ int ssl_cipher_list_to_bytes(SSL *s,STACK_OF(SSL_CIPHER) *sk,unsigned char *p, if (sk == NULL) return(0); q=p; + if (put_cb == NULL) + put_cb = s->method->put_cipher_by_char; for (i=0; isrp_ctx.srp_Mask & SSL_kSRP)) continue; #endif /* OPENSSL_NO_SRP */ - j = put_cb ? put_cb(c,p) : ssl_put_cipher_by_char(s,c,p); + j = put_cb(c,p); p+=j; } - /* If p == q, no ciphers and caller indicates an error. Otherwise - * add SCSV if not renegotiating. - */ - if (p != q && !s->renegotiate) + /* If p == q, no ciphers; caller indicates an error. + * Otherwise, add applicable SCSVs. */ + if (p != q) { - static SSL_CIPHER scsv = + if (!s->renegotiate) { - 0, NULL, SSL3_CK_SCSV, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - j = put_cb ? put_cb(&scsv,p) : ssl_put_cipher_by_char(s,&scsv,p); - p+=j; + static SSL_CIPHER scsv = + { + 0, NULL, SSL3_CK_SCSV, 0, 0, 0, 0, 0, 0, 0, 0, 0 + }; + j = put_cb(&scsv,p); + p+=j; #ifdef OPENSSL_RI_DEBUG - fprintf(stderr, "SCSV sent by client\n"); + fprintf(stderr, "TLS_EMPTY_RENEGOTIATION_INFO_SCSV sent by client\n"); #endif - } + } + + if (s->mode & SSL_MODE_SEND_FALLBACK_SCSV) + { + static SSL_CIPHER scsv = + { + 0, NULL, SSL3_CK_FALLBACK_SCSV, 0, 0, 0, 0, 0, 0, 0, 0, 0 + }; + j = put_cb(&scsv,p); + p+=j; + } + } return(p-q); } @@ -1439,11 +1453,12 @@ STACK_OF(SSL_CIPHER) *ssl_bytes_to_cipher_list(SSL *s,unsigned char *p,int num, const SSL_CIPHER *c; STACK_OF(SSL_CIPHER) *sk; int i,n; + if (s->s3) s->s3->send_connection_binding = 0; n=ssl_put_cipher_by_char(s,NULL,NULL); - if ((num%n) != 0) + if (n == 0 || (num%n) != 0) { SSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST,SSL_R_ERROR_IN_RECEIVED_CIPHER_LIST); return(NULL); @@ -1458,7 +1473,7 @@ STACK_OF(SSL_CIPHER) *ssl_bytes_to_cipher_list(SSL *s,unsigned char *p,int num, for (i=0; is3 && (n != 3 || !p[0]) && (p[n-2] == ((SSL3_CK_SCSV >> 8) & 0xff)) && (p[n-1] == (SSL3_CK_SCSV & 0xff))) @@ -1478,6 +1493,23 @@ STACK_OF(SSL_CIPHER) *ssl_bytes_to_cipher_list(SSL *s,unsigned char *p,int num, continue; } + /* Check for TLS_FALLBACK_SCSV */ + if ((n != 3 || !p[0]) && + (p[n-2] == ((SSL3_CK_FALLBACK_SCSV >> 8) & 0xff)) && + (p[n-1] == (SSL3_CK_FALLBACK_SCSV & 0xff))) + { + /* The SCSV indicates that the client previously tried a higher version. + * Fail if the current version is an unexpected downgrade. */ + if (!SSL_ctrl(s, SSL_CTRL_CHECK_PROTO_VERSION, 0, NULL)) + { + SSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST,SSL_R_INAPPROPRIATE_FALLBACK); + if (s->s3) + ssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_INAPPROPRIATE_FALLBACK); + goto err; + } + continue; + } + c=ssl_get_cipher_by_char(s,p); p+=n; if (c != NULL) @@ -2944,15 +2976,26 @@ SSL_CTX *SSL_get_SSL_CTX(const SSL *ssl) SSL_CTX *SSL_set_SSL_CTX(SSL *ssl, SSL_CTX* ctx) { + CERT *ocert = ssl->cert; if (ssl->ctx == ctx) return ssl->ctx; #ifndef OPENSSL_NO_TLSEXT if (ctx == NULL) ctx = ssl->initial_ctx; #endif - if (ssl->cert != NULL) - ssl_cert_free(ssl->cert); ssl->cert = ssl_cert_dup(ctx->cert); + if (ocert != NULL) + { + int i; + /* Copy negotiated digests from original */ + for (i = 0; i < SSL_PKEY_NUM; i++) + { + CERT_PKEY *cpk = ocert->pkeys + i; + CERT_PKEY *rpk = ssl->cert->pkeys + i; + rpk->digest = cpk->digest; + } + ssl_cert_free(ocert); + } CRYPTO_add(&ctx->references,1,CRYPTO_LOCK_SSL_CTX); if (ssl->ctx != NULL) SSL_CTX_free(ssl->ctx); /* decrement reference count */ diff --git a/deps/openssl/openssl/ssl/t1_enc.c b/deps/openssl/openssl/ssl/t1_enc.c index 1427484a325bb4..1923cf3e9d123d 100644 --- a/deps/openssl/openssl/ssl/t1_enc.c +++ b/deps/openssl/openssl/ssl/t1_enc.c @@ -1241,6 +1241,7 @@ int tls1_alert_code(int code) case SSL_AD_BAD_CERTIFICATE_STATUS_RESPONSE: return(TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE); case SSL_AD_BAD_CERTIFICATE_HASH_VALUE: return(TLS1_AD_BAD_CERTIFICATE_HASH_VALUE); case SSL_AD_UNKNOWN_PSK_IDENTITY:return(TLS1_AD_UNKNOWN_PSK_IDENTITY); + case SSL_AD_INAPPROPRIATE_FALLBACK:return(TLS1_AD_INAPPROPRIATE_FALLBACK); #if 0 /* not appropriate for TLS, not used for DTLS */ case DTLS1_AD_MISSING_HANDSHAKE_MESSAGE: return (DTLS1_AD_MISSING_HANDSHAKE_MESSAGE); diff --git a/deps/openssl/openssl/ssl/t1_lib.c b/deps/openssl/openssl/ssl/t1_lib.c index 022a4fb289e36f..d6aff4b682f234 100644 --- a/deps/openssl/openssl/ssl/t1_lib.c +++ b/deps/openssl/openssl/ssl/t1_lib.c @@ -643,7 +643,7 @@ unsigned char *ssl_add_clienthello_tlsext(SSL *s, unsigned char *buf, unsigned c #endif #ifndef OPENSSL_NO_SRTP - if(SSL_get_srtp_profiles(s)) + if(SSL_IS_DTLS(s) && SSL_get_srtp_profiles(s)) { int el; @@ -806,7 +806,7 @@ unsigned char *ssl_add_serverhello_tlsext(SSL *s, unsigned char *buf, unsigned c #endif #ifndef OPENSSL_NO_SRTP - if(s->srtp_profile) + if(SSL_IS_DTLS(s) && s->srtp_profile) { int el; @@ -1444,7 +1444,8 @@ int ssl_parse_clienthello_tlsext(SSL *s, unsigned char **p, unsigned char *d, in /* session ticket processed earlier */ #ifndef OPENSSL_NO_SRTP - else if (type == TLSEXT_TYPE_use_srtp) + else if (SSL_IS_DTLS(s) && SSL_get_srtp_profiles(s) + && type == TLSEXT_TYPE_use_srtp) { if(ssl_parse_clienthello_use_srtp_ext(s, data, size, al)) @@ -1698,7 +1699,7 @@ int ssl_parse_serverhello_tlsext(SSL *s, unsigned char **p, unsigned char *d, in } #endif #ifndef OPENSSL_NO_SRTP - else if (type == TLSEXT_TYPE_use_srtp) + else if (SSL_IS_DTLS(s) && type == TLSEXT_TYPE_use_srtp) { if(ssl_parse_serverhello_use_srtp_ext(s, data, size, al)) @@ -2347,7 +2348,10 @@ static int tls_decrypt_ticket(SSL *s, const unsigned char *etick, int eticklen, HMAC_Final(&hctx, tick_hmac, NULL); HMAC_CTX_cleanup(&hctx); if (CRYPTO_memcmp(tick_hmac, etick + eticklen, mlen)) + { + EVP_CIPHER_CTX_cleanup(&ctx); return 2; + } /* Attempt to decrypt session data */ /* Move p after IV to start of encrypted ticket, update length */ p = etick + 16 + EVP_CIPHER_CTX_iv_length(&ctx); diff --git a/deps/openssl/openssl/ssl/tls1.h b/deps/openssl/openssl/ssl/tls1.h index c992091e305e5f..6ae8876462535c 100644 --- a/deps/openssl/openssl/ssl/tls1.h +++ b/deps/openssl/openssl/ssl/tls1.h @@ -159,17 +159,19 @@ extern "C" { #define TLS1_ALLOW_EXPERIMENTAL_CIPHERSUITES 0 +#define TLS1_VERSION 0x0301 +#define TLS1_1_VERSION 0x0302 #define TLS1_2_VERSION 0x0303 -#define TLS1_2_VERSION_MAJOR 0x03 -#define TLS1_2_VERSION_MINOR 0x03 +#define TLS_MAX_VERSION TLS1_2_VERSION + +#define TLS1_VERSION_MAJOR 0x03 +#define TLS1_VERSION_MINOR 0x01 -#define TLS1_1_VERSION 0x0302 #define TLS1_1_VERSION_MAJOR 0x03 #define TLS1_1_VERSION_MINOR 0x02 -#define TLS1_VERSION 0x0301 -#define TLS1_VERSION_MAJOR 0x03 -#define TLS1_VERSION_MINOR 0x01 +#define TLS1_2_VERSION_MAJOR 0x03 +#define TLS1_2_VERSION_MINOR 0x03 #define TLS1_get_version(s) \ ((s->version >> 8) == TLS1_VERSION_MAJOR ? s->version : 0) @@ -187,6 +189,7 @@ extern "C" { #define TLS1_AD_PROTOCOL_VERSION 70 /* fatal */ #define TLS1_AD_INSUFFICIENT_SECURITY 71 /* fatal */ #define TLS1_AD_INTERNAL_ERROR 80 /* fatal */ +#define TLS1_AD_INAPPROPRIATE_FALLBACK 86 /* fatal */ #define TLS1_AD_USER_CANCELLED 90 #define TLS1_AD_NO_RENEGOTIATION 100 /* codes 110-114 are from RFC3546 */ diff --git a/deps/openssl/openssl/test/Makefile b/deps/openssl/openssl/test/Makefile index 9fb62cf6656682..685a691afbf03b 100644 --- a/deps/openssl/openssl/test/Makefile +++ b/deps/openssl/openssl/test/Makefile @@ -63,7 +63,8 @@ IGETEST= igetest JPAKETEST= jpaketest SRPTEST= srptest ASN1TEST= asn1test -HEARTBEATTEST= heartbeat_test +HEARTBEATTEST= heartbeat_test +CONSTTIMETEST= constant_time_test TESTS= alltests @@ -75,7 +76,7 @@ EXE= $(BNTEST)$(EXE_EXT) $(ECTEST)$(EXE_EXT) $(ECDSATEST)$(EXE_EXT) $(ECDHTEST) $(RANDTEST)$(EXE_EXT) $(DHTEST)$(EXE_EXT) $(ENGINETEST)$(EXE_EXT) \ $(BFTEST)$(EXE_EXT) $(CASTTEST)$(EXE_EXT) $(SSLTEST)$(EXE_EXT) $(EXPTEST)$(EXE_EXT) $(DSATEST)$(EXE_EXT) $(RSATEST)$(EXE_EXT) \ $(EVPTEST)$(EXE_EXT) $(IGETEST)$(EXE_EXT) $(JPAKETEST)$(EXE_EXT) $(SRPTEST)$(EXE_EXT) \ - $(ASN1TEST)$(EXE_EXT) $(HEARTBEATTEST)$(EXE_EXT) + $(ASN1TEST)$(EXE_EXT) $(HEARTBEATTEST)$(EXE_EXT) $(CONSTTIMETEST)$(EXE_EXT) # $(METHTEST)$(EXE_EXT) @@ -87,7 +88,8 @@ OBJ= $(BNTEST).o $(ECTEST).o $(ECDSATEST).o $(ECDHTEST).o $(IDEATEST).o \ $(MDC2TEST).o $(RMDTEST).o \ $(RANDTEST).o $(DHTEST).o $(ENGINETEST).o $(CASTTEST).o \ $(BFTEST).o $(SSLTEST).o $(DSATEST).o $(EXPTEST).o $(RSATEST).o \ - $(EVPTEST).o $(IGETEST).o $(JPAKETEST).o $(ASN1TEST).o $(HEARTBEATTEST).o + $(EVPTEST).o $(IGETEST).o $(JPAKETEST).o $(ASN1TEST).o \ + $(HEARTBEATTEST).o $(CONSTTIMETEST).o SRC= $(BNTEST).c $(ECTEST).c $(ECDSATEST).c $(ECDHTEST).c $(IDEATEST).c \ $(MD2TEST).c $(MD4TEST).c $(MD5TEST).c \ @@ -97,7 +99,7 @@ SRC= $(BNTEST).c $(ECTEST).c $(ECDSATEST).c $(ECDHTEST).c $(IDEATEST).c \ $(RANDTEST).c $(DHTEST).c $(ENGINETEST).c $(CASTTEST).c \ $(BFTEST).c $(SSLTEST).c $(DSATEST).c $(EXPTEST).c $(RSATEST).c \ $(EVPTEST).c $(IGETEST).c $(JPAKETEST).c $(SRPTEST).c $(ASN1TEST).c \ - $(HEARTBEATTEST).c + $(HEARTBEATTEST).c $(CONSTTIMETEST).c EXHEADER= HEADER= $(EXHEADER) @@ -140,7 +142,7 @@ alltests: \ test_enc test_x509 test_rsa test_crl test_sid \ test_gen test_req test_pkcs7 test_verify test_dh test_dsa \ test_ss test_ca test_engine test_evp test_ssl test_tsa test_ige \ - test_jpake test_srp test_cms test_heartbeat + test_jpake test_srp test_cms test_heartbeat test_constant_time test_evp: ../util/shlib_wrap.sh ./$(EVPTEST) evptests.txt @@ -324,6 +326,10 @@ test_srp: $(SRPTEST)$(EXE_EXT) test_heartbeat: $(HEARTBEATTEST)$(EXE_EXT) ../util/shlib_wrap.sh ./$(HEARTBEATTEST) +test_constant_time: $(CONSTTIMETEST)$(EXE_EXT) + @echo "Test constant time utilites" + ../util/shlib_wrap.sh ./$(CONSTTIMETEST) + lint: lint -DLINT $(INCLUDES) $(SRC)>fluff @@ -485,6 +491,9 @@ $(SRPTEST)$(EXE_EXT): $(SRPTEST).o $(DLIBCRYPTO) $(HEARTBEATTEST)$(EXE_EXT): $(HEARTBEATTEST).o $(DLIBCRYPTO) @target=$(HEARTBEATTEST); $(BUILD_CMD_STATIC) +$(CONSTTIMETEST)$(EXE_EXT): $(CONSTTIMETEST).o + @target=$(CONSTTIMETEST) $(BUILD_CMD) + #$(AESTEST).o: $(AESTEST).c # $(CC) -c $(CFLAGS) -DINTERMEDIATE_VALUE_KAT -DTRACE_KAT_MCT $(AESTEST).c @@ -530,6 +539,9 @@ bntest.o: ../include/openssl/stack.h ../include/openssl/symhacks.h bntest.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h bntest.c casttest.o: ../e_os.h ../include/openssl/cast.h ../include/openssl/e_os2.h casttest.o: ../include/openssl/opensslconf.h casttest.c +constant_time_test.o: ../crypto/constant_time_locl.h ../e_os.h +constant_time_test.o: ../include/openssl/e_os2.h +constant_time_test.o: ../include/openssl/opensslconf.h constant_time_test.c destest.o: ../include/openssl/des.h ../include/openssl/des_old.h destest.o: ../include/openssl/e_os2.h ../include/openssl/opensslconf.h destest.o: ../include/openssl/ossl_typ.h ../include/openssl/safestack.h diff --git a/deps/openssl/openssl/test/constant_time_test.c b/deps/openssl/openssl/test/constant_time_test.c new file mode 100644 index 00000000000000..d9c6a44aed055d --- /dev/null +++ b/deps/openssl/openssl/test/constant_time_test.c @@ -0,0 +1,330 @@ +/* crypto/constant_time_test.c */ +/* + * Utilities for constant-time cryptography. + * + * Author: Emilia Kasper (emilia@openssl.org) + * Based on previous work by Bodo Moeller, Emilia Kasper, Adam Langley + * (Google). + * ==================================================================== + * Copyright (c) 2014 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include "../crypto/constant_time_locl.h" + +#include +#include +#include + +static const unsigned int CONSTTIME_TRUE = (unsigned)(~0); +static const unsigned int CONSTTIME_FALSE = 0; +static const unsigned char CONSTTIME_TRUE_8 = 0xff; +static const unsigned char CONSTTIME_FALSE_8 = 0; + +static int test_binary_op(unsigned int (*op)(unsigned int a, unsigned int b), + const char* op_name, unsigned int a, unsigned int b, int is_true) + { + unsigned c = op(a, b); + if (is_true && c != CONSTTIME_TRUE) + { + fprintf(stderr, "Test failed for %s(%du, %du): expected %du " + "(TRUE), got %du\n", op_name, a, b, CONSTTIME_TRUE, c); + return 1; + } + else if (!is_true && c != CONSTTIME_FALSE) + { + fprintf(stderr, "Test failed for %s(%du, %du): expected %du " + "(FALSE), got %du\n", op_name, a, b, CONSTTIME_FALSE, + c); + return 1; + } + return 0; + } + +static int test_binary_op_8(unsigned char (*op)(unsigned int a, unsigned int b), + const char* op_name, unsigned int a, unsigned int b, int is_true) + { + unsigned char c = op(a, b); + if (is_true && c != CONSTTIME_TRUE_8) + { + fprintf(stderr, "Test failed for %s(%du, %du): expected %u " + "(TRUE), got %u\n", op_name, a, b, CONSTTIME_TRUE_8, c); + return 1; + } + else if (!is_true && c != CONSTTIME_FALSE_8) + { + fprintf(stderr, "Test failed for %s(%du, %du): expected %u " + "(FALSE), got %u\n", op_name, a, b, CONSTTIME_FALSE_8, + c); + return 1; + } + return 0; + } + +static int test_is_zero(unsigned int a) + { + unsigned int c = constant_time_is_zero(a); + if (a == 0 && c != CONSTTIME_TRUE) + { + fprintf(stderr, "Test failed for constant_time_is_zero(%du): " + "expected %du (TRUE), got %du\n", a, CONSTTIME_TRUE, c); + return 1; + } + else if (a != 0 && c != CONSTTIME_FALSE) + { + fprintf(stderr, "Test failed for constant_time_is_zero(%du): " + "expected %du (FALSE), got %du\n", a, CONSTTIME_FALSE, + c); + return 1; + } + return 0; + } + +static int test_is_zero_8(unsigned int a) + { + unsigned char c = constant_time_is_zero_8(a); + if (a == 0 && c != CONSTTIME_TRUE_8) + { + fprintf(stderr, "Test failed for constant_time_is_zero(%du): " + "expected %u (TRUE), got %u\n", a, CONSTTIME_TRUE_8, c); + return 1; + } + else if (a != 0 && c != CONSTTIME_FALSE) + { + fprintf(stderr, "Test failed for constant_time_is_zero(%du): " + "expected %u (FALSE), got %u\n", a, CONSTTIME_FALSE_8, + c); + return 1; + } + return 0; + } + +static int test_select(unsigned int a, unsigned int b) + { + unsigned int selected = constant_time_select(CONSTTIME_TRUE, a, b); + if (selected != a) + { + fprintf(stderr, "Test failed for constant_time_select(%du, %du," + "%du): expected %du(first value), got %du\n", + CONSTTIME_TRUE, a, b, a, selected); + return 1; + } + selected = constant_time_select(CONSTTIME_FALSE, a, b); + if (selected != b) + { + fprintf(stderr, "Test failed for constant_time_select(%du, %du," + "%du): expected %du(second value), got %du\n", + CONSTTIME_FALSE, a, b, b, selected); + return 1; + } + return 0; + } + +static int test_select_8(unsigned char a, unsigned char b) + { + unsigned char selected = constant_time_select_8(CONSTTIME_TRUE_8, a, b); + if (selected != a) + { + fprintf(stderr, "Test failed for constant_time_select(%u, %u," + "%u): expected %u(first value), got %u\n", + CONSTTIME_TRUE, a, b, a, selected); + return 1; + } + selected = constant_time_select_8(CONSTTIME_FALSE_8, a, b); + if (selected != b) + { + fprintf(stderr, "Test failed for constant_time_select(%u, %u," + "%u): expected %u(second value), got %u\n", + CONSTTIME_FALSE, a, b, b, selected); + return 1; + } + return 0; + } + +static int test_select_int(int a, int b) + { + int selected = constant_time_select_int(CONSTTIME_TRUE, a, b); + if (selected != a) + { + fprintf(stderr, "Test failed for constant_time_select(%du, %d," + "%d): expected %d(first value), got %d\n", + CONSTTIME_TRUE, a, b, a, selected); + return 1; + } + selected = constant_time_select_int(CONSTTIME_FALSE, a, b); + if (selected != b) + { + fprintf(stderr, "Test failed for constant_time_select(%du, %d," + "%d): expected %d(second value), got %d\n", + CONSTTIME_FALSE, a, b, b, selected); + return 1; + } + return 0; + } + +static int test_eq_int(int a, int b) + { + unsigned int equal = constant_time_eq_int(a, b); + if (a == b && equal != CONSTTIME_TRUE) + { + fprintf(stderr, "Test failed for constant_time_eq_int(%d, %d): " + "expected %du(TRUE), got %du\n", + a, b, CONSTTIME_TRUE, equal); + return 1; + } + else if (a != b && equal != CONSTTIME_FALSE) + { + fprintf(stderr, "Test failed for constant_time_eq_int(%d, %d): " + "expected %du(FALSE), got %du\n", + a, b, CONSTTIME_FALSE, equal); + return 1; + } + return 0; + } + +static int test_eq_int_8(int a, int b) + { + unsigned char equal = constant_time_eq_int_8(a, b); + if (a == b && equal != CONSTTIME_TRUE_8) + { + fprintf(stderr, "Test failed for constant_time_eq_int_8(%d, %d): " + "expected %u(TRUE), got %u\n", + a, b, CONSTTIME_TRUE_8, equal); + return 1; + } + else if (a != b && equal != CONSTTIME_FALSE_8) + { + fprintf(stderr, "Test failed for constant_time_eq_int_8(%d, %d): " + "expected %u(FALSE), got %u\n", + a, b, CONSTTIME_FALSE_8, equal); + return 1; + } + return 0; + } + +static unsigned int test_values[] = {0, 1, 1024, 12345, 32000, UINT_MAX/2-1, + UINT_MAX/2, UINT_MAX/2+1, UINT_MAX-1, + UINT_MAX}; + +static unsigned char test_values_8[] = {0, 1, 2, 20, 32, 127, 128, 129, 255}; + +static int signed_test_values[] = {0, 1, -1, 1024, -1024, 12345, -12345, + 32000, -32000, INT_MAX, INT_MIN, INT_MAX-1, + INT_MIN+1}; + + +int main(int argc, char *argv[]) + { + unsigned int a, b, i, j; + int c, d; + unsigned char e, f; + int num_failed = 0, num_all = 0; + fprintf(stdout, "Testing constant time operations...\n"); + + for (i = 0; i < sizeof(test_values)/sizeof(int); ++i) + { + a = test_values[i]; + num_failed += test_is_zero(a); + num_failed += test_is_zero_8(a); + num_all += 2; + for (j = 0; j < sizeof(test_values)/sizeof(int); ++j) + { + b = test_values[j]; + num_failed += test_binary_op(&constant_time_lt, + "constant_time_lt", a, b, a < b); + num_failed += test_binary_op_8(&constant_time_lt_8, + "constant_time_lt_8", a, b, a < b); + num_failed += test_binary_op(&constant_time_lt, + "constant_time_lt_8", b, a, b < a); + num_failed += test_binary_op_8(&constant_time_lt_8, + "constant_time_lt_8", b, a, b < a); + num_failed += test_binary_op(&constant_time_ge, + "constant_time_ge", a, b, a >= b); + num_failed += test_binary_op_8(&constant_time_ge_8, + "constant_time_ge_8", a, b, a >= b); + num_failed += test_binary_op(&constant_time_ge, + "constant_time_ge", b, a, b >= a); + num_failed += test_binary_op_8(&constant_time_ge_8, + "constant_time_ge_8", b, a, b >= a); + num_failed += test_binary_op(&constant_time_eq, + "constant_time_eq", a, b, a == b); + num_failed += test_binary_op_8(&constant_time_eq_8, + "constant_time_eq_8", a, b, a == b); + num_failed += test_binary_op(&constant_time_eq, + "constant_time_eq", b, a, b == a); + num_failed += test_binary_op_8(&constant_time_eq_8, + "constant_time_eq_8", b, a, b == a); + num_failed += test_select(a, b); + num_all += 13; + } + } + + for (i = 0; i < sizeof(signed_test_values)/sizeof(int); ++i) + { + c = signed_test_values[i]; + for (j = 0; j < sizeof(signed_test_values)/sizeof(int); ++j) + { + d = signed_test_values[j]; + num_failed += test_select_int(c, d); + num_failed += test_eq_int(c, d); + num_failed += test_eq_int_8(c, d); + num_all += 3; + } + } + + for (i = 0; i < sizeof(test_values_8); ++i) + { + e = test_values_8[i]; + for (j = 0; j < sizeof(test_values_8); ++j) + { + f = test_values_8[j]; + num_failed += test_select_8(e, f); + num_all += 1; + } + } + + if (!num_failed) + { + fprintf(stdout, "ok (ran %d tests)\n", num_all); + return EXIT_SUCCESS; + } + else + { + fprintf(stdout, "%d of %d tests failed!\n", num_failed, num_all); + return EXIT_FAILURE; + } + } diff --git a/deps/openssl/openssl/test/ectest.c b/deps/openssl/openssl/test/ectest.c index 82c8c8bfb119c6..d1bf980599c8ac 100644 --- a/deps/openssl/openssl/test/ectest.c +++ b/deps/openssl/openssl/test/ectest.c @@ -251,14 +251,15 @@ static void group_order_tests(EC_GROUP *group) if (!EC_POINT_is_at_infinity(group, Q)) ABORT; /* Exercise EC_POINTs_mul, including corner cases. */ + if (EC_POINT_is_at_infinity(group, P)) ABORT; scalars[0] = n1; points[0] = Q; /* => infinity */ scalars[1] = n2; points[1] = P; /* => -P */ scalars[2] = n1; points[2] = Q; /* => infinity */ scalars[3] = n2; points[3] = Q; /* => infinity */ scalars[4] = n1; points[4] = P; /* => P */ scalars[5] = n2; points[5] = Q; /* => infinity */ - if (!EC_POINTs_mul(group, Q, NULL, 5, points, scalars, ctx)) ABORT; - if (!EC_POINT_is_at_infinity(group, Q)) ABORT; + if (!EC_POINTs_mul(group, P, NULL, 6, points, scalars, ctx)) ABORT; + if (!EC_POINT_is_at_infinity(group, P)) ABORT; } fprintf(stdout, "ok\n"); diff --git a/deps/openssl/openssl/test/exptest.c b/deps/openssl/openssl/test/exptest.c index 074a8e882a8eb5..5fa02a1229e88c 100644 --- a/deps/openssl/openssl/test/exptest.c +++ b/deps/openssl/openssl/test/exptest.c @@ -71,6 +71,43 @@ static const char rnd_seed[] = "string to make the random number generator think it has entropy"; +/* test_exp_mod_zero tests that x**0 mod 1 == 0. It returns zero on success. */ +static int test_exp_mod_zero() { + BIGNUM a, p, m; + BIGNUM r; + BN_CTX *ctx = BN_CTX_new(); + int ret = 1; + + BN_init(&m); + BN_one(&m); + + BN_init(&a); + BN_one(&a); + + BN_init(&p); + BN_zero(&p); + + BN_init(&r); + BN_mod_exp(&r, &a, &p, &m, ctx); + BN_CTX_free(ctx); + + if (BN_is_zero(&r)) + ret = 0; + else + { + printf("1**0 mod 1 = "); + BN_print_fp(stdout, &r); + printf(", should be 0\n"); + } + + BN_free(&r); + BN_free(&a); + BN_free(&p); + BN_free(&m); + + return ret; +} + int main(int argc, char *argv[]) { BN_CTX *ctx; @@ -190,7 +227,13 @@ int main(int argc, char *argv[]) ERR_remove_thread_state(NULL); CRYPTO_mem_leaks(out); BIO_free(out); - printf(" done\n"); + printf("\n"); + + if (test_exp_mod_zero() != 0) + goto err; + + printf("done\n"); + EXIT(0); err: ERR_load_crypto_strings(); diff --git a/deps/openssl/openssl/test/maketests.com b/deps/openssl/openssl/test/maketests.com index 9b64cba234742c..97e0c3bd396fae 100644 --- a/deps/openssl/openssl/test/maketests.com +++ b/deps/openssl/openssl/test/maketests.com @@ -6,6 +6,7 @@ $! A-Com Computing, Inc. $! byer@mail.all-net.net $! $! Changes by Richard Levitte +$! Zoltan Arpadffy $! $! This command files compiles and creates all the various different $! "test" programs for the different types of encryption for OpenSSL. @@ -147,7 +148,7 @@ $ TEST_FILES = "BNTEST,ECTEST,ECDSATEST,ECDHTEST,IDEATEST,"+ - "RANDTEST,DHTEST,ENGINETEST,"+ - "BFTEST,CASTTEST,SSLTEST,EXPTEST,DSATEST,RSA_TEST,"+ - "EVP_TEST,IGETEST,JPAKETEST,SRPTEST,"+ - - "ASN1TEST" + "ASN1TEST,HEARTBEAT_TEST,CONSTANT_TIME_TEST" $! Should we add MTTEST,PQ_TEST,LH_TEST,DIVTEST,TABTEST as well? $! $! Additional directory information. @@ -185,6 +186,8 @@ $ T_D_IGETEST := [-.test] $ T_D_JPAKETEST := [-.crypto.jpake] $ T_D_SRPTEST := [-.crypto.srp] $ T_D_ASN1TEST := [-.test] +$ T_D_HEARTBEAT_TEST := [-.ssl] +$ T_D_CONSTANT_TIME_TEST := [-.crypto] $! $ TCPIP_PROGRAMS = ",," $ IF COMPILER .EQS. "VAXC" THEN - diff --git a/deps/openssl/openssl/test/tests.com b/deps/openssl/openssl/test/tests.com index a840d5078f0e03..39a7bfa60779cf 100644 --- a/deps/openssl/openssl/test/tests.com +++ b/deps/openssl/openssl/test/tests.com @@ -56,7 +56,7 @@ $ tests := - test_enc,test_x509,test_rsa,test_crl,test_sid,- test_gen,test_req,test_pkcs7,test_verify,test_dh,test_dsa,- test_ss,test_ca,test_engine,test_evp,test_ssl,test_tsa,test_ige,- - test_jpake,test_srp,test_cms + test_jpake,test_srp,test_cms,test_heartbeat,test_constant_time $ endif $ tests = f$edit(tests,"COLLAPSE") $ @@ -95,6 +95,8 @@ $ IGETEST := igetest $ JPAKETEST := jpaketest $ SRPTEST := srptest $ ASN1TEST := asn1test +$ HEARTBEATTEST := heartbeat_test +$ CONSTTIMETEST := constant_time_test $! $ tests_i = 0 $ loop_tests: @@ -366,10 +368,20 @@ $ test_srp: $ write sys$output "Test SRP" $ mcr 'texe_dir''srptest' $ return +$ test_heartbeat: +$ write sys$output "Test HEARTBEAT" +$ mcr 'texe_dir''heartbeattest' +$ return +$ test_constant_time: +$ write sys$output "Test constant time utilities" +$ mcr 'texe_dir''consttimetest' +$ return $ $ $ exit: +$ on error then goto exit2 ! In case openssl.exe didn't build. $ mcr 'exe_dir'openssl version -a +$ exit2: $ set default '__save_default' $ deassign sslroot $ exit diff --git a/deps/openssl/openssl/test/testssl b/deps/openssl/openssl/test/testssl index 4e8542b5568a56..9fb89a3ddde4f7 100644 --- a/deps/openssl/openssl/test/testssl +++ b/deps/openssl/openssl/test/testssl @@ -173,6 +173,12 @@ else echo test tls1 with SRP via BIO pair $ssltest -bio_pair -tls1 -cipher SRP -srpuser test -srppass abc123 + + echo test tls1 with SRP auth + $ssltest -tls1 -cipher aSRP -srpuser test -srppass abc123 + + echo test tls1 with SRP auth via BIO pair + $ssltest -bio_pair -tls1 -cipher aSRP -srpuser test -srppass abc123 fi exit 0 diff --git a/deps/openssl/openssl/util/mk1mf.pl b/deps/openssl/openssl/util/mk1mf.pl index bcd00ba9436a74..f0c2df02675f69 100755 --- a/deps/openssl/openssl/util/mk1mf.pl +++ b/deps/openssl/openssl/util/mk1mf.pl @@ -1145,6 +1145,7 @@ sub read_options "dll" => \$shlib, "shared" => 0, "no-sctp" => 0, + "no-srtp" => 0, "no-gmp" => 0, "no-rfc3779" => 0, "no-montasm" => 0, diff --git a/deps/openssl/openssl/util/mkdef.pl b/deps/openssl/openssl/util/mkdef.pl index 79d4de896281c5..1eaa7b8acd290c 100755 --- a/deps/openssl/openssl/util/mkdef.pl +++ b/deps/openssl/openssl/util/mkdef.pl @@ -117,6 +117,8 @@ "SSL_INTERN", # SCTP "SCTP", + # SRTP + "SRTP", # Unit testing "UNIT_TEST"); @@ -138,7 +140,7 @@ my $no_fp_api; my $no_static_engine=1; my $no_gmp; my $no_deprecated; my $no_rfc3779; my $no_psk; my $no_tlsext; my $no_cms; my $no_capieng; my $no_jpake; my $no_srp; my $no_ssl2; my $no_ec2m; my $no_nistp_gcc; -my $no_nextprotoneg; my $no_sctp; +my $no_nextprotoneg; my $no_sctp; my $no_srtp; my $no_unit_test; my $fips; @@ -238,6 +240,7 @@ elsif (/^no-jpake$/) { $no_jpake=1; } elsif (/^no-srp$/) { $no_srp=1; } elsif (/^no-sctp$/) { $no_sctp=1; } + elsif (/^no-srtp$/) { $no_srtp=1; } elsif (/^no-unit-test$/){ $no_unit_test=1; } } @@ -1209,6 +1212,7 @@ sub is_valid if ($keyword eq "JPAKE" && $no_jpake) { return 0; } if ($keyword eq "SRP" && $no_srp) { return 0; } if ($keyword eq "SCTP" && $no_sctp) { return 0; } + if ($keyword eq "SRTP" && $no_srtp) { return 0; } if ($keyword eq "UNIT_TEST" && $no_unit_test) { return 0; } if ($keyword eq "DEPRECATED" && $no_deprecated) { return 0; } diff --git a/deps/openssl/openssl/util/ssleay.num b/deps/openssl/openssl/util/ssleay.num index 1c05a3c4cbf7eb..dd21e95779d3d8 100755 --- a/deps/openssl/openssl/util/ssleay.num +++ b/deps/openssl/openssl/util/ssleay.num @@ -310,14 +310,14 @@ TLSv1_2_method 350 EXIST::FUNCTION: SSL_SESSION_get_id_len 351 NOEXIST::FUNCTION: kssl_ctx_get0_client_princ 352 EXIST::FUNCTION:KRB5 SSL_export_keying_material 353 EXIST::FUNCTION:TLSEXT -SSL_set_tlsext_use_srtp 354 EXIST::FUNCTION: +SSL_set_tlsext_use_srtp 354 EXIST::FUNCTION:SRTP SSL_CTX_set_next_protos_advertised_cb 355 EXIST:!VMS:FUNCTION:NEXTPROTONEG SSL_CTX_set_next_protos_adv_cb 355 EXIST:VMS:FUNCTION:NEXTPROTONEG SSL_get0_next_proto_negotiated 356 EXIST::FUNCTION:NEXTPROTONEG -SSL_get_selected_srtp_profile 357 EXIST::FUNCTION: -SSL_CTX_set_tlsext_use_srtp 358 EXIST::FUNCTION: +SSL_get_selected_srtp_profile 357 EXIST::FUNCTION:SRTP +SSL_CTX_set_tlsext_use_srtp 358 EXIST::FUNCTION:SRTP SSL_select_next_proto 359 EXIST::FUNCTION:NEXTPROTONEG -SSL_get_srtp_profiles 360 EXIST::FUNCTION: +SSL_get_srtp_profiles 360 EXIST::FUNCTION:SRTP SSL_CTX_set_next_proto_select_cb 361 EXIST:!VMS:FUNCTION:NEXTPROTONEG SSL_CTX_set_next_proto_sel_cb 361 EXIST:VMS:FUNCTION:NEXTPROTONEG SSL_SESSION_get_compress_id 362 EXIST::FUNCTION: diff --git a/deps/v8/.DEPS.git b/deps/v8/.DEPS.git index 7775744953a334..8f9da45bb6746d 100644 --- a/deps/v8/.DEPS.git +++ b/deps/v8/.DEPS.git @@ -24,6 +24,11 @@ deps = { } deps_os = { + 'android': + { + 'v8/third_party/android_tools': + Var('git_url') + '/android_tools.git@31869996507de16812bb53a3d0aaa15cd6194c16', + }, 'win': { 'v8/third_party/cygwin': diff --git a/deps/v8/.gitignore b/deps/v8/.gitignore index d0d4b436df1db9..d0407f37f124f5 100644 --- a/deps/v8/.gitignore +++ b/deps/v8/.gitignore @@ -61,6 +61,9 @@ shell_g /test/test262/data /test/test262/data.old /test/test262/tc39-test262-* +/test/test262-es6/data +/test/test262-es6/data.old +/test/test262-es6/tc39-test262-* /testing/gmock /testing/gtest /third_party/icu @@ -80,3 +83,6 @@ GRTAGS GSYMS GPATH gtags.files +turbo*.cfg +turbo*.dot +turbo*.json diff --git a/deps/v8/AUTHORS b/deps/v8/AUTHORS index 7ac08156994c20..89caae648c6286 100644 --- a/deps/v8/AUTHORS +++ b/deps/v8/AUTHORS @@ -14,6 +14,9 @@ NVIDIA Corporation BlackBerry Limited Opera Software ASA Intel Corporation +MIPS Technologies, Inc. +Imagination Technologies, LLC +Loongson Technology Corporation Limited Akinori MUSHA Alexander Botero-Lowry @@ -24,6 +27,7 @@ Andreas Anyuru Baptiste Afsa Bert Belder Burcu Dogan +Caitlin Potter Craig Schlenter Chunyang Dai Daniel Andersson @@ -35,6 +39,7 @@ Fedor Indutny Filipe David Manana Haitao Feng Ioseb Dzmanashvili +Isiah Meadows Jacob Bramley Jan de Mooij Jay Freeman @@ -56,6 +61,7 @@ Patrick Gansterer Peter Varga Rafal Krypa Rajeev R Krithivasan +Refael Ackermann Rene Rebe Robert Mustacchi Rodolph Perfetta diff --git a/deps/v8/BUILD.gn b/deps/v8/BUILD.gn index efa4b717c9a13b..1758ee9e1fa86d 100644 --- a/deps/v8/BUILD.gn +++ b/deps/v8/BUILD.gn @@ -25,7 +25,7 @@ v8_random_seed = "314159265" # Configurations # config("internal_config") { - visibility = ":*" # Only targets in this file can depend on this. + visibility = [ ":*" ] # Only targets in this file can depend on this. include_dirs = [ "." ] @@ -38,7 +38,7 @@ config("internal_config") { } config("internal_config_base") { - visibility = ":*" # Only targets in this file can depend on this. + visibility = [ ":*" ] # Only targets in this file can depend on this. include_dirs = [ "." ] } @@ -56,7 +56,7 @@ config("external_config") { } config("features") { - visibility = ":*" # Only targets in this file can depend on this. + visibility = [ ":*" ] # Only targets in this file can depend on this. defines = [] @@ -118,7 +118,7 @@ config("features") { } config("toolchain") { - visibility = ":*" # Only targets in this file can depend on this. + visibility = [ ":*" ] # Only targets in this file can depend on this. defines = [] cflags = [] @@ -167,7 +167,7 @@ config("toolchain") { # action("js2c") { - visibility = ":*" # Only targets in this file can depend on this. + visibility = [ ":*" ] # Only targets in this file can depend on this. script = "tools/js2c.py" @@ -182,26 +182,27 @@ action("js2c") { "src/array.js", "src/string.js", "src/uri.js", - "third_party/fdlibm/fdlibm.js", + "src/third_party/fdlibm/fdlibm.js", "src/math.js", - "src/messages.js", "src/apinatives.js", - "src/debug-debugger.js", - "src/mirror-debugger.js", - "src/liveedit-debugger.js", "src/date.js", - "src/json.js", "src/regexp.js", "src/arraybuffer.js", "src/typedarray.js", + "src/generator.js", + "src/object-observe.js", "src/collection.js", + "src/weak-collection.js", "src/collection-iterator.js", - "src/weak_collection.js", "src/promise.js", - "src/object-observe.js", - "src/macros.py", + "src/messages.js", + "src/json.js", "src/array-iterator.js", "src/string-iterator.js", + "src/debug-debugger.js", + "src/mirror-debugger.js", + "src/liveedit-debugger.js", + "src/macros.py", ] outputs = [ @@ -228,7 +229,7 @@ action("js2c") { } action("js2c_experimental") { - visibility = ":*" # Only targets in this file can depend on this. + visibility = [ ":*" ] # Only targets in this file can depend on this. script = "tools/js2c.py" @@ -242,6 +243,9 @@ action("js2c_experimental") { "src/generator.js", "src/harmony-string.js", "src/harmony-array.js", + "src/harmony-typedarray.js", + "src/harmony-classes.js", + "src/harmony-tostring.js" ] outputs = [ @@ -265,7 +269,7 @@ action("js2c_experimental") { if (v8_use_external_startup_data) { action("natives_blob") { - visibility = ":*" # Only targets in this file can depend on this. + visibility = [ ":*" ] # Only targets in this file can depend on this. deps = [ ":js2c", @@ -288,7 +292,7 @@ if (v8_use_external_startup_data) { } action("postmortem-metadata") { - visibility = ":*" # Only targets in this file can depend on this. + visibility = [ ":*" ] # Only targets in this file can depend on this. script = "tools/gen-postmortem-metadata.py" @@ -307,7 +311,7 @@ action("postmortem-metadata") { } action("run_mksnapshot") { - visibility = ":*" # Only targets in this file can depend on this. + visibility = [ ":*" ] # Only targets in this file can depend on this. deps = [ ":mksnapshot($host_toolchain)" ] @@ -345,7 +349,7 @@ action("run_mksnapshot") { # source_set("v8_nosnapshot") { - visibility = ":*" # Only targets in this file can depend on this. + visibility = [ ":*" ] # Only targets in this file can depend on this. deps = [ ":js2c", @@ -366,7 +370,7 @@ source_set("v8_nosnapshot") { } source_set("v8_snapshot") { - visibility = ":*" # Only targets in this file can depend on this. + visibility = [ ":*" ] # Only targets in this file can depend on this. deps = [ ":js2c", @@ -389,7 +393,7 @@ source_set("v8_snapshot") { if (v8_use_external_startup_data) { source_set("v8_external_snapshot") { - visibility = ":*" # Only targets in this file can depend on this. + visibility = [ ":*" ] # Only targets in this file can depend on this. deps = [ ":js2c", @@ -411,7 +415,7 @@ if (v8_use_external_startup_data) { } source_set("v8_base") { - visibility = ":*" # Only targets in this file can depend on this. + visibility = [ ":*" ] # Only targets in this file can depend on this. sources = [ "src/accessors.cc", @@ -430,14 +434,24 @@ source_set("v8_base") { "src/assembler.h", "src/assert-scope.h", "src/assert-scope.cc", + "src/ast-numbering.cc", + "src/ast-numbering.h", "src/ast-value-factory.cc", "src/ast-value-factory.h", "src/ast.cc", "src/ast.h", + "src/background-parsing-task.cc", + "src/background-parsing-task.h", + "src/bailout-reason.cc", + "src/bailout-reason.h", + "src/basic-block-profiler.cc", + "src/basic-block-profiler.h", "src/bignum-dtoa.cc", "src/bignum-dtoa.h", "src/bignum.cc", "src/bignum.h", + "src/bit-vector.cc", + "src/bit-vector.h", "src/bootstrapper.cc", "src/bootstrapper.h", "src/builtins.cc", @@ -445,12 +459,15 @@ source_set("v8_base") { "src/bytecodes-irregexp.h", "src/cached-powers.cc", "src/cached-powers.h", + "src/char-predicates.cc", "src/char-predicates-inl.h", "src/char-predicates.h", "src/checks.cc", "src/checks.h", "src/circular-queue-inl.h", "src/circular-queue.h", + "src/code-factory.cc", + "src/code-factory.h", "src/code-stubs.cc", "src/code-stubs.h", "src/code-stubs-hydrogen.cc", @@ -459,15 +476,29 @@ source_set("v8_base") { "src/codegen.h", "src/compilation-cache.cc", "src/compilation-cache.h", + "src/compilation-statistics.cc", + "src/compilation-statistics.h", + "src/compiler/access-builder.cc", + "src/compiler/access-builder.h", "src/compiler/ast-graph-builder.cc", "src/compiler/ast-graph-builder.h", + "src/compiler/ast-loop-assignment-analyzer.cc", + "src/compiler/ast-loop-assignment-analyzer.h", + "src/compiler/basic-block-instrumentor.cc", + "src/compiler/basic-block-instrumentor.h", + "src/compiler/change-lowering.cc", + "src/compiler/change-lowering.h", "src/compiler/code-generator-impl.h", "src/compiler/code-generator.cc", "src/compiler/code-generator.h", "src/compiler/common-node-cache.h", + "src/compiler/common-operator.cc", "src/compiler/common-operator.h", "src/compiler/control-builders.cc", "src/compiler/control-builders.h", + "src/compiler/control-reducer.cc", + "src/compiler/control-reducer.h", + "src/compiler/diamond.h", "src/compiler/frame.h", "src/compiler/gap-resolver.cc", "src/compiler/gap-resolver.h", @@ -493,24 +524,31 @@ source_set("v8_base") { "src/compiler/instruction-selector.h", "src/compiler/instruction.cc", "src/compiler/instruction.h", + "src/compiler/js-builtin-reducer.cc", + "src/compiler/js-builtin-reducer.h", "src/compiler/js-context-specialization.cc", "src/compiler/js-context-specialization.h", "src/compiler/js-generic-lowering.cc", "src/compiler/js-generic-lowering.h", "src/compiler/js-graph.cc", "src/compiler/js-graph.h", + "src/compiler/js-inlining.cc", + "src/compiler/js-inlining.h", + "src/compiler/js-intrinsic-builder.cc", + "src/compiler/js-intrinsic-builder.h", + "src/compiler/js-operator.cc", "src/compiler/js-operator.h", "src/compiler/js-typed-lowering.cc", "src/compiler/js-typed-lowering.h", "src/compiler/linkage-impl.h", "src/compiler/linkage.cc", "src/compiler/linkage.h", - "src/compiler/lowering-builder.cc", - "src/compiler/lowering-builder.h", - "src/compiler/machine-node-factory.h", "src/compiler/machine-operator-reducer.cc", "src/compiler/machine-operator-reducer.h", + "src/compiler/machine-operator.cc", "src/compiler/machine-operator.h", + "src/compiler/machine-type.cc", + "src/compiler/machine-type.h", "src/compiler/node-aux-data-inl.h", "src/compiler/node-aux-data.h", "src/compiler/node-cache.cc", @@ -523,31 +561,42 @@ source_set("v8_base") { "src/compiler/opcodes.h", "src/compiler/operator-properties-inl.h", "src/compiler/operator-properties.h", + "src/compiler/operator.cc", "src/compiler/operator.h", "src/compiler/phi-reducer.h", "src/compiler/pipeline.cc", "src/compiler/pipeline.h", + "src/compiler/pipeline-statistics.cc", + "src/compiler/pipeline-statistics.h", "src/compiler/raw-machine-assembler.cc", "src/compiler/raw-machine-assembler.h", "src/compiler/register-allocator.cc", "src/compiler/register-allocator.h", + "src/compiler/register-configuration.cc", + "src/compiler/register-configuration.h", "src/compiler/representation-change.h", "src/compiler/schedule.cc", "src/compiler/schedule.h", "src/compiler/scheduler.cc", "src/compiler/scheduler.h", + "src/compiler/select-lowering.cc", + "src/compiler/select-lowering.h", "src/compiler/simplified-lowering.cc", "src/compiler/simplified-lowering.h", - "src/compiler/simplified-node-factory.h", + "src/compiler/simplified-operator-reducer.cc", + "src/compiler/simplified-operator-reducer.h", + "src/compiler/simplified-operator.cc", "src/compiler/simplified-operator.h", "src/compiler/source-position.cc", "src/compiler/source-position.h", - "src/compiler/structured-machine-assembler.cc", - "src/compiler/structured-machine-assembler.h", "src/compiler/typer.cc", "src/compiler/typer.h", + "src/compiler/value-numbering-reducer.cc", + "src/compiler/value-numbering-reducer.h", "src/compiler/verifier.cc", "src/compiler/verifier.h", + "src/compiler/zone-pool.cc", + "src/compiler/zone-pool.h", "src/compiler.cc", "src/compiler.h", "src/contexts.cc", @@ -560,8 +609,6 @@ source_set("v8_base") { "src/cpu-profiler-inl.h", "src/cpu-profiler.cc", "src/cpu-profiler.h", - "src/data-flow.cc", - "src/data-flow.h", "src/date.cc", "src/date.h", "src/dateparser-inl.h", @@ -600,8 +647,6 @@ source_set("v8_base") { "src/factory.h", "src/fast-dtoa.cc", "src/fast-dtoa.h", - "src/feedback-slots.h", - "src/field-index.cc", "src/field-index.h", "src/field-index-inl.h", "src/fixed-dtoa.cc", @@ -630,6 +675,8 @@ source_set("v8_base") { "src/heap-snapshot-generator-inl.h", "src/heap-snapshot-generator.cc", "src/heap-snapshot-generator.h", + "src/heap/gc-idle-time-handler.cc", + "src/heap/gc-idle-time-handler.h", "src/heap/gc-tracer.cc", "src/heap/gc-tracer.h", "src/heap/heap-inl.h", @@ -649,8 +696,6 @@ source_set("v8_base") { "src/heap/store-buffer-inl.h", "src/heap/store-buffer.cc", "src/heap/store-buffer.h", - "src/heap/sweeper-thread.h", - "src/heap/sweeper-thread.cc", "src/hydrogen-alias-analysis.h", "src/hydrogen-bce.cc", "src/hydrogen-bce.h", @@ -707,11 +752,25 @@ source_set("v8_base") { "src/i18n.h", "src/icu_util.cc", "src/icu_util.h", - "src/ic-inl.h", - "src/ic.cc", - "src/ic.h", + "src/ic/access-compiler.cc", + "src/ic/access-compiler.h", + "src/ic/call-optimization.cc", + "src/ic/call-optimization.h", + "src/ic/handler-compiler.cc", + "src/ic/handler-compiler.h", + "src/ic/ic-inl.h", + "src/ic/ic-state.cc", + "src/ic/ic-state.h", + "src/ic/ic.cc", + "src/ic/ic.h", + "src/ic/ic-compiler.cc", + "src/ic/ic-compiler.h", + "src/ic/stub-cache.cc", + "src/ic/stub-cache.h", "src/interface.cc", "src/interface.h", + "src/interface-descriptors.cc", + "src/interface-descriptors.h", "src/interpreter-irregexp.cc", "src/interpreter-irregexp.h", "src/isolate.cc", @@ -785,8 +844,36 @@ source_set("v8_base") { "src/rewriter.h", "src/runtime-profiler.cc", "src/runtime-profiler.h", - "src/runtime.cc", - "src/runtime.h", + "src/runtime/runtime-api.cc", + "src/runtime/runtime-array.cc", + "src/runtime/runtime-classes.cc", + "src/runtime/runtime-collections.cc", + "src/runtime/runtime-compiler.cc", + "src/runtime/runtime-date.cc", + "src/runtime/runtime-debug.cc", + "src/runtime/runtime-function.cc", + "src/runtime/runtime-generator.cc", + "src/runtime/runtime-i18n.cc", + "src/runtime/runtime-internal.cc", + "src/runtime/runtime-json.cc", + "src/runtime/runtime-literals.cc", + "src/runtime/runtime-liveedit.cc", + "src/runtime/runtime-maths.cc", + "src/runtime/runtime-numbers.cc", + "src/runtime/runtime-object.cc", + "src/runtime/runtime-observe.cc", + "src/runtime/runtime-proxy.cc", + "src/runtime/runtime-regexp.cc", + "src/runtime/runtime-scopes.cc", + "src/runtime/runtime-strings.cc", + "src/runtime/runtime-symbol.cc", + "src/runtime/runtime-test.cc", + "src/runtime/runtime-typedarray.cc", + "src/runtime/runtime-uri.cc", + "src/runtime/runtime-utils.h", + "src/runtime/runtime.cc", + "src/runtime/runtime.h", + "src/runtime/string-builder.h", "src/safepoint-table.cc", "src/safepoint-table.h", "src/sampler.cc", @@ -812,13 +899,14 @@ source_set("v8_base") { "src/string-stream.h", "src/strtod.cc", "src/strtod.h", - "src/stub-cache.cc", - "src/stub-cache.h", "src/token.cc", "src/token.h", "src/transitions-inl.h", "src/transitions.cc", "src/transitions.h", + "src/type-feedback-vector-inl.h", + "src/type-feedback-vector.cc", + "src/type-feedback-vector.h", "src/type-info.cc", "src/type-info.h", "src/types-inl.h", @@ -831,8 +919,9 @@ source_set("v8_base") { "src/unicode-inl.h", "src/unicode.cc", "src/unicode.h", + "src/unicode-decoder.cc", + "src/unicode-decoder.h", "src/unique.h", - "src/uri.h", "src/utils-inl.h", "src/utils.cc", "src/utils.h", @@ -850,8 +939,8 @@ source_set("v8_base") { "src/zone-inl.h", "src/zone.cc", "src/zone.h", - "third_party/fdlibm/fdlibm.cc", - "third_party/fdlibm/fdlibm.h", + "src/third_party/fdlibm/fdlibm.cc", + "src/third_party/fdlibm/fdlibm.h", ] if (v8_target_arch == "x86") { @@ -871,7 +960,7 @@ source_set("v8_base") { "src/ia32/frames-ia32.cc", "src/ia32/frames-ia32.h", "src/ia32/full-codegen-ia32.cc", - "src/ia32/ic-ia32.cc", + "src/ia32/interface-descriptors-ia32.cc", "src/ia32/lithium-codegen-ia32.cc", "src/ia32/lithium-codegen-ia32.h", "src/ia32/lithium-gap-resolver-ia32.cc", @@ -882,11 +971,15 @@ source_set("v8_base") { "src/ia32/macro-assembler-ia32.h", "src/ia32/regexp-macro-assembler-ia32.cc", "src/ia32/regexp-macro-assembler-ia32.h", - "src/ia32/stub-cache-ia32.cc", "src/compiler/ia32/code-generator-ia32.cc", "src/compiler/ia32/instruction-codes-ia32.h", "src/compiler/ia32/instruction-selector-ia32.cc", "src/compiler/ia32/linkage-ia32.cc", + "src/ic/ia32/access-compiler-ia32.cc", + "src/ic/ia32/handler-compiler-ia32.cc", + "src/ic/ia32/ic-ia32.cc", + "src/ic/ia32/ic-compiler-ia32.cc", + "src/ic/ia32/stub-cache-ia32.cc", ] } else if (v8_target_arch == "x64") { sources += [ @@ -905,7 +998,7 @@ source_set("v8_base") { "src/x64/frames-x64.cc", "src/x64/frames-x64.h", "src/x64/full-codegen-x64.cc", - "src/x64/ic-x64.cc", + "src/x64/interface-descriptors-x64.cc", "src/x64/lithium-codegen-x64.cc", "src/x64/lithium-codegen-x64.h", "src/x64/lithium-gap-resolver-x64.cc", @@ -916,11 +1009,15 @@ source_set("v8_base") { "src/x64/macro-assembler-x64.h", "src/x64/regexp-macro-assembler-x64.cc", "src/x64/regexp-macro-assembler-x64.h", - "src/x64/stub-cache-x64.cc", "src/compiler/x64/code-generator-x64.cc", "src/compiler/x64/instruction-codes-x64.h", "src/compiler/x64/instruction-selector-x64.cc", "src/compiler/x64/linkage-x64.cc", + "src/ic/x64/access-compiler-x64.cc", + "src/ic/x64/handler-compiler-x64.cc", + "src/ic/x64/ic-x64.cc", + "src/ic/x64/ic-compiler-x64.cc", + "src/ic/x64/stub-cache-x64.cc", ] } else if (v8_target_arch == "arm") { sources += [ @@ -941,7 +1038,8 @@ source_set("v8_base") { "src/arm/frames-arm.cc", "src/arm/frames-arm.h", "src/arm/full-codegen-arm.cc", - "src/arm/ic-arm.cc", + "src/arm/interface-descriptors-arm.cc", + "src/arm/interface-descriptors-arm.h", "src/arm/lithium-arm.cc", "src/arm/lithium-arm.h", "src/arm/lithium-codegen-arm.cc", @@ -953,11 +1051,15 @@ source_set("v8_base") { "src/arm/regexp-macro-assembler-arm.cc", "src/arm/regexp-macro-assembler-arm.h", "src/arm/simulator-arm.cc", - "src/arm/stub-cache-arm.cc", "src/compiler/arm/code-generator-arm.cc", "src/compiler/arm/instruction-codes-arm.h", "src/compiler/arm/instruction-selector-arm.cc", "src/compiler/arm/linkage-arm.cc", + "src/ic/arm/access-compiler-arm.cc", + "src/ic/arm/handler-compiler-arm.cc", + "src/ic/arm/ic-arm.cc", + "src/ic/arm/ic-compiler-arm.cc", + "src/ic/arm/stub-cache-arm.cc", ] } else if (v8_target_arch == "arm64") { sources += [ @@ -981,11 +1083,12 @@ source_set("v8_base") { "src/arm64/frames-arm64.cc", "src/arm64/frames-arm64.h", "src/arm64/full-codegen-arm64.cc", - "src/arm64/ic-arm64.cc", "src/arm64/instructions-arm64.cc", "src/arm64/instructions-arm64.h", "src/arm64/instrument-arm64.cc", "src/arm64/instrument-arm64.h", + "src/arm64/interface-descriptors-arm64.cc", + "src/arm64/interface-descriptors-arm64.h", "src/arm64/lithium-arm64.cc", "src/arm64/lithium-arm64.h", "src/arm64/lithium-codegen-arm64.cc", @@ -999,13 +1102,17 @@ source_set("v8_base") { "src/arm64/regexp-macro-assembler-arm64.h", "src/arm64/simulator-arm64.cc", "src/arm64/simulator-arm64.h", - "src/arm64/stub-cache-arm64.cc", "src/arm64/utils-arm64.cc", "src/arm64/utils-arm64.h", "src/compiler/arm64/code-generator-arm64.cc", "src/compiler/arm64/instruction-codes-arm64.h", "src/compiler/arm64/instruction-selector-arm64.cc", "src/compiler/arm64/linkage-arm64.cc", + "src/ic/arm64/access-compiler-arm64.cc", + "src/ic/arm64/handler-compiler-arm64.cc", + "src/ic/arm64/ic-arm64.cc", + "src/ic/arm64/ic-compiler-arm64.cc", + "src/ic/arm64/stub-cache-arm64.cc", ] } else if (v8_target_arch == "mipsel") { sources += [ @@ -1026,7 +1133,7 @@ source_set("v8_base") { "src/mips/frames-mips.cc", "src/mips/frames-mips.h", "src/mips/full-codegen-mips.cc", - "src/mips/ic-mips.cc", + "src/mips/interface-descriptors-mips.cc", "src/mips/lithium-codegen-mips.cc", "src/mips/lithium-codegen-mips.h", "src/mips/lithium-gap-resolver-mips.cc", @@ -1038,7 +1145,52 @@ source_set("v8_base") { "src/mips/regexp-macro-assembler-mips.cc", "src/mips/regexp-macro-assembler-mips.h", "src/mips/simulator-mips.cc", - "src/mips/stub-cache-mips.cc", + "src/compiler/mips/code-generator-mips.cc", + "src/compiler/mips/instruction-codes-mips.h", + "src/compiler/mips/instruction-selector-mips.cc", + "src/compiler/mips/linkage-mips.cc", + "src/ic/mips/access-compiler-mips.cc", + "src/ic/mips/handler-compiler-mips.cc", + "src/ic/mips/ic-mips.cc", + "src/ic/mips/ic-compiler-mips.cc", + "src/ic/mips/stub-cache-mips.cc", + ] + } else if (v8_target_arch == "mips64el") { + sources += [ + "src/mips64/assembler-mips64.cc", + "src/mips64/assembler-mips64.h", + "src/mips64/assembler-mips64-inl.h", + "src/mips64/builtins-mips64.cc", + "src/mips64/codegen-mips64.cc", + "src/mips64/codegen-mips64.h", + "src/mips64/code-stubs-mips64.cc", + "src/mips64/code-stubs-mips64.h", + "src/mips64/constants-mips64.cc", + "src/mips64/constants-mips64.h", + "src/mips64/cpu-mips64.cc", + "src/mips64/debug-mips64.cc", + "src/mips64/deoptimizer-mips64.cc", + "src/mips64/disasm-mips64.cc", + "src/mips64/frames-mips64.cc", + "src/mips64/frames-mips64.h", + "src/mips64/full-codegen-mips64.cc", + "src/mips64/interface-descriptors-mips64.cc", + "src/mips64/lithium-codegen-mips64.cc", + "src/mips64/lithium-codegen-mips64.h", + "src/mips64/lithium-gap-resolver-mips64.cc", + "src/mips64/lithium-gap-resolver-mips64.h", + "src/mips64/lithium-mips64.cc", + "src/mips64/lithium-mips64.h", + "src/mips64/macro-assembler-mips64.cc", + "src/mips64/macro-assembler-mips64.h", + "src/mips64/regexp-macro-assembler-mips64.cc", + "src/mips64/regexp-macro-assembler-mips64.h", + "src/mips64/simulator-mips64.cc", + "src/ic/mips64/access-compiler-mips64.cc", + "src/ic/mips64/handler-compiler-mips64.cc", + "src/ic/mips64/ic-mips64.cc", + "src/ic/mips64/ic-compiler-mips64.cc", + "src/ic/mips64/stub-cache-mips64.cc", ] } @@ -1046,9 +1198,18 @@ source_set("v8_base") { configs += [ "//build/config/compiler:no_chromium_code" ] configs += [ ":internal_config", ":features", ":toolchain" ] + if (!is_debug) { + configs -= [ "//build/config/compiler:optimize" ] + configs += [ "//build/config/compiler:optimize_max" ] + } + defines = [] deps = [ ":v8_libbase" ] + if (is_win) { + # TODO(jschuh): crbug.com/167187 fix size_t to int truncations. + cflags = [ "/wd4267" ] + } if (is_linux) { if (v8_compress_startup_data == "bz2") { libs += [ "bz2" ] @@ -1076,7 +1237,7 @@ source_set("v8_base") { } source_set("v8_libbase") { - visibility = ":*" # Only targets in this file can depend on this. + visibility = [ ":*" ] # Only targets in this file can depend on this. sources = [ "src/base/atomicops.h", @@ -1089,9 +1250,16 @@ source_set("v8_libbase") { "src/base/atomicops_internals_x86_gcc.cc", "src/base/atomicops_internals_x86_gcc.h", "src/base/atomicops_internals_x86_msvc.h", + "src/base/bits.cc", + "src/base/bits.h", "src/base/build_config.h", "src/base/cpu.cc", "src/base/cpu.h", + "src/base/division-by-constant.cc", + "src/base/division-by-constant.h", + "src/base/flags.h", + "src/base/functional.cc", + "src/base/functional.h", "src/base/lazy-instance.h", "src/base/logging.cc", "src/base/logging.h", @@ -1112,6 +1280,8 @@ source_set("v8_libbase") { "src/base/safe_conversions_impl.h", "src/base/safe_math.h", "src/base/safe_math_impl.h", + "src/base/sys-info.cc", + "src/base/sys-info.h", "src/base/utils/random-number-generator.cc", "src/base/utils/random-number-generator.h", ] @@ -1120,6 +1290,11 @@ source_set("v8_libbase") { configs += [ "//build/config/compiler:no_chromium_code" ] configs += [ ":internal_config_base", ":features", ":toolchain" ] + if (!is_debug) { + configs -= [ "//build/config/compiler:optimize" ] + configs += [ "//build/config/compiler:optimize_max" ] + } + defines = [] if (is_posix) { @@ -1156,8 +1331,6 @@ source_set("v8_libbase") { sources += [ "src/base/platform/platform-win32.cc", "src/base/win32-headers.h", - "src/base/win32-math.cc", - "src/base/win32-math.h", ] defines += [ "_CRT_RAND_S" ] # for rand_s() @@ -1183,6 +1356,11 @@ source_set("v8_libplatform") { configs += [ "//build/config/compiler:no_chromium_code" ] configs += [ ":internal_config_base", ":features", ":toolchain" ] + if (!is_debug) { + configs -= [ "//build/config/compiler:optimize" ] + configs += [ "//build/config/compiler:optimize_max" ] + } + deps = [ ":v8_libbase", ] @@ -1194,7 +1372,7 @@ source_set("v8_libplatform") { if (current_toolchain == host_toolchain) { executable("mksnapshot") { - visibility = ":*" # Only targets in this file can depend on this. + visibility = [ ":*" ] # Only targets in this file can depend on this. sources = [ "src/mksnapshot.cc", @@ -1208,6 +1386,7 @@ if (current_toolchain == host_toolchain) { ":v8_base", ":v8_libplatform", ":v8_nosnapshot", + "//build/config/sanitizers:deps", ] if (v8_compress_startup_data == "bz2") { @@ -1250,6 +1429,7 @@ component("v8") { direct_dependent_configs = [ ":external_config" ] + libs = [] if (is_android && current_toolchain != host_toolchain) { libs += [ "log" ] } diff --git a/deps/v8/ChangeLog b/deps/v8/ChangeLog index 0b2872a7c214c6..1e298537caf125 100644 --- a/deps/v8/ChangeLog +++ b/deps/v8/ChangeLog @@ -1,4 +1,542 @@ -2014-08-13: Version 3.28.73 +2014-11-05: Version 3.30.33 + + `1..isPrototypeOf.call(null)` should return false, not throw TypeError + (issue 3483). + + Refactor ObjectGetOwnPropertyKeys to accept bitmask rather than boolean + (issue 3549). + + Add debug mirror support for ES6 Map/Set iterators (Chromium issue + 427868). + + Performance and stability improvements on all platforms. + + +2014-11-04: Version 3.30.30 + + Performance and stability improvements on all platforms. + + +2014-11-02: Version 3.30.27 + + Performance and stability improvements on all platforms. + + +2014-11-02: Version 3.30.26 + + Performance and stability improvements on all platforms. + + +2014-11-01: Version 3.30.25 + + Performance and stability improvements on all platforms. + + +2014-11-01: Version 3.30.24 + + Ensure we don't try to inline raw access to indexed interceptor + receivers (Chromium issue 419220). + + Performance and stability improvements on all platforms. + + +2014-10-31: Version 3.30.23 + + Introduce v8::Exception::GetMessage to find location of an error object + (Chromium issue 427954). + + Performance and stability improvements on all platforms. + + +2014-10-30: Version 3.30.22 + + MIPS: Classes: Add super support in methods and accessors (issue 3330). + + Classes: Add super support in methods and accessors (issue 3330). + + Performance and stability improvements on all platforms. + + +2014-10-29: Version 3.30.21 + + MIPS: Classes: Add basic support for properties (issue 3330). + + Classes: Add more tests for prototype edge cases (Chromium issue 3655). + + Classes: Add test for method prototype (issue 3330). + + Get stack trace for uncaught exceptions/promise rejections from the + simple stack when available. + + Classes: Add basic support for properties (issue 3330). + + Allow duplicate property names in classes (issue 3570). + + Windows: use SystemTimeToTzSpecificLocalTime instead of localtime_s + (Chromium issue 417640). + + Performance and stability improvements on all platforms. + + +2014-10-28: Version 3.30.20 + + Performance and stability improvements on all platforms. + + +2014-10-27: Version 3.30.19 + + Check string literals with escapes in PreParserTraits::GetSymbol() + (issue 3606). + + only define ARRAYSIZE_UNSAFE for NaCl builds (Chromium issue 405225). + + Performance and stability improvements on all platforms. + + +2014-10-24: Version 3.30.18 + + Narrow cases where Sparse/Smart versions of Array methods are used + (issues 2615, 3612, 3621). + + Shrink new space in idle notification (Chromium issue 424423). + + Performance and stability improvements on all platforms. + + +2014-10-23: Version 3.30.17 + + ARM64: Fix stack manipulation (Chromium issue 425585). + + Speed up creation of Objects whose prototype has dictionary elements + (Chromium issue 422754). + + Enable libstdc++ debug mode in debug builds (issue 3638). + + Performance and stability improvements on all platforms. + + +2014-10-22: Version 3.30.16 + + Remove v8stdint.h, it doesn't serve a purpose anymore. + + Performance and stability improvements on all platforms. + + +2014-10-21: Version 3.30.15 + + Avoid the Marsaglia effect in 3D (Chromium issue 423311). + + Performance and stability improvements on all platforms. + + +2014-10-20: Version 3.30.14 + + Performance and stability improvements on all platforms. + + +2014-10-17: Version 3.30.13 + + Don't expose Array.prototype.values as it breaks webcompat (Chromium + issue 409858). + + Fix break location calculation (Chromium issue 419663). + + Enable libstdc++ debug mode in debug builds (issue 3638). + + Performance and stability improvements on all platforms. + + +2014-10-17: Version 3.30.12 + + Implement .forEach() on typed arrays (issue 3578). + + Introduce v8::Exception::GetStackTrace API method. + + Remove SmartMove, bringing Array methods further into spec compliance + (issue 2615). + + Convert argument toObject() in Object.getOwnPropertyNames/Descriptors + (issue 3443). + + Performance and stability improvements on all platforms. + + +2014-10-15: Version 3.30.11 + + Array.prototype.{every, filter, find, findIndex, forEach, map, some}: + Use fresh primitive wrapper for calls (issue 3536). + + Correctly expand literal buffer for surrogate pairs (Chromium issue + 423212). + + Performance and stability improvements on all platforms. + + +2014-10-15: Version 3.30.10 + + Squeeze the layout of various AST node types (Chromium issue 417697). + + Performance and stability improvements on all platforms. + + +2014-10-14: Version 3.30.9 + + Performance and stability improvements on all platforms. + + +2014-10-13: Version 3.30.8 + + AST nodes have at most one bailout/typefeedback ID now, saving lots of + memory (Chromium issue 417697). + + Allow identifier code points from supplementary multilingual planes + (issue 3617). + + Performance and stability improvements on all platforms. + + +2014-10-10: Version 3.30.7 + + Fix computation of UTC time from local time at DST change points (issue + 3116, Chromium issues 415424, 417640). + + Convert `obj` ToObject in Object.keys() (issue 3587). + + Performance and stability improvements on all platforms. + + +2014-10-09: Version 3.30.6 + + Update unicode to 7.0.0 (issue 2892). + + Classes: Add support for toString (issue 3330). + + Don't enable WPO on Win64 and require Server 2003 / x64 for win64 + (Chromium issue 421363). + + Performance and stability improvements on all platforms. + + +2014-10-08: Version 3.30.5 + + Performance and stability improvements on all platforms. + + +2014-10-08: Version 3.30.4 + + This uses a runtime function to set up the the constructor and its + prototype (issue 3330). + + Remove PersistentBase::ClearAndLeak. + + Squeeze the layout of variable proxy nodes (Chromium issue 417697). + + Add MonotonicallyIncreasingTime to V8 Platform (Chromium issue 417668). + + Fix representation of HLoadRoot (Chromium issue 419036). + + Performance and stability improvements on all platforms. + + +2014-10-03: Version 3.30.3 + + Removed the Isolate* field from literal nodes (Chromium issue 417697). + + Squeeze the layout of expression nodes a bit (Chromium issue 417697). + + Merged FeedbackSlotInterface into AstNode, removing the need for a 2nd + vtable (Chromium issue 417697). + + Extend CPU profiler with mapping ticks to source lines. + + Remove support for parallel sweeping. + + Introduce v8::Object::GetIsolate(). + + Performance and stability improvements on all platforms. + + +2014-10-02: Version 3.30.2 + + Fix Hydrogen's BuildStore() (Chromium issue 417508). + + Move unit tests to test/unittests (issue 3489). + + Changes to ALLOW_UNUSED to match upcoming changes to the Chromium trunk: + * Eliminate usage of ALLOW_UNUSED to define COMPILE_ASSERT and just use + static_assert() in all cases now that all platforms build with C++11. * + Convert remaining uses of ALLOW_UNUSED to ALLOW_UNUSED_TYPE to match how + Chromium will be splitting this functionality. (In Chromium we'll have + both ALLOW_UNUSED_TYPE and ALLOW_UNUSED_LOCAL, which have different + syntax to enable us to use these with MSVC.) (Chromium issue 81439). + + Performance and stability improvements on all platforms. + + +2014-10-01: Version 3.30.1 + + Introduce PromiseRejectCallback (issue 3093). + + ES6: Implement object literal property shorthand (issue 3584). + + Performance and stability improvements on all platforms. + + +2014-09-30: Version 3.29.93 + + Add a getter for the address and size of the code range to the pulic API + (issue 3598). + + Convert `obj` ToObject in Object.keys() (issue 3587). + + Performance and stability improvements on all platforms. + + +2014-09-29: Version 3.29.92 + + Performance and stability improvements on all platforms. + + +2014-09-26: Version 3.29.91 + + Performance and stability improvements on all platforms. + + +2014-09-25: Version 3.29.88 + + Performance and stability improvements on all platforms. + + +2014-09-24: Version 3.29.87 + + Preserve message when rethrowing exception (issue 3583). + + Fix escaped index JSON parsing (Chromium issue 416449). + + Performance and stability improvements on all platforms. + + +2014-09-23: Version 3.29.84 + + Performance and stability improvements on all platforms. + + +2014-09-23: Version 3.29.83 + + Performance and stability improvements on all platforms. + + +2014-09-23: Version 3.29.82 + + Fix escaped index JSON parsing (Chromium issue 416449). + + Performance and stability improvements on all platforms. + + +2014-09-17: Version 3.29.70 + + Enable ES6 generators (issue 2355). + + Fixed int vs. uintptr_t confusion (plus some cleanup on the way) (issue + 3556). + + Move configuration of ResourceConstraints to Isolate construction. + + Performance and stability improvements on all platforms. + + +2014-09-16: Version 3.29.66 + + Currently, a new isolate is created in an uninitialized state, and + several API methods will automatically initialize it. During this + uninitialized state, code event handlers and function entry handlers can + be attached to the isolate. + + Performance and stability improvements on all platforms. + + +2014-09-15: Version 3.29.64 + + ES6: String(symbol) should work like symbol.toString (issue 3554). + + Arrow functions: Cleanup handling of the prototype property (issue + 2700). + + Remove V8_HOST_CAN_READ_UNALIGNED and its uses (Chromium issue 412967). + + Fix Smi vs. HeapObject confusion in HConstants (Chromium issue 412215). + + Performance and stability improvements on all platforms. + + +2014-09-12: Version 3.29.59 + + Do not use wide reads in CopyCharsUnsigned (Chromium issue 412967). + + Fix inaccurate type condition in Hydrogen (Chromium issue 412210). + + Fix crash in ScriptDebugServer::wrapCallFrames (Chromium issue 411196). + + Performance and stability improvements on all platforms. + + +2014-09-11: Version 3.29.57 + + ES6: Add support for method shorthand in object literals (issue 3516). + + Unbreak FreeBSD build (hopefully) (issue 3548). + + Performance and stability improvements on all platforms. + + +2014-09-09: Version 3.29.53 + + Performance and stability improvements on all platforms. + + +2014-09-08: Version 3.29.50 + + Allocate a new empty number dictionary when resetting elements (Chromium + issue 410332). + + Performance and stability improvements on all platforms. + + +2014-09-05: Version 3.29.43 + + Enforce correct number comparisons when inlining Array.indexOf (Chromium + issue 407946). + + Performance and stability improvements on all platforms. + + +2014-09-04: Version 3.29.41 + + Performance and stability improvements on all platforms. + + +2014-09-03: Version 3.29.40 + + Use correct receiver for DOM accessors on the prototype chain (issue + 3538). + + Performance and stability improvements on all platforms. + + +2014-09-02: Version 3.29.38 + + Do not clear weak monomorphic IC after context disposal (Chromium issue + 404020). + + Turn on job-based sweeping (issue 3104). + + Performance and stability improvements on all platforms. + + +2014-09-01: Version 3.29.35 + + Performance and stability improvements on all platforms. + + +2014-08-29: Version 3.29.29 + + Performance and stability improvements on all platforms. + + +2014-08-28: Version 3.29.27 + + Performance and stability improvements on all platforms. + + +2014-08-28: Version 3.29.25 + + Performance and stability improvements on all platforms. + + +2014-08-28: Version 3.29.24 + + Tweaks to generate XP-compatible .exes (Chromium issue 407517). + + Performance and stability improvements on all platforms. + + +2014-08-28: Version 3.29.23 + + Performance and stability improvements on all platforms. + + +2014-08-27: Version 3.29.20 + + Handle empty allocation list in CodeRange properly (issue 3540, Chromium + issue 407566). + + Fixed inlining of constant values (issue 3529). + + Performance and stability improvements on all platforms. + + +2014-08-25: Version 3.29.17 + + Performance and stability improvements on all platforms. + + +2014-08-24: Version 3.29.16 + + Fix issue with numeric property names (issue 3507). + + Add back the duplicate property checker (issue 3498). + + Performance and stability improvements on all platforms. + + +2014-08-22: Version 3.29.14 + + Don't inline Array.shift() if receiver map is not extensible (Chromium + issue 405517). + + Performance and stability improvements on all platforms. + + +2014-08-21: Version 3.29.11 + + Refactor ParseObjectLiteral. + + Support symbol-named properties in API (issue 3394). + + Suppress test262 test that tests duplicate properties. + + ES6: Duplicate properties are no longer an error (issue 3498). + + Expose function CheckDebugBreak in the debugger api. + + Remove RegExp.$input (issue 3486). + + Performance and stability improvements on all platforms. + + +2014-08-21: Version 3.29.10 + + ES6: Make sure we do not store -0 as the key in Map/Set (issue 3515). + + Remove removed flags from tests. + + Expose well-known Symbols to C++ API (Chromium issue 341423). + + Implement ES6 Array.of() (issue 3427). + + Performance and stability improvements on all platforms. + + +2014-08-20: Version 3.29.9 + + Correctly handle holes when concat()ing double arrays (Chromium issue + 403409). + + [turbofan] Refactor the InstructionSelector tests (issue 3489). + + ES6: Make Map/Set constructors support iterable values (issue 3508). + + WeakMap/WeakSet: Add test for non object keys (issue 3399). Performance and stability improvements on all platforms. diff --git a/deps/v8/DEPS b/deps/v8/DEPS index 9459204f2cb605..d4139c6098545b 100644 --- a/deps/v8/DEPS +++ b/deps/v8/DEPS @@ -3,6 +3,8 @@ # all paths in here must match this assumption. vars = { + "chromium_git": "https://chromium.googlesource.com", + "chromium_trunk": "https://src.chromium.org/svn/trunk", "buildtools_revision": "fb782d4369d5ae04f17a2fceef7de5a63e50f07b", @@ -28,6 +30,11 @@ deps = { } deps_os = { + "android": { + "v8/third_party/android_tools": + Var("chromium_git") + "/android_tools.git" + "@" + + "31869996507de16812bb53a3d0aaa15cd6194c16", + }, "win": { "v8/third_party/cygwin": Var("chromium_trunk") + "/deps/third_party/cygwin@66844", diff --git a/deps/v8/Makefile b/deps/v8/Makefile index 96d7a7ae4d3208..3b02f52d2ad65d 100644 --- a/deps/v8/Makefile +++ b/deps/v8/Makefile @@ -140,10 +140,15 @@ endif # asan=/path/to/clang++ ifneq ($(strip $(asan)),) GYPFLAGS += -Dasan=1 + export CC=$(dir $(asan))clang export CXX=$(asan) export CXX_host=$(asan) export LINK=$(asan) - export ASAN_SYMBOLIZER_PATH="$(dir $(asan))llvm-symbolizer" + export ASAN_SYMBOLIZER_PATH=$(dir $(asan))llvm-symbolizer + TESTFLAGS += --asan + ifeq ($(lsan), on) + GYPFLAGS += -Dlsan=1 + endif endif # arm specific flags. @@ -231,7 +236,7 @@ NACL_ARCHES = nacl_ia32 nacl_x64 # List of files that trigger Makefile regeneration: GYPFILES = build/all.gyp build/features.gypi build/standalone.gypi \ build/toolchain.gypi samples/samples.gyp src/d8.gyp \ - test/cctest/cctest.gyp tools/gyp/v8.gyp + test/cctest/cctest.gyp test/unittests/unittests.gyp tools/gyp/v8.gyp # If vtunejit=on, the v8vtune.gyp will be appended. ifeq ($(vtunejit), on) @@ -252,7 +257,7 @@ NACL_CHECKS = $(addsuffix .check,$(NACL_BUILDS)) ENVFILE = $(OUTDIR)/environment .PHONY: all check clean builddeps dependencies $(ENVFILE).new native \ - qc quickcheck $(QUICKCHECKS) \ + qc quickcheck $(QUICKCHECKS) turbocheck \ $(addsuffix .quickcheck,$(MODES)) $(addsuffix .quickcheck,$(ARCHES)) \ $(ARCHES) $(MODES) $(BUILDS) $(CHECKS) $(addsuffix .clean,$(ARCHES)) \ $(addsuffix .check,$(MODES)) $(addsuffix .check,$(ARCHES)) \ @@ -381,6 +386,15 @@ quickcheck: $(subst $(COMMA),$(SPACE),$(FASTCOMPILEMODES)) --arch-and-mode=$(FASTTESTMODES) $(TESTFLAGS) --quickcheck qc: quickcheck +turbocheck: $(subst $(COMMA),$(SPACE),$(FASTCOMPILEMODES)) + tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \ + --arch-and-mode=$(SUPERFASTTESTMODES) $(TESTFLAGS) \ + --quickcheck --variants=turbofan --download-data mozilla webkit + tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \ + --arch-and-mode=$(FASTTESTMODES) $(TESTFLAGS) \ + --quickcheck --variants=turbofan +tc: turbocheck + # Clean targets. You can clean each architecture individually, or everything. $(addsuffix .clean, $(ARCHES) $(ANDROID_ARCHES) $(NACL_ARCHES)): rm -f $(OUTDIR)/Makefile.$(basename $@)* diff --git a/deps/v8/Makefile.android b/deps/v8/Makefile.android index d46af31fdb76af..8e200f1f246caf 100644 --- a/deps/v8/Makefile.android +++ b/deps/v8/Makefile.android @@ -64,20 +64,20 @@ else DEFINES += android_target_arch=mips mips_arch_variant=mips32r2 TOOLCHAIN_ARCH = mipsel-linux-android TOOLCHAIN_PREFIX = $(TOOLCHAIN_ARCH) - TOOLCHAIN_VER = 4.6 + TOOLCHAIN_VER = 4.8 else ifeq ($(ARCH), android_ia32) DEFINES = target_arch=ia32 v8_target_arch=ia32 android_target_arch=x86 android_target_platform=14 TOOLCHAIN_ARCH = x86 TOOLCHAIN_PREFIX = i686-linux-android - TOOLCHAIN_VER = 4.6 + TOOLCHAIN_VER = 4.8 else ifeq ($(ARCH), android_x87) DEFINES = target_arch=x87 v8_target_arch=x87 android_target_arch=x86 android_target_platform=14 TOOLCHAIN_ARCH = x86 TOOLCHAIN_PREFIX = i686-linux-android - TOOLCHAIN_VER = 4.6 + TOOLCHAIN_VER = 4.8 else $(error Target architecture "${ARCH}" is not supported) endif diff --git a/deps/v8/Makefile.nacl b/deps/v8/Makefile.nacl index 34bd960fed1cb5..3459c42c0d865c 100644 --- a/deps/v8/Makefile.nacl +++ b/deps/v8/Makefile.nacl @@ -36,41 +36,29 @@ NACL_BUILDS = $(foreach mode,$(MODES), \ $(addsuffix .$(mode),$(NACL_ARCHES))) HOST_OS = $(shell uname -s | sed -e 's/Linux/linux/;s/Darwin/mac/') -ifeq ($(HOST_OS), linux) - TOOLCHAIN_DIR = linux_x86_glibc -else - ifeq ($(HOST_OS), mac) - TOOLCHAIN_DIR = mac_x86_glibc - else - $(error Host platform "${HOST_OS}" is not supported) - endif -endif - TOOLCHAIN_PATH = $(realpath ${NACL_SDK_ROOT}/toolchain) -NACL_TOOLCHAIN ?= ${TOOLCHAIN_PATH}/${TOOLCHAIN_DIR} +NACL_TOOLCHAIN ?= ${TOOLCHAIN_PATH}/linux_pnacl + +ifeq ($(wildcard $(NACL_TOOLCHAIN)),) + $(error Cannot find Native Client toolchain in "${NACL_TOOLCHAIN}") +endif ifeq ($(ARCH), nacl_ia32) GYPENV = nacl_target_arch=nacl_ia32 v8_target_arch=arm v8_host_arch=ia32 - TOOLCHAIN_ARCH = x86-4.4 - NACL_CC = "$(NACL_TOOLCHAIN)/bin/i686-nacl-gcc" - NACL_CXX = "$(NACL_TOOLCHAIN)/bin/i686-nacl-g++" - NACL_LINK = "$(NACL_TOOLCHAIN)/bin/i686-nacl-g++" + NACL_CC = "$(NACL_TOOLCHAIN)/bin/pnacl-clang" + NACL_CXX = "$(NACL_TOOLCHAIN)/bin/pnacl-clang++" + NACL_LINK = "$(NACL_TOOLCHAIN)/bin/pnacl-clang++ --pnacl-allow-native -arch x86-32" else ifeq ($(ARCH), nacl_x64) GYPENV = nacl_target_arch=nacl_x64 v8_target_arch=arm v8_host_arch=ia32 - TOOLCHAIN_ARCH = x86-4.4 - NACL_CC = "$(NACL_TOOLCHAIN)/bin/x86_64-nacl-gcc" - NACL_CXX = "$(NACL_TOOLCHAIN)/bin/x86_64-nacl-g++" - NACL_LINK = "$(NACL_TOOLCHAIN)/bin/x86_64-nacl-g++" + NACL_CC = "$(NACL_TOOLCHAIN)/bin/pnacl-clang" + NACL_CXX = "$(NACL_TOOLCHAIN)/bin/pnacl-clang++" + NACL_LINK = "$(NACL_TOOLCHAIN)/bin/pnacl-clang++ --pnacl-allow-native -arch x86-64" else $(error Target architecture "${ARCH}" is not supported) endif endif -ifeq ($(wildcard $(NACL_TOOLCHAIN)),) - $(error Cannot find Native Client toolchain in "${NACL_TOOLCHAIN}") -endif - # For mksnapshot host generation. GYPENV += host_os=${HOST_OS} @@ -85,7 +73,11 @@ NACL_MAKEFILES = $(addprefix $(OUTDIR)/Makefile.,$(NACL_BUILDS)) # For some reason the $$(basename $$@) expansion didn't work here... $(NACL_BUILDS): $(NACL_MAKEFILES) @$(MAKE) -C "$(OUTDIR)" -f Makefile.$@ \ + CC=${NACL_CC} \ CXX=${NACL_CXX} \ + AR="$(NACL_TOOLCHAIN)/bin/pnacl-ar" \ + RANLIB="$(NACL_TOOLCHAIN)/bin/pnacl-ranlib" \ + LD="$(NACL_TOOLCHAIN)/bin/pnacl-ld" \ LINK=${NACL_LINK} \ BUILDTYPE=$(shell echo $(subst .,,$(suffix $@)) | \ python -c "print raw_input().capitalize()") \ @@ -97,6 +89,7 @@ $(NACL_MAKEFILES): GYP_DEFINES="${GYPENV}" \ CC=${NACL_CC} \ CXX=${NACL_CXX} \ + LINK=${NACL_LINK} \ PYTHONPATH="$(shell pwd)/tools/generate_shim_headers:$(shell pwd)/build:$(PYTHONPATH)" \ build/gyp/gyp --generator-output="${OUTDIR}" build/all.gyp \ -Ibuild/standalone.gypi --depth=. \ diff --git a/deps/v8/OWNERS b/deps/v8/OWNERS index f67b3ec5c6286e..aa5f64449ec68c 100644 --- a/deps/v8/OWNERS +++ b/deps/v8/OWNERS @@ -16,7 +16,6 @@ rossberg@chromium.org svenpanne@chromium.org titzer@chromium.org ulan@chromium.org -vegorov@chromium.org verwaest@chromium.org vogelheim@chromium.org yangguo@chromium.org diff --git a/deps/v8/PRESUBMIT.py b/deps/v8/PRESUBMIT.py index 55bb99ab8ac00d..3a9895db8df028 100644 --- a/deps/v8/PRESUBMIT.py +++ b/deps/v8/PRESUBMIT.py @@ -34,6 +34,32 @@ import sys +_EXCLUDED_PATHS = ( + r"^test[\\\/].*", + r"^testing[\\\/].*", + r"^third_party[\\\/].*", + r"^tools[\\\/].*", +) + + +# Regular expression that matches code only used for test binaries +# (best effort). +_TEST_CODE_EXCLUDED_PATHS = ( + r'.+-unittest\.cc', + # Has a method VisitForTest(). + r'src[\\\/]compiler[\\\/]ast-graph-builder\.cc', + # Test extension. + r'src[\\\/]extensions[\\\/]gc-extension\.cc', +) + + +_TEST_ONLY_WARNING = ( + 'You might be calling functions intended only for testing from\n' + 'production code. It is OK to ignore this warning if you know what\n' + 'you are doing, as the heuristics used to detect the situation are\n' + 'not perfect. The commit queue will not block on this warning.') + + def _V8PresubmitChecks(input_api, output_api): """Runs the V8 presubmit checks.""" import sys @@ -41,7 +67,7 @@ def _V8PresubmitChecks(input_api, output_api): input_api.PresubmitLocalPath(), 'tools')) from presubmit import CppLintProcessor from presubmit import SourceProcessor - from presubmit import CheckGeneratedRuntimeTests + from presubmit import CheckRuntimeVsNativesNameClashes from presubmit import CheckExternalReferenceRegistration results = [] @@ -51,9 +77,9 @@ def _V8PresubmitChecks(input_api, output_api): results.append(output_api.PresubmitError( "Copyright header, trailing whitespaces and two empty lines " \ "between declarations check failed")) - if not CheckGeneratedRuntimeTests(input_api.PresubmitLocalPath()): + if not CheckRuntimeVsNativesNameClashes(input_api.PresubmitLocalPath()): results.append(output_api.PresubmitError( - "Generated runtime tests check failed")) + "Runtime/natives name clash check failed")) if not CheckExternalReferenceRegistration(input_api.PresubmitLocalPath()): results.append(output_api.PresubmitError( "External references registration check failed")) @@ -113,6 +139,49 @@ def _CheckUnwantedDependencies(input_api, output_api): return results +def _CheckNoProductionCodeUsingTestOnlyFunctions(input_api, output_api): + """Attempts to prevent use of functions intended only for testing in + non-testing code. For now this is just a best-effort implementation + that ignores header files and may have some false positives. A + better implementation would probably need a proper C++ parser. + """ + # We only scan .cc files, as the declaration of for-testing functions in + # header files are hard to distinguish from calls to such functions without a + # proper C++ parser. + file_inclusion_pattern = r'.+\.cc' + + base_function_pattern = r'[ :]test::[^\s]+|ForTest(ing)?|for_test(ing)?' + inclusion_pattern = input_api.re.compile(r'(%s)\s*\(' % base_function_pattern) + comment_pattern = input_api.re.compile(r'//.*(%s)' % base_function_pattern) + exclusion_pattern = input_api.re.compile( + r'::[A-Za-z0-9_]+(%s)|(%s)[^;]+\{' % ( + base_function_pattern, base_function_pattern)) + + def FilterFile(affected_file): + black_list = (_EXCLUDED_PATHS + + _TEST_CODE_EXCLUDED_PATHS + + input_api.DEFAULT_BLACK_LIST) + return input_api.FilterSourceFile( + affected_file, + white_list=(file_inclusion_pattern, ), + black_list=black_list) + + problems = [] + for f in input_api.AffectedSourceFiles(FilterFile): + local_path = f.LocalPath() + for line_number, line in f.ChangedContents(): + if (inclusion_pattern.search(line) and + not comment_pattern.search(line) and + not exclusion_pattern.search(line)): + problems.append( + '%s:%d\n %s' % (local_path, line_number, line.strip())) + + if problems: + return [output_api.PresubmitPromptOrNotify(_TEST_ONLY_WARNING, problems)] + else: + return [] + + def _CommonChecks(input_api, output_api): """Checks common to both upload and commit.""" results = [] @@ -122,6 +191,8 @@ def _CommonChecks(input_api, output_api): input_api, output_api)) results.extend(_V8PresubmitChecks(input_api, output_api)) results.extend(_CheckUnwantedDependencies(input_api, output_api)) + results.extend( + _CheckNoProductionCodeUsingTestOnlyFunctions(input_api, output_api)) return results @@ -180,6 +251,6 @@ def GetPreferredTryMasters(project, change): 'v8_linux_layout_dbg': set(['defaulttests']), 'v8_mac_rel': set(['defaulttests']), 'v8_win_rel': set(['defaulttests']), - 'v8_win64_rel': set(['defaulttests']), + 'v8_win64_compile_rel': set(['defaulttests']), }, } diff --git a/deps/v8/README.md b/deps/v8/README.md new file mode 100644 index 00000000000000..7ce52a0b03a200 --- /dev/null +++ b/deps/v8/README.md @@ -0,0 +1,26 @@ +V8 JavaScript Engine +============= + +V8 is Google's open source JavaScript engine. + +V8 implements ECMAScript as specified in ECMA-262. + +V8 is written in C++ and is used in Google Chrome, the open source +browser from Google. + +V8 can run standalone, or can be embedded into any C++ application. + +V8 Project page: https://code.google.com/p/v8/ + + +Getting the Code +============= + +V8 Git repository: https://chromium.googlesource.com/v8/v8.git +GitHub mirror: https://github.com/v8/v8-git-mirror + +For fetching all branches, add the following into your remote +configuration in `.git/config`: + + fetch = +refs/branch-heads/*:refs/remotes/branch-heads/* + fetch = +refs/tags/*:refs/tags/* diff --git a/deps/v8/benchmarks/v8.json b/deps/v8/benchmarks/v8.json index f4210d9d406806..03ea9621acaf91 100644 --- a/deps/v8/benchmarks/v8.json +++ b/deps/v8/benchmarks/v8.json @@ -3,7 +3,7 @@ "main": "run.js", "run_count": 2, "results_regexp": "^%s: (.+)$", - "benchmarks": [ + "tests": [ {"name": "Richards"}, {"name": "DeltaBlue"}, {"name": "Crypto"}, diff --git a/deps/v8/build/all.gyp b/deps/v8/build/all.gyp index 5e410a3d0f2603..4aeb507dcab73e 100644 --- a/deps/v8/build/all.gyp +++ b/deps/v8/build/all.gyp @@ -10,15 +10,13 @@ 'dependencies': [ '../samples/samples.gyp:*', '../src/d8.gyp:d8', - '../test/base-unittests/base-unittests.gyp:*', '../test/cctest/cctest.gyp:*', - '../test/compiler-unittests/compiler-unittests.gyp:*', + '../test/unittests/unittests.gyp:*', ], 'conditions': [ ['component!="shared_library"', { 'dependencies': [ - '../tools/lexer-shell.gyp:lexer-shell', - '../tools/lexer-shell.gyp:parser-shell', + '../tools/parser-shell.gyp:parser-shell', ], }], ] diff --git a/deps/v8/build/android.gypi b/deps/v8/build/android.gypi index 46ece08524e8c7..f984ea3af61b32 100644 --- a/deps/v8/build/android.gypi +++ b/deps/v8/build/android.gypi @@ -87,7 +87,6 @@ '-pthread', # Not supported by Android toolchain. ], 'cflags': [ - '-U__linux__', # Don't allow toolchain to claim -D__linux__ '-ffunction-sections', '-funwind-tables', '-fstack-protector', diff --git a/deps/v8/build/get_landmines.py b/deps/v8/build/get_landmines.py index c6ff8165f937a6..66a86cbb5082ad 100755 --- a/deps/v8/build/get_landmines.py +++ b/deps/v8/build/get_landmines.py @@ -19,6 +19,7 @@ def main(): print 'Landmines test.' print 'Activating MSVS 2013.' print 'Revert activation of MSVS 2013.' + print 'Activating MSVS 2013 again.' return 0 diff --git a/deps/v8/build/standalone.gypi b/deps/v8/build/standalone.gypi index 2ed19f65eaca08..47b276311d90a5 100644 --- a/deps/v8/build/standalone.gypi +++ b/deps/v8/build/standalone.gypi @@ -136,6 +136,14 @@ 'configurations': { 'DebugBaseCommon': { 'cflags': [ '-g', '-O0' ], + 'conditions': [ + ['(v8_target_arch=="ia32" or v8_target_arch=="x87") and \ + OS=="linux"', { + 'defines': [ + '_GLIBCXX_DEBUG' + ], + }], + ], }, 'Optdebug': { 'inherit_from': [ 'DebugBaseCommon', 'DebugBase2' ], @@ -215,9 +223,18 @@ ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris" \ or OS=="netbsd"', { 'target_defaults': { - 'cflags': [ '-Wall', '<(werror)', '-W', '-Wno-unused-parameter', - '-Wno-long-long', '-pthread', '-fno-exceptions', - '-pedantic' ], + 'cflags': [ + '-Wall', + '<(werror)', + '-W', + '-Wno-unused-parameter', + '-Wno-long-long', + '-pthread', + '-fno-exceptions', + '-pedantic', + # Don't warn about the "struct foo f = {0};" initialization pattern. + '-Wno-missing-field-initializers', + ], 'cflags_cc': [ '-Wnon-virtual-dtor', '-fno-rtti', '-std=gnu++0x' ], 'ldflags': [ '-pthread', ], 'conditions': [ @@ -234,8 +251,15 @@ # or OS=="netbsd"' ['OS=="qnx"', { 'target_defaults': { - 'cflags': [ '-Wall', '<(werror)', '-W', '-Wno-unused-parameter', - '-fno-exceptions' ], + 'cflags': [ + '-Wall', + '<(werror)', + '-W', + '-Wno-unused-parameter', + '-fno-exceptions', + # Don't warn about the "struct foo f = {0};" initialization pattern. + '-Wno-missing-field-initializers', + ], 'cflags_cc': [ '-Wnon-virtual-dtor', '-fno-rtti', '-std=gnu++0x' ], 'conditions': [ [ 'visibility=="hidden"', { @@ -263,6 +287,7 @@ 'defines': [ '_CRT_SECURE_NO_DEPRECATE', '_CRT_NONSTDC_NO_DEPRECATE', + '_USING_V110_SDK71_', ], 'conditions': [ ['component=="static_library"', { @@ -296,6 +321,13 @@ }, 'VCLibrarianTool': { 'AdditionalOptions': ['/ignore:4221'], + 'conditions': [ + ['v8_target_arch=="x64"', { + 'TargetMachine': '17', # x64 + }, { + 'TargetMachine': '1', # ia32 + }], + ], }, 'VCLinkerTool': { 'AdditionalDependencies': [ @@ -322,6 +354,13 @@ 'advapi32.lib', ], }], + ['v8_target_arch=="x64"', { + 'MinimumRequiredVersion': '5.02', # Server 2003. + 'TargetMachine': '17', # x64 + }, { + 'MinimumRequiredVersion': '5.01', # XP. + 'TargetMachine': '1', # ia32 + }], ], }, }, @@ -359,6 +398,8 @@ '-Wendif-labels', '-W', '-Wno-unused-parameter', + # Don't warn about the "struct foo f = {0};" initialization pattern. + '-Wno-missing-field-initializers', ], }, 'conditions': [ diff --git a/deps/v8/build/toolchain.gypi b/deps/v8/build/toolchain.gypi index 1d47360d2a7aae..20c2c943bb9f72 100644 --- a/deps/v8/build/toolchain.gypi +++ b/deps/v8/build/toolchain.gypi @@ -58,6 +58,14 @@ # Default arch variant for MIPS. 'mips_arch_variant%': 'r2', + # Possible values fp32, fp64, fpxx. + # fp32 - 32 32-bit FPU registers are available, doubles are placed in + # register pairs. + # fp64 - 32 64-bit FPU registers are available. + # fpxx - compatibility mode, it chooses fp32 or fp64 depending on runtime + # detection + 'mips_fpu_mode%': 'fp32', + 'v8_enable_backtrace%': 0, # Enable profiling support. Only required on Windows. @@ -83,6 +91,9 @@ # Allow to suppress the array bounds warning (default is no suppression). 'wno_array_bounds%': '', + # Link-Time Optimizations + 'use_lto%': 0, + 'variables': { # This is set when building the Android WebView inside the Android build # system, using the 'android' gyp backend. @@ -233,6 +244,15 @@ }], ], }], + # Disable LTO for v8 + # v8 is optimized for speed, which takes precedence over + # size optimization in LTO. + ['use_lto==1', { + 'cflags!': [ + '-flto', + '-ffat-lto-objects', + ], + }], ], }], # _toolset=="target" ], @@ -272,11 +292,37 @@ 'cflags': ['-msoft-float'], 'ldflags': ['-msoft-float'], }], + ['mips_fpu_mode=="fp64"', { + 'cflags': ['-mfp64'], + }], + ['mips_fpu_mode=="fpxx"', { + 'cflags': ['-mfpxx'], + }], + ['mips_fpu_mode=="fp32"', { + 'cflags': ['-mfp32'], + }], + ['mips_arch_variant=="r6"', { + 'cflags!': ['-mfp32', '-mfpxx'], + 'cflags': ['-mips32r6', '-Wa,-mips32r6'], + 'ldflags': [ + '-mips32r6', + '-Wl,--dynamic-linker=$(LDSO_PATH)', + '-Wl,--rpath=$(LD_R_PATH)', + ], + }], ['mips_arch_variant=="r2"', { 'cflags': ['-mips32r2', '-Wa,-mips32r2'], + 'ldflags': ['-mips32r2'], }], ['mips_arch_variant=="r1"', { + 'cflags!': ['-mfp64', '-mfpxx'], 'cflags': ['-mips32', '-Wa,-mips32'], + 'ldflags': ['-mips32'], + }], + ['mips_arch_variant=="rx"', { + 'cflags!': ['-mfp64', '-mfp32'], + 'cflags': ['-mips32', '-Wa,-mips32', '-mfpxx'], + 'ldflags': ['-mips32'], }], ], }], @@ -297,8 +343,34 @@ '__mips_soft_float=1' ], }], + ['mips_arch_variant=="rx"', { + 'defines': [ + '_MIPS_ARCH_MIPS32RX', + 'FPU_MODE_FPXX', + ], + }], + ['mips_arch_variant=="r6"', { + 'defines': [ + '_MIPS_ARCH_MIPS32R6', + 'FPU_MODE_FP64', + ], + }], ['mips_arch_variant=="r2"', { 'defines': ['_MIPS_ARCH_MIPS32R2',], + 'conditions': [ + ['mips_fpu_mode=="fp64"', { + 'defines': ['FPU_MODE_FP64',], + }], + ['mips_fpu_mode=="fpxx"', { + 'defines': ['FPU_MODE_FPXX',], + }], + ['mips_fpu_mode=="fp32"', { + 'defines': ['FPU_MODE_FP32',], + }], + ], + }], + ['mips_arch_variant=="r1"', { + 'defines': ['FPU_MODE_FP32',], }], ], }], # v8_target_arch=="mips" @@ -321,13 +393,40 @@ 'cflags': ['-msoft-float'], 'ldflags': ['-msoft-float'], }], + ['mips_fpu_mode=="fp64"', { + 'cflags': ['-mfp64'], + }], + ['mips_fpu_mode=="fpxx"', { + 'cflags': ['-mfpxx'], + }], + ['mips_fpu_mode=="fp32"', { + 'cflags': ['-mfp32'], + }], + ['mips_arch_variant=="r6"', { + 'cflags!': ['-mfp32', '-mfpxx'], + 'cflags': ['-mips32r6', '-Wa,-mips32r6'], + 'ldflags': [ + '-mips32r6', + '-Wl,--dynamic-linker=$(LDSO_PATH)', + '-Wl,--rpath=$(LD_R_PATH)', + ], + }], ['mips_arch_variant=="r2"', { 'cflags': ['-mips32r2', '-Wa,-mips32r2'], + 'ldflags': ['-mips32r2'], }], ['mips_arch_variant=="r1"', { + 'cflags!': ['-mfp64', '-mfpxx'], 'cflags': ['-mips32', '-Wa,-mips32'], - }], + 'ldflags': ['-mips32'], + }], + ['mips_arch_variant=="rx"', { + 'cflags!': ['-mfp64', '-mfp32'], + 'cflags': ['-mips32', '-Wa,-mips32', '-mfpxx'], + 'ldflags': ['-mips32'], + }], ['mips_arch_variant=="loongson"', { + 'cflags!': ['-mfp64', '-mfp32', '-mfpxx'], 'cflags': ['-mips3', '-Wa,-mips3'], }], ], @@ -349,11 +448,40 @@ '__mips_soft_float=1' ], }], + ['mips_arch_variant=="rx"', { + 'defines': [ + '_MIPS_ARCH_MIPS32RX', + 'FPU_MODE_FPXX', + ], + }], + ['mips_arch_variant=="r6"', { + 'defines': [ + '_MIPS_ARCH_MIPS32R6', + 'FPU_MODE_FP64', + ], + }], ['mips_arch_variant=="r2"', { 'defines': ['_MIPS_ARCH_MIPS32R2',], + 'conditions': [ + ['mips_fpu_mode=="fp64"', { + 'defines': ['FPU_MODE_FP64',], + }], + ['mips_fpu_mode=="fpxx"', { + 'defines': ['FPU_MODE_FPXX',], + }], + ['mips_fpu_mode=="fp32"', { + 'defines': ['FPU_MODE_FP32',], + }], + ], + }], + ['mips_arch_variant=="r1"', { + 'defines': ['FPU_MODE_FP32',], }], ['mips_arch_variant=="loongson"', { - 'defines': ['_MIPS_ARCH_LOONGSON',], + 'defines': [ + '_MIPS_ARCH_LOONGSON', + 'FPU_MODE_FP32', + ], }], ], }], # v8_target_arch=="mipsel" @@ -499,6 +627,12 @@ 'cflags': [ '-m32' ], 'ldflags': [ '-m32' ], }], + # Enable feedback-directed optimisation when building in android. + [ 'android_webview_build == 1', { + 'aosp_build_settings': { + 'LOCAL_FDO_SUPPORT': 'true', + }, + }], ], 'xcode_settings': { 'ARCHS': [ 'i386' ], @@ -523,6 +657,12 @@ 'cflags': [ '-m64' ], 'ldflags': [ '-m64' ], }], + # Enable feedback-directed optimisation when building in android. + [ 'android_webview_build == 1', { + 'aosp_build_settings': { + 'LOCAL_FDO_SUPPORT': 'true', + }, + }], ] }], ], @@ -568,7 +708,6 @@ ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="netbsd" or \ OS=="qnx"', { 'cflags!': [ - '-O0', '-O3', '-O2', '-O1', @@ -657,10 +796,6 @@ }, { 'RuntimeLibrary': '1', #/MTd }], - ['v8_target_arch=="x64"', { - # TODO(2207): remove this option once the bug is fixed. - 'WholeProgramOptimization': 'true', - }], ], }, 'VCLinkerTool': { @@ -830,10 +965,6 @@ }, { 'RuntimeLibrary': '0', #/MT }], - ['v8_target_arch=="x64"', { - # TODO(2207): remove this option once the bug is fixed. - 'WholeProgramOptimization': 'true', - }], ], }, 'VCLinkerTool': { diff --git a/deps/v8/include/v8-debug.h b/deps/v8/include/v8-debug.h index e72415952d97c0..6abf4e095bccad 100644 --- a/deps/v8/include/v8-debug.h +++ b/deps/v8/include/v8-debug.h @@ -167,6 +167,9 @@ class V8_EXPORT Debug { // happened yet. static void CancelDebugBreak(Isolate* isolate); + // Check if a debugger break is scheduled in the given isolate. + static bool CheckDebugBreak(Isolate* isolate); + // Break execution of JavaScript in the given isolate (this method // can be invoked from a non-VM thread) for further client command // execution on a VM thread. Client data is then passed in diff --git a/deps/v8/include/v8-platform.h b/deps/v8/include/v8-platform.h index 1f1679f0e0b60e..67fb384c99ba52 100644 --- a/deps/v8/include/v8-platform.h +++ b/deps/v8/include/v8-platform.h @@ -55,6 +55,15 @@ class Platform { * scheduling. The definition of "foreground" is opaque to V8. */ virtual void CallOnForegroundThread(Isolate* isolate, Task* task) = 0; + + /** + * Monotonically increasing time in seconds from an arbitrary fixed point in + * the past. This function is expected to return at least + * millisecond-precision values. For this reason, + * it is recommended that the fixed point be no further in the past than + * the epoch. + **/ + virtual double MonotonicallyIncreasingTime() = 0; }; } // namespace v8 diff --git a/deps/v8/include/v8-profiler.h b/deps/v8/include/v8-profiler.h index 7fc193db58e9de..d0215205f5fa97 100644 --- a/deps/v8/include/v8-profiler.h +++ b/deps/v8/include/v8-profiler.h @@ -22,6 +22,14 @@ typedef uint32_t SnapshotObjectId; */ class V8_EXPORT CpuProfileNode { public: + struct LineTick { + /** The 1-based number of the source line where the function originates. */ + int line; + + /** The count of samples associated with the source line. */ + unsigned int hit_count; + }; + /** Returns function name (empty string for anonymous functions.) */ Handle GetFunctionName() const; @@ -43,6 +51,18 @@ class V8_EXPORT CpuProfileNode { */ int GetColumnNumber() const; + /** + * Returns the number of the function's source lines that collect the samples. + */ + unsigned int GetHitLineCount() const; + + /** Returns the set of source lines that collect the samples. + * The caller allocates buffer and responsible for releasing it. + * True if all available entries are copied, otherwise false. + * The function copies nothing if buffer is not large enough. + */ + bool GetLineTicks(LineTick* entries, unsigned int length) const; + /** Returns bailout reason for the function * if the optimization was disabled for it. */ diff --git a/deps/v8/include/v8.h b/deps/v8/include/v8.h index ef0bda63f43d82..d5433a6a269836 100644 --- a/deps/v8/include/v8.h +++ b/deps/v8/include/v8.h @@ -15,7 +15,11 @@ #ifndef V8_H_ #define V8_H_ -#include "v8stdint.h" +#include +#include +#include + +#include "v8config.h" // We reserve the V8_* prefix for macros defined in V8 public API and // assume there are no name conflicts with the embedder's code. @@ -77,6 +81,7 @@ class ImplementationUtilities; class Int32; class Integer; class Isolate; +class Name; class Number; class NumberObject; class Object; @@ -84,6 +89,7 @@ class ObjectOperationDescriptor; class ObjectTemplate; class Platform; class Primitive; +class Promise; class RawOperationDescriptor; class Script; class Signature; @@ -129,6 +135,7 @@ class Heap; class HeapObject; class Isolate; class Object; +struct StreamedSource; template class CustomArguments; class PropertyCallbackArguments; class FunctionCallbackArguments; @@ -509,6 +516,18 @@ template class PersistentBase { P* parameter, typename WeakCallbackData::Callback callback); + // Phantom persistents work like weak persistents, except that the pointer to + // the object being collected is not available in the finalization callback. + // This enables the garbage collector to collect the object and any objects + // it references transitively in one GC cycle. + template + V8_INLINE void SetPhantom(P* parameter, + typename WeakCallbackData::Callback callback); + + template + V8_INLINE void SetPhantom(P* parameter, + typename WeakCallbackData::Callback callback); + template V8_INLINE P* ClearWeak(); @@ -694,9 +713,6 @@ template class Persistent : public PersistentBase { return Persistent::Cast(*this); } - // This will be removed. - V8_INLINE T* ClearAndLeak(); - private: friend class Isolate; friend class Utils; @@ -1087,6 +1103,73 @@ class V8_EXPORT ScriptCompiler { CachedData* cached_data; }; + /** + * For streaming incomplete script data to V8. The embedder should implement a + * subclass of this class. + */ + class ExternalSourceStream { + public: + virtual ~ExternalSourceStream() {} + + /** + * V8 calls this to request the next chunk of data from the embedder. This + * function will be called on a background thread, so it's OK to block and + * wait for the data, if the embedder doesn't have data yet. Returns the + * length of the data returned. When the data ends, GetMoreData should + * return 0. Caller takes ownership of the data. + * + * When streaming UTF-8 data, V8 handles multi-byte characters split between + * two data chunks, but doesn't handle multi-byte characters split between + * more than two data chunks. The embedder can avoid this problem by always + * returning at least 2 bytes of data. + * + * If the embedder wants to cancel the streaming, they should make the next + * GetMoreData call return 0. V8 will interpret it as end of data (and most + * probably, parsing will fail). The streaming task will return as soon as + * V8 has parsed the data it received so far. + */ + virtual size_t GetMoreData(const uint8_t** src) = 0; + }; + + + /** + * Source code which can be streamed into V8 in pieces. It will be parsed + * while streaming. It can be compiled after the streaming is complete. + * StreamedSource must be kept alive while the streaming task is ran (see + * ScriptStreamingTask below). + */ + class V8_EXPORT StreamedSource { + public: + enum Encoding { ONE_BYTE, TWO_BYTE, UTF8 }; + + StreamedSource(ExternalSourceStream* source_stream, Encoding encoding); + ~StreamedSource(); + + // Ownership of the CachedData or its buffers is *not* transferred to the + // caller. The CachedData object is alive as long as the StreamedSource + // object is alive. + const CachedData* GetCachedData() const; + + internal::StreamedSource* impl() const { return impl_; } + + private: + // Prevent copying. Not implemented. + StreamedSource(const StreamedSource&); + StreamedSource& operator=(const StreamedSource&); + + internal::StreamedSource* impl_; + }; + + /** + * A streaming task which the embedder must run on a background thread to + * stream scripts into V8. Returned by ScriptCompiler::StartStreamingScript. + */ + class ScriptStreamingTask { + public: + virtual ~ScriptStreamingTask() {} + virtual void Run() = 0; + }; + enum CompileOptions { kNoCompileOptions = 0, kProduceParserCache, @@ -1129,6 +1212,32 @@ class V8_EXPORT ScriptCompiler { static Local