├── .circleci └── config.yml ├── .dockerignore ├── .eslintrc.js ├── .gitattributes ├── .gitignore ├── .npmignore ├── CHANGELOG.md ├── CONTRIBUTING.md ├── Dockerfile ├── LICENSE ├── Makefile ├── README.md ├── SQLCipher.md ├── benchmark ├── insert-transaction.sql └── insert.js ├── binding.gyp ├── cloudformation └── ci.template.js ├── deps ├── OpenSSL-Win32 │ ├── libcrypto.lib │ ├── libssl.lib │ └── ossl_static.pdb ├── OpenSSL-Win64-ARM │ ├── libcrypto.lib │ ├── libssl.lib │ └── ossl_static.pdb ├── OpenSSL-Win64 │ ├── libcrypto.lib │ ├── libssl.lib │ └── ossl_static.pdb ├── common-sqlite.gypi ├── openssl-include │ └── openssl │ │ ├── __DECC_INCLUDE_EPILOGUE.H │ │ ├── __DECC_INCLUDE_PROLOGUE.H │ │ ├── aes.h │ │ ├── asn1.h │ │ ├── asn1_mac.h │ │ ├── asn1err.h │ │ ├── asn1t.h │ │ ├── async.h │ │ ├── asyncerr.h │ │ ├── bio.h │ │ ├── bioerr.h │ │ ├── blowfish.h │ │ ├── bn.h │ │ ├── bnerr.h │ │ ├── buffer.h │ │ ├── buffererr.h │ │ ├── camellia.h │ │ ├── cast.h │ │ ├── cmac.h │ │ ├── cms.h │ │ ├── cmserr.h │ │ ├── comp.h │ │ ├── comperr.h │ │ ├── conf.h │ │ ├── conf_api.h │ │ ├── conferr.h │ │ ├── crypto.h │ │ ├── cryptoerr.h │ │ ├── ct.h │ │ ├── cterr.h │ │ ├── des.h │ │ ├── dh.h │ │ ├── dherr.h │ │ ├── dsa.h │ │ ├── dsaerr.h │ │ ├── dtls1.h │ │ ├── e_os2.h │ │ ├── ebcdic.h │ │ ├── ec.h │ │ ├── ecdh.h │ │ ├── ecdsa.h │ │ ├── ecerr.h │ │ ├── engine.h │ │ ├── engineerr.h │ │ ├── err.h │ │ ├── evp.h │ │ ├── evperr.h │ │ ├── hmac.h │ │ ├── idea.h │ │ ├── kdf.h │ │ ├── kdferr.h │ │ ├── lhash.h │ │ ├── md2.h │ │ ├── md4.h │ │ ├── md5.h │ │ ├── mdc2.h │ │ ├── modes.h │ │ ├── obj_mac.h │ │ ├── objects.h │ │ ├── objectserr.h │ │ ├── ocsp.h │ │ ├── ocsperr.h │ │ ├── opensslconf.h │ │ ├── opensslv.h │ │ ├── ossl_typ.h │ │ ├── pem.h │ │ ├── pem2.h │ │ ├── pemerr.h │ │ ├── pkcs12.h │ │ ├── pkcs12err.h │ │ ├── pkcs7.h │ │ ├── pkcs7err.h │ │ ├── rand.h │ │ ├── rand_drbg.h │ │ ├── randerr.h │ │ ├── rc2.h │ │ ├── rc4.h │ │ ├── rc5.h │ │ ├── ripemd.h │ │ ├── rsa.h │ │ ├── rsaerr.h │ │ ├── safestack.h │ │ ├── seed.h │ │ ├── sha.h │ │ ├── srp.h │ │ ├── srtp.h │ │ ├── ssl.h │ │ ├── ssl2.h │ │ ├── ssl3.h │ │ ├── sslerr.h │ │ ├── stack.h │ │ ├── store.h │ │ ├── storeerr.h │ │ ├── symhacks.h │ │ ├── tls1.h │ │ ├── ts.h │ │ ├── tserr.h │ │ ├── txt_db.h │ │ ├── ui.h │ │ ├── uierr.h │ │ ├── whrlpool.h │ │ ├── x509.h │ │ ├── x509_vfy.h │ │ ├── x509err.h │ │ ├── x509v3.h │ │ └── x509v3err.h ├── openssl-macos │ ├── README.md │ ├── libcrypto.a │ └── libssl.a ├── openssl-windows.bat ├── sqlcipher-amalgamation │ ├── VERSION.txt │ ├── shell.c │ ├── sqlite3.c │ ├── sqlite3.h │ └── sqlite3ext.h └── sqlite3.gyp ├── examples └── simple-chaining.js ├── lib ├── index.js ├── sqlite3-binding.js ├── sqlite3.d.ts ├── sqlite3.js └── trace.js ├── package-lock.json ├── package.json ├── scripts ├── build-appveyor.bat ├── build-local.bat ├── build_against_electron.sh ├── build_against_node.sh ├── build_against_node_webkit.sh ├── build_for_node_webkit.cmd ├── install_node.sh └── validate_tag.sh ├── sqlite3.js ├── src ├── async.h ├── backup.cc ├── backup.h ├── database.cc ├── database.h ├── gcc-preinclude.h ├── macros.h ├── node_sqlite3.cc ├── statement.cc ├── statement.h └── threading.h ├── test ├── affected.test.js ├── backup.test.js ├── blob.test.js ├── cache.test.js ├── constants.test.js ├── database_fail.test.js ├── each.test.js ├── exec.test.js ├── extension.test.js ├── fts-content.test.js ├── interrupt.test.js ├── issue-108.test.js ├── json.test.js ├── map.test.js ├── named_columns.test.js ├── named_params.test.js ├── null_error.test.js ├── nw │ ├── .gitignore │ ├── Makefile │ ├── index.html │ └── package.json ├── open_close.test.js ├── other_objects.test.js ├── parallel_insert.test.js ├── prepare.test.js ├── profile.test.js ├── rerun.test.js ├── scheduling.test.js ├── serialization.test.js ├── sqlcipher.test.js ├── support │ ├── createdb-electron.js │ ├── createdb.js │ ├── elmo.png │ ├── helper.js │ ├── prepare.db │ └── script.sql ├── trace.test.js ├── unicode.test.js ├── upsert.test.js └── verbose.test.js └── tools └── docker └── architecture ├── linux-arm ├── Dockerfile └── run.sh └── linux-arm64 ├── Dockerfile └── run.sh /.dockerignore: -------------------------------------------------------------------------------- 1 | #.dockerignore 2 | *~ 3 | Dockerfile 4 | .git/ 5 | 6 | #.gitignore 7 | *.dylib 8 | *.so 9 | *.o 10 | *.lo 11 | *.Makefile 12 | *.target.gyp.mk 13 | lib/binding 14 | build 15 | out 16 | Release 17 | Debug 18 | node_modules 19 | .deps 20 | Makefile.gyp 21 | gyp-mac-tool 22 | .dirstamp 23 | npm-debug.log 24 | test/support/big.db 25 | test/tmp 26 | test/nw/app.nw 27 | .DS_Store 28 | .idea 29 | .dtps 30 | local.env 31 | .mason 32 | .eslintrc.js 33 | setup.sh -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | "extends": "eslint:recommended", 3 | "env": { 4 | "node": true 5 | }, 6 | "rules": { 7 | "indent": ["error", 4], 8 | "linebreak-style": ["error", "unix"], 9 | "semi": ["error", "always"], 10 | "no-cond-assign": ["error", "always"] 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | deps/sqlcipher-*.tar.gz filter=lfs diff=lfs merge=lfs -text 2 | deps/**/*.lib filter=lfs diff=lfs merge=lfs -text 3 | deps/**/*.pdb filter=lfs diff=lfs merge=lfs -text 4 | deps/**/*.a filter=lfs diff=lfs merge=lfs -text 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.dylib 2 | *.so 3 | *.o 4 | *.lo 5 | *.Makefile 6 | *.target.gyp.mk 7 | lib/binding 8 | build 9 | out 10 | Release 11 | Debug 12 | node_modules 13 | .deps 14 | Makefile.gyp 15 | gyp-mac-tool 16 | .dirstamp 17 | npm-debug.log 18 | test/support/big.db 19 | test/tmp 20 | test/nw/app.nw 21 | .DS_Store 22 | .idea 23 | .dtps 24 | local.env 25 | .mason 26 | .eslintrc.js 27 | setup.sh 28 | bin 29 | /build-tmp-napi-v3 30 | /build-tmp-napi-v6 31 | deps/vcpkg 32 | deps/openssl-windows 33 | /sqlcipher-amalgamation-* 34 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | .gitignore 2 | .npmignore 3 | node_modules 4 | lib/binding 5 | build 6 | test 7 | benchmark 8 | configure 9 | Makefile 10 | scripts 11 | .travis.yml 12 | examples 13 | .dtps 14 | local.env 15 | .mason 16 | .eslintrc.js 17 | setup.sh 18 | bin 19 | .circleci 20 | *.tgz 21 | cloudformation/ci.template.js 22 | appveyor.yml 23 | .vscode 24 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## 5.3.1 4 | 5 | - Linux: Downgrade glibc requirement to 2.24, supporting Ubuntu 16.10+ and Debian 9 (Stretch)+ again. 6 | 7 | ## 5.3.0 8 | 9 | - Pre-built binaries for macos/darwin arm64. 10 | - Add typescript types. 11 | - Don't fallback to building from source. 12 | - Smaller NPM package (build dependencies not included anymore). 13 | - Linux: Requires glibc 2.28+ (Ubuntu 18.10+). 14 | 15 | ## 5.2.0 16 | 17 | - Statically link OpenSSL on Linux and Windows, in addition to MacOS. No more DLLs distributed. 18 | - Upgrade to OpenSSL 1.1.1i. 19 | - Provide pre-built binaries for ARM64 on Windows (not regularly tested, but should work). 20 | 21 | ## 5.1.0 22 | 23 | - Update to SQLCipher 4.4.2 / SQLite 3.33.0. 24 | - Fix crash on Electron on Windows. 25 | - Always use system or bundled OpenSSL, not OpenSSL bundled with Node. 26 | 27 | ## 5.0.0 28 | 29 | - Major change: Use N-API instead of NAN. 30 | This removes the need to have separate Node binaries for each Node and Electron version, which was the most common cause of reported issues. 31 | - Update to SQLCipher 4.4.0 / SQLite 3.31.0. 32 | - Drop support for Node < 10, and Electron < 6. 33 | 34 | Includes these upstream changes from mapbox/node-sqlite3: 35 | 36 | 5.0.1 37 | - dep: node-addon-api to ^3.0.0 [#1367](https://github.com/mapbox/node-sqlite3/pull/1367) 38 | - bug: bad comparison of c string [#1347](https://github.com/mapbox/node-sqlite3/pull/1347) 39 | - bug: worker threads crash [#1367](https://github.com/mapbox/node-sqlite3/pull/1367) 40 | - bug: segfaults [#1368](https://github.com/mapbox/node-sqlite3/pull/1368) 41 | - typo: broken link to MapBox site [#1369](https://github.com/mapbox/node-sqlite3/pull/1369) 42 | 43 | 5.0.0 44 | - prebuilt: Node 14 support, dropped support for all version of Node < 10 [#1304](https://github.com/mapbox/node-sqlite3/pull/1304) 45 | - napi: refactor codebase to use N-API instead of NAN (+ various improvements) [#1304](https://github.com/mapbox/node-sqlite3/pull/1304) 46 | - trace: don't require throw to add trace info for verbose [#1317](https://github.com/mapbox/node-sqlite3/pull/1317) 47 | 48 | 4.2.0 49 | - webpack: split sqlite3-binding.js out so that it could be override by webpack [#1268](https://github.com/mapbox/node-sqlite3/pull/1268) 50 | - sqlite3: enable 'SQLITE_ENABLE_DBSTAT_VTAB=1' [#1281](https://github.com/mapbox/node-sqlite3/pull/1281) 51 | - deps: remove request [#1287](https://github.com/mapbox/node-sqlite3/pull/1287) 52 | - electron: fix dist url [#1282](https://github.com/mapbox/node-sqlite3/pull/1282) 53 | 54 | 4.1.0 55 | - https everywhere [#1177](https://github.com/mapbox/node-sqlite3/pull/1177) 56 | 57 | 58 | ## 4.1.0 59 | 60 | - Update to SQLCipher 4.3.0 / SQLite 3.30.1. 61 | 62 | ## 4.0.0 63 | 64 | - Update to SQLCipher 4.2.0 / SQLite 3.28.0. 65 | 66 | ## 3.2.1 67 | 68 | - Publish more prebuilt binaries. 69 | 70 | ## 3.2.0 71 | 72 | - Update to SQLCipher 3.4.1 / SQLite 3.20.1. 73 | - Also bundle msvcr120.dll 74 | 75 | ## 3.1.16 76 | 77 | - First release of the fork, based on SQLCipher 3.4.1 / SQLite 3.15.2. 78 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | General guidelines for contributing to node-sqlcipher. 4 | 5 | # Testing 6 | 7 | [mocha](https://github.com/visionmedia/mocha) is required to run unit tests. 8 | 9 | In sqlite3's directory (where its `package.json` resides) run the following: 10 | 11 | npm install --build-from-source 12 | npm test 13 | 14 | ## Developing / Pre-release 15 | 16 | Create a milestone for the next release on github. If all anticipated changes are back compatible then a `patch` release is in order. If minor API changes are needed then a `minor` release is in order. And a `major` bump is warranted if major API changes are needed. 17 | 18 | Assign tickets and pull requests you are working to the milestone you created. 19 | 20 | ## Releasing 21 | 22 | To release a new version: 23 | 24 | **1)** Ensure tests are passing 25 | 26 | Before considering a release all the tests need to be passing on CircleCI. 27 | 28 | **2)** Bump commit 29 | 30 | Bump the version in `package.json` like https://github.com/mapbox/node-sqlite3/commit/77d51d5785b047ff40f6a8225051488a0d96f7fd 31 | 32 | What if you already committed the `package.json` bump and you have no changes to commit but want to publish binaries? In this case you can do: 33 | 34 | ```sh 35 | git commit --allow-empty -m "[publish binary]" 36 | ``` 37 | 38 | **3)** Ensure binaries built 39 | 40 | Check the CircleCI pages to ensure they are all green as an indication that the `[publish binary]` command worked. 41 | 42 | Note: NEVER republish binaries for an existing released version. 43 | 44 | **7)** Officially release 45 | 46 | An official release requires: 47 | 48 | - Updating the CHANGELOG.md 49 | - Create and push github tag like `git tag v3.1.1 -m "v3.1.1" && git push --tags` 50 | - Ensure you have a clean checkout (no extra files in your check that are not known by git). You need to be careful, for instance, to avoid a large accidental file being packaged by npm. You can get a view of what npm will publish by running `make testpack` 51 | - Fully rebuild and ensure install from binary works: `make clean && npm install --fallback-to-build=false` 52 | - Then publish the module to npm repositories by running `npm publish` 53 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | #!/bin/echo docker build . -f 2 | # -*- coding: utf-8 -*- 3 | #{ 4 | # ISC License 5 | # Copyright (c) 2004-2010 by Internet Systems Consortium, Inc. ("ISC") 6 | # Copyright (c) 1995-2003 by Internet Software Consortium 7 | # Permission to use, copy, modify, and /or distribute this software 8 | # for any purpose with or without fee is hereby granted, 9 | # provided that the above copyright notice 10 | # and this permission notice appear in all copies. 11 | # THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES 12 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES 13 | # OF MERCHANTABILITY AND FITNESS. 14 | # IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, 15 | # OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 17 | # WHETHER IN AN ACTION OF CONTRACT, 18 | # NEGLIGENCE OR OTHER TORTIOUS ACTION, 19 | # ARISING OUT OF OR IN CONNECTION WITH THE USE 20 | # OR PERFORMANCE OF THIS SOFTWARE. 21 | #} 22 | 23 | FROM ubuntu:latest 24 | MAINTAINER Philippe Coval (p.coval@samsung.com) 25 | 26 | ENV DEBIAN_FRONTEND noninteractive 27 | ENV LC_ALL en_US.UTF-8 28 | ENV LANG ${LC_ALL} 29 | 30 | RUN echo "#log: Configuring locales" \ 31 | && set -x \ 32 | && apt-get update -y \ 33 | && apt-get install -y locales \ 34 | && echo "${LC_ALL} UTF-8" | tee /etc/locale.gen \ 35 | && locale-gen ${LC_ALL} \ 36 | && dpkg-reconfigure locales \ 37 | && sync 38 | 39 | ENV project node-sqlite3 40 | 41 | RUN echo "#log: ${project}: Setup system" \ 42 | && set -x \ 43 | && apt-get update -y \ 44 | && apt-get install -y \ 45 | curl \ 46 | sudo \ 47 | build-essential \ 48 | python \ 49 | && apt-get clean \ 50 | && NVM_VERSION="v0.33.8" \ 51 | && NODE_VERSION="--lts=carbon" \ 52 | && curl -o- https://raw.githubusercontent.com/creationix/nvm/${NVM_VERSION}/install.sh | bash \ 53 | && which nvm || . ~/.bashrc \ 54 | && nvm install ${NODE_VERSION} \ 55 | && nvm use ${NODE_VERSION} \ 56 | && sync 57 | 58 | ADD . /usr/local/${project}/${project} 59 | WORKDIR /usr/local/${project}/${project} 60 | RUN echo "#log: ${project}: Preparing sources" \ 61 | && set -x \ 62 | && which npm || . ~/.bashrc \ 63 | && npm install || cat npm-debug.log \ 64 | && npm install \ 65 | && npm install --unsafe-perm --build-from-source \ 66 | && sync 67 | 68 | WORKDIR /usr/local/${project}/${project} 69 | RUN echo "#log: ${project}: Building sources" \ 70 | && set -x \ 71 | && which npm || . ~/.bashrc \ 72 | && npm run pack \ 73 | && npm pack \ 74 | && find build/stage/ -type f \ 75 | && sync 76 | 77 | WORKDIR /usr/local/${project}/${project} 78 | RUN echo "#log: ${project}: Installing sources" \ 79 | && set -x \ 80 | && install -d /usr/local/src/${project}/deploy/ \ 81 | && install *.tgz /usr/local/src/${project}/deploy/ \ 82 | && cp -rfva ./build/stage/ /usr/local/src/${project}/deploy/ \ 83 | && find /usr/local/src/${project}/deploy/ -type f \ 84 | && sync 85 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) MapBox 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | - Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | - Redistributions in binary form must reproduce the above copyright notice, this 10 | list of conditions and the following disclaimer in the documentation and/or 11 | other materials provided with the distribution. 12 | - Neither the name "MapBox" nor the names of its contributors may be 13 | used to endorse or promote products derived from this software without 14 | specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | #https://www.gnu.org/prep/standards/html_node/Standard-Targets.html#Standard-Targets 2 | 3 | all: build 4 | 5 | ./node_modules: 6 | npm install --build-from-source 7 | 8 | build: ./node_modules 9 | ./node_modules/.bin/node-pre-gyp build --loglevel=silent 10 | 11 | debug: 12 | ./node_modules/.bin/node-pre-gyp rebuild --debug 13 | 14 | verbose: 15 | ./node_modules/.bin/node-pre-gyp rebuild --loglevel=verbose 16 | 17 | clean: 18 | @rm -rf ./build 19 | rm -rf lib/binding/ 20 | rm -f test/support/big.db-journal 21 | rm -rf ./node_modules/ 22 | 23 | grind: 24 | valgrind --leak-check=full node node_modules/.bin/_mocha 25 | 26 | testpack: 27 | rm -f ./*tgz 28 | npm pack 29 | tar -ztvf *tgz 30 | rm -f ./*tgz 31 | 32 | rebuild: 33 | @make clean 34 | @make 35 | 36 | test: 37 | npm test 38 | 39 | check: test 40 | 41 | .PHONY: test clean build 42 | -------------------------------------------------------------------------------- /SQLCipher.md: -------------------------------------------------------------------------------- 1 | # Including SQLCipher 2 | 3 | **Note:** All these steps have already been performed in this repository. This is just for reference to e.g. change the SQLCipher version. 4 | 5 | ## Step 1: Get the SQLCipher source 6 | 7 | Clone the sqlcipher repo, and build the amalgamation source. 8 | 9 | ``` 10 | git clone git@github.com:sqlcipher/sqlcipher.git 11 | cd sqlcipher 12 | ./configure 13 | make sqlite3.c 14 | 15 | VERSION=3031000 16 | mkdir sqlcipher-amalgamation-$VERSION 17 | cp sqlite3.c sqlite3.h shell.c sqlite3ext.h VERSION sqlcipher-amalgamation-$VERSION/ 18 | ``` 19 | 20 | The above produces 4 files of interest: 21 | 22 | ``` 23 | sqlite3.c 24 | sqlite3.h 25 | shell.c 26 | sqlite3ext.h 27 | VERSION # rename to VERSION.txt 28 | ``` 29 | 30 | Copy these files to: `deps/sqlcipher-amalgamation`. 31 | 32 | ## Step 2: Get OpenSSL libraries 33 | 34 | NodeJS typically includes OpenSSL. However, to support Electron, we statically link against libcrypto from OpenSSL. 35 | 36 | Run the following commands to generate the latest OpenSSL libs for Windows: 37 | 38 | ``` 39 | cd deps 40 | .\openssl-windows.bat 41 | ``` 42 | 43 | ... this will output the libs in `deps/` (OpenSSL-WinXX), including the header files in `deps/openssl-include`. Every arch-specific folder includes these binaries: 44 | 45 | ``` 46 | libcrypto.lib 47 | libssl.lib 48 | ossl_static.pdb 49 | ``` 50 | 51 | ## Step 3: Test the build 52 | 53 | Run: 54 | 55 | ```sh 56 | ./node_modules/.bin/node-pre-gyp install --build-from-source 57 | ``` 58 | 59 | Then run the tests: 60 | 61 | ```sh 62 | npm run test 63 | ``` 64 | 65 | 66 | # Notes 67 | 68 | The OpenSSL files are specifically required for Electron, which doesn't bundle OpenSSL like NodeJS does. The header and .lib files are required at compile-time. We bundle a statically-linked version of OpenSSL with the library, so the user does not need to manually install OpenSSL. 69 | 70 | `deps/sqlite3.gyp` has been modified from the original node-sqlite3 one to: 71 | * Use the bundled OpenSSL on Windows and MacOS. 72 | * Add additional define statements required by SQLCipher. 73 | 74 | 75 | -------------------------------------------------------------------------------- /benchmark/insert.js: -------------------------------------------------------------------------------- 1 | var sqlite3 = require('../lib/sqlite3'); 2 | var fs = require('fs'); 3 | 4 | var iterations = 10000; 5 | 6 | exports.compare = { 7 | 'insert literal file': function(finished) { 8 | var db = new sqlite3.Database(''); 9 | var file = fs.readFileSync('benchmark/insert-transaction.sql', 'utf8'); 10 | db.exec(file); 11 | db.close(finished) 12 | }, 13 | 14 | 'insert with transaction and two statements': function(finished) { 15 | var db = new sqlite3.Database(''); 16 | 17 | db.serialize(function() { 18 | db.run("CREATE TABLE foo (id INT, txt TEXT)"); 19 | db.run("BEGIN"); 20 | 21 | db.parallelize(function() { 22 | var stmt1 = db.prepare("INSERT INTO foo VALUES (?, ?)"); 23 | var stmt2 = db.prepare("INSERT INTO foo VALUES (?, ?)"); 24 | for (var i = 0; i < iterations; i++) { 25 | stmt1.run(i, 'Row ' + i); 26 | i++; 27 | stmt2.run(i, 'Row ' + i); 28 | } 29 | stmt1.finalize(); 30 | stmt2.finalize(); 31 | }); 32 | 33 | db.run("COMMIT"); 34 | }); 35 | 36 | db.close(finished); 37 | }, 38 | 'insert with transaction': function(finished) { 39 | var db = new sqlite3.Database(''); 40 | 41 | db.serialize(function() { 42 | db.run("CREATE TABLE foo (id INT, txt TEXT)"); 43 | db.run("BEGIN"); 44 | var stmt = db.prepare("INSERT INTO foo VALUES (?, ?)"); 45 | for (var i = 0; i < iterations; i++) { 46 | stmt.run(i, 'Row ' + i); 47 | } 48 | stmt.finalize(); 49 | db.run("COMMIT"); 50 | }); 51 | 52 | db.close(finished); 53 | }, 54 | 'insert without transaction': function(finished) { 55 | var db = new sqlite3.Database(''); 56 | 57 | db.serialize(function() { 58 | db.run("CREATE TABLE foo (id INT, txt TEXT)"); 59 | var stmt = db.prepare("INSERT INTO foo VALUES (?, ?)"); 60 | for (var i = 0; i < iterations; i++) { 61 | stmt.run(i, 'Row ' + i); 62 | } 63 | stmt.finalize(); 64 | }); 65 | 66 | db.close(finished); 67 | } 68 | }; -------------------------------------------------------------------------------- /binding.gyp: -------------------------------------------------------------------------------- 1 | { 2 | "includes": [ "deps/common-sqlite.gypi" ], 3 | "variables": { 4 | "sqlite%":"internal", 5 | "sqlite_libname%":"sqlite3" 6 | }, 7 | "targets": [ 8 | { 9 | "target_name": "<(module_name)", 10 | "cflags!": [ "-fno-exceptions" ], 11 | "cflags_cc!": [ "-fno-exceptions" ], 12 | "xcode_settings": { "GCC_ENABLE_CPP_EXCEPTIONS": "YES", 13 | "CLANG_CXX_LIBRARY": "libc++", 14 | "MACOSX_DEPLOYMENT_TARGET": "10.7", 15 | }, 16 | "msvs_settings": { 17 | "VCCLCompilerTool": { "ExceptionHandling": 1 }, 18 | }, 19 | "include_dirs": [ 20 | " 14 | 15 | # include 16 | # ifdef __cplusplus 17 | extern "C" { 18 | # endif 19 | 20 | # define AES_ENCRYPT 1 21 | # define AES_DECRYPT 0 22 | 23 | /* 24 | * Because array size can't be a const in C, the following two are macros. 25 | * Both sizes are in bytes. 26 | */ 27 | # define AES_MAXNR 14 28 | # define AES_BLOCK_SIZE 16 29 | 30 | /* This should be a hidden type, but EVP requires that the size be known */ 31 | struct aes_key_st { 32 | # ifdef AES_LONG 33 | unsigned long rd_key[4 * (AES_MAXNR + 1)]; 34 | # else 35 | unsigned int rd_key[4 * (AES_MAXNR + 1)]; 36 | # endif 37 | int rounds; 38 | }; 39 | typedef struct aes_key_st AES_KEY; 40 | 41 | const char *AES_options(void); 42 | 43 | int AES_set_encrypt_key(const unsigned char *userKey, const int bits, 44 | AES_KEY *key); 45 | int AES_set_decrypt_key(const unsigned char *userKey, const int bits, 46 | AES_KEY *key); 47 | 48 | void AES_encrypt(const unsigned char *in, unsigned char *out, 49 | const AES_KEY *key); 50 | void AES_decrypt(const unsigned char *in, unsigned char *out, 51 | const AES_KEY *key); 52 | 53 | void AES_ecb_encrypt(const unsigned char *in, unsigned char *out, 54 | const AES_KEY *key, const int enc); 55 | void AES_cbc_encrypt(const unsigned char *in, unsigned char *out, 56 | size_t length, const AES_KEY *key, 57 | unsigned char *ivec, const int enc); 58 | void AES_cfb128_encrypt(const unsigned char *in, unsigned char *out, 59 | size_t length, const AES_KEY *key, 60 | unsigned char *ivec, int *num, const int enc); 61 | void AES_cfb1_encrypt(const unsigned char *in, unsigned char *out, 62 | size_t length, const AES_KEY *key, 63 | unsigned char *ivec, int *num, const int enc); 64 | void AES_cfb8_encrypt(const unsigned char *in, unsigned char *out, 65 | size_t length, const AES_KEY *key, 66 | unsigned char *ivec, int *num, const int enc); 67 | void AES_ofb128_encrypt(const unsigned char *in, unsigned char *out, 68 | size_t length, const AES_KEY *key, 69 | unsigned char *ivec, int *num); 70 | /* NB: the IV is _two_ blocks long */ 71 | void AES_ige_encrypt(const unsigned char *in, unsigned char *out, 72 | size_t length, const AES_KEY *key, 73 | unsigned char *ivec, const int enc); 74 | /* NB: the IV is _four_ blocks long */ 75 | void AES_bi_ige_encrypt(const unsigned char *in, unsigned char *out, 76 | size_t length, const AES_KEY *key, 77 | const AES_KEY *key2, const unsigned char *ivec, 78 | const int enc); 79 | 80 | int AES_wrap_key(AES_KEY *key, const unsigned char *iv, 81 | unsigned char *out, 82 | const unsigned char *in, unsigned int inlen); 83 | int AES_unwrap_key(AES_KEY *key, const unsigned char *iv, 84 | unsigned char *out, 85 | const unsigned char *in, unsigned int inlen); 86 | 87 | 88 | # ifdef __cplusplus 89 | } 90 | # endif 91 | 92 | #endif 93 | -------------------------------------------------------------------------------- /deps/openssl-include/openssl/asn1_mac.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #error "This file is obsolete; please update your software." 11 | -------------------------------------------------------------------------------- /deps/openssl-include/openssl/async.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #include 11 | 12 | #ifndef HEADER_ASYNC_H 13 | # define HEADER_ASYNC_H 14 | 15 | #if defined(_WIN32) 16 | # if defined(BASETYPES) || defined(_WINDEF_H) 17 | /* application has to include to use this */ 18 | #define OSSL_ASYNC_FD HANDLE 19 | #define OSSL_BAD_ASYNC_FD INVALID_HANDLE_VALUE 20 | # endif 21 | #else 22 | #define OSSL_ASYNC_FD int 23 | #define OSSL_BAD_ASYNC_FD -1 24 | #endif 25 | # include 26 | 27 | 28 | # ifdef __cplusplus 29 | extern "C" { 30 | # endif 31 | 32 | typedef struct async_job_st ASYNC_JOB; 33 | typedef struct async_wait_ctx_st ASYNC_WAIT_CTX; 34 | 35 | #define ASYNC_ERR 0 36 | #define ASYNC_NO_JOBS 1 37 | #define ASYNC_PAUSE 2 38 | #define ASYNC_FINISH 3 39 | 40 | int ASYNC_init_thread(size_t max_size, size_t init_size); 41 | void ASYNC_cleanup_thread(void); 42 | 43 | #ifdef OSSL_ASYNC_FD 44 | ASYNC_WAIT_CTX *ASYNC_WAIT_CTX_new(void); 45 | void ASYNC_WAIT_CTX_free(ASYNC_WAIT_CTX *ctx); 46 | int ASYNC_WAIT_CTX_set_wait_fd(ASYNC_WAIT_CTX *ctx, const void *key, 47 | OSSL_ASYNC_FD fd, 48 | void *custom_data, 49 | void (*cleanup)(ASYNC_WAIT_CTX *, const void *, 50 | OSSL_ASYNC_FD, void *)); 51 | int ASYNC_WAIT_CTX_get_fd(ASYNC_WAIT_CTX *ctx, const void *key, 52 | OSSL_ASYNC_FD *fd, void **custom_data); 53 | int ASYNC_WAIT_CTX_get_all_fds(ASYNC_WAIT_CTX *ctx, OSSL_ASYNC_FD *fd, 54 | size_t *numfds); 55 | int ASYNC_WAIT_CTX_get_changed_fds(ASYNC_WAIT_CTX *ctx, OSSL_ASYNC_FD *addfd, 56 | size_t *numaddfds, OSSL_ASYNC_FD *delfd, 57 | size_t *numdelfds); 58 | int ASYNC_WAIT_CTX_clear_fd(ASYNC_WAIT_CTX *ctx, const void *key); 59 | #endif 60 | 61 | int ASYNC_is_capable(void); 62 | 63 | int ASYNC_start_job(ASYNC_JOB **job, ASYNC_WAIT_CTX *ctx, int *ret, 64 | int (*func)(void *), void *args, size_t size); 65 | int ASYNC_pause_job(void); 66 | 67 | ASYNC_JOB *ASYNC_get_current_job(void); 68 | ASYNC_WAIT_CTX *ASYNC_get_wait_ctx(ASYNC_JOB *job); 69 | void ASYNC_block_pause(void); 70 | void ASYNC_unblock_pause(void); 71 | 72 | 73 | # ifdef __cplusplus 74 | } 75 | # endif 76 | #endif 77 | -------------------------------------------------------------------------------- /deps/openssl-include/openssl/asyncerr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Generated by util/mkerr.pl DO NOT EDIT 3 | * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. 4 | * 5 | * Licensed under the OpenSSL license (the "License"). You may not use 6 | * this file except in compliance with the License. You can obtain a copy 7 | * in the file LICENSE in the source distribution or at 8 | * https://www.openssl.org/source/license.html 9 | */ 10 | 11 | #ifndef HEADER_ASYNCERR_H 12 | # define HEADER_ASYNCERR_H 13 | 14 | # ifndef HEADER_SYMHACKS_H 15 | # include 16 | # endif 17 | 18 | # ifdef __cplusplus 19 | extern "C" 20 | # endif 21 | int ERR_load_ASYNC_strings(void); 22 | 23 | /* 24 | * ASYNC function codes. 25 | */ 26 | # define ASYNC_F_ASYNC_CTX_NEW 100 27 | # define ASYNC_F_ASYNC_INIT_THREAD 101 28 | # define ASYNC_F_ASYNC_JOB_NEW 102 29 | # define ASYNC_F_ASYNC_PAUSE_JOB 103 30 | # define ASYNC_F_ASYNC_START_FUNC 104 31 | # define ASYNC_F_ASYNC_START_JOB 105 32 | # define ASYNC_F_ASYNC_WAIT_CTX_SET_WAIT_FD 106 33 | 34 | /* 35 | * ASYNC reason codes. 36 | */ 37 | # define ASYNC_R_FAILED_TO_SET_POOL 101 38 | # define ASYNC_R_FAILED_TO_SWAP_CONTEXT 102 39 | # define ASYNC_R_INIT_FAILED 105 40 | # define ASYNC_R_INVALID_POOL_SIZE 103 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /deps/openssl-include/openssl/blowfish.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_BLOWFISH_H 11 | # define HEADER_BLOWFISH_H 12 | 13 | # include 14 | 15 | # ifndef OPENSSL_NO_BF 16 | # include 17 | # ifdef __cplusplus 18 | extern "C" { 19 | # endif 20 | 21 | # define BF_ENCRYPT 1 22 | # define BF_DECRYPT 0 23 | 24 | /*- 25 | * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 26 | * ! BF_LONG has to be at least 32 bits wide. ! 27 | * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 28 | */ 29 | # define BF_LONG unsigned int 30 | 31 | # define BF_ROUNDS 16 32 | # define BF_BLOCK 8 33 | 34 | typedef struct bf_key_st { 35 | BF_LONG P[BF_ROUNDS + 2]; 36 | BF_LONG S[4 * 256]; 37 | } BF_KEY; 38 | 39 | void BF_set_key(BF_KEY *key, int len, const unsigned char *data); 40 | 41 | void BF_encrypt(BF_LONG *data, const BF_KEY *key); 42 | void BF_decrypt(BF_LONG *data, const BF_KEY *key); 43 | 44 | void BF_ecb_encrypt(const unsigned char *in, unsigned char *out, 45 | const BF_KEY *key, int enc); 46 | void BF_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, 47 | const BF_KEY *schedule, unsigned char *ivec, int enc); 48 | void BF_cfb64_encrypt(const unsigned char *in, unsigned char *out, 49 | long length, const BF_KEY *schedule, 50 | unsigned char *ivec, int *num, int enc); 51 | void BF_ofb64_encrypt(const unsigned char *in, unsigned char *out, 52 | long length, const BF_KEY *schedule, 53 | unsigned char *ivec, int *num); 54 | const char *BF_options(void); 55 | 56 | # ifdef __cplusplus 57 | } 58 | # endif 59 | # endif 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /deps/openssl-include/openssl/buffer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_BUFFER_H 11 | # define HEADER_BUFFER_H 12 | 13 | # include 14 | # ifndef HEADER_CRYPTO_H 15 | # include 16 | # endif 17 | # include 18 | 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | # include 25 | # include 26 | 27 | /* 28 | * These names are outdated as of OpenSSL 1.1; a future release 29 | * will move them to be deprecated. 30 | */ 31 | # define BUF_strdup(s) OPENSSL_strdup(s) 32 | # define BUF_strndup(s, size) OPENSSL_strndup(s, size) 33 | # define BUF_memdup(data, size) OPENSSL_memdup(data, size) 34 | # define BUF_strlcpy(dst, src, size) OPENSSL_strlcpy(dst, src, size) 35 | # define BUF_strlcat(dst, src, size) OPENSSL_strlcat(dst, src, size) 36 | # define BUF_strnlen(str, maxlen) OPENSSL_strnlen(str, maxlen) 37 | 38 | struct buf_mem_st { 39 | size_t length; /* current number of bytes */ 40 | char *data; 41 | size_t max; /* size of buffer */ 42 | unsigned long flags; 43 | }; 44 | 45 | # define BUF_MEM_FLAG_SECURE 0x01 46 | 47 | BUF_MEM *BUF_MEM_new(void); 48 | BUF_MEM *BUF_MEM_new_ex(unsigned long flags); 49 | void BUF_MEM_free(BUF_MEM *a); 50 | size_t BUF_MEM_grow(BUF_MEM *str, size_t len); 51 | size_t BUF_MEM_grow_clean(BUF_MEM *str, size_t len); 52 | void BUF_reverse(unsigned char *out, const unsigned char *in, size_t siz); 53 | 54 | 55 | # ifdef __cplusplus 56 | } 57 | # endif 58 | #endif 59 | -------------------------------------------------------------------------------- /deps/openssl-include/openssl/buffererr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Generated by util/mkerr.pl DO NOT EDIT 3 | * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. 4 | * 5 | * Licensed under the OpenSSL license (the "License"). You may not use 6 | * this file except in compliance with the License. You can obtain a copy 7 | * in the file LICENSE in the source distribution or at 8 | * https://www.openssl.org/source/license.html 9 | */ 10 | 11 | #ifndef HEADER_BUFERR_H 12 | # define HEADER_BUFERR_H 13 | 14 | # ifndef HEADER_SYMHACKS_H 15 | # include 16 | # endif 17 | 18 | # ifdef __cplusplus 19 | extern "C" 20 | # endif 21 | int ERR_load_BUF_strings(void); 22 | 23 | /* 24 | * BUF function codes. 25 | */ 26 | # define BUF_F_BUF_MEM_GROW 100 27 | # define BUF_F_BUF_MEM_GROW_CLEAN 105 28 | # define BUF_F_BUF_MEM_NEW 101 29 | 30 | /* 31 | * BUF reason codes. 32 | */ 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /deps/openssl-include/openssl/camellia.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2006-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_CAMELLIA_H 11 | # define HEADER_CAMELLIA_H 12 | 13 | # include 14 | 15 | # ifndef OPENSSL_NO_CAMELLIA 16 | # include 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | # define CAMELLIA_ENCRYPT 1 22 | # define CAMELLIA_DECRYPT 0 23 | 24 | /* 25 | * Because array size can't be a const in C, the following two are macros. 26 | * Both sizes are in bytes. 27 | */ 28 | 29 | /* This should be a hidden type, but EVP requires that the size be known */ 30 | 31 | # define CAMELLIA_BLOCK_SIZE 16 32 | # define CAMELLIA_TABLE_BYTE_LEN 272 33 | # define CAMELLIA_TABLE_WORD_LEN (CAMELLIA_TABLE_BYTE_LEN / 4) 34 | 35 | typedef unsigned int KEY_TABLE_TYPE[CAMELLIA_TABLE_WORD_LEN]; /* to match 36 | * with WORD */ 37 | 38 | struct camellia_key_st { 39 | union { 40 | double d; /* ensures 64-bit align */ 41 | KEY_TABLE_TYPE rd_key; 42 | } u; 43 | int grand_rounds; 44 | }; 45 | typedef struct camellia_key_st CAMELLIA_KEY; 46 | 47 | int Camellia_set_key(const unsigned char *userKey, const int bits, 48 | CAMELLIA_KEY *key); 49 | 50 | void Camellia_encrypt(const unsigned char *in, unsigned char *out, 51 | const CAMELLIA_KEY *key); 52 | void Camellia_decrypt(const unsigned char *in, unsigned char *out, 53 | const CAMELLIA_KEY *key); 54 | 55 | void Camellia_ecb_encrypt(const unsigned char *in, unsigned char *out, 56 | const CAMELLIA_KEY *key, const int enc); 57 | void Camellia_cbc_encrypt(const unsigned char *in, unsigned char *out, 58 | size_t length, const CAMELLIA_KEY *key, 59 | unsigned char *ivec, const int enc); 60 | void Camellia_cfb128_encrypt(const unsigned char *in, unsigned char *out, 61 | size_t length, const CAMELLIA_KEY *key, 62 | unsigned char *ivec, int *num, const int enc); 63 | void Camellia_cfb1_encrypt(const unsigned char *in, unsigned char *out, 64 | size_t length, const CAMELLIA_KEY *key, 65 | unsigned char *ivec, int *num, const int enc); 66 | void Camellia_cfb8_encrypt(const unsigned char *in, unsigned char *out, 67 | size_t length, const CAMELLIA_KEY *key, 68 | unsigned char *ivec, int *num, const int enc); 69 | void Camellia_ofb128_encrypt(const unsigned char *in, unsigned char *out, 70 | size_t length, const CAMELLIA_KEY *key, 71 | unsigned char *ivec, int *num); 72 | void Camellia_ctr128_encrypt(const unsigned char *in, unsigned char *out, 73 | size_t length, const CAMELLIA_KEY *key, 74 | unsigned char ivec[CAMELLIA_BLOCK_SIZE], 75 | unsigned char ecount_buf[CAMELLIA_BLOCK_SIZE], 76 | unsigned int *num); 77 | 78 | # ifdef __cplusplus 79 | } 80 | # endif 81 | # endif 82 | 83 | #endif 84 | -------------------------------------------------------------------------------- /deps/openssl-include/openssl/cast.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_CAST_H 11 | # define HEADER_CAST_H 12 | 13 | # include 14 | 15 | # ifndef OPENSSL_NO_CAST 16 | # ifdef __cplusplus 17 | extern "C" { 18 | # endif 19 | 20 | # define CAST_ENCRYPT 1 21 | # define CAST_DECRYPT 0 22 | 23 | # define CAST_LONG unsigned int 24 | 25 | # define CAST_BLOCK 8 26 | # define CAST_KEY_LENGTH 16 27 | 28 | typedef struct cast_key_st { 29 | CAST_LONG data[32]; 30 | int short_key; /* Use reduced rounds for short key */ 31 | } CAST_KEY; 32 | 33 | void CAST_set_key(CAST_KEY *key, int len, const unsigned char *data); 34 | void CAST_ecb_encrypt(const unsigned char *in, unsigned char *out, 35 | const CAST_KEY *key, int enc); 36 | void CAST_encrypt(CAST_LONG *data, const CAST_KEY *key); 37 | void CAST_decrypt(CAST_LONG *data, const CAST_KEY *key); 38 | void CAST_cbc_encrypt(const unsigned char *in, unsigned char *out, 39 | long length, const CAST_KEY *ks, unsigned char *iv, 40 | int enc); 41 | void CAST_cfb64_encrypt(const unsigned char *in, unsigned char *out, 42 | long length, const CAST_KEY *schedule, 43 | unsigned char *ivec, int *num, int enc); 44 | void CAST_ofb64_encrypt(const unsigned char *in, unsigned char *out, 45 | long length, const CAST_KEY *schedule, 46 | unsigned char *ivec, int *num); 47 | 48 | # ifdef __cplusplus 49 | } 50 | # endif 51 | # endif 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /deps/openssl-include/openssl/cmac.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_CMAC_H 11 | # define HEADER_CMAC_H 12 | 13 | # ifndef OPENSSL_NO_CMAC 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | # include 20 | 21 | /* Opaque */ 22 | typedef struct CMAC_CTX_st CMAC_CTX; 23 | 24 | CMAC_CTX *CMAC_CTX_new(void); 25 | void CMAC_CTX_cleanup(CMAC_CTX *ctx); 26 | void CMAC_CTX_free(CMAC_CTX *ctx); 27 | EVP_CIPHER_CTX *CMAC_CTX_get0_cipher_ctx(CMAC_CTX *ctx); 28 | int CMAC_CTX_copy(CMAC_CTX *out, const CMAC_CTX *in); 29 | 30 | int CMAC_Init(CMAC_CTX *ctx, const void *key, size_t keylen, 31 | const EVP_CIPHER *cipher, ENGINE *impl); 32 | int CMAC_Update(CMAC_CTX *ctx, const void *data, size_t dlen); 33 | int CMAC_Final(CMAC_CTX *ctx, unsigned char *out, size_t *poutlen); 34 | int CMAC_resume(CMAC_CTX *ctx); 35 | 36 | #ifdef __cplusplus 37 | } 38 | #endif 39 | 40 | # endif 41 | #endif 42 | -------------------------------------------------------------------------------- /deps/openssl-include/openssl/comp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_COMP_H 11 | # define HEADER_COMP_H 12 | 13 | # include 14 | 15 | # ifndef OPENSSL_NO_COMP 16 | # include 17 | # include 18 | # ifdef __cplusplus 19 | extern "C" { 20 | # endif 21 | 22 | 23 | 24 | COMP_CTX *COMP_CTX_new(COMP_METHOD *meth); 25 | const COMP_METHOD *COMP_CTX_get_method(const COMP_CTX *ctx); 26 | int COMP_CTX_get_type(const COMP_CTX* comp); 27 | int COMP_get_type(const COMP_METHOD *meth); 28 | const char *COMP_get_name(const COMP_METHOD *meth); 29 | void COMP_CTX_free(COMP_CTX *ctx); 30 | 31 | int COMP_compress_block(COMP_CTX *ctx, unsigned char *out, int olen, 32 | unsigned char *in, int ilen); 33 | int COMP_expand_block(COMP_CTX *ctx, unsigned char *out, int olen, 34 | unsigned char *in, int ilen); 35 | 36 | COMP_METHOD *COMP_zlib(void); 37 | 38 | #if OPENSSL_API_COMPAT < 0x10100000L 39 | #define COMP_zlib_cleanup() while(0) continue 40 | #endif 41 | 42 | # ifdef HEADER_BIO_H 43 | # ifdef ZLIB 44 | const BIO_METHOD *BIO_f_zlib(void); 45 | # endif 46 | # endif 47 | 48 | 49 | # ifdef __cplusplus 50 | } 51 | # endif 52 | # endif 53 | #endif 54 | -------------------------------------------------------------------------------- /deps/openssl-include/openssl/comperr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Generated by util/mkerr.pl DO NOT EDIT 3 | * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. 4 | * 5 | * Licensed under the OpenSSL license (the "License"). You may not use 6 | * this file except in compliance with the License. You can obtain a copy 7 | * in the file LICENSE in the source distribution or at 8 | * https://www.openssl.org/source/license.html 9 | */ 10 | 11 | #ifndef HEADER_COMPERR_H 12 | # define HEADER_COMPERR_H 13 | 14 | # ifndef HEADER_SYMHACKS_H 15 | # include 16 | # endif 17 | 18 | # include 19 | 20 | # ifndef OPENSSL_NO_COMP 21 | 22 | # ifdef __cplusplus 23 | extern "C" 24 | # endif 25 | int ERR_load_COMP_strings(void); 26 | 27 | /* 28 | * COMP function codes. 29 | */ 30 | # define COMP_F_BIO_ZLIB_FLUSH 99 31 | # define COMP_F_BIO_ZLIB_NEW 100 32 | # define COMP_F_BIO_ZLIB_READ 101 33 | # define COMP_F_BIO_ZLIB_WRITE 102 34 | # define COMP_F_COMP_CTX_NEW 103 35 | 36 | /* 37 | * COMP reason codes. 38 | */ 39 | # define COMP_R_ZLIB_DEFLATE_ERROR 99 40 | # define COMP_R_ZLIB_INFLATE_ERROR 100 41 | # define COMP_R_ZLIB_NOT_SUPPORTED 101 42 | 43 | # endif 44 | #endif 45 | -------------------------------------------------------------------------------- /deps/openssl-include/openssl/conf_api.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_CONF_API_H 11 | # define HEADER_CONF_API_H 12 | 13 | # include 14 | # include 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | /* Up until OpenSSL 0.9.5a, this was new_section */ 21 | CONF_VALUE *_CONF_new_section(CONF *conf, const char *section); 22 | /* Up until OpenSSL 0.9.5a, this was get_section */ 23 | CONF_VALUE *_CONF_get_section(const CONF *conf, const char *section); 24 | /* Up until OpenSSL 0.9.5a, this was CONF_get_section */ 25 | STACK_OF(CONF_VALUE) *_CONF_get_section_values(const CONF *conf, 26 | const char *section); 27 | 28 | int _CONF_add_string(CONF *conf, CONF_VALUE *section, CONF_VALUE *value); 29 | char *_CONF_get_string(const CONF *conf, const char *section, 30 | const char *name); 31 | long _CONF_get_number(const CONF *conf, const char *section, 32 | const char *name); 33 | 34 | int _CONF_new_data(CONF *conf); 35 | void _CONF_free_data(CONF *conf); 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | #endif 41 | -------------------------------------------------------------------------------- /deps/openssl-include/openssl/conferr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Generated by util/mkerr.pl DO NOT EDIT 3 | * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. 4 | * 5 | * Licensed under the OpenSSL license (the "License"). You may not use 6 | * this file except in compliance with the License. You can obtain a copy 7 | * in the file LICENSE in the source distribution or at 8 | * https://www.openssl.org/source/license.html 9 | */ 10 | 11 | #ifndef HEADER_CONFERR_H 12 | # define HEADER_CONFERR_H 13 | 14 | # ifndef HEADER_SYMHACKS_H 15 | # include 16 | # endif 17 | 18 | # ifdef __cplusplus 19 | extern "C" 20 | # endif 21 | int ERR_load_CONF_strings(void); 22 | 23 | /* 24 | * CONF function codes. 25 | */ 26 | # define CONF_F_CONF_DUMP_FP 104 27 | # define CONF_F_CONF_LOAD 100 28 | # define CONF_F_CONF_LOAD_FP 103 29 | # define CONF_F_CONF_PARSE_LIST 119 30 | # define CONF_F_DEF_LOAD 120 31 | # define CONF_F_DEF_LOAD_BIO 121 32 | # define CONF_F_GET_NEXT_FILE 107 33 | # define CONF_F_MODULE_ADD 122 34 | # define CONF_F_MODULE_INIT 115 35 | # define CONF_F_MODULE_LOAD_DSO 117 36 | # define CONF_F_MODULE_RUN 118 37 | # define CONF_F_NCONF_DUMP_BIO 105 38 | # define CONF_F_NCONF_DUMP_FP 106 39 | # define CONF_F_NCONF_GET_NUMBER_E 112 40 | # define CONF_F_NCONF_GET_SECTION 108 41 | # define CONF_F_NCONF_GET_STRING 109 42 | # define CONF_F_NCONF_LOAD 113 43 | # define CONF_F_NCONF_LOAD_BIO 110 44 | # define CONF_F_NCONF_LOAD_FP 114 45 | # define CONF_F_NCONF_NEW 111 46 | # define CONF_F_PROCESS_INCLUDE 116 47 | # define CONF_F_SSL_MODULE_INIT 123 48 | # define CONF_F_STR_COPY 101 49 | 50 | /* 51 | * CONF reason codes. 52 | */ 53 | # define CONF_R_ERROR_LOADING_DSO 110 54 | # define CONF_R_LIST_CANNOT_BE_NULL 115 55 | # define CONF_R_MISSING_CLOSE_SQUARE_BRACKET 100 56 | # define CONF_R_MISSING_EQUAL_SIGN 101 57 | # define CONF_R_MISSING_INIT_FUNCTION 112 58 | # define CONF_R_MODULE_INITIALIZATION_ERROR 109 59 | # define CONF_R_NO_CLOSE_BRACE 102 60 | # define CONF_R_NO_CONF 105 61 | # define CONF_R_NO_CONF_OR_ENVIRONMENT_VARIABLE 106 62 | # define CONF_R_NO_SECTION 107 63 | # define CONF_R_NO_SUCH_FILE 114 64 | # define CONF_R_NO_VALUE 108 65 | # define CONF_R_NUMBER_TOO_LARGE 121 66 | # define CONF_R_RECURSIVE_DIRECTORY_INCLUDE 111 67 | # define CONF_R_SSL_COMMAND_SECTION_EMPTY 117 68 | # define CONF_R_SSL_COMMAND_SECTION_NOT_FOUND 118 69 | # define CONF_R_SSL_SECTION_EMPTY 119 70 | # define CONF_R_SSL_SECTION_NOT_FOUND 120 71 | # define CONF_R_UNABLE_TO_CREATE_NEW_SECTION 103 72 | # define CONF_R_UNKNOWN_MODULE_NAME 113 73 | # define CONF_R_VARIABLE_EXPANSION_TOO_LONG 116 74 | # define CONF_R_VARIABLE_HAS_NO_VALUE 104 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /deps/openssl-include/openssl/cryptoerr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Generated by util/mkerr.pl DO NOT EDIT 3 | * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. 4 | * 5 | * Licensed under the OpenSSL license (the "License"). You may not use 6 | * this file except in compliance with the License. You can obtain a copy 7 | * in the file LICENSE in the source distribution or at 8 | * https://www.openssl.org/source/license.html 9 | */ 10 | 11 | #ifndef HEADER_CRYPTOERR_H 12 | # define HEADER_CRYPTOERR_H 13 | 14 | # ifndef HEADER_SYMHACKS_H 15 | # include 16 | # endif 17 | 18 | # ifdef __cplusplus 19 | extern "C" 20 | # endif 21 | int ERR_load_CRYPTO_strings(void); 22 | 23 | /* 24 | * CRYPTO function codes. 25 | */ 26 | # define CRYPTO_F_CMAC_CTX_NEW 120 27 | # define CRYPTO_F_CRYPTO_DUP_EX_DATA 110 28 | # define CRYPTO_F_CRYPTO_FREE_EX_DATA 111 29 | # define CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX 100 30 | # define CRYPTO_F_CRYPTO_MEMDUP 115 31 | # define CRYPTO_F_CRYPTO_NEW_EX_DATA 112 32 | # define CRYPTO_F_CRYPTO_OCB128_COPY_CTX 121 33 | # define CRYPTO_F_CRYPTO_OCB128_INIT 122 34 | # define CRYPTO_F_CRYPTO_SET_EX_DATA 102 35 | # define CRYPTO_F_FIPS_MODE_SET 109 36 | # define CRYPTO_F_GET_AND_LOCK 113 37 | # define CRYPTO_F_OPENSSL_ATEXIT 114 38 | # define CRYPTO_F_OPENSSL_BUF2HEXSTR 117 39 | # define CRYPTO_F_OPENSSL_FOPEN 119 40 | # define CRYPTO_F_OPENSSL_HEXSTR2BUF 118 41 | # define CRYPTO_F_OPENSSL_INIT_CRYPTO 116 42 | # define CRYPTO_F_OPENSSL_LH_NEW 126 43 | # define CRYPTO_F_OPENSSL_SK_DEEP_COPY 127 44 | # define CRYPTO_F_OPENSSL_SK_DUP 128 45 | # define CRYPTO_F_PKEY_HMAC_INIT 123 46 | # define CRYPTO_F_PKEY_POLY1305_INIT 124 47 | # define CRYPTO_F_PKEY_SIPHASH_INIT 125 48 | # define CRYPTO_F_SK_RESERVE 129 49 | 50 | /* 51 | * CRYPTO reason codes. 52 | */ 53 | # define CRYPTO_R_FIPS_MODE_NOT_SUPPORTED 101 54 | # define CRYPTO_R_ILLEGAL_HEX_DIGIT 102 55 | # define CRYPTO_R_ODD_NUMBER_OF_DIGITS 103 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /deps/openssl-include/openssl/cterr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Generated by util/mkerr.pl DO NOT EDIT 3 | * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. 4 | * 5 | * Licensed under the OpenSSL license (the "License"). You may not use 6 | * this file except in compliance with the License. You can obtain a copy 7 | * in the file LICENSE in the source distribution or at 8 | * https://www.openssl.org/source/license.html 9 | */ 10 | 11 | #ifndef HEADER_CTERR_H 12 | # define HEADER_CTERR_H 13 | 14 | # ifndef HEADER_SYMHACKS_H 15 | # include 16 | # endif 17 | 18 | # include 19 | 20 | # ifndef OPENSSL_NO_CT 21 | 22 | # ifdef __cplusplus 23 | extern "C" 24 | # endif 25 | int ERR_load_CT_strings(void); 26 | 27 | /* 28 | * CT function codes. 29 | */ 30 | # define CT_F_CTLOG_NEW 117 31 | # define CT_F_CTLOG_NEW_FROM_BASE64 118 32 | # define CT_F_CTLOG_NEW_FROM_CONF 119 33 | # define CT_F_CTLOG_STORE_LOAD_CTX_NEW 122 34 | # define CT_F_CTLOG_STORE_LOAD_FILE 123 35 | # define CT_F_CTLOG_STORE_LOAD_LOG 130 36 | # define CT_F_CTLOG_STORE_NEW 131 37 | # define CT_F_CT_BASE64_DECODE 124 38 | # define CT_F_CT_POLICY_EVAL_CTX_NEW 133 39 | # define CT_F_CT_V1_LOG_ID_FROM_PKEY 125 40 | # define CT_F_I2O_SCT 107 41 | # define CT_F_I2O_SCT_LIST 108 42 | # define CT_F_I2O_SCT_SIGNATURE 109 43 | # define CT_F_O2I_SCT 110 44 | # define CT_F_O2I_SCT_LIST 111 45 | # define CT_F_O2I_SCT_SIGNATURE 112 46 | # define CT_F_SCT_CTX_NEW 126 47 | # define CT_F_SCT_CTX_VERIFY 128 48 | # define CT_F_SCT_NEW 100 49 | # define CT_F_SCT_NEW_FROM_BASE64 127 50 | # define CT_F_SCT_SET0_LOG_ID 101 51 | # define CT_F_SCT_SET1_EXTENSIONS 114 52 | # define CT_F_SCT_SET1_LOG_ID 115 53 | # define CT_F_SCT_SET1_SIGNATURE 116 54 | # define CT_F_SCT_SET_LOG_ENTRY_TYPE 102 55 | # define CT_F_SCT_SET_SIGNATURE_NID 103 56 | # define CT_F_SCT_SET_VERSION 104 57 | 58 | /* 59 | * CT reason codes. 60 | */ 61 | # define CT_R_BASE64_DECODE_ERROR 108 62 | # define CT_R_INVALID_LOG_ID_LENGTH 100 63 | # define CT_R_LOG_CONF_INVALID 109 64 | # define CT_R_LOG_CONF_INVALID_KEY 110 65 | # define CT_R_LOG_CONF_MISSING_DESCRIPTION 111 66 | # define CT_R_LOG_CONF_MISSING_KEY 112 67 | # define CT_R_LOG_KEY_INVALID 113 68 | # define CT_R_SCT_FUTURE_TIMESTAMP 116 69 | # define CT_R_SCT_INVALID 104 70 | # define CT_R_SCT_INVALID_SIGNATURE 107 71 | # define CT_R_SCT_LIST_INVALID 105 72 | # define CT_R_SCT_LOG_ID_MISMATCH 114 73 | # define CT_R_SCT_NOT_SET 106 74 | # define CT_R_SCT_UNSUPPORTED_VERSION 115 75 | # define CT_R_UNRECOGNIZED_SIGNATURE_NID 101 76 | # define CT_R_UNSUPPORTED_ENTRY_TYPE 102 77 | # define CT_R_UNSUPPORTED_VERSION 103 78 | 79 | # endif 80 | #endif 81 | -------------------------------------------------------------------------------- /deps/openssl-include/openssl/dherr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Generated by util/mkerr.pl DO NOT EDIT 3 | * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. 4 | * 5 | * Licensed under the OpenSSL license (the "License"). You may not use 6 | * this file except in compliance with the License. You can obtain a copy 7 | * in the file LICENSE in the source distribution or at 8 | * https://www.openssl.org/source/license.html 9 | */ 10 | 11 | #ifndef HEADER_DHERR_H 12 | # define HEADER_DHERR_H 13 | 14 | # ifndef HEADER_SYMHACKS_H 15 | # include 16 | # endif 17 | 18 | # include 19 | 20 | # ifndef OPENSSL_NO_DH 21 | 22 | # ifdef __cplusplus 23 | extern "C" 24 | # endif 25 | int ERR_load_DH_strings(void); 26 | 27 | /* 28 | * DH function codes. 29 | */ 30 | # define DH_F_COMPUTE_KEY 102 31 | # define DH_F_DHPARAMS_PRINT_FP 101 32 | # define DH_F_DH_BUILTIN_GENPARAMS 106 33 | # define DH_F_DH_CHECK_EX 121 34 | # define DH_F_DH_CHECK_PARAMS_EX 122 35 | # define DH_F_DH_CHECK_PUB_KEY_EX 123 36 | # define DH_F_DH_CMS_DECRYPT 114 37 | # define DH_F_DH_CMS_SET_PEERKEY 115 38 | # define DH_F_DH_CMS_SET_SHARED_INFO 116 39 | # define DH_F_DH_METH_DUP 117 40 | # define DH_F_DH_METH_NEW 118 41 | # define DH_F_DH_METH_SET1_NAME 119 42 | # define DH_F_DH_NEW_BY_NID 104 43 | # define DH_F_DH_NEW_METHOD 105 44 | # define DH_F_DH_PARAM_DECODE 107 45 | # define DH_F_DH_PKEY_PUBLIC_CHECK 124 46 | # define DH_F_DH_PRIV_DECODE 110 47 | # define DH_F_DH_PRIV_ENCODE 111 48 | # define DH_F_DH_PUB_DECODE 108 49 | # define DH_F_DH_PUB_ENCODE 109 50 | # define DH_F_DO_DH_PRINT 100 51 | # define DH_F_GENERATE_KEY 103 52 | # define DH_F_PKEY_DH_CTRL_STR 120 53 | # define DH_F_PKEY_DH_DERIVE 112 54 | # define DH_F_PKEY_DH_INIT 125 55 | # define DH_F_PKEY_DH_KEYGEN 113 56 | 57 | /* 58 | * DH reason codes. 59 | */ 60 | # define DH_R_BAD_GENERATOR 101 61 | # define DH_R_BN_DECODE_ERROR 109 62 | # define DH_R_BN_ERROR 106 63 | # define DH_R_CHECK_INVALID_J_VALUE 115 64 | # define DH_R_CHECK_INVALID_Q_VALUE 116 65 | # define DH_R_CHECK_PUBKEY_INVALID 122 66 | # define DH_R_CHECK_PUBKEY_TOO_LARGE 123 67 | # define DH_R_CHECK_PUBKEY_TOO_SMALL 124 68 | # define DH_R_CHECK_P_NOT_PRIME 117 69 | # define DH_R_CHECK_P_NOT_SAFE_PRIME 118 70 | # define DH_R_CHECK_Q_NOT_PRIME 119 71 | # define DH_R_DECODE_ERROR 104 72 | # define DH_R_INVALID_PARAMETER_NAME 110 73 | # define DH_R_INVALID_PARAMETER_NID 114 74 | # define DH_R_INVALID_PUBKEY 102 75 | # define DH_R_KDF_PARAMETER_ERROR 112 76 | # define DH_R_KEYS_NOT_SET 108 77 | # define DH_R_MISSING_PUBKEY 125 78 | # define DH_R_MODULUS_TOO_LARGE 103 79 | # define DH_R_NOT_SUITABLE_GENERATOR 120 80 | # define DH_R_NO_PARAMETERS_SET 107 81 | # define DH_R_NO_PRIVATE_VALUE 100 82 | # define DH_R_PARAMETER_ENCODING_ERROR 105 83 | # define DH_R_PEER_KEY_ERROR 111 84 | # define DH_R_SHARED_INFO_ERROR 113 85 | # define DH_R_UNABLE_TO_CHECK_GENERATOR 121 86 | 87 | # endif 88 | #endif 89 | -------------------------------------------------------------------------------- /deps/openssl-include/openssl/dsaerr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Generated by util/mkerr.pl DO NOT EDIT 3 | * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. 4 | * 5 | * Licensed under the OpenSSL license (the "License"). You may not use 6 | * this file except in compliance with the License. You can obtain a copy 7 | * in the file LICENSE in the source distribution or at 8 | * https://www.openssl.org/source/license.html 9 | */ 10 | 11 | #ifndef HEADER_DSAERR_H 12 | # define HEADER_DSAERR_H 13 | 14 | # ifndef HEADER_SYMHACKS_H 15 | # include 16 | # endif 17 | 18 | # include 19 | 20 | # ifndef OPENSSL_NO_DSA 21 | 22 | # ifdef __cplusplus 23 | extern "C" 24 | # endif 25 | int ERR_load_DSA_strings(void); 26 | 27 | /* 28 | * DSA function codes. 29 | */ 30 | # define DSA_F_DSAPARAMS_PRINT 100 31 | # define DSA_F_DSAPARAMS_PRINT_FP 101 32 | # define DSA_F_DSA_BUILTIN_PARAMGEN 125 33 | # define DSA_F_DSA_BUILTIN_PARAMGEN2 126 34 | # define DSA_F_DSA_DO_SIGN 112 35 | # define DSA_F_DSA_DO_VERIFY 113 36 | # define DSA_F_DSA_METH_DUP 127 37 | # define DSA_F_DSA_METH_NEW 128 38 | # define DSA_F_DSA_METH_SET1_NAME 129 39 | # define DSA_F_DSA_NEW_METHOD 103 40 | # define DSA_F_DSA_PARAM_DECODE 119 41 | # define DSA_F_DSA_PRINT_FP 105 42 | # define DSA_F_DSA_PRIV_DECODE 115 43 | # define DSA_F_DSA_PRIV_ENCODE 116 44 | # define DSA_F_DSA_PUB_DECODE 117 45 | # define DSA_F_DSA_PUB_ENCODE 118 46 | # define DSA_F_DSA_SIGN 106 47 | # define DSA_F_DSA_SIGN_SETUP 107 48 | # define DSA_F_DSA_SIG_NEW 102 49 | # define DSA_F_OLD_DSA_PRIV_DECODE 122 50 | # define DSA_F_PKEY_DSA_CTRL 120 51 | # define DSA_F_PKEY_DSA_CTRL_STR 104 52 | # define DSA_F_PKEY_DSA_KEYGEN 121 53 | 54 | /* 55 | * DSA reason codes. 56 | */ 57 | # define DSA_R_BAD_Q_VALUE 102 58 | # define DSA_R_BN_DECODE_ERROR 108 59 | # define DSA_R_BN_ERROR 109 60 | # define DSA_R_DECODE_ERROR 104 61 | # define DSA_R_INVALID_DIGEST_TYPE 106 62 | # define DSA_R_INVALID_PARAMETERS 112 63 | # define DSA_R_MISSING_PARAMETERS 101 64 | # define DSA_R_MISSING_PRIVATE_KEY 111 65 | # define DSA_R_MODULUS_TOO_LARGE 103 66 | # define DSA_R_NO_PARAMETERS_SET 107 67 | # define DSA_R_PARAMETER_ENCODING_ERROR 105 68 | # define DSA_R_Q_NOT_PRIME 113 69 | # define DSA_R_SEED_LEN_SMALL 110 70 | 71 | # endif 72 | #endif 73 | -------------------------------------------------------------------------------- /deps/openssl-include/openssl/dtls1.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005-2018 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_DTLS1_H 11 | # define HEADER_DTLS1_H 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | # define DTLS1_VERSION 0xFEFF 18 | # define DTLS1_2_VERSION 0xFEFD 19 | # define DTLS_MIN_VERSION DTLS1_VERSION 20 | # define DTLS_MAX_VERSION DTLS1_2_VERSION 21 | # define DTLS1_VERSION_MAJOR 0xFE 22 | 23 | # define DTLS1_BAD_VER 0x0100 24 | 25 | /* Special value for method supporting multiple versions */ 26 | # define DTLS_ANY_VERSION 0x1FFFF 27 | 28 | /* lengths of messages */ 29 | /* 30 | * Actually the max cookie length in DTLS is 255. But we can't change this now 31 | * due to compatibility concerns. 32 | */ 33 | # define DTLS1_COOKIE_LENGTH 256 34 | 35 | # define DTLS1_RT_HEADER_LENGTH 13 36 | 37 | # define DTLS1_HM_HEADER_LENGTH 12 38 | 39 | # define DTLS1_HM_BAD_FRAGMENT -2 40 | # define DTLS1_HM_FRAGMENT_RETRY -3 41 | 42 | # define DTLS1_CCS_HEADER_LENGTH 1 43 | 44 | # define DTLS1_AL_HEADER_LENGTH 2 45 | 46 | /* Timeout multipliers */ 47 | # define DTLS1_TMO_READ_COUNT 2 48 | # define DTLS1_TMO_WRITE_COUNT 2 49 | 50 | # define DTLS1_TMO_ALERT_COUNT 12 51 | 52 | #ifdef __cplusplus 53 | } 54 | #endif 55 | #endif 56 | -------------------------------------------------------------------------------- /deps/openssl-include/openssl/ebcdic.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_EBCDIC_H 11 | # define HEADER_EBCDIC_H 12 | 13 | # include 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | /* Avoid name clashes with other applications */ 20 | # define os_toascii _openssl_os_toascii 21 | # define os_toebcdic _openssl_os_toebcdic 22 | # define ebcdic2ascii _openssl_ebcdic2ascii 23 | # define ascii2ebcdic _openssl_ascii2ebcdic 24 | 25 | extern const unsigned char os_toascii[256]; 26 | extern const unsigned char os_toebcdic[256]; 27 | void *ebcdic2ascii(void *dest, const void *srce, size_t count); 28 | void *ascii2ebcdic(void *dest, const void *srce, size_t count); 29 | 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | #endif 34 | -------------------------------------------------------------------------------- /deps/openssl-include/openssl/ecdh.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #include 11 | -------------------------------------------------------------------------------- /deps/openssl-include/openssl/ecdsa.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #include 11 | -------------------------------------------------------------------------------- /deps/openssl-include/openssl/hmac.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_HMAC_H 11 | # define HEADER_HMAC_H 12 | 13 | # include 14 | 15 | # include 16 | 17 | # if OPENSSL_API_COMPAT < 0x10200000L 18 | # define HMAC_MAX_MD_CBLOCK 128 /* Deprecated */ 19 | # endif 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | size_t HMAC_size(const HMAC_CTX *e); 26 | HMAC_CTX *HMAC_CTX_new(void); 27 | int HMAC_CTX_reset(HMAC_CTX *ctx); 28 | void HMAC_CTX_free(HMAC_CTX *ctx); 29 | 30 | DEPRECATEDIN_1_1_0(__owur int HMAC_Init(HMAC_CTX *ctx, const void *key, int len, 31 | const EVP_MD *md)) 32 | 33 | /*__owur*/ int HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len, 34 | const EVP_MD *md, ENGINE *impl); 35 | /*__owur*/ int HMAC_Update(HMAC_CTX *ctx, const unsigned char *data, 36 | size_t len); 37 | /*__owur*/ int HMAC_Final(HMAC_CTX *ctx, unsigned char *md, 38 | unsigned int *len); 39 | unsigned char *HMAC(const EVP_MD *evp_md, const void *key, int key_len, 40 | const unsigned char *d, size_t n, unsigned char *md, 41 | unsigned int *md_len); 42 | __owur int HMAC_CTX_copy(HMAC_CTX *dctx, HMAC_CTX *sctx); 43 | 44 | void HMAC_CTX_set_flags(HMAC_CTX *ctx, unsigned long flags); 45 | const EVP_MD *HMAC_CTX_get_md(const HMAC_CTX *ctx); 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /deps/openssl-include/openssl/idea.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_IDEA_H 11 | # define HEADER_IDEA_H 12 | 13 | # include 14 | 15 | # ifndef OPENSSL_NO_IDEA 16 | # ifdef __cplusplus 17 | extern "C" { 18 | # endif 19 | 20 | typedef unsigned int IDEA_INT; 21 | 22 | # define IDEA_ENCRYPT 1 23 | # define IDEA_DECRYPT 0 24 | 25 | # define IDEA_BLOCK 8 26 | # define IDEA_KEY_LENGTH 16 27 | 28 | typedef struct idea_key_st { 29 | IDEA_INT data[9][6]; 30 | } IDEA_KEY_SCHEDULE; 31 | 32 | const char *IDEA_options(void); 33 | void IDEA_ecb_encrypt(const unsigned char *in, unsigned char *out, 34 | IDEA_KEY_SCHEDULE *ks); 35 | void IDEA_set_encrypt_key(const unsigned char *key, IDEA_KEY_SCHEDULE *ks); 36 | void IDEA_set_decrypt_key(IDEA_KEY_SCHEDULE *ek, IDEA_KEY_SCHEDULE *dk); 37 | void IDEA_cbc_encrypt(const unsigned char *in, unsigned char *out, 38 | long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv, 39 | int enc); 40 | void IDEA_cfb64_encrypt(const unsigned char *in, unsigned char *out, 41 | long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv, 42 | int *num, int enc); 43 | void IDEA_ofb64_encrypt(const unsigned char *in, unsigned char *out, 44 | long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv, 45 | int *num); 46 | void IDEA_encrypt(unsigned long *in, IDEA_KEY_SCHEDULE *ks); 47 | 48 | # if OPENSSL_API_COMPAT < 0x10100000L 49 | # define idea_options IDEA_options 50 | # define idea_ecb_encrypt IDEA_ecb_encrypt 51 | # define idea_set_encrypt_key IDEA_set_encrypt_key 52 | # define idea_set_decrypt_key IDEA_set_decrypt_key 53 | # define idea_cbc_encrypt IDEA_cbc_encrypt 54 | # define idea_cfb64_encrypt IDEA_cfb64_encrypt 55 | # define idea_ofb64_encrypt IDEA_ofb64_encrypt 56 | # define idea_encrypt IDEA_encrypt 57 | # endif 58 | 59 | # ifdef __cplusplus 60 | } 61 | # endif 62 | # endif 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /deps/openssl-include/openssl/kdferr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Generated by util/mkerr.pl DO NOT EDIT 3 | * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. 4 | * 5 | * Licensed under the OpenSSL license (the "License"). You may not use 6 | * this file except in compliance with the License. You can obtain a copy 7 | * in the file LICENSE in the source distribution or at 8 | * https://www.openssl.org/source/license.html 9 | */ 10 | 11 | #ifndef HEADER_KDFERR_H 12 | # define HEADER_KDFERR_H 13 | 14 | # ifndef HEADER_SYMHACKS_H 15 | # include 16 | # endif 17 | 18 | # ifdef __cplusplus 19 | extern "C" 20 | # endif 21 | int ERR_load_KDF_strings(void); 22 | 23 | /* 24 | * KDF function codes. 25 | */ 26 | # define KDF_F_PKEY_HKDF_CTRL_STR 103 27 | # define KDF_F_PKEY_HKDF_DERIVE 102 28 | # define KDF_F_PKEY_HKDF_INIT 108 29 | # define KDF_F_PKEY_SCRYPT_CTRL_STR 104 30 | # define KDF_F_PKEY_SCRYPT_CTRL_UINT64 105 31 | # define KDF_F_PKEY_SCRYPT_DERIVE 109 32 | # define KDF_F_PKEY_SCRYPT_INIT 106 33 | # define KDF_F_PKEY_SCRYPT_SET_MEMBUF 107 34 | # define KDF_F_PKEY_TLS1_PRF_CTRL_STR 100 35 | # define KDF_F_PKEY_TLS1_PRF_DERIVE 101 36 | # define KDF_F_PKEY_TLS1_PRF_INIT 110 37 | # define KDF_F_TLS1_PRF_ALG 111 38 | 39 | /* 40 | * KDF reason codes. 41 | */ 42 | # define KDF_R_INVALID_DIGEST 100 43 | # define KDF_R_MISSING_ITERATION_COUNT 109 44 | # define KDF_R_MISSING_KEY 104 45 | # define KDF_R_MISSING_MESSAGE_DIGEST 105 46 | # define KDF_R_MISSING_PARAMETER 101 47 | # define KDF_R_MISSING_PASS 110 48 | # define KDF_R_MISSING_SALT 111 49 | # define KDF_R_MISSING_SECRET 107 50 | # define KDF_R_MISSING_SEED 106 51 | # define KDF_R_UNKNOWN_PARAMETER_TYPE 103 52 | # define KDF_R_VALUE_ERROR 108 53 | # define KDF_R_VALUE_MISSING 102 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /deps/openssl-include/openssl/md2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_MD2_H 11 | # define HEADER_MD2_H 12 | 13 | # include 14 | 15 | # ifndef OPENSSL_NO_MD2 16 | # include 17 | # ifdef __cplusplus 18 | extern "C" { 19 | # endif 20 | 21 | typedef unsigned char MD2_INT; 22 | 23 | # define MD2_DIGEST_LENGTH 16 24 | # define MD2_BLOCK 16 25 | 26 | typedef struct MD2state_st { 27 | unsigned int num; 28 | unsigned char data[MD2_BLOCK]; 29 | MD2_INT cksm[MD2_BLOCK]; 30 | MD2_INT state[MD2_BLOCK]; 31 | } MD2_CTX; 32 | 33 | const char *MD2_options(void); 34 | int MD2_Init(MD2_CTX *c); 35 | int MD2_Update(MD2_CTX *c, const unsigned char *data, size_t len); 36 | int MD2_Final(unsigned char *md, MD2_CTX *c); 37 | unsigned char *MD2(const unsigned char *d, size_t n, unsigned char *md); 38 | 39 | # ifdef __cplusplus 40 | } 41 | # endif 42 | # endif 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /deps/openssl-include/openssl/md4.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_MD4_H 11 | # define HEADER_MD4_H 12 | 13 | # include 14 | 15 | # ifndef OPENSSL_NO_MD4 16 | # include 17 | # include 18 | # ifdef __cplusplus 19 | extern "C" { 20 | # endif 21 | 22 | /*- 23 | * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 24 | * ! MD4_LONG has to be at least 32 bits wide. ! 25 | * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 26 | */ 27 | # define MD4_LONG unsigned int 28 | 29 | # define MD4_CBLOCK 64 30 | # define MD4_LBLOCK (MD4_CBLOCK/4) 31 | # define MD4_DIGEST_LENGTH 16 32 | 33 | typedef struct MD4state_st { 34 | MD4_LONG A, B, C, D; 35 | MD4_LONG Nl, Nh; 36 | MD4_LONG data[MD4_LBLOCK]; 37 | unsigned int num; 38 | } MD4_CTX; 39 | 40 | int MD4_Init(MD4_CTX *c); 41 | int MD4_Update(MD4_CTX *c, const void *data, size_t len); 42 | int MD4_Final(unsigned char *md, MD4_CTX *c); 43 | unsigned char *MD4(const unsigned char *d, size_t n, unsigned char *md); 44 | void MD4_Transform(MD4_CTX *c, const unsigned char *b); 45 | 46 | # ifdef __cplusplus 47 | } 48 | # endif 49 | # endif 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /deps/openssl-include/openssl/md5.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_MD5_H 11 | # define HEADER_MD5_H 12 | 13 | # include 14 | 15 | # ifndef OPENSSL_NO_MD5 16 | # include 17 | # include 18 | # ifdef __cplusplus 19 | extern "C" { 20 | # endif 21 | 22 | /* 23 | * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 24 | * ! MD5_LONG has to be at least 32 bits wide. ! 25 | * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 26 | */ 27 | # define MD5_LONG unsigned int 28 | 29 | # define MD5_CBLOCK 64 30 | # define MD5_LBLOCK (MD5_CBLOCK/4) 31 | # define MD5_DIGEST_LENGTH 16 32 | 33 | typedef struct MD5state_st { 34 | MD5_LONG A, B, C, D; 35 | MD5_LONG Nl, Nh; 36 | MD5_LONG data[MD5_LBLOCK]; 37 | unsigned int num; 38 | } MD5_CTX; 39 | 40 | int MD5_Init(MD5_CTX *c); 41 | int MD5_Update(MD5_CTX *c, const void *data, size_t len); 42 | int MD5_Final(unsigned char *md, MD5_CTX *c); 43 | unsigned char *MD5(const unsigned char *d, size_t n, unsigned char *md); 44 | void MD5_Transform(MD5_CTX *c, const unsigned char *b); 45 | # ifdef __cplusplus 46 | } 47 | # endif 48 | # endif 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /deps/openssl-include/openssl/mdc2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_MDC2_H 11 | # define HEADER_MDC2_H 12 | 13 | # include 14 | 15 | #ifndef OPENSSL_NO_MDC2 16 | # include 17 | # include 18 | # ifdef __cplusplus 19 | extern "C" { 20 | # endif 21 | 22 | # define MDC2_BLOCK 8 23 | # define MDC2_DIGEST_LENGTH 16 24 | 25 | typedef struct mdc2_ctx_st { 26 | unsigned int num; 27 | unsigned char data[MDC2_BLOCK]; 28 | DES_cblock h, hh; 29 | int pad_type; /* either 1 or 2, default 1 */ 30 | } MDC2_CTX; 31 | 32 | int MDC2_Init(MDC2_CTX *c); 33 | int MDC2_Update(MDC2_CTX *c, const unsigned char *data, size_t len); 34 | int MDC2_Final(unsigned char *md, MDC2_CTX *c); 35 | unsigned char *MDC2(const unsigned char *d, size_t n, unsigned char *md); 36 | 37 | # ifdef __cplusplus 38 | } 39 | # endif 40 | # endif 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /deps/openssl-include/openssl/objectserr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Generated by util/mkerr.pl DO NOT EDIT 3 | * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. 4 | * 5 | * Licensed under the OpenSSL license (the "License"). You may not use 6 | * this file except in compliance with the License. You can obtain a copy 7 | * in the file LICENSE in the source distribution or at 8 | * https://www.openssl.org/source/license.html 9 | */ 10 | 11 | #ifndef HEADER_OBJERR_H 12 | # define HEADER_OBJERR_H 13 | 14 | # ifndef HEADER_SYMHACKS_H 15 | # include 16 | # endif 17 | 18 | # ifdef __cplusplus 19 | extern "C" 20 | # endif 21 | int ERR_load_OBJ_strings(void); 22 | 23 | /* 24 | * OBJ function codes. 25 | */ 26 | # define OBJ_F_OBJ_ADD_OBJECT 105 27 | # define OBJ_F_OBJ_ADD_SIGID 107 28 | # define OBJ_F_OBJ_CREATE 100 29 | # define OBJ_F_OBJ_DUP 101 30 | # define OBJ_F_OBJ_NAME_NEW_INDEX 106 31 | # define OBJ_F_OBJ_NID2LN 102 32 | # define OBJ_F_OBJ_NID2OBJ 103 33 | # define OBJ_F_OBJ_NID2SN 104 34 | # define OBJ_F_OBJ_TXT2OBJ 108 35 | 36 | /* 37 | * OBJ reason codes. 38 | */ 39 | # define OBJ_R_OID_EXISTS 102 40 | # define OBJ_R_UNKNOWN_NID 101 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /deps/openssl-include/openssl/ocsperr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Generated by util/mkerr.pl DO NOT EDIT 3 | * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. 4 | * 5 | * Licensed under the OpenSSL license (the "License"). You may not use 6 | * this file except in compliance with the License. You can obtain a copy 7 | * in the file LICENSE in the source distribution or at 8 | * https://www.openssl.org/source/license.html 9 | */ 10 | 11 | #ifndef HEADER_OCSPERR_H 12 | # define HEADER_OCSPERR_H 13 | 14 | # ifndef HEADER_SYMHACKS_H 15 | # include 16 | # endif 17 | 18 | # include 19 | 20 | # ifndef OPENSSL_NO_OCSP 21 | 22 | # ifdef __cplusplus 23 | extern "C" 24 | # endif 25 | int ERR_load_OCSP_strings(void); 26 | 27 | /* 28 | * OCSP function codes. 29 | */ 30 | # define OCSP_F_D2I_OCSP_NONCE 102 31 | # define OCSP_F_OCSP_BASIC_ADD1_STATUS 103 32 | # define OCSP_F_OCSP_BASIC_SIGN 104 33 | # define OCSP_F_OCSP_BASIC_SIGN_CTX 119 34 | # define OCSP_F_OCSP_BASIC_VERIFY 105 35 | # define OCSP_F_OCSP_CERT_ID_NEW 101 36 | # define OCSP_F_OCSP_CHECK_DELEGATED 106 37 | # define OCSP_F_OCSP_CHECK_IDS 107 38 | # define OCSP_F_OCSP_CHECK_ISSUER 108 39 | # define OCSP_F_OCSP_CHECK_VALIDITY 115 40 | # define OCSP_F_OCSP_MATCH_ISSUERID 109 41 | # define OCSP_F_OCSP_PARSE_URL 114 42 | # define OCSP_F_OCSP_REQUEST_SIGN 110 43 | # define OCSP_F_OCSP_REQUEST_VERIFY 116 44 | # define OCSP_F_OCSP_RESPONSE_GET1_BASIC 111 45 | # define OCSP_F_PARSE_HTTP_LINE1 118 46 | 47 | /* 48 | * OCSP reason codes. 49 | */ 50 | # define OCSP_R_CERTIFICATE_VERIFY_ERROR 101 51 | # define OCSP_R_DIGEST_ERR 102 52 | # define OCSP_R_ERROR_IN_NEXTUPDATE_FIELD 122 53 | # define OCSP_R_ERROR_IN_THISUPDATE_FIELD 123 54 | # define OCSP_R_ERROR_PARSING_URL 121 55 | # define OCSP_R_MISSING_OCSPSIGNING_USAGE 103 56 | # define OCSP_R_NEXTUPDATE_BEFORE_THISUPDATE 124 57 | # define OCSP_R_NOT_BASIC_RESPONSE 104 58 | # define OCSP_R_NO_CERTIFICATES_IN_CHAIN 105 59 | # define OCSP_R_NO_RESPONSE_DATA 108 60 | # define OCSP_R_NO_REVOKED_TIME 109 61 | # define OCSP_R_NO_SIGNER_KEY 130 62 | # define OCSP_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE 110 63 | # define OCSP_R_REQUEST_NOT_SIGNED 128 64 | # define OCSP_R_RESPONSE_CONTAINS_NO_REVOCATION_DATA 111 65 | # define OCSP_R_ROOT_CA_NOT_TRUSTED 112 66 | # define OCSP_R_SERVER_RESPONSE_ERROR 114 67 | # define OCSP_R_SERVER_RESPONSE_PARSE_ERROR 115 68 | # define OCSP_R_SIGNATURE_FAILURE 117 69 | # define OCSP_R_SIGNER_CERTIFICATE_NOT_FOUND 118 70 | # define OCSP_R_STATUS_EXPIRED 125 71 | # define OCSP_R_STATUS_NOT_YET_VALID 126 72 | # define OCSP_R_STATUS_TOO_OLD 127 73 | # define OCSP_R_UNKNOWN_MESSAGE_DIGEST 119 74 | # define OCSP_R_UNKNOWN_NID 120 75 | # define OCSP_R_UNSUPPORTED_REQUESTORNAME_TYPE 129 76 | 77 | # endif 78 | #endif 79 | -------------------------------------------------------------------------------- /deps/openssl-include/openssl/pem2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2018 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_PEM2_H 11 | # define HEADER_PEM2_H 12 | # include 13 | #endif 14 | -------------------------------------------------------------------------------- /deps/openssl-include/openssl/pkcs12err.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Generated by util/mkerr.pl DO NOT EDIT 3 | * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. 4 | * 5 | * Licensed under the OpenSSL license (the "License"). You may not use 6 | * this file except in compliance with the License. You can obtain a copy 7 | * in the file LICENSE in the source distribution or at 8 | * https://www.openssl.org/source/license.html 9 | */ 10 | 11 | #ifndef HEADER_PKCS12ERR_H 12 | # define HEADER_PKCS12ERR_H 13 | 14 | # ifndef HEADER_SYMHACKS_H 15 | # include 16 | # endif 17 | 18 | # ifdef __cplusplus 19 | extern "C" 20 | # endif 21 | int ERR_load_PKCS12_strings(void); 22 | 23 | /* 24 | * PKCS12 function codes. 25 | */ 26 | # define PKCS12_F_OPENSSL_ASC2UNI 121 27 | # define PKCS12_F_OPENSSL_UNI2ASC 124 28 | # define PKCS12_F_OPENSSL_UNI2UTF8 127 29 | # define PKCS12_F_OPENSSL_UTF82UNI 129 30 | # define PKCS12_F_PKCS12_CREATE 105 31 | # define PKCS12_F_PKCS12_GEN_MAC 107 32 | # define PKCS12_F_PKCS12_INIT 109 33 | # define PKCS12_F_PKCS12_ITEM_DECRYPT_D2I 106 34 | # define PKCS12_F_PKCS12_ITEM_I2D_ENCRYPT 108 35 | # define PKCS12_F_PKCS12_ITEM_PACK_SAFEBAG 117 36 | # define PKCS12_F_PKCS12_KEY_GEN_ASC 110 37 | # define PKCS12_F_PKCS12_KEY_GEN_UNI 111 38 | # define PKCS12_F_PKCS12_KEY_GEN_UTF8 116 39 | # define PKCS12_F_PKCS12_NEWPASS 128 40 | # define PKCS12_F_PKCS12_PACK_P7DATA 114 41 | # define PKCS12_F_PKCS12_PACK_P7ENCDATA 115 42 | # define PKCS12_F_PKCS12_PARSE 118 43 | # define PKCS12_F_PKCS12_PBE_CRYPT 119 44 | # define PKCS12_F_PKCS12_PBE_KEYIVGEN 120 45 | # define PKCS12_F_PKCS12_SAFEBAG_CREATE0_P8INF 112 46 | # define PKCS12_F_PKCS12_SAFEBAG_CREATE0_PKCS8 113 47 | # define PKCS12_F_PKCS12_SAFEBAG_CREATE_PKCS8_ENCRYPT 133 48 | # define PKCS12_F_PKCS12_SETUP_MAC 122 49 | # define PKCS12_F_PKCS12_SET_MAC 123 50 | # define PKCS12_F_PKCS12_UNPACK_AUTHSAFES 130 51 | # define PKCS12_F_PKCS12_UNPACK_P7DATA 131 52 | # define PKCS12_F_PKCS12_VERIFY_MAC 126 53 | # define PKCS12_F_PKCS8_ENCRYPT 125 54 | # define PKCS12_F_PKCS8_SET0_PBE 132 55 | 56 | /* 57 | * PKCS12 reason codes. 58 | */ 59 | # define PKCS12_R_CANT_PACK_STRUCTURE 100 60 | # define PKCS12_R_CONTENT_TYPE_NOT_DATA 121 61 | # define PKCS12_R_DECODE_ERROR 101 62 | # define PKCS12_R_ENCODE_ERROR 102 63 | # define PKCS12_R_ENCRYPT_ERROR 103 64 | # define PKCS12_R_ERROR_SETTING_ENCRYPTED_DATA_TYPE 120 65 | # define PKCS12_R_INVALID_NULL_ARGUMENT 104 66 | # define PKCS12_R_INVALID_NULL_PKCS12_POINTER 105 67 | # define PKCS12_R_IV_GEN_ERROR 106 68 | # define PKCS12_R_KEY_GEN_ERROR 107 69 | # define PKCS12_R_MAC_ABSENT 108 70 | # define PKCS12_R_MAC_GENERATION_ERROR 109 71 | # define PKCS12_R_MAC_SETUP_ERROR 110 72 | # define PKCS12_R_MAC_STRING_SET_ERROR 111 73 | # define PKCS12_R_MAC_VERIFY_FAILURE 113 74 | # define PKCS12_R_PARSE_ERROR 114 75 | # define PKCS12_R_PKCS12_ALGOR_CIPHERINIT_ERROR 115 76 | # define PKCS12_R_PKCS12_CIPHERFINAL_ERROR 116 77 | # define PKCS12_R_PKCS12_PBE_CRYPT_ERROR 117 78 | # define PKCS12_R_UNKNOWN_DIGEST_ALGORITHM 118 79 | # define PKCS12_R_UNSUPPORTED_PKCS12_MODE 119 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /deps/openssl-include/openssl/rand.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_RAND_H 11 | # define HEADER_RAND_H 12 | 13 | # include 14 | # include 15 | # include 16 | # include 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | struct rand_meth_st { 23 | int (*seed) (const void *buf, int num); 24 | int (*bytes) (unsigned char *buf, int num); 25 | void (*cleanup) (void); 26 | int (*add) (const void *buf, int num, double randomness); 27 | int (*pseudorand) (unsigned char *buf, int num); 28 | int (*status) (void); 29 | }; 30 | 31 | int RAND_set_rand_method(const RAND_METHOD *meth); 32 | const RAND_METHOD *RAND_get_rand_method(void); 33 | # ifndef OPENSSL_NO_ENGINE 34 | int RAND_set_rand_engine(ENGINE *engine); 35 | # endif 36 | 37 | RAND_METHOD *RAND_OpenSSL(void); 38 | 39 | # if OPENSSL_API_COMPAT < 0x10100000L 40 | # define RAND_cleanup() while(0) continue 41 | # endif 42 | int RAND_bytes(unsigned char *buf, int num); 43 | int RAND_priv_bytes(unsigned char *buf, int num); 44 | DEPRECATEDIN_1_1_0(int RAND_pseudo_bytes(unsigned char *buf, int num)) 45 | 46 | void RAND_seed(const void *buf, int num); 47 | void RAND_keep_random_devices_open(int keep); 48 | 49 | # if defined(__ANDROID__) && defined(__NDK_FPABI__) 50 | __NDK_FPABI__ /* __attribute__((pcs("aapcs"))) on ARM */ 51 | # endif 52 | void RAND_add(const void *buf, int num, double randomness); 53 | int RAND_load_file(const char *file, long max_bytes); 54 | int RAND_write_file(const char *file); 55 | const char *RAND_file_name(char *file, size_t num); 56 | int RAND_status(void); 57 | 58 | # ifndef OPENSSL_NO_EGD 59 | int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes); 60 | int RAND_egd(const char *path); 61 | int RAND_egd_bytes(const char *path, int bytes); 62 | # endif 63 | 64 | int RAND_poll(void); 65 | 66 | # if defined(_WIN32) && (defined(BASETYPES) || defined(_WINDEF_H)) 67 | /* application has to include in order to use these */ 68 | DEPRECATEDIN_1_1_0(void RAND_screen(void)) 69 | DEPRECATEDIN_1_1_0(int RAND_event(UINT, WPARAM, LPARAM)) 70 | # endif 71 | 72 | 73 | #ifdef __cplusplus 74 | } 75 | #endif 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /deps/openssl-include/openssl/rc2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_RC2_H 11 | # define HEADER_RC2_H 12 | 13 | # include 14 | 15 | # ifndef OPENSSL_NO_RC2 16 | # ifdef __cplusplus 17 | extern "C" { 18 | # endif 19 | 20 | typedef unsigned int RC2_INT; 21 | 22 | # define RC2_ENCRYPT 1 23 | # define RC2_DECRYPT 0 24 | 25 | # define RC2_BLOCK 8 26 | # define RC2_KEY_LENGTH 16 27 | 28 | typedef struct rc2_key_st { 29 | RC2_INT data[64]; 30 | } RC2_KEY; 31 | 32 | void RC2_set_key(RC2_KEY *key, int len, const unsigned char *data, int bits); 33 | void RC2_ecb_encrypt(const unsigned char *in, unsigned char *out, 34 | RC2_KEY *key, int enc); 35 | void RC2_encrypt(unsigned long *data, RC2_KEY *key); 36 | void RC2_decrypt(unsigned long *data, RC2_KEY *key); 37 | void RC2_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, 38 | RC2_KEY *ks, unsigned char *iv, int enc); 39 | void RC2_cfb64_encrypt(const unsigned char *in, unsigned char *out, 40 | long length, RC2_KEY *schedule, unsigned char *ivec, 41 | int *num, int enc); 42 | void RC2_ofb64_encrypt(const unsigned char *in, unsigned char *out, 43 | long length, RC2_KEY *schedule, unsigned char *ivec, 44 | int *num); 45 | 46 | # ifdef __cplusplus 47 | } 48 | # endif 49 | # endif 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /deps/openssl-include/openssl/rc4.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_RC4_H 11 | # define HEADER_RC4_H 12 | 13 | # include 14 | 15 | # ifndef OPENSSL_NO_RC4 16 | # include 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | typedef struct rc4_key_st { 22 | RC4_INT x, y; 23 | RC4_INT data[256]; 24 | } RC4_KEY; 25 | 26 | const char *RC4_options(void); 27 | void RC4_set_key(RC4_KEY *key, int len, const unsigned char *data); 28 | void RC4(RC4_KEY *key, size_t len, const unsigned char *indata, 29 | unsigned char *outdata); 30 | 31 | # ifdef __cplusplus 32 | } 33 | # endif 34 | # endif 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /deps/openssl-include/openssl/rc5.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_RC5_H 11 | # define HEADER_RC5_H 12 | 13 | # include 14 | 15 | # ifndef OPENSSL_NO_RC5 16 | # ifdef __cplusplus 17 | extern "C" { 18 | # endif 19 | 20 | # define RC5_ENCRYPT 1 21 | # define RC5_DECRYPT 0 22 | 23 | # define RC5_32_INT unsigned int 24 | 25 | # define RC5_32_BLOCK 8 26 | # define RC5_32_KEY_LENGTH 16/* This is a default, max is 255 */ 27 | 28 | /* 29 | * This are the only values supported. Tweak the code if you want more The 30 | * most supported modes will be RC5-32/12/16 RC5-32/16/8 31 | */ 32 | # define RC5_8_ROUNDS 8 33 | # define RC5_12_ROUNDS 12 34 | # define RC5_16_ROUNDS 16 35 | 36 | typedef struct rc5_key_st { 37 | /* Number of rounds */ 38 | int rounds; 39 | RC5_32_INT data[2 * (RC5_16_ROUNDS + 1)]; 40 | } RC5_32_KEY; 41 | 42 | void RC5_32_set_key(RC5_32_KEY *key, int len, const unsigned char *data, 43 | int rounds); 44 | void RC5_32_ecb_encrypt(const unsigned char *in, unsigned char *out, 45 | RC5_32_KEY *key, int enc); 46 | void RC5_32_encrypt(unsigned long *data, RC5_32_KEY *key); 47 | void RC5_32_decrypt(unsigned long *data, RC5_32_KEY *key); 48 | void RC5_32_cbc_encrypt(const unsigned char *in, unsigned char *out, 49 | long length, RC5_32_KEY *ks, unsigned char *iv, 50 | int enc); 51 | void RC5_32_cfb64_encrypt(const unsigned char *in, unsigned char *out, 52 | long length, RC5_32_KEY *schedule, 53 | unsigned char *ivec, int *num, int enc); 54 | void RC5_32_ofb64_encrypt(const unsigned char *in, unsigned char *out, 55 | long length, RC5_32_KEY *schedule, 56 | unsigned char *ivec, int *num); 57 | 58 | # ifdef __cplusplus 59 | } 60 | # endif 61 | # endif 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /deps/openssl-include/openssl/ripemd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_RIPEMD_H 11 | # define HEADER_RIPEMD_H 12 | 13 | # include 14 | 15 | #ifndef OPENSSL_NO_RMD160 16 | # include 17 | # include 18 | # ifdef __cplusplus 19 | extern "C" { 20 | # endif 21 | 22 | # define RIPEMD160_LONG unsigned int 23 | 24 | # define RIPEMD160_CBLOCK 64 25 | # define RIPEMD160_LBLOCK (RIPEMD160_CBLOCK/4) 26 | # define RIPEMD160_DIGEST_LENGTH 20 27 | 28 | typedef struct RIPEMD160state_st { 29 | RIPEMD160_LONG A, B, C, D, E; 30 | RIPEMD160_LONG Nl, Nh; 31 | RIPEMD160_LONG data[RIPEMD160_LBLOCK]; 32 | unsigned int num; 33 | } RIPEMD160_CTX; 34 | 35 | int RIPEMD160_Init(RIPEMD160_CTX *c); 36 | int RIPEMD160_Update(RIPEMD160_CTX *c, const void *data, size_t len); 37 | int RIPEMD160_Final(unsigned char *md, RIPEMD160_CTX *c); 38 | unsigned char *RIPEMD160(const unsigned char *d, size_t n, unsigned char *md); 39 | void RIPEMD160_Transform(RIPEMD160_CTX *c, const unsigned char *b); 40 | 41 | # ifdef __cplusplus 42 | } 43 | # endif 44 | # endif 45 | 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /deps/openssl-include/openssl/seed.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | /* 11 | * Copyright (c) 2007 KISA(Korea Information Security Agency). All rights reserved. 12 | * 13 | * Redistribution and use in source and binary forms, with or without 14 | * modification, are permitted provided that the following conditions 15 | * are met: 16 | * 1. Redistributions of source code must retain the above copyright 17 | * notice, this list of conditions and the following disclaimer. 18 | * 2. Neither the name of author nor the names of its contributors may 19 | * be used to endorse or promote products derived from this software 20 | * without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND 23 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 | * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 | * SUCH DAMAGE. 33 | */ 34 | 35 | #ifndef HEADER_SEED_H 36 | # define HEADER_SEED_H 37 | 38 | # include 39 | 40 | # ifndef OPENSSL_NO_SEED 41 | # include 42 | # include 43 | 44 | #ifdef __cplusplus 45 | extern "C" { 46 | #endif 47 | 48 | /* look whether we need 'long' to get 32 bits */ 49 | # ifdef AES_LONG 50 | # ifndef SEED_LONG 51 | # define SEED_LONG 1 52 | # endif 53 | # endif 54 | 55 | # include 56 | 57 | # define SEED_BLOCK_SIZE 16 58 | # define SEED_KEY_LENGTH 16 59 | 60 | typedef struct seed_key_st { 61 | # ifdef SEED_LONG 62 | unsigned long data[32]; 63 | # else 64 | unsigned int data[32]; 65 | # endif 66 | } SEED_KEY_SCHEDULE; 67 | 68 | void SEED_set_key(const unsigned char rawkey[SEED_KEY_LENGTH], 69 | SEED_KEY_SCHEDULE *ks); 70 | 71 | void SEED_encrypt(const unsigned char s[SEED_BLOCK_SIZE], 72 | unsigned char d[SEED_BLOCK_SIZE], 73 | const SEED_KEY_SCHEDULE *ks); 74 | void SEED_decrypt(const unsigned char s[SEED_BLOCK_SIZE], 75 | unsigned char d[SEED_BLOCK_SIZE], 76 | const SEED_KEY_SCHEDULE *ks); 77 | 78 | void SEED_ecb_encrypt(const unsigned char *in, unsigned char *out, 79 | const SEED_KEY_SCHEDULE *ks, int enc); 80 | void SEED_cbc_encrypt(const unsigned char *in, unsigned char *out, size_t len, 81 | const SEED_KEY_SCHEDULE *ks, 82 | unsigned char ivec[SEED_BLOCK_SIZE], int enc); 83 | void SEED_cfb128_encrypt(const unsigned char *in, unsigned char *out, 84 | size_t len, const SEED_KEY_SCHEDULE *ks, 85 | unsigned char ivec[SEED_BLOCK_SIZE], int *num, 86 | int enc); 87 | void SEED_ofb128_encrypt(const unsigned char *in, unsigned char *out, 88 | size_t len, const SEED_KEY_SCHEDULE *ks, 89 | unsigned char ivec[SEED_BLOCK_SIZE], int *num); 90 | 91 | # ifdef __cplusplus 92 | } 93 | # endif 94 | # endif 95 | 96 | #endif 97 | -------------------------------------------------------------------------------- /deps/openssl-include/openssl/srtp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | /* 11 | * DTLS code by Eric Rescorla 12 | * 13 | * Copyright (C) 2006, Network Resonance, Inc. Copyright (C) 2011, RTFM, Inc. 14 | */ 15 | 16 | #ifndef HEADER_D1_SRTP_H 17 | # define HEADER_D1_SRTP_H 18 | 19 | # include 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | # define SRTP_AES128_CM_SHA1_80 0x0001 26 | # define SRTP_AES128_CM_SHA1_32 0x0002 27 | # define SRTP_AES128_F8_SHA1_80 0x0003 28 | # define SRTP_AES128_F8_SHA1_32 0x0004 29 | # define SRTP_NULL_SHA1_80 0x0005 30 | # define SRTP_NULL_SHA1_32 0x0006 31 | 32 | /* AEAD SRTP protection profiles from RFC 7714 */ 33 | # define SRTP_AEAD_AES_128_GCM 0x0007 34 | # define SRTP_AEAD_AES_256_GCM 0x0008 35 | 36 | # ifndef OPENSSL_NO_SRTP 37 | 38 | __owur int SSL_CTX_set_tlsext_use_srtp(SSL_CTX *ctx, const char *profiles); 39 | __owur int SSL_set_tlsext_use_srtp(SSL *ssl, const char *profiles); 40 | 41 | __owur STACK_OF(SRTP_PROTECTION_PROFILE) *SSL_get_srtp_profiles(SSL *ssl); 42 | __owur SRTP_PROTECTION_PROFILE *SSL_get_selected_srtp_profile(SSL *s); 43 | 44 | # endif 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /deps/openssl-include/openssl/ssl2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_SSL2_H 11 | # define HEADER_SSL2_H 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | # define SSL2_VERSION 0x0002 18 | 19 | # define SSL2_MT_CLIENT_HELLO 1 20 | 21 | #ifdef __cplusplus 22 | } 23 | #endif 24 | #endif 25 | -------------------------------------------------------------------------------- /deps/openssl-include/openssl/stack.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_STACK_H 11 | # define HEADER_STACK_H 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | typedef struct stack_st OPENSSL_STACK; /* Use STACK_OF(...) instead */ 18 | 19 | typedef int (*OPENSSL_sk_compfunc)(const void *, const void *); 20 | typedef void (*OPENSSL_sk_freefunc)(void *); 21 | typedef void *(*OPENSSL_sk_copyfunc)(const void *); 22 | 23 | int OPENSSL_sk_num(const OPENSSL_STACK *); 24 | void *OPENSSL_sk_value(const OPENSSL_STACK *, int); 25 | 26 | void *OPENSSL_sk_set(OPENSSL_STACK *st, int i, const void *data); 27 | 28 | OPENSSL_STACK *OPENSSL_sk_new(OPENSSL_sk_compfunc cmp); 29 | OPENSSL_STACK *OPENSSL_sk_new_null(void); 30 | OPENSSL_STACK *OPENSSL_sk_new_reserve(OPENSSL_sk_compfunc c, int n); 31 | int OPENSSL_sk_reserve(OPENSSL_STACK *st, int n); 32 | void OPENSSL_sk_free(OPENSSL_STACK *); 33 | void OPENSSL_sk_pop_free(OPENSSL_STACK *st, void (*func) (void *)); 34 | OPENSSL_STACK *OPENSSL_sk_deep_copy(const OPENSSL_STACK *, 35 | OPENSSL_sk_copyfunc c, 36 | OPENSSL_sk_freefunc f); 37 | int OPENSSL_sk_insert(OPENSSL_STACK *sk, const void *data, int where); 38 | void *OPENSSL_sk_delete(OPENSSL_STACK *st, int loc); 39 | void *OPENSSL_sk_delete_ptr(OPENSSL_STACK *st, const void *p); 40 | int OPENSSL_sk_find(OPENSSL_STACK *st, const void *data); 41 | int OPENSSL_sk_find_ex(OPENSSL_STACK *st, const void *data); 42 | int OPENSSL_sk_push(OPENSSL_STACK *st, const void *data); 43 | int OPENSSL_sk_unshift(OPENSSL_STACK *st, const void *data); 44 | void *OPENSSL_sk_shift(OPENSSL_STACK *st); 45 | void *OPENSSL_sk_pop(OPENSSL_STACK *st); 46 | void OPENSSL_sk_zero(OPENSSL_STACK *st); 47 | OPENSSL_sk_compfunc OPENSSL_sk_set_cmp_func(OPENSSL_STACK *sk, 48 | OPENSSL_sk_compfunc cmp); 49 | OPENSSL_STACK *OPENSSL_sk_dup(const OPENSSL_STACK *st); 50 | void OPENSSL_sk_sort(OPENSSL_STACK *st); 51 | int OPENSSL_sk_is_sorted(const OPENSSL_STACK *st); 52 | 53 | # if OPENSSL_API_COMPAT < 0x10100000L 54 | # define _STACK OPENSSL_STACK 55 | # define sk_num OPENSSL_sk_num 56 | # define sk_value OPENSSL_sk_value 57 | # define sk_set OPENSSL_sk_set 58 | # define sk_new OPENSSL_sk_new 59 | # define sk_new_null OPENSSL_sk_new_null 60 | # define sk_free OPENSSL_sk_free 61 | # define sk_pop_free OPENSSL_sk_pop_free 62 | # define sk_deep_copy OPENSSL_sk_deep_copy 63 | # define sk_insert OPENSSL_sk_insert 64 | # define sk_delete OPENSSL_sk_delete 65 | # define sk_delete_ptr OPENSSL_sk_delete_ptr 66 | # define sk_find OPENSSL_sk_find 67 | # define sk_find_ex OPENSSL_sk_find_ex 68 | # define sk_push OPENSSL_sk_push 69 | # define sk_unshift OPENSSL_sk_unshift 70 | # define sk_shift OPENSSL_sk_shift 71 | # define sk_pop OPENSSL_sk_pop 72 | # define sk_zero OPENSSL_sk_zero 73 | # define sk_set_cmp_func OPENSSL_sk_set_cmp_func 74 | # define sk_dup OPENSSL_sk_dup 75 | # define sk_sort OPENSSL_sk_sort 76 | # define sk_is_sorted OPENSSL_sk_is_sorted 77 | # endif 78 | 79 | #ifdef __cplusplus 80 | } 81 | #endif 82 | 83 | #endif 84 | -------------------------------------------------------------------------------- /deps/openssl-include/openssl/symhacks.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2018 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_SYMHACKS_H 11 | # define HEADER_SYMHACKS_H 12 | 13 | # include 14 | 15 | /* Case insensitive linking causes problems.... */ 16 | # if defined(OPENSSL_SYS_VMS) 17 | # undef ERR_load_CRYPTO_strings 18 | # define ERR_load_CRYPTO_strings ERR_load_CRYPTOlib_strings 19 | # undef OCSP_crlID_new 20 | # define OCSP_crlID_new OCSP_crlID2_new 21 | 22 | # undef d2i_ECPARAMETERS 23 | # define d2i_ECPARAMETERS d2i_UC_ECPARAMETERS 24 | # undef i2d_ECPARAMETERS 25 | # define i2d_ECPARAMETERS i2d_UC_ECPARAMETERS 26 | # undef d2i_ECPKPARAMETERS 27 | # define d2i_ECPKPARAMETERS d2i_UC_ECPKPARAMETERS 28 | # undef i2d_ECPKPARAMETERS 29 | # define i2d_ECPKPARAMETERS i2d_UC_ECPKPARAMETERS 30 | 31 | /* This one clashes with CMS_data_create */ 32 | # undef cms_Data_create 33 | # define cms_Data_create priv_cms_Data_create 34 | 35 | # endif 36 | 37 | #endif /* ! defined HEADER_VMS_IDHACKS_H */ 38 | -------------------------------------------------------------------------------- /deps/openssl-include/openssl/txt_db.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_TXT_DB_H 11 | # define HEADER_TXT_DB_H 12 | 13 | # include 14 | # include 15 | # include 16 | # include 17 | 18 | # define DB_ERROR_OK 0 19 | # define DB_ERROR_MALLOC 1 20 | # define DB_ERROR_INDEX_CLASH 2 21 | # define DB_ERROR_INDEX_OUT_OF_RANGE 3 22 | # define DB_ERROR_NO_INDEX 4 23 | # define DB_ERROR_INSERT_INDEX_CLASH 5 24 | # define DB_ERROR_WRONG_NUM_FIELDS 6 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | typedef OPENSSL_STRING *OPENSSL_PSTRING; 31 | DEFINE_SPECIAL_STACK_OF(OPENSSL_PSTRING, OPENSSL_STRING) 32 | 33 | typedef struct txt_db_st { 34 | int num_fields; 35 | STACK_OF(OPENSSL_PSTRING) *data; 36 | LHASH_OF(OPENSSL_STRING) **index; 37 | int (**qual) (OPENSSL_STRING *); 38 | long error; 39 | long arg1; 40 | long arg2; 41 | OPENSSL_STRING *arg_row; 42 | } TXT_DB; 43 | 44 | TXT_DB *TXT_DB_read(BIO *in, int num); 45 | long TXT_DB_write(BIO *out, TXT_DB *db); 46 | int TXT_DB_create_index(TXT_DB *db, int field, int (*qual) (OPENSSL_STRING *), 47 | OPENSSL_LH_HASHFUNC hash, OPENSSL_LH_COMPFUNC cmp); 48 | void TXT_DB_free(TXT_DB *db); 49 | OPENSSL_STRING *TXT_DB_get_by_index(TXT_DB *db, int idx, 50 | OPENSSL_STRING *value); 51 | int TXT_DB_insert(TXT_DB *db, OPENSSL_STRING *value); 52 | 53 | #ifdef __cplusplus 54 | } 55 | #endif 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /deps/openssl-include/openssl/uierr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Generated by util/mkerr.pl DO NOT EDIT 3 | * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. 4 | * 5 | * Licensed under the OpenSSL license (the "License"). You may not use 6 | * this file except in compliance with the License. You can obtain a copy 7 | * in the file LICENSE in the source distribution or at 8 | * https://www.openssl.org/source/license.html 9 | */ 10 | 11 | #ifndef HEADER_UIERR_H 12 | # define HEADER_UIERR_H 13 | 14 | # ifndef HEADER_SYMHACKS_H 15 | # include 16 | # endif 17 | 18 | # ifdef __cplusplus 19 | extern "C" 20 | # endif 21 | int ERR_load_UI_strings(void); 22 | 23 | /* 24 | * UI function codes. 25 | */ 26 | # define UI_F_CLOSE_CONSOLE 115 27 | # define UI_F_ECHO_CONSOLE 116 28 | # define UI_F_GENERAL_ALLOCATE_BOOLEAN 108 29 | # define UI_F_GENERAL_ALLOCATE_PROMPT 109 30 | # define UI_F_NOECHO_CONSOLE 117 31 | # define UI_F_OPEN_CONSOLE 114 32 | # define UI_F_UI_CONSTRUCT_PROMPT 121 33 | # define UI_F_UI_CREATE_METHOD 112 34 | # define UI_F_UI_CTRL 111 35 | # define UI_F_UI_DUP_ERROR_STRING 101 36 | # define UI_F_UI_DUP_INFO_STRING 102 37 | # define UI_F_UI_DUP_INPUT_BOOLEAN 110 38 | # define UI_F_UI_DUP_INPUT_STRING 103 39 | # define UI_F_UI_DUP_USER_DATA 118 40 | # define UI_F_UI_DUP_VERIFY_STRING 106 41 | # define UI_F_UI_GET0_RESULT 107 42 | # define UI_F_UI_GET_RESULT_LENGTH 119 43 | # define UI_F_UI_NEW_METHOD 104 44 | # define UI_F_UI_PROCESS 113 45 | # define UI_F_UI_SET_RESULT 105 46 | # define UI_F_UI_SET_RESULT_EX 120 47 | 48 | /* 49 | * UI reason codes. 50 | */ 51 | # define UI_R_COMMON_OK_AND_CANCEL_CHARACTERS 104 52 | # define UI_R_INDEX_TOO_LARGE 102 53 | # define UI_R_INDEX_TOO_SMALL 103 54 | # define UI_R_NO_RESULT_BUFFER 105 55 | # define UI_R_PROCESSING_ERROR 107 56 | # define UI_R_RESULT_TOO_LARGE 100 57 | # define UI_R_RESULT_TOO_SMALL 101 58 | # define UI_R_SYSASSIGN_ERROR 109 59 | # define UI_R_SYSDASSGN_ERROR 110 60 | # define UI_R_SYSQIOW_ERROR 111 61 | # define UI_R_UNKNOWN_CONTROL_COMMAND 106 62 | # define UI_R_UNKNOWN_TTYGET_ERRNO_VALUE 108 63 | # define UI_R_USER_DATA_DUPLICATION_UNSUPPORTED 112 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /deps/openssl-include/openssl/whrlpool.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_WHRLPOOL_H 11 | # define HEADER_WHRLPOOL_H 12 | 13 | #include 14 | 15 | # ifndef OPENSSL_NO_WHIRLPOOL 16 | # include 17 | # include 18 | # ifdef __cplusplus 19 | extern "C" { 20 | # endif 21 | 22 | # define WHIRLPOOL_DIGEST_LENGTH (512/8) 23 | # define WHIRLPOOL_BBLOCK 512 24 | # define WHIRLPOOL_COUNTER (256/8) 25 | 26 | typedef struct { 27 | union { 28 | unsigned char c[WHIRLPOOL_DIGEST_LENGTH]; 29 | /* double q is here to ensure 64-bit alignment */ 30 | double q[WHIRLPOOL_DIGEST_LENGTH / sizeof(double)]; 31 | } H; 32 | unsigned char data[WHIRLPOOL_BBLOCK / 8]; 33 | unsigned int bitoff; 34 | size_t bitlen[WHIRLPOOL_COUNTER / sizeof(size_t)]; 35 | } WHIRLPOOL_CTX; 36 | 37 | int WHIRLPOOL_Init(WHIRLPOOL_CTX *c); 38 | int WHIRLPOOL_Update(WHIRLPOOL_CTX *c, const void *inp, size_t bytes); 39 | void WHIRLPOOL_BitUpdate(WHIRLPOOL_CTX *c, const void *inp, size_t bits); 40 | int WHIRLPOOL_Final(unsigned char *md, WHIRLPOOL_CTX *c); 41 | unsigned char *WHIRLPOOL(const void *inp, size_t bytes, unsigned char *md); 42 | 43 | # ifdef __cplusplus 44 | } 45 | # endif 46 | # endif 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /deps/openssl-macos/README.md: -------------------------------------------------------------------------------- 1 | 2 | OpenSSL 1.1.1l, built for arm64 and x86_64 3 | 4 | Source: https://github.com/krzyzanowskim/OpenSSL/tree/23d8b94ae16d668b2916be1fdade7de375c6ccb0/macosx/lib 5 | -------------------------------------------------------------------------------- /deps/openssl-macos/libcrypto.a: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:d940dfd0a7428122ccfd74117af4ab00c5d663d14b34d8a7eeffca2a4bbed0c2 3 | size 7378168 4 | -------------------------------------------------------------------------------- /deps/openssl-macos/libssl.a: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:e323e3457e7c3428ce8345df75b635a2dcfcd4da9ff5d9b8a085a6bb040b1cfc 3 | size 1560232 4 | -------------------------------------------------------------------------------- /deps/openssl-windows.bat: -------------------------------------------------------------------------------- 1 | call git clone https://github.com/microsoft/vcpkg vcpkg 2 | call .\vcpkg\bootstrap-vcpkg.bat 3 | 4 | .\vcpkg\vcpkg install openssl:x64-windows-static 5 | if %errorlevel% neq 0 exit /b %errorlevel% 6 | .\vcpkg\vcpkg install openssl:x86-windows-static 7 | if %errorlevel% neq 0 exit /b %errorlevel% 8 | .\vcpkg\vcpkg install openssl:arm64-windows-static 9 | if %errorlevel% neq 0 exit /b %errorlevel% 10 | 11 | if not exist .\OpenSSL-Win32 mkdir .\OpenSSL-Win32 12 | if not exist .\OpenSSL-Win64 mkdir .\OpenSSL-Win64 13 | if not exist .\OpenSSL-Win64-ARM mkdir .\OpenSSL-Win64-ARM 14 | if not exist .\openssl-include mkdir .\openssl-include 15 | 16 | copy .\vcpkg\installed\x64-windows-static\lib\*.* .\OpenSSL-Win64 17 | copy .\vcpkg\installed\x64-windows-static\include\openssl\*.* .\openssl-include\openssl 18 | copy .\vcpkg\installed\x86-windows-static\lib\*.* .\OpenSSL-Win32 19 | copy .\vcpkg\installed\arm64-windows-static\lib\*.* .\OpenSSL-Win64-ARM 20 | -------------------------------------------------------------------------------- /deps/sqlcipher-amalgamation/VERSION.txt: -------------------------------------------------------------------------------- 1 | 3.33.0 2 | -------------------------------------------------------------------------------- /deps/sqlite3.gyp: -------------------------------------------------------------------------------- 1 | { 2 | 'includes': [ 'common-sqlite.gypi' ], 3 | 4 | 'target_defaults': { 5 | 'default_configuration': 'Release', 6 | 'cflags':[ 7 | '-std=c99' 8 | ], 9 | 'configurations': { 10 | 'Debug': { 11 | 'defines': [ 'DEBUG', '_DEBUG' ], 12 | 'msvs_settings': { 13 | 'VCCLCompilerTool': { 14 | 'RuntimeLibrary': 1, # static debug 15 | }, 16 | }, 17 | }, 18 | 'Release': { 19 | 'defines': [ 'NDEBUG' ], 20 | 'msvs_settings': { 21 | 'VCCLCompilerTool': { 22 | 'RuntimeLibrary': 0, # static release 23 | }, 24 | }, 25 | } 26 | }, 27 | 'msvs_settings': { 28 | 'VCCLCompilerTool': { 29 | }, 30 | 'VCLibrarianTool': { 31 | }, 32 | 'VCLinkerTool': { 33 | 'GenerateDebugInformation': 'true', 34 | }, 35 | }, 36 | 'conditions': [ 37 | ['OS == "win"', { 38 | 'defines': [ 39 | 'WIN32' 40 | ], 41 | 'conditions': [ 42 | ['target_arch == "ia32"', { 43 | 'variables': { 44 | 'openssl_root%': 'OpenSSL-Win32', 45 | } 46 | }, 'target_arch == "arm64"', { 47 | 'variables': { 48 | 'openssl_root%': 'OpenSSL-Win64-ARM', 49 | } 50 | }, { 51 | 'variables': { 52 | 'openssl_root%': 'OpenSSL-Win64', 53 | } 54 | }] 55 | ], 56 | 'link_settings': { 57 | 'libraries': [ 58 | '-llibcrypto.lib', 59 | '-llibssl.lib', 60 | # The two libs below are needed for the Electron build to succeed 61 | '-lws2_32.lib', 62 | '-lcrypt32.lib' 63 | ], 64 | 'library_dirs': [ 65 | '<(module_root_dir)/deps/<(openssl_root)' 66 | ] 67 | } 68 | }, 69 | 'OS == "mac"', { 70 | 'link_settings': { 71 | 'libraries': [ 72 | # This statically links libcrypto, whereas -lcrypto would dynamically link it 73 | '<(module_root_dir)/deps/openssl-macos/libcrypto.a' 74 | ] 75 | } 76 | }, 77 | { # Linux 78 | 'link_settings': { 79 | 'libraries': [ 80 | '-lcrypto' 81 | ] 82 | } 83 | }] 84 | ], 85 | }, 86 | 87 | 'targets': [ 88 | { 89 | 'target_name': 'sqlite3', 90 | 'type': 'static_library', 91 | "conditions": [ 92 | ["OS == \"win\"", { 93 | 'include_dirs': [ 94 | './sqlcipher-amalgamation/', 95 | './openssl-include/' 96 | ] 97 | }, 98 | "OS == \"mac\"", { 99 | 'include_dirs': [ 100 | './sqlcipher-amalgamation/', 101 | './openssl-include/' 102 | ] 103 | }, 104 | { # linux 105 | 'include_dirs': [ 106 | './sqlcipher-amalgamation/' 107 | ] 108 | }] 109 | ], 110 | 'sources': [ 111 | './sqlcipher-amalgamation/sqlite3.c' 112 | ], 113 | 'direct_dependent_settings': { 114 | 'include_dirs': [ 115 | './sqlcipher-amalgamation/' 116 | ], 117 | 'defines': [ 118 | 'SQLITE_THREADSAFE=1', 119 | 'HAVE_USLEEP=1', 120 | 'SQLITE_ENABLE_FTS3', 121 | 'SQLITE_ENABLE_FTS5', 122 | 'SQLITE_ENABLE_JSON1', 123 | 'SQLITE_ENABLE_RTREE', 124 | 'SQLITE_HAS_CODEC', 125 | 'SQLITE_TEMP_STORE=2', 126 | 'SQLITE_SECURE_DELETE', 127 | 'SQLITE_ENABLE_DBSTAT_VTAB=1' 128 | ], 129 | }, 130 | 'cflags_cc': [ 131 | '-Wno-unused-value' 132 | ], 133 | 'defines': [ 134 | '_REENTRANT=1', 135 | 'SQLITE_THREADSAFE=1', 136 | 'HAVE_USLEEP=1', 137 | 'SQLITE_ENABLE_FTS3', 138 | 'SQLITE_ENABLE_FTS5', 139 | 'SQLITE_ENABLE_JSON1', 140 | 'SQLITE_ENABLE_RTREE', 141 | 'SQLITE_HAS_CODEC', 142 | 'SQLITE_TEMP_STORE=2', 143 | 'SQLITE_SECURE_DELETE', 144 | 'SQLITE_ENABLE_DBSTAT_VTAB=1' 145 | ] 146 | } 147 | ] 148 | } 149 | -------------------------------------------------------------------------------- /examples/simple-chaining.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Shows how to use chaining rather than the `serialize` method. 3 | */ 4 | "use strict"; 5 | 6 | var sqlite3 = require('sqlite3').verbose(); 7 | var db; 8 | 9 | function createDb() { 10 | console.log("createDb chain"); 11 | db = new sqlite3.Database('chain.sqlite3', createTable); 12 | } 13 | 14 | 15 | function createTable() { 16 | console.log("createTable lorem"); 17 | db.run("CREATE TABLE IF NOT EXISTS lorem (info TEXT)", insertRows); 18 | } 19 | 20 | function insertRows() { 21 | console.log("insertRows Ipsum i"); 22 | var stmt = db.prepare("INSERT INTO lorem VALUES (?)"); 23 | 24 | for (var i = 0; i < 10; i++) { 25 | stmt.run("Ipsum " + i); 26 | } 27 | 28 | stmt.finalize(readAllRows); 29 | } 30 | 31 | function readAllRows() { 32 | console.log("readAllRows lorem"); 33 | db.all("SELECT rowid AS id, info FROM lorem", function(err, rows) { 34 | rows.forEach(function (row) { 35 | console.log(row.id + ": " + row.info); 36 | }); 37 | closeDb(); 38 | }); 39 | } 40 | 41 | function closeDb() { 42 | console.log("closeDb"); 43 | db.close(); 44 | } 45 | 46 | function runChainExample() { 47 | createDb(); 48 | } 49 | 50 | runChainExample(); 51 | -------------------------------------------------------------------------------- /lib/index.js: -------------------------------------------------------------------------------- 1 | module.exports = require('./sqlite3'); 2 | -------------------------------------------------------------------------------- /lib/sqlite3-binding.js: -------------------------------------------------------------------------------- 1 | var binary = require('@mapbox/node-pre-gyp'); 2 | var path = require('path'); 3 | var binding_path = binary.find(path.resolve(path.join(__dirname,'../package.json'))); 4 | var binding = require(binding_path); 5 | module.exports = exports = binding; 6 | -------------------------------------------------------------------------------- /lib/trace.js: -------------------------------------------------------------------------------- 1 | // Inspired by https://github.com/tlrobinson/long-stack-traces 2 | var util = require('util'); 3 | 4 | function extendTrace(object, property, pos) { 5 | var old = object[property]; 6 | object[property] = function() { 7 | var error = new Error(); 8 | var name = object.constructor.name + '#' + property + '(' + 9 | Array.prototype.slice.call(arguments).map(function(el) { 10 | return util.inspect(el, false, 0); 11 | }).join(', ') + ')'; 12 | 13 | if (typeof pos === 'undefined') pos = -1; 14 | if (pos < 0) pos += arguments.length; 15 | var cb = arguments[pos]; 16 | if (typeof arguments[pos] === 'function') { 17 | arguments[pos] = function replacement() { 18 | var err = arguments[0]; 19 | if (err && err.stack && !err.__augmented) { 20 | err.stack = filter(err).join('\n'); 21 | err.stack += '\n--> in ' + name; 22 | err.stack += '\n' + filter(error).slice(1).join('\n'); 23 | err.__augmented = true; 24 | } 25 | return cb.apply(this, arguments); 26 | }; 27 | } 28 | return old.apply(this, arguments); 29 | }; 30 | } 31 | exports.extendTrace = extendTrace; 32 | 33 | 34 | function filter(error) { 35 | return error.stack.split('\n').filter(function(line) { 36 | return line.indexOf(__filename) < 0; 37 | }); 38 | } 39 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@journeyapps/sqlcipher", 3 | "description": "Asynchronous, non-blocking SQLCipher bindings", 4 | "version": "5.3.1", 5 | "homepage": "http://github.com/journeyapps/node-sqlcipher", 6 | "author": { 7 | "name": "JourneyApps", 8 | "url": "https://journeyapps.com/" 9 | }, 10 | "binary": { 11 | "module_name": "node_sqlite3", 12 | "module_path": "./lib/binding/napi-v{napi_build_version}-{platform}-{arch}", 13 | "host": "https://journeyapps-node-binary.s3.amazonaws.com", 14 | "remote_path": "./{name}/v{version}/{toolset}/", 15 | "package_name": "napi-v{napi_build_version}-{platform}-{arch}.tar.gz", 16 | "napi_versions": [ 17 | 3, 18 | 6 19 | ] 20 | }, 21 | "contributors": [ 22 | "Konstantin Käfer ", 23 | "Dane Springmeyer ", 24 | "Will White ", 25 | "Orlando Vazquez ", 26 | "Artem Kustikov ", 27 | "Eric Fredricksen ", 28 | "John Wright ", 29 | "Ryan Dahl ", 30 | "Tom MacWright ", 31 | "Carter Thaxton ", 32 | "Audrius Kažukauskas ", 33 | "Johannes Schauer ", 34 | "Nathan Rajlich ", 35 | "AJ ONeal ", 36 | "Mithgol", 37 | "Ben Noordhuis " 38 | ], 39 | "repository": { 40 | "type": "git", 41 | "url": "git://github.com/journeyapps/node-sqlcipher.git" 42 | }, 43 | "dependencies": { 44 | "@mapbox/node-pre-gyp": "^1.0.0", 45 | "node-addon-api": "^3.0.0" 46 | }, 47 | "devDependencies": { 48 | "aws-sdk": "^2.641.0", 49 | "electron": "^11.2.3", 50 | "electron-mocha": "^10.0.0", 51 | "electron-rebuild": "^1.11.0", 52 | "eslint": "3.5.0", 53 | "mocha": "^5.2.0", 54 | "node-abi": "^2.19.3", 55 | "node-gyp": "^6.1.0" 56 | }, 57 | "scripts": { 58 | "install": "node-pre-gyp install --fallback-to-build", 59 | "pretest": "node test/support/createdb.js", 60 | "test": "mocha -R spec --timeout 480000", 61 | "pack": "node-pre-gyp package" 62 | }, 63 | "license": "BSD-3-Clause", 64 | "keywords": [ 65 | "sql", 66 | "sqlite", 67 | "sqlite3", 68 | "database" 69 | ], 70 | "main": "./lib/sqlite3", 71 | "types": "./lib/sqlite3.d.ts", 72 | "files": [ 73 | "lib/**/*.js", 74 | "lib/**/*.ts", 75 | "sqlite3.js" 76 | ] 77 | } 78 | -------------------------------------------------------------------------------- /scripts/build-local.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | SETLOCAL 3 | SET EL=0 4 | 5 | ECHO ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ %~f0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6 | 7 | SET PATH=C:\Python27;%PATH% 8 | 9 | SET APPVEYOR_REPO_COMMIT_MESSAGE=local build 10 | 11 | IF EXIST lib\binding ECHO deleting lib/binding && RD /Q /S lib\binding 12 | IF %ERRORLEVEL% NEQ 0 GOTO ERROR 13 | IF EXIST node_modules ECHO deleting node_modules && RD /Q /S node_modules 14 | IF %ERRORLEVEL% NEQ 0 GOTO ERROR 15 | 16 | GOTO VS2015 17 | 18 | ECHO ============================ 19 | ECHO VS2013 20 | ECHO ============================ 21 | SET nodejs_version=4.4.2 22 | SET platform=x86 23 | SET msvs_toolset=12 24 | SET TOOLSET_ARGS= 25 | 26 | CALL scripts\build-appveyor.bat 27 | IF %ERRORLEVEL% NEQ 0 GOTO ERROR 28 | 29 | GOTO DONE 30 | 31 | :VS2015 32 | 33 | IF EXIST lib\binding ECHO deleting lib/binding && RD /Q /S lib\binding 34 | IF %ERRORLEVEL% NEQ 0 GOTO ERROR 35 | IF EXIST node_modules ECHO deleting node_modules && RD /Q /S node_modules 36 | IF %ERRORLEVEL% NEQ 0 GOTO ERROR 37 | 38 | ECHO ============================ 39 | ECHO VS2015 40 | ECHO ============================ 41 | SET nodejs_version=0.10.40 42 | ECHO SET nodejs_version^: %nodejs_version% 43 | SET platform=x64 44 | ECHO SET platform^: %platform% 45 | SET msvs_toolset=14 46 | ECHO SET msvs_toolset^: %msvs_toolset% 47 | ::SET TOOLSET_ARGS=--dist-url=https://s3.amazonaws.com/mapbox/node-cpp11 --toolset=v140 48 | 49 | CALL scripts\build-appveyor.bat 50 | IF %ERRORLEVEL% NEQ 0 GOTO ERROR 51 | 52 | 53 | 54 | 55 | GOTO DONE 56 | 57 | :ERROR 58 | ECHO ~~~~~~~~~~~~~~~~~~~~~~ ERROR %~f0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 59 | ECHO ERRORLEVEL^: %ERRORLEVEL% 60 | SET EL=%ERRORLEVEL% 61 | 62 | :DONE 63 | ECHO ~~~~~~~~~~~~~~~~~~~~~~ DONE %~f0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 64 | 65 | EXIT /b %EL% 66 | -------------------------------------------------------------------------------- /scripts/build_against_electron.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | source ~/.nvm/nvm.sh 4 | 5 | set -e -u 6 | 7 | export DISPLAY=":99.0" 8 | GYP_ARGS="--runtime=electron --target=${ELECTRON_VERSION} --dist-url=https://electronjs.org/headers" 9 | NPM_BIN_DIR="$(npm bin -g 2>/dev/null)" 10 | 11 | function publish() { 12 | if [[ ${PUBLISHABLE:-false} == true ]] && [[ ${COMMIT_MESSAGE} =~ "[publish binary]" ]]; then 13 | node-pre-gyp package $GYP_ARGS 14 | node-pre-gyp publish $GYP_ARGS 15 | node-pre-gyp info $GYP_ARGS 16 | fi 17 | } 18 | 19 | function electron_pretest() { 20 | npm install -g electron@${ELECTRON_VERSION} 21 | if [ "$NODE_VERSION" -le 6 ]; then 22 | npm install -g electron-mocha@7 23 | else 24 | npm install -g electron-mocha 25 | fi 26 | if [ "${TRAVIS_OS_NAME}" = "osx" ]; then 27 | (sudo Xvfb :99 -ac -screen 0 1024x768x8; echo ok )& 28 | else 29 | sh -e /etc/init.d/xvfb start 30 | fi 31 | 32 | sleep 3 33 | } 34 | 35 | function electron_test() { 36 | "$NPM_BIN_DIR"/electron test/support/createdb-electron.js 37 | "$NPM_BIN_DIR"/electron-mocha -R spec --timeout 480000 38 | } 39 | 40 | # test installing from source 41 | npm install --build-from-source --clang=1 $GYP_ARGS 42 | 43 | electron_pretest 44 | electron_test 45 | 46 | publish 47 | make clean 48 | 49 | # now test building against shared sqlite 50 | export NODE_SQLITE3_JSON1=no 51 | if [[ $(uname -s) == 'Darwin' ]]; then 52 | brew update 53 | brew install sqlite 54 | npm install --build-from-source --sqlite=$(brew --prefix) --clang=1 $GYP_ARGS 55 | else 56 | npm install --build-from-source --sqlite=/usr --clang=1 $GYP_ARGS 57 | fi 58 | electron_test 59 | export NODE_SQLITE3_JSON1=yes 60 | -------------------------------------------------------------------------------- /scripts/build_against_node.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | source ~/.nvm/nvm.sh 4 | 5 | set -e -u 6 | 7 | function publish() { 8 | if [[ ${PUBLISHABLE:-false} == true ]] && [[ ${COMMIT_MESSAGE} =~ "[publish binary]" ]]; then 9 | node-pre-gyp package testpackage 10 | node-pre-gyp publish 11 | node-pre-gyp info 12 | make clean 13 | fi 14 | } 15 | 16 | echo "building binaries for publishing" 17 | CFLAGS="${CFLAGS:-} -include $(pwd)/src/gcc-preinclude.h" CXXFLAGS="${CXXFLAGS:-} -include $(pwd)/src/gcc-preinclude.h" V=1 npm install --build-from-source --clang=1 18 | nm lib/binding/*/node_sqlite3.node | grep "GLIBCXX_" | c++filt || true 19 | nm lib/binding/*/node_sqlite3.node | grep "GLIBC_" | c++filt || true 20 | npm test 21 | 22 | publish 23 | 24 | # now test building against shared sqlite 25 | echo "building from source to test against external libsqlite3" 26 | export NODE_SQLITE3_JSON1=no 27 | if [[ $(uname -s) == 'Darwin' ]]; then 28 | brew update 29 | brew install sqlite 30 | npm install --build-from-source --sqlite=$(brew --prefix) --clang=1 31 | else 32 | npm install --build-from-source --sqlite=/usr --clang=1 33 | fi 34 | npm test 35 | export NODE_SQLITE3_JSON1=yes 36 | 37 | platform=$(uname -s | sed "y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/") 38 | 39 | : ' 40 | if [[ $(uname -s) == 'Linux' ]]; then 41 | # node v0.8 and above provide pre-built 32 bit and 64 bit binaries 42 | # so here we use the 32 bit ones to also test 32 bit builds 43 | NVER=`node -v` 44 | # enable 32 bit node 45 | export PATH=$(pwd)/node-${NVER}-${platform}-x86/bin:$PATH 46 | if [[ ${NODE_VERSION:0:4} == 'iojs' ]]; then 47 | wget https://iojs.org/download/release/${NVER}/iojs-${NVER}-${platform}-x86.tar.gz 48 | tar xf iojs-${NVER}-${platform}-x86.tar.gz 49 | # enable 32 bit iojs 50 | export PATH=$(pwd)/iojs-${NVER}-${platform}-x86/bin:$(pwd)/iojs-${NVER}-${platform}-ia32/bin:$PATH 51 | else 52 | wget https://nodejs.org/dist/${NVER}/node-${NVER}-${platform}-x86.tar.gz 53 | tar xf node-${NVER}-${platform}-x86.tar.gz 54 | # enable 32 bit node 55 | export PATH=$(pwd)/node-${NVER}-${platform}-x86/bin:$(pwd)/node-${NVER}-${platform}-ia32/bin:$PATH 56 | fi 57 | which node 58 | ls -l $(which node) 59 | #node -e "console.log(process.arch,process.execPath)" 60 | # install 32 bit compiler toolchain and X11 61 | # test source compile in 32 bit mode with internal libsqlite3 62 | CC=gcc-4.6 CXX=g++-4.6 npm install --build-from-source --clang=1 63 | node-pre-gyp package testpackage 64 | npm test 65 | publish 66 | make clean 67 | # broken for some unknown reason against io.js 68 | if [[ ${NODE_VERSION:0:4} != 'iojs' ]]; then 69 | # test source compile in 32 bit mode against external libsqlite3 70 | export NODE_SQLITE3_JSON1=no 71 | CC=gcc-4.6 CXX=g++-4.6 npm install --build-from-source --sqlite=/usr --clang=1 72 | npm test 73 | fi 74 | fi 75 | 76 | ' 77 | -------------------------------------------------------------------------------- /scripts/build_against_node_webkit.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | 4 | if [[ ! -d ../.nvm ]]; then 5 | git clone https://github.com/creationix/nvm.git ../.nvm 6 | fi 7 | source ../.nvm/nvm.sh 8 | nvm install 0.10 9 | 10 | set -u -e 11 | 12 | npm install nw-gyp -g 13 | 14 | OLD_PATH="$PATH" 15 | 16 | GYP_ARGS="--runtime=node-webkit --target=${NODE_WEBKIT} --target_arch=${TARGET_ARCH}" 17 | if [[ $(uname -s) == 'Darwin' ]]; then 18 | if [[ '${TARGET_ARCH}' == 'x64' ]]; then 19 | # do not build on Mac OS X x64 until node-webkit 0.10.1 is released 20 | false 21 | fi 22 | fi 23 | 24 | if [[ $(uname -s) == 'Darwin' ]]; then 25 | export NW_DOWNLOAD=node-webkit-v${NODE_WEBKIT}-osx-${TARGET_ARCH} 26 | wget https://dl.node-webkit.org/v${NODE_WEBKIT}/${NW_DOWNLOAD}.zip 27 | unzip -q ${NW_DOWNLOAD}.zip 28 | export PATH=$(pwd)/node-webkit.app/Contents/MacOS/:${PATH} 29 | # v0.10.0-rc1 unzips with extra folder 30 | export PATH=$(pwd)/${NW_DOWNLOAD}/node-webkit.app/Contents/MacOS/:${PATH} 31 | npm install --build-from-source ${GYP_ARGS} 32 | else 33 | sudo apt-get install build-essential 34 | # Linux 35 | export NW_DOWNLOAD=node-webkit-v${NODE_WEBKIT}-linux-${TARGET_ARCH} 36 | # for testing node-webkit, launch a virtual display 37 | export DISPLAY=:99.0 38 | # NOTE: travis already has xvfb installed 39 | # https://docs.travis-ci.com/user/gui-and-headless-browsers/#Using-xvfb-to-Run-Tests-That-Require-GUI-%28e.g.-a-Web-browser%29 40 | sh -e /etc/init.d/xvfb start +extension RANDR 41 | wget https://dl.node-webkit.org/v${NODE_WEBKIT}/${NW_DOWNLOAD}.tar.gz 42 | tar xf ${NW_DOWNLOAD}.tar.gz 43 | export PATH=$(pwd)/${NW_DOWNLOAD}:${PATH} 44 | if [[ "${TARGET_ARCH}" == 'ia32' ]]; then 45 | # for nw >= 0.11.0 on ia32 we need gcc/g++ 4.8 46 | IFS='.' read -a NODE_WEBKIT_VERSION <<< "${NODE_WEBKIT}" 47 | if test ${NODE_WEBKIT_VERSION[0]} -ge 0 -a ${NODE_WEBKIT_VERSION[1]} -ge 11; then 48 | # travis-ci runs ubuntu 12.04, so we need this ppa for gcc/g++ 4.8 49 | sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test 50 | export CC=gcc-4.8 51 | export CXX=g++-4.8 52 | export CXXFLAGS="-fpermissive" 53 | COMPILER_PACKAGES="gcc-4.8-multilib g++-4.8-multilib" 54 | else 55 | export CC=gcc-4.6 56 | export CXX=g++-4.6 57 | export CXXFLAGS="-fpermissive" 58 | COMPILER_PACKAGES="gcc-multilib g++-multilib" 59 | fi 60 | # need to update to avoid 404 for linux-libc-dev_3.2.0-64.97_amd64.deb 61 | sudo apt-get update 62 | # prepare packages for 32-bit builds on Linux 63 | sudo apt-get -y install $COMPILER_PACKAGES libx11-6:i386 libnotify4:i386 libxtst6:i386 libcap2:i386 libglib2.0-0:i386 libgtk2.0-0:i386 libatk1.0-0:i386 libgdk-pixbuf2.0-0:i386 libcairo2:i386 libfreetype6:i386 libfontconfig1:i386 libxcomposite1:i386 libasound2:i386 libxdamage1:i386 libxext6:i386 libxfixes3:i386 libnss3:i386 libnspr4:i386 libgconf-2-4:i386 libexpat1:i386 libdbus-1-3:i386 libudev0:i386 64 | # also use ldd to find out if some necessary apt-get is missing 65 | ldd $(pwd)/${NW_DOWNLOAD}/nw 66 | npm install --build-from-source ${GYP_ARGS} 67 | else 68 | npm install --build-from-source ${GYP_ARGS} 69 | fi 70 | fi 71 | 72 | # test the package 73 | node-pre-gyp package testpackage ${GYP_ARGS} 74 | 75 | PUBLISH_BINARY=false 76 | if test "${COMMIT_MESSAGE#*'[publish binary]'}" != "$COMMIT_MESSAGE"; then 77 | node-pre-gyp publish ${GYP_ARGS} 78 | node-pre-gyp info ${GYP_ARGS} 79 | node-pre-gyp clean ${GYP_ARGS} 80 | make clean 81 | # now install from binary 82 | INSTALL_RESULT=$(npm install ${GYP_ARGS} --fallback-to-build=false > /dev/null)$? || true 83 | # if install returned non zero (errored) then we first unpublish and then call false so travis will bail at this line 84 | if [[ $INSTALL_RESULT != 0 ]]; then echo "returned $INSTALL_RESULT";node-pre-gyp unpublish ${GYP_ARGS};false; fi 85 | # If success then we arrive here so lets clean up 86 | node-pre-gyp clean ${GYP_ARGS} 87 | fi 88 | 89 | # restore PATH 90 | export PATH="$OLD_PATH" 91 | rm -rf ${NW_DOWNLOAD} 92 | -------------------------------------------------------------------------------- /scripts/build_for_node_webkit.cmd: -------------------------------------------------------------------------------- 1 | echo Platform: %1 2 | echo The list of environment variables: 3 | set 4 | if not "%1" == "x86" goto end 5 | if "%nw_version%" == "" goto end 6 | call npm install nw-gyp 7 | call cinst wget 7zip.commandline 8 | call wget https://dl.node-webkit.org/v%nw_version%/node-webkit-v%nw_version%-win-ia32.zip 9 | call 7z e -onw node-webkit-v%nw_version%-win-ia32.zip 10 | dir nw 11 | set PATH=nw;%PATH% 12 | call node-pre-gyp rebuild --runtime=node-webkit --target=%nw_version% --target_arch=ia32 13 | call node-pre-gyp package testpackage --runtime=node-webkit --target=%nw_version% --target_arch=ia32 14 | if not "%CM%" == "%CM:[publish binary]=%" call node-pre-gyp publish --msvs_version=2013 --runtime=node-webkit --target=%nw_version% --target_arch=ia32 15 | :end -------------------------------------------------------------------------------- /scripts/install_node.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | if [[ ${1:-false} == 'false' ]]; then 4 | echo "Error: pass node version as first argument" 5 | exit 1 6 | fi 7 | 8 | NODE_VERSION=$1 9 | 10 | # if an existing nvm is already installed we need to unload it 11 | nvm unload || true 12 | 13 | # here we set up the node version on the fly based on the matrix value. 14 | # This is done manually so that the build works the same on OS X 15 | rm -rf ./__nvm/ && git clone --depth 1 https://github.com/creationix/nvm.git ./__nvm 16 | source ./__nvm/nvm.sh 17 | nvm install ${NODE_VERSION} 18 | nvm use --delete-prefix ${NODE_VERSION} 19 | node --version 20 | npm --version 21 | which node 22 | -------------------------------------------------------------------------------- /scripts/validate_tag.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -u 4 | 5 | # let's catch the case where we tag but 6 | # forget to increment the package.json version 7 | 8 | # check if we are on a tag 9 | if [ `git describe --tags --always HEAD` ]; then 10 | echo 'looks like we are on a tag' 11 | if [[ $TRAVIS_BRANCH == `git describe --tags --always HEAD` ]]; then 12 | echo 'git reports the same tag as travis' 13 | # now check to make sure package.json `version` matches 14 | MODULE_VERSION=$(node -e "console.log(require('./package.json').version)") 15 | if [[ $MODULE_VERSION != $TRAVIS_BRANCH ]] && [[ v$MODULE_VERSION != $TRAVIS_BRANCH ]]; then 16 | echo "package.json version ($MODULE_VERSION) does not match tag ($TRAVIS_BRANCH)" 17 | exit 1 18 | else 19 | echo "Validation success: package.json ($MODULE_VERSION) matches tag ($TRAVIS_BRANCH)" 20 | fi 21 | else 22 | echo "warning: travis thinks the tag ($TRAVIS_BRANCH) differs from git (`git describe --tags --always HEAD`)" 23 | fi 24 | fi 25 | -------------------------------------------------------------------------------- /sqlite3.js: -------------------------------------------------------------------------------- 1 | module.exports = require('./lib/sqlite3'); 2 | -------------------------------------------------------------------------------- /src/async.h: -------------------------------------------------------------------------------- 1 | #ifndef NODE_SQLITE3_SRC_ASYNC_H 2 | #define NODE_SQLITE3_SRC_ASYNC_H 3 | 4 | #include 5 | #include 6 | 7 | #include "threading.h" 8 | 9 | #if defined(NODE_SQLITE3_BOOST_THREADING) 10 | #include 11 | #endif 12 | 13 | 14 | // Generic uv_async handler. 15 | template class Async { 16 | typedef void (*Callback)(Parent* parent, Item* item); 17 | 18 | protected: 19 | uv_async_t watcher; 20 | NODE_SQLITE3_MUTEX_t 21 | std::vector data; 22 | Callback callback; 23 | public: 24 | Parent* parent; 25 | 26 | public: 27 | Async(Parent* parent_, Callback cb_) 28 | : callback(cb_), parent(parent_) { 29 | watcher.data = this; 30 | NODE_SQLITE3_MUTEX_INIT 31 | uv_loop_t *loop; 32 | napi_get_uv_event_loop(parent_->Env(), &loop); 33 | uv_async_init(loop, &watcher, reinterpret_cast(listener)); 34 | } 35 | 36 | static void listener(uv_async_t* handle) { 37 | Async* async = static_cast(handle->data); 38 | std::vector rows; 39 | NODE_SQLITE3_MUTEX_LOCK(&async->mutex) 40 | rows.swap(async->data); 41 | NODE_SQLITE3_MUTEX_UNLOCK(&async->mutex) 42 | for (unsigned int i = 0, size = rows.size(); i < size; i++) { 43 | async->callback(async->parent, rows[i]); 44 | } 45 | } 46 | 47 | static void close(uv_handle_t* handle) { 48 | assert(handle != NULL); 49 | assert(handle->data != NULL); 50 | Async* async = static_cast(handle->data); 51 | delete async; 52 | } 53 | 54 | void finish() { 55 | // Need to call the listener again to ensure all items have been 56 | // processed. Is this a bug in uv_async? Feels like uv_close 57 | // should handle that. 58 | listener(&watcher); 59 | uv_close((uv_handle_t*)&watcher, close); 60 | } 61 | 62 | void add(Item* item) { 63 | NODE_SQLITE3_MUTEX_LOCK(&mutex); 64 | data.push_back(item); 65 | NODE_SQLITE3_MUTEX_UNLOCK(&mutex) 66 | } 67 | 68 | void send() { 69 | uv_async_send(&watcher); 70 | } 71 | 72 | void send(Item* item) { 73 | add(item); 74 | send(); 75 | } 76 | 77 | ~Async() { 78 | NODE_SQLITE3_MUTEX_DESTROY 79 | } 80 | }; 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /src/gcc-preinclude.h: -------------------------------------------------------------------------------- 1 | 2 | // http://web.archive.org/web/20140401031018/http://rjpower9000.wordpress.com:80/2012/04/09/fun-with-shared-libraries-version-glibc_2-14-not-found/ 3 | 4 | #if defined(__linux__) && defined(__x86_64__) 5 | __asm__(".symver memcpy,memcpy@GLIBC_2.2.5"); 6 | #endif 7 | -------------------------------------------------------------------------------- /src/threading.h: -------------------------------------------------------------------------------- 1 | #ifndef NODE_SQLITE3_SRC_THREADING_H 2 | #define NODE_SQLITE3_SRC_THREADING_H 3 | 4 | 5 | #ifdef _WIN32 6 | 7 | #include 8 | 9 | #define NODE_SQLITE3_MUTEX_t HANDLE mutex; 10 | 11 | #define NODE_SQLITE3_MUTEX_INIT mutex = CreateMutex(NULL, FALSE, NULL); 12 | 13 | #define NODE_SQLITE3_MUTEX_LOCK(m) WaitForSingleObject(*m, INFINITE); 14 | 15 | #define NODE_SQLITE3_MUTEX_UNLOCK(m) ReleaseMutex(*m); 16 | 17 | #define NODE_SQLITE3_MUTEX_DESTROY CloseHandle(mutex); 18 | 19 | #elif defined(NODE_SQLITE3_BOOST_THREADING) 20 | 21 | #include 22 | 23 | #define NODE_SQLITE3_MUTEX_t boost::mutex mutex; 24 | 25 | #define NODE_SQLITE3_MUTEX_INIT 26 | 27 | #define NODE_SQLITE3_MUTEX_LOCK(m) (*m).lock(); 28 | 29 | #define NODE_SQLITE3_MUTEX_UNLOCK(m) (*m).unlock(); 30 | 31 | #define NODE_SQLITE3_MUTEX_DESTROY mutex.unlock(); 32 | 33 | #else 34 | 35 | #define NODE_SQLITE3_MUTEX_t pthread_mutex_t mutex; 36 | 37 | #define NODE_SQLITE3_MUTEX_INIT pthread_mutex_init(&mutex,NULL); 38 | 39 | #define NODE_SQLITE3_MUTEX_LOCK(m) pthread_mutex_lock(m); 40 | 41 | #define NODE_SQLITE3_MUTEX_UNLOCK(m) pthread_mutex_unlock(m); 42 | 43 | #define NODE_SQLITE3_MUTEX_DESTROY pthread_mutex_destroy(&mutex); 44 | 45 | #endif 46 | 47 | 48 | #endif // NODE_SQLITE3_SRC_THREADING_H 49 | -------------------------------------------------------------------------------- /test/affected.test.js: -------------------------------------------------------------------------------- 1 | var sqlite3 = require('..'); 2 | var assert = require('assert'); 3 | 4 | describe('query properties', function() { 5 | var db; 6 | before(function(done) { 7 | db = new sqlite3.Database(':memory:'); 8 | db.run("CREATE TABLE foo (id INT, txt TEXT)", done); 9 | }); 10 | 11 | it('should return the correct lastID', function(done) { 12 | var stmt = db.prepare("INSERT INTO foo VALUES(?, ?)"); 13 | var j = 1; 14 | for (var i = 0; i < 5000; i++) { 15 | stmt.run(i, "demo", function(err) { 16 | if (err) throw err; 17 | // Relies on SQLite's row numbering to be gapless and starting 18 | // from 1. 19 | assert.equal(j++, this.lastID); 20 | }); 21 | } 22 | db.wait(done); 23 | }); 24 | 25 | it('should return the correct changes count', function(done) { 26 | db.run("UPDATE foo SET id = id + 1 WHERE id % 2 = 0", function(err) { 27 | if (err) throw err; 28 | assert.equal(2500, this.changes); 29 | done(); 30 | }); 31 | }); 32 | }); 33 | -------------------------------------------------------------------------------- /test/blob.test.js: -------------------------------------------------------------------------------- 1 | var sqlite3 = require('..'), 2 | fs = require('fs'), 3 | assert = require('assert'), 4 | Buffer = require('buffer').Buffer; 5 | 6 | // lots of elmo 7 | var elmo = fs.readFileSync(__dirname + '/support/elmo.png'); 8 | 9 | describe('blob', function() { 10 | var db; 11 | before(function(done) { 12 | db = new sqlite3.Database(':memory:'); 13 | db.run("CREATE TABLE elmos (id INT, image BLOB)", done); 14 | }); 15 | 16 | var total = 10; 17 | var inserted = 0; 18 | var retrieved = 0; 19 | 20 | 21 | it('should insert blobs', function(done) { 22 | for (var i = 0; i < total; i++) { 23 | db.run('INSERT INTO elmos (id, image) VALUES (?, ?)', i, elmo, function(err) { 24 | if (err) throw err; 25 | inserted++; 26 | }); 27 | } 28 | db.wait(function() { 29 | assert.equal(inserted, total); 30 | done(); 31 | }); 32 | }); 33 | 34 | it('should retrieve the blobs', function(done) { 35 | db.all('SELECT id, image FROM elmos ORDER BY id', function(err, rows) { 36 | if (err) throw err; 37 | for (var i = 0; i < rows.length; i++) { 38 | assert.ok(Buffer.isBuffer(rows[i].image)); 39 | assert.ok(elmo.length, rows[i].image); 40 | 41 | for (var j = 0; j < elmo.length; j++) { 42 | if (elmo[j] !== rows[i].image[j]) { 43 | assert.ok(false, "Wrong byte"); 44 | } 45 | } 46 | 47 | retrieved++; 48 | } 49 | 50 | assert.equal(retrieved, total); 51 | done(); 52 | }); 53 | }); 54 | }); 55 | -------------------------------------------------------------------------------- /test/cache.test.js: -------------------------------------------------------------------------------- 1 | var sqlite3 = require('..'); 2 | var assert = require('assert'); 3 | var helper = require('./support/helper'); 4 | 5 | describe('cache', function() { 6 | before(function() { 7 | helper.ensureExists('test/tmp'); 8 | }); 9 | 10 | it('should cache Database objects while opening', function(done) { 11 | var filename = 'test/tmp/test_cache.db'; 12 | helper.deleteFile(filename); 13 | var opened1 = false, opened2 = false; 14 | var db1 = new sqlite3.cached.Database(filename, function(err) { 15 | if (err) throw err; 16 | opened1 = true; 17 | if (opened1 && opened2) done(); 18 | }); 19 | var db2 = new sqlite3.cached.Database(filename, function(err) { 20 | if (err) throw err; 21 | opened2 = true; 22 | if (opened1 && opened2) done(); 23 | }); 24 | assert.equal(db1, db2); 25 | }); 26 | 27 | it('should cache Database objects after they are open', function(done) { 28 | var filename = 'test/tmp/test_cache2.db'; 29 | helper.deleteFile(filename); 30 | var db1, db2; 31 | db1 = new sqlite3.cached.Database(filename, function(err) { 32 | if (err) throw err; 33 | process.nextTick(function() { 34 | db2 = new sqlite3.cached.Database(filename, function(err) { 35 | done(); 36 | 37 | }); 38 | assert.equal(db1, db2); 39 | }); 40 | }); 41 | }); 42 | }); 43 | -------------------------------------------------------------------------------- /test/constants.test.js: -------------------------------------------------------------------------------- 1 | var sqlite3 = require('..'); 2 | var assert = require('assert'); 3 | 4 | describe('constants', function() { 5 | it('should have the right OPEN_* flags', function() { 6 | assert.ok(sqlite3.OPEN_READONLY === 1); 7 | assert.ok(sqlite3.OPEN_READWRITE === 2); 8 | assert.ok(sqlite3.OPEN_CREATE === 4); 9 | assert.ok(sqlite3.OPEN_URI === 0x00000040); 10 | assert.ok(sqlite3.OPEN_FULLMUTEX === 0x00010000); 11 | assert.ok(sqlite3.OPEN_SHAREDCACHE === 0x00020000); 12 | assert.ok(sqlite3.OPEN_PRIVATECACHE === 0x00040000); 13 | }); 14 | 15 | it('should have the right error flags', function() { 16 | assert.ok(sqlite3.OK === 0); 17 | assert.ok(sqlite3.ERROR === 1); 18 | assert.ok(sqlite3.INTERNAL === 2); 19 | assert.ok(sqlite3.PERM === 3); 20 | assert.ok(sqlite3.ABORT === 4); 21 | assert.ok(sqlite3.BUSY === 5); 22 | assert.ok(sqlite3.LOCKED === 6); 23 | assert.ok(sqlite3.NOMEM === 7); 24 | assert.ok(sqlite3.READONLY === 8); 25 | assert.ok(sqlite3.INTERRUPT === 9); 26 | assert.ok(sqlite3.IOERR === 10); 27 | assert.ok(sqlite3.CORRUPT === 11); 28 | assert.ok(sqlite3.NOTFOUND === 12); 29 | assert.ok(sqlite3.FULL === 13); 30 | assert.ok(sqlite3.CANTOPEN === 14); 31 | assert.ok(sqlite3.PROTOCOL === 15); 32 | assert.ok(sqlite3.EMPTY === 16); 33 | assert.ok(sqlite3.SCHEMA === 17); 34 | assert.ok(sqlite3.TOOBIG === 18); 35 | assert.ok(sqlite3.CONSTRAINT === 19); 36 | assert.ok(sqlite3.MISMATCH === 20); 37 | assert.ok(sqlite3.MISUSE === 21); 38 | assert.ok(sqlite3.NOLFS === 22); 39 | assert.ok(sqlite3.AUTH === 23); 40 | assert.ok(sqlite3.FORMAT === 24); 41 | assert.ok(sqlite3.RANGE === 25); 42 | assert.ok(sqlite3.NOTADB === 26); 43 | }); 44 | }); 45 | -------------------------------------------------------------------------------- /test/each.test.js: -------------------------------------------------------------------------------- 1 | var sqlite3 = require('..'); 2 | var assert = require('assert'); 3 | 4 | describe('each', function() { 5 | var db; 6 | before(function(done) { 7 | db = new sqlite3.Database('test/support/big.db', sqlite3.OPEN_READONLY, done); 8 | }); 9 | 10 | it('retrieve 100,000 rows with Statement#each', function(done) { 11 | var total = 100000; 12 | var retrieved = 0; 13 | 14 | 15 | db.each('SELECT id, txt FROM foo LIMIT 0, ?', total, function(err, row) { 16 | if (err) throw err; 17 | retrieved++; 18 | 19 | if(retrieved === total) { 20 | assert.equal(retrieved, total, "Only retrieved " + retrieved + " out of " + total + " rows."); 21 | done(); 22 | } 23 | }); 24 | }); 25 | 26 | it('Statement#each with complete callback', function(done) { 27 | var total = 10000; 28 | var retrieved = 0; 29 | 30 | db.each('SELECT id, txt FROM foo LIMIT 0, ?', total, function(err, row) { 31 | if (err) throw err; 32 | retrieved++; 33 | }, function(err, num) { 34 | assert.equal(retrieved, num); 35 | assert.equal(retrieved, total, "Only retrieved " + retrieved + " out of " + total + " rows."); 36 | done(); 37 | }); 38 | }); 39 | }); 40 | -------------------------------------------------------------------------------- /test/exec.test.js: -------------------------------------------------------------------------------- 1 | var sqlite3 = require('..'); 2 | var assert = require('assert'); 3 | var fs = require('fs'); 4 | 5 | describe('exec', function() { 6 | var db; 7 | before(function(done) { 8 | db = new sqlite3.Database(':memory:', done); 9 | }); 10 | 11 | it('Database#exec', function(done) { 12 | var sql = fs.readFileSync('test/support/script.sql', 'utf8'); 13 | db.exec(sql, done); 14 | }); 15 | 16 | it('retrieve database structure', function(done) { 17 | db.all("SELECT type, name FROM sqlite_master ORDER BY type, name", function(err, rows) { 18 | if (err) throw err; 19 | assert.deepEqual(rows, [ 20 | { type: 'index', name: 'grid_key_lookup' }, 21 | { type: 'index', name: 'grid_utfgrid_lookup' }, 22 | { type: 'index', name: 'images_id' }, 23 | { type: 'index', name: 'keymap_lookup' }, 24 | { type: 'index', name: 'map_index' }, 25 | { type: 'index', name: 'name' }, 26 | { type: 'table', name: 'grid_key' }, 27 | { type: 'table', name: 'grid_utfgrid' }, 28 | { type: 'table', name: 'images' }, 29 | { type: 'table', name: 'keymap' }, 30 | { type: 'table', name: 'map' }, 31 | { type: 'table', name: 'metadata' }, 32 | { type: 'view', name: 'grid_data' }, 33 | { type: 'view', name: 'grids' }, 34 | { type: 'view', name: 'tiles' } 35 | ]); 36 | done(); 37 | }); 38 | }); 39 | }); 40 | -------------------------------------------------------------------------------- /test/extension.test.js: -------------------------------------------------------------------------------- 1 | var sqlite3 = require('..'); 2 | var assert = require('assert'); 3 | var exists = require('fs').existsSync || require('path').existsSync; 4 | 5 | /* 6 | 7 | // disabled because this is not a generically safe test to run on all systems 8 | 9 | var spatialite_ext = '/usr/local/lib/libspatialite.dylib'; 10 | 11 | describe('loadExtension', function(done) { 12 | var db; 13 | before(function(done) { 14 | db = new sqlite3.Database(':memory:', done); 15 | }); 16 | 17 | if (exists(spatialite_ext)) { 18 | it('libspatialite', function(done) { 19 | db.loadExtension(spatialite_ext, done); 20 | }); 21 | } else { 22 | it('libspatialite'); 23 | } 24 | }); 25 | 26 | */ -------------------------------------------------------------------------------- /test/fts-content.test.js: -------------------------------------------------------------------------------- 1 | var sqlite3 = require('..'); 2 | var assert = require('assert'); 3 | 4 | describe('fts', function() { 5 | var db; 6 | before(function(done) { 7 | db = new sqlite3.Database(':memory:', done); 8 | }); 9 | 10 | it('should create a new fts4 table', function(done) { 11 | db.exec('CREATE VIRTUAL TABLE t1 USING fts4(content="", a, b, c);', done); 12 | }); 13 | 14 | it('should create a new fts5 table', function(done) { 15 | db.exec('CREATE VIRTUAL TABLE t2 USING fts5(content="", a, b, c);', done); 16 | }); 17 | }); 18 | -------------------------------------------------------------------------------- /test/interrupt.test.js: -------------------------------------------------------------------------------- 1 | var sqlite3 = require('..'); 2 | var assert = require('assert'); 3 | 4 | describe('interrupt', function() { 5 | it('should interrupt queries', function(done) { 6 | var interrupted = false; 7 | var saved = null; 8 | 9 | var db = new sqlite3.Database(':memory:', function() { 10 | db.serialize(); 11 | 12 | var setup = 'create table t (n int);'; 13 | for (var i = 0; i < 8; i += 1) { 14 | setup += 'insert into t values (' + i + ');'; 15 | } 16 | 17 | db.exec(setup, function(err) { 18 | if (err) { 19 | return done(err); 20 | } 21 | 22 | var query = 'select last.n ' + 23 | 'from t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t as last'; 24 | 25 | db.each(query, function(err) { 26 | if (err) { 27 | saved = err; 28 | } else if (!interrupted) { 29 | interrupted = true; 30 | db.interrupt(); 31 | } 32 | }); 33 | 34 | db.close(function() { 35 | if (saved) { 36 | assert.equal(saved.message, 'SQLITE_INTERRUPT: interrupted'); 37 | assert.equal(saved.errno, sqlite3.INTERRUPT); 38 | assert.equal(saved.code, 'SQLITE_INTERRUPT'); 39 | done(); 40 | } else { 41 | done(new Error('Completed query without error, but expected error')); 42 | } 43 | }); 44 | }); 45 | }); 46 | }); 47 | 48 | it('should throw if interrupt is called before open', function(done) { 49 | var db = new sqlite3.Database(':memory:'); 50 | 51 | assert.throws(function() { 52 | db.interrupt(); 53 | }, (/Database is not open/)); 54 | 55 | db.close(); 56 | done(); 57 | }); 58 | 59 | it('should throw if interrupt is called after close', function(done) { 60 | var db = new sqlite3.Database(':memory:'); 61 | 62 | db.close(function() { 63 | assert.throws(function() { 64 | db.interrupt(); 65 | }, (/Database is not open/)); 66 | 67 | done(); 68 | }); 69 | }); 70 | 71 | it('should throw if interrupt is called during close', function(done) { 72 | var db = new sqlite3.Database(':memory:', function() { 73 | db.close(); 74 | assert.throws(function() { 75 | db.interrupt(); 76 | }, (/Database is closing/)); 77 | done(); 78 | }); 79 | }); 80 | }); 81 | -------------------------------------------------------------------------------- /test/issue-108.test.js: -------------------------------------------------------------------------------- 1 | var sqlite3 = require('..'), 2 | assert = require('assert'); 3 | 4 | describe('buffer', function() { 5 | var db; 6 | // before(function() { 7 | // }); 8 | 9 | it('should insert blobs', function(done) { 10 | db = new sqlite3.Database(':memory:'); 11 | db.serialize(function () { 12 | 13 | db.run("CREATE TABLE lorem (info BLOB)"); 14 | var stmt = db.prepare("INSERT INTO lorem VALUES (?)"); 15 | 16 | stmt.on('error', function (err) { 17 | throw err; 18 | }); 19 | 20 | var buff = new Buffer(2); 21 | stmt.run(buff); 22 | stmt.finalize(); 23 | }); 24 | 25 | db.close(done); 26 | 27 | }); 28 | }); 29 | -------------------------------------------------------------------------------- /test/json.test.js: -------------------------------------------------------------------------------- 1 | var sqlite3 = require('..'); 2 | 3 | if( process.env.NODE_SQLITE3_JSON1 === 'no' ){ 4 | describe('json', function() { 5 | it( 6 | 'skips JSON tests when --sqlite=/usr (or similar) is tested', 7 | function(){} 8 | ); 9 | }); 10 | } else { 11 | describe('json', function() { 12 | var db; 13 | 14 | before(function(done) { 15 | db = new sqlite3.Database(':memory:', done); 16 | }); 17 | 18 | it('should select JSON', function(done) { 19 | db.run('SELECT json(?)', JSON.stringify({ok:true}), done); 20 | }); 21 | }); 22 | } 23 | -------------------------------------------------------------------------------- /test/map.test.js: -------------------------------------------------------------------------------- 1 | var sqlite3 = require('..'); 2 | var assert = require('assert'); 3 | 4 | describe('map', function() { 5 | it('test Database#map() with two columns', function(done) { 6 | var count = 10; 7 | var inserted = 0; 8 | 9 | var db = new sqlite3.Database(':memory:'); 10 | db.serialize(function() { 11 | db.run("CREATE TABLE foo (id INT, value TEXT)"); 12 | 13 | var stmt = db.prepare("INSERT INTO foo VALUES(?, ?)"); 14 | for (var i = 5; i < count; i++) { 15 | stmt.run(i, 'Value for ' + i, function(err) { 16 | if (err) throw err; 17 | inserted++; 18 | }); 19 | } 20 | stmt.finalize(); 21 | 22 | db.map("SELECT * FROM foo", function(err, map) { 23 | if (err) throw err; 24 | assert.deepEqual(map, { 5: 'Value for 5', 6: 'Value for 6', 7: 'Value for 7', 8: 'Value for 8', 9: 'Value for 9' }); 25 | assert.equal(inserted, 5); 26 | done(); 27 | }); 28 | }); 29 | }); 30 | 31 | it('test Database#map() with three columns', function(done) { 32 | var db = new sqlite3.Database(':memory:'); 33 | 34 | var count = 10; 35 | var inserted = 0; 36 | 37 | db.serialize(function() { 38 | db.run("CREATE TABLE foo (id INT, value TEXT, other TEXT)"); 39 | 40 | var stmt = db.prepare("INSERT INTO foo VALUES(?, ?, ?)"); 41 | for (var i = 5; i < count; i++) { 42 | stmt.run(i, 'Value for ' + i, null, function(err) { 43 | if (err) throw err; 44 | inserted++; 45 | }); 46 | } 47 | stmt.finalize(); 48 | 49 | db.map("SELECT * FROM foo", function(err, map) { 50 | if (err) throw err; 51 | assert.deepEqual(map, { 52 | 5: { id: 5, value: 'Value for 5', other: null }, 53 | 6: { id: 6, value: 'Value for 6', other: null }, 54 | 7: { id: 7, value: 'Value for 7', other: null }, 55 | 8: { id: 8, value: 'Value for 8', other: null }, 56 | 9: { id: 9, value: 'Value for 9', other: null } 57 | }); 58 | assert.equal(inserted, 5); 59 | done(); 60 | }); 61 | }); 62 | }); 63 | }); 64 | -------------------------------------------------------------------------------- /test/named_columns.test.js: -------------------------------------------------------------------------------- 1 | var sqlite3 = require('..'); 2 | var assert = require('assert'); 3 | 4 | describe('named columns', function() { 5 | var db; 6 | before(function(done) { 7 | db = new sqlite3.Database(':memory:', done); 8 | }); 9 | 10 | it('should create the table', function(done) { 11 | db.run("CREATE TABLE foo (txt TEXT, num INT)", done); 12 | }); 13 | 14 | it('should insert a value', function(done) { 15 | db.run("INSERT INTO foo VALUES($text, $id)", { 16 | $id: 1, 17 | $text: "Lorem Ipsum" 18 | }, done); 19 | }); 20 | 21 | it('should retrieve the values', function(done) { 22 | db.get("SELECT txt, num FROM foo ORDER BY num", function(err, row) { 23 | if (err) throw err; 24 | assert.equal(row.txt, "Lorem Ipsum"); 25 | assert.equal(row.num, 1); 26 | done(); 27 | }); 28 | }); 29 | 30 | it('should be able to retrieve rowid of last inserted value', function(done) { 31 | db.get("SELECT last_insert_rowid() as last_id FROM foo", function(err, row) { 32 | if (err) throw err; 33 | assert.equal(row.last_id, 1); 34 | done(); 35 | }); 36 | }); 37 | 38 | }); 39 | -------------------------------------------------------------------------------- /test/named_params.test.js: -------------------------------------------------------------------------------- 1 | var sqlite3 = require('..'); 2 | var assert = require('assert'); 3 | 4 | describe('named parameters', function() { 5 | var db; 6 | before(function(done) { 7 | db = new sqlite3.Database(':memory:', done); 8 | }); 9 | 10 | it('should create the table', function(done) { 11 | db.run("CREATE TABLE foo (txt TEXT, num INT)", done); 12 | }); 13 | 14 | it('should insert a value with $ placeholders', function(done) { 15 | db.run("INSERT INTO foo VALUES($text, $id)", { 16 | $id: 1, 17 | $text: "Lorem Ipsum" 18 | }, done); 19 | }); 20 | 21 | it('should insert a value with : placeholders', function(done) { 22 | db.run("INSERT INTO foo VALUES(:text, :id)", { 23 | ':id': 2, 24 | ':text': "Dolor Sit Amet" 25 | }, done); 26 | }); 27 | 28 | it('should insert a value with @ placeholders', function(done) { 29 | db.run("INSERT INTO foo VALUES(@txt, @id)", { 30 | "@id": 3, 31 | "@txt": "Consectetur Adipiscing Elit" 32 | }, done); 33 | }); 34 | 35 | it('should insert a value with @ placeholders using an array', function(done) { 36 | db.run("INSERT INTO foo VALUES(@txt, @id)", [ 'Sed Do Eiusmod', 4 ], done); 37 | }); 38 | 39 | it('should insert a value with indexed placeholders', function(done) { 40 | db.run("INSERT INTO foo VALUES(?2, ?4)", 41 | [ null, 'Tempor Incididunt', null, 5 ], done); 42 | }); 43 | 44 | it('should insert a value with autoindexed placeholders', function(done) { 45 | db.run("INSERT INTO foo VALUES(?, ?)", { 46 | 2: 6, 47 | 1: "Ut Labore Et Dolore" 48 | }, done); 49 | }); 50 | 51 | it('should retrieve all inserted values', function(done) { 52 | db.all("SELECT txt, num FROM foo ORDER BY num", function(err, rows) { 53 | if (err) throw err; 54 | assert.equal(rows[0].txt, "Lorem Ipsum"); 55 | assert.equal(rows[0].num, 1); 56 | assert.equal(rows[1].txt, "Dolor Sit Amet"); 57 | assert.equal(rows[1].num, 2); 58 | assert.equal(rows[2].txt, "Consectetur Adipiscing Elit"); 59 | assert.equal(rows[2].num, 3); 60 | assert.equal(rows[3].txt, "Sed Do Eiusmod"); 61 | assert.equal(rows[3].num, 4); 62 | assert.equal(rows[4].txt, "Tempor Incididunt"); 63 | assert.equal(rows[4].num, 5); 64 | assert.equal(rows[5].txt, "Ut Labore Et Dolore"); 65 | assert.equal(rows[5].num, 6); 66 | done(); 67 | }); 68 | }); 69 | }); 70 | -------------------------------------------------------------------------------- /test/nw/.gitignore: -------------------------------------------------------------------------------- 1 | node-webkit.app 2 | node-webkit-v0.8.4-osx-ia32.zip 3 | node_modules -------------------------------------------------------------------------------- /test/nw/Makefile: -------------------------------------------------------------------------------- 1 | NODE_WEBKIT_VERSION=0.8.4 2 | 3 | all: app.nw 4 | 5 | node_modules/sqlite3: 6 | npm install https://github.com/mapbox/node-sqlite3/tarball/master --build-from-source --runtime=node-webkit --target_arch=ia32 --target=$(NODE_WEBKIT_VERSION) 7 | 8 | rebuild: 9 | cd node_modules/sqlite3 && ./node_modules/.bin/node-pre-gyp rebuild --runtime=node-webkit --target_arch=ia32 --target=$(NODE_WEBKIT_VERSION) 10 | 11 | node-webkit-v$(NODE_WEBKIT_VERSION)-osx-ia32.zip: 12 | wget https://s3.amazonaws.com/node-webkit/v$(NODE_WEBKIT_VERSION)/node-webkit-v$(NODE_WEBKIT_VERSION)-osx-ia32.zip 13 | 14 | ./node-webkit.app: node-webkit-v$(NODE_WEBKIT_VERSION)-osx-ia32.zip 15 | unzip -o node-webkit-v$(NODE_WEBKIT_VERSION)-osx-ia32.zip 16 | 17 | app.nw: ./node-webkit.app Makefile package.json index.html node_modules/sqlite3 18 | zip app.nw index.html package.json node_modules 19 | 20 | test: ./node-webkit.app app.nw 21 | ./node-webkit.app/Contents/MacOS/node-webkit app.nw 22 | 23 | package: ./node-webkit.app Makefile package.json index.html node_modules/sqlite3 24 | rm -rf node-sqlite-test.app 25 | cp -r ./node-webkit.app node-sqlite-test.app 26 | mkdir ./node-sqlite-test.app/Contents/Resources/app.nw/ 27 | cp package.json ./node-sqlite-test.app/Contents/Resources/app.nw/ 28 | cp index.html ./node-sqlite-test.app/Contents/Resources/app.nw/ 29 | cp -r node_modules/ ./node-sqlite-test.app/Contents/Resources/app.nw/ 30 | ./node-sqlite-test.app/Contents/MacOS/node-webkit 31 | 32 | clean: 33 | rm -rf ./node_modules/sqlite3 34 | rm -f ./app.nw 35 | rm -rf node-sqlite-test.app 36 | rm -f credits.html 37 | rm -f nwsnapshot 38 | 39 | .PHONY: test 40 | -------------------------------------------------------------------------------- /test/nw/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Hello World! 5 | 6 | 7 |

Hello World!

8 | Using node-sqlite3: 9 | . 13 | 14 | -------------------------------------------------------------------------------- /test/nw/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nw-demo", 3 | "main": "index.html", 4 | "window": { 5 | "toolbar": false, 6 | "width": 800, 7 | "height": 600 8 | } 9 | } -------------------------------------------------------------------------------- /test/other_objects.test.js: -------------------------------------------------------------------------------- 1 | var sqlite3 = require('..'); 2 | var assert = require('assert'); 3 | 4 | describe('data types', function() { 5 | var db; 6 | before(function(done) { 7 | db = new sqlite3.Database(':memory:'); 8 | db.run("CREATE TABLE txt_table (txt TEXT)"); 9 | db.run("CREATE TABLE int_table (int INTEGER)"); 10 | db.run("CREATE TABLE flt_table (flt FLOAT)"); 11 | db.wait(done); 12 | }); 13 | 14 | beforeEach(function(done) { 15 | db.exec('DELETE FROM txt_table; DELETE FROM int_table; DELETE FROM flt_table;', done); 16 | }); 17 | 18 | it('should serialize Date()', function(done) { 19 | var date = new Date(); 20 | db.run("INSERT INTO int_table VALUES(?)", date, function (err) { 21 | if (err) throw err; 22 | db.get("SELECT int FROM int_table", function(err, row) { 23 | if (err) throw err; 24 | assert.equal(row.int, +date); 25 | done(); 26 | }); 27 | }); 28 | }); 29 | 30 | it('should serialize RegExp()', function(done) { 31 | var regexp = /^f\noo/; 32 | db.run("INSERT INTO txt_table VALUES(?)", regexp, function (err) { 33 | if (err) throw err; 34 | db.get("SELECT txt FROM txt_table", function(err, row) { 35 | if (err) throw err; 36 | assert.equal(row.txt, String(regexp)); 37 | done(); 38 | }); 39 | }); 40 | }); 41 | 42 | [ 43 | 4294967296.249, 44 | Math.PI, 45 | 3924729304762836.5, 46 | new Date().valueOf(), 47 | 912667.394828365, 48 | 2.3948728634826374e+83, 49 | 9.293476892934982e+300, 50 | Infinity, 51 | -9.293476892934982e+300, 52 | -2.3948728634826374e+83, 53 | -Infinity 54 | ].forEach(function(flt) { 55 | it('should serialize float ' + flt, function(done) { 56 | db.run("INSERT INTO flt_table VALUES(?)", flt, function (err) { 57 | if (err) throw err; 58 | db.get("SELECT flt FROM flt_table", function(err, row) { 59 | if (err) throw err; 60 | assert.equal(row.flt, flt); 61 | done(); 62 | }); 63 | }); 64 | }); 65 | }); 66 | 67 | [ 68 | 4294967299, 69 | 3924729304762836, 70 | new Date().valueOf(), 71 | 2.3948728634826374e+83, 72 | 9.293476892934982e+300, 73 | Infinity, 74 | -9.293476892934982e+300, 75 | -2.3948728634826374e+83, 76 | -Infinity 77 | ].forEach(function(integer) { 78 | it('should serialize integer ' + integer, function(done) { 79 | db.run("INSERT INTO int_table VALUES(?)", integer, function (err) { 80 | if (err) throw err; 81 | db.get("SELECT int AS integer FROM int_table", function(err, row) { 82 | if (err) throw err; 83 | assert.equal(row.integer, integer); 84 | done(); 85 | }); 86 | }); 87 | }); 88 | }); 89 | }); 90 | -------------------------------------------------------------------------------- /test/parallel_insert.test.js: -------------------------------------------------------------------------------- 1 | var sqlite3 = require('..'); 2 | var assert = require('assert'); 3 | var helper = require('./support/helper'); 4 | 5 | describe('parallel', function() { 6 | this.timeout(20000); 7 | 8 | var db; 9 | before(function(done) { 10 | helper.deleteFile('test/tmp/test_parallel_inserts.db'); 11 | helper.ensureExists('test/tmp'); 12 | db = new sqlite3.Database('test/tmp/test_parallel_inserts.db', done); 13 | }); 14 | 15 | var columns = []; 16 | for (var i = 0; i < 128; i++) { 17 | columns.push('id' + i); 18 | } 19 | 20 | it('should create the table', function(done) { 21 | db.run("CREATE TABLE foo (" + columns + ")", done); 22 | }); 23 | 24 | it('should insert in parallel', function(done) { 25 | for (var i = 0; i < 1000; i++) { 26 | for (var values = [], j = 0; j < columns.length; j++) { 27 | values.push(i * j); 28 | } 29 | db.run("INSERT INTO foo VALUES (" + values + ")"); 30 | } 31 | 32 | db.wait(done); 33 | }); 34 | 35 | it('should close the database', function(done) { 36 | db.close(done); 37 | }); 38 | 39 | it('should verify that the database exists', function() { 40 | assert.fileExists('test/tmp/test_parallel_inserts.db'); 41 | }); 42 | 43 | after(function() { 44 | helper.deleteFile('test/tmp/test_parallel_inserts.db'); 45 | }); 46 | }); 47 | -------------------------------------------------------------------------------- /test/profile.test.js: -------------------------------------------------------------------------------- 1 | var sqlite3 = require('..'); 2 | var assert = require('assert'); 3 | 4 | describe('profiling', function() { 5 | var create = false; 6 | var select = false; 7 | 8 | var db; 9 | before(function(done) { 10 | db = new sqlite3.Database(':memory:', done); 11 | 12 | db.on('profile', function(sql, nsecs) { 13 | assert.ok(typeof nsecs === "number"); 14 | if (sql.match(/^SELECT/)) { 15 | assert.ok(!select); 16 | assert.equal(sql, "SELECT * FROM foo"); 17 | console.log('profile select'); 18 | select = true; 19 | } 20 | else if (sql.match(/^CREATE/)) { 21 | assert.ok(!create); 22 | assert.equal(sql, "CREATE TABLE foo (id int)"); 23 | create = true; 24 | } 25 | else { 26 | assert.ok(false); 27 | } 28 | }); 29 | }); 30 | 31 | it('should profile a create table', function(done) { 32 | assert.ok(!create); 33 | db.run("CREATE TABLE foo (id int)", function(err) { 34 | if (err) throw err; 35 | setImmediate(function() { 36 | assert.ok(create); 37 | done(); 38 | }); 39 | }); 40 | }); 41 | 42 | 43 | it('should profile a select', function(done) { 44 | assert.ok(!select); 45 | db.run("SELECT * FROM foo", function(err) { 46 | if (err) throw err; 47 | setImmediate(function() { 48 | assert.ok(select); 49 | done(); 50 | }, 0); 51 | }); 52 | }); 53 | 54 | after(function(done) { 55 | db.close(done); 56 | }); 57 | }); 58 | -------------------------------------------------------------------------------- /test/rerun.test.js: -------------------------------------------------------------------------------- 1 | var sqlite3 = require('..'); 2 | var assert = require('assert'); 3 | 4 | describe('rerunning statements', function() { 5 | var db; 6 | before(function(done) { db = new sqlite3.Database(':memory:', done); }); 7 | 8 | var count = 10; 9 | var inserted = 0; 10 | var retrieved = 0; 11 | 12 | it('should create the table', function(done) { 13 | db.run("CREATE TABLE foo (id int)", done); 14 | }); 15 | 16 | it('should insert repeatedly, reusing the same statement', function(done) { 17 | var stmt = db.prepare("INSERT INTO foo VALUES(?)"); 18 | for (var i = 5; i < count; i++) { 19 | stmt.run(i, function(err) { 20 | if (err) throw err; 21 | inserted++; 22 | }); 23 | } 24 | stmt.finalize(done); 25 | }); 26 | 27 | it('should retrieve repeatedly, resuing the same statement', function(done) { 28 | var collected = []; 29 | var stmt = db.prepare("SELECT id FROM foo WHERE id = ?"); 30 | for (var i = 0; i < count; i++) { 31 | stmt.get(i, function(err, row) { 32 | if (err) throw err; 33 | if (row) collected.push(row); 34 | }); 35 | } 36 | stmt.finalize(function(err) { 37 | if (err) throw err; 38 | retrieved += collected.length; 39 | assert.deepEqual(collected, [ { id: 5 }, { id: 6 }, { id: 7 }, { id: 8 }, { id: 9 } ]); 40 | done(); 41 | }); 42 | }); 43 | 44 | it('should have inserted and retrieved the right amount', function() { 45 | assert.equal(inserted, 5); 46 | assert.equal(retrieved, 5); 47 | }); 48 | 49 | after(function(done) { db.close(done); }); 50 | }); 51 | -------------------------------------------------------------------------------- /test/scheduling.test.js: -------------------------------------------------------------------------------- 1 | var sqlite3 = require('..'); 2 | var assert = require('assert'); 3 | 4 | describe('scheduling', function() { 5 | it('scheduling after the database was closed', function(done) { 6 | var db = new sqlite3.Database(':memory:'); 7 | db.on('error', function(err) { 8 | assert.ok(err.message && err.message.indexOf("SQLITE_MISUSE: Database handle is closed") > -1); 9 | done(); 10 | }); 11 | 12 | db.close(); 13 | db.run("CREATE TABLE foo (id int)"); 14 | }); 15 | 16 | 17 | it('scheduling a query with callback after the database was closed', function(done) { 18 | var db = new sqlite3.Database(':memory:'); 19 | db.on('error', function(err) { 20 | assert.ok(false, 'Event was accidentally triggered'); 21 | }); 22 | 23 | db.close(); 24 | db.run("CREATE TABLE foo (id int)", function(err) { 25 | assert.ok(err.message && err.message.indexOf("SQLITE_MISUSE: Database handle is closed") > -1); 26 | done(); 27 | }); 28 | }); 29 | 30 | it('running a query after the database was closed', function(done) { 31 | var db = new sqlite3.Database(':memory:'); 32 | 33 | var stmt = db.prepare("SELECT * FROM sqlite_master", function(err) { 34 | if (err) throw err; 35 | db.close(function(err) { 36 | assert.ok(err); 37 | assert.ok(err.message && err.message.indexOf("SQLITE_BUSY: unable to close due to") > -1); 38 | 39 | // Running a statement now should not fail. 40 | stmt.run(done); 41 | }); 42 | }); 43 | }); 44 | }); 45 | -------------------------------------------------------------------------------- /test/serialization.test.js: -------------------------------------------------------------------------------- 1 | var sqlite3 = require('..'); 2 | var assert = require('assert'); 3 | 4 | 5 | describe('serialize() and parallelize()', function() { 6 | var db; 7 | before(function(done) { db = new sqlite3.Database(':memory:', done); }); 8 | 9 | var inserted1 = 0; 10 | var inserted2 = 0; 11 | var retrieved = 0; 12 | 13 | var count = 1000; 14 | 15 | it('should toggle', function(done) { 16 | db.serialize(); 17 | db.run("CREATE TABLE foo (txt text, num int, flt float, blb blob)"); 18 | db.parallelize(done); 19 | }); 20 | 21 | it('should insert rows', function() { 22 | var stmt1 = db.prepare("INSERT INTO foo VALUES(?, ?, ?, ?)"); 23 | var stmt2 = db.prepare("INSERT INTO foo VALUES(?, ?, ?, ?)"); 24 | for (var i = 0; i < count; i++) { 25 | // Interleaved inserts with two statements. 26 | stmt1.run('String ' + i, i, i * Math.PI, function(err) { 27 | if (err) throw err; 28 | inserted1++; 29 | }); 30 | i++; 31 | stmt2.run('String ' + i, i, i * Math.PI, function(err) { 32 | if (err) throw err; 33 | inserted2++; 34 | }); 35 | } 36 | stmt1.finalize(); 37 | stmt2.finalize(); 38 | }); 39 | 40 | it('should have inserted all the rows after synchronizing with serialize()', function(done) { 41 | db.serialize(); 42 | db.all("SELECT txt, num, flt, blb FROM foo ORDER BY num", function(err, rows) { 43 | if (err) throw err; 44 | for (var i = 0; i < rows.length; i++) { 45 | assert.equal(rows[i].txt, 'String ' + i); 46 | assert.equal(rows[i].num, i); 47 | assert.equal(rows[i].flt, i * Math.PI); 48 | assert.equal(rows[i].blb, null); 49 | retrieved++; 50 | } 51 | 52 | assert.equal(count, inserted1 + inserted2, "Didn't insert all rows"); 53 | assert.equal(count, retrieved, "Didn't retrieve all rows"); 54 | done(); 55 | }); 56 | }); 57 | 58 | after(function(done) { db.close(done); }); 59 | }); 60 | 61 | describe('serialize(fn)', function() { 62 | var db; 63 | before(function(done) { db = new sqlite3.Database(':memory:', done); }); 64 | 65 | var inserted = 0; 66 | var retrieved = 0; 67 | 68 | var count = 1000; 69 | 70 | it('should call the callback', function(done) { 71 | db.serialize(function() { 72 | db.run("CREATE TABLE foo (txt text, num int, flt float, blb blob)"); 73 | 74 | var stmt = db.prepare("INSERT INTO foo VALUES(?, ?, ?, ?)"); 75 | for (var i = 0; i < count; i++) { 76 | stmt.run('String ' + i, i, i * Math.PI, function(err) { 77 | if (err) throw err; 78 | inserted++; 79 | }); 80 | } 81 | stmt.finalize(); 82 | 83 | db.all("SELECT txt, num, flt, blb FROM foo ORDER BY num", function(err, rows) { 84 | if (err) throw err; 85 | for (var i = 0; i < rows.length; i++) { 86 | assert.equal(rows[i].txt, 'String ' + i); 87 | assert.equal(rows[i].num, i); 88 | assert.equal(rows[i].flt, i * Math.PI); 89 | assert.equal(rows[i].blb, null); 90 | retrieved++; 91 | } 92 | done(); 93 | }); 94 | }); 95 | }); 96 | 97 | 98 | it('should have inserted and retrieved all rows', function() { 99 | assert.equal(count, inserted, "Didn't insert all rows"); 100 | assert.equal(count, retrieved, "Didn't retrieve all rows"); 101 | }); 102 | 103 | after(function(done) { db.close(done); }); 104 | }); 105 | -------------------------------------------------------------------------------- /test/sqlcipher.test.js: -------------------------------------------------------------------------------- 1 | var sqlite3 = require('..'); 2 | var assert = require('assert'); 3 | var fs = require('fs'); 4 | var helper = require('./support/helper'); 5 | 6 | describe('sqlcipher', function() { 7 | before(function() { 8 | helper.ensureExists('test/tmp'); 9 | }); 10 | 11 | before(function() { 12 | helper.deleteFile('test/tmp/test_create.db.enc'); 13 | }); 14 | 15 | var db; 16 | it('should open the database', function(done) { 17 | db = new sqlite3.Database('test/tmp/test_create.db.enc', done); 18 | }); 19 | 20 | it('should enable encryption', function(done) { 21 | db.run("PRAGMA key = 'mysecret'", done); 22 | }); 23 | 24 | 25 | it("should use openssl", function(done) { 26 | db.get("PRAGMA cipher_provider", (err, result) => { 27 | assert.deepEqual(result, { cipher_provider: 'openssl' }); 28 | done(err); 29 | }); 30 | }); 31 | 32 | it('should create a table', function(done) { 33 | db.run("CREATE TABLE foo (id INT, num INT)", done); 34 | }); 35 | 36 | it('should insert data', function(done) { 37 | var stmt = db.prepare("INSERT INTO foo (id, num) VALUES (?, ?)"); 38 | stmt.run(1, 2, function() { 39 | stmt.finalize(); 40 | done(); 41 | }); 42 | }); 43 | 44 | it('should read the table', function(done) { 45 | db.run("SELECT * FROM foo", done); 46 | }); 47 | 48 | it('should close the database', function(done) { 49 | db.close(done); 50 | }); 51 | 52 | it('should have created the file', function() { 53 | assert.fileExists('test/tmp/test_create.db.enc'); 54 | }); 55 | 56 | it("should not be plaintext", function(done) { 57 | const buffer = fs.readFileSync("test/tmp/test_create.db.enc"); 58 | const sqliteMagic = "SQLite format 3"; 59 | const actual = buffer.slice(0, sqliteMagic.length).toString("utf8"); 60 | if (actual == sqliteMagic) { 61 | // The file contains the header in plain-text. 62 | // This means it's definitely not encrypted. 63 | done(new Error("The database is not encrypted!")); 64 | } else { 65 | // Not necessarily encrypted, but at least we did a basic check. 66 | done(); 67 | } 68 | }); 69 | 70 | it('should open the database without a key', function(done) { 71 | db = new sqlite3.Database('test/tmp/test_create.db.enc', done); 72 | }); 73 | 74 | it('should fail to read a table', function(done) { 75 | db.run("SELECT * FROM foo", function(err) { 76 | if (err) { 77 | assert.equal(err.message, 'SQLITE_NOTADB: file is not a database'); 78 | assert.equal(err.errno, sqlite3.NOTADB); 79 | assert.equal(err.code, 'SQLITE_NOTADB'); 80 | done(); 81 | } else { 82 | done(new Error('Completed query without error, but expected SQLITE_NOTADB')); 83 | } 84 | }); 85 | }); 86 | 87 | it('should close the database', function(done) { 88 | db.close(done); 89 | }); 90 | 91 | it('should open the database again', function(done) { 92 | db = new sqlite3.Database('test/tmp/test_create.db.enc', done); 93 | }); 94 | 95 | it('should set the same key', function(done) { 96 | db.run("PRAGMA key = 'mysecret'", done); 97 | }); 98 | 99 | it('should read the table', function(done) { 100 | db.run("SELECT * FROM foo", done); 101 | }); 102 | 103 | it('should close the database', function(done) { 104 | db.close(done); 105 | }); 106 | 107 | after(function() { 108 | helper.deleteFile('test/tmp/test_create.db.enc'); 109 | }); 110 | }); 111 | -------------------------------------------------------------------------------- /test/support/createdb-electron.js: -------------------------------------------------------------------------------- 1 | 2 | var {app} = require('electron'); 3 | var createdb = require('./createdb.js'); 4 | 5 | createdb(function () { 6 | setTimeout(function () { 7 | app.quit(); 8 | }, 20000); 9 | }); 10 | 11 | -------------------------------------------------------------------------------- /test/support/createdb.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | function createdb(callback) { 4 | var existsSync = require('fs').existsSync || require('path').existsSync; 5 | var path = require('path'); 6 | 7 | var sqlite3 = require('../../lib/sqlite3'); 8 | 9 | var count = 1000000; 10 | var db_path = path.join(__dirname,'big.db'); 11 | 12 | function randomString() { 13 | var str = ''; 14 | var chars = 'abcdefghijklmnopqrstuvwxzyABCDEFGHIJKLMNOPQRSTUVWXZY0123456789 '; 15 | for (var i = Math.random() * 100; i > 0; i--) { 16 | str += chars[Math.floor(Math.random() * chars.length)]; 17 | } 18 | return str; 19 | }; 20 | 21 | 22 | if (existsSync(db_path)) { 23 | console.log('okay: database already created (' + db_path + ')'); 24 | if (callback) callback(); 25 | } else { 26 | console.log("Creating test database... This may take several minutes."); 27 | var db = new sqlite3.Database(db_path); 28 | db.serialize(function() { 29 | db.run("CREATE TABLE foo (id INT, txt TEXT)"); 30 | db.run("BEGIN TRANSACTION"); 31 | var stmt = db.prepare("INSERT INTO foo VALUES(?, ?)"); 32 | for (var i = 0; i < count; i++) { 33 | stmt.run(i, randomString()); 34 | } 35 | stmt.finalize(); 36 | db.run("COMMIT TRANSACTION", [], function () { 37 | db.close(callback); 38 | }); 39 | }); 40 | } 41 | }; 42 | 43 | if (require.main === module) { 44 | createdb(); 45 | } 46 | 47 | module.exports = createdb; 48 | -------------------------------------------------------------------------------- /test/support/elmo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/journeyapps/node-sqlcipher/ae62115ba51f596e5366ac8262db57bbc80925a5/test/support/elmo.png -------------------------------------------------------------------------------- /test/support/helper.js: -------------------------------------------------------------------------------- 1 | var assert = require('assert'); 2 | var fs = require('fs'); 3 | var pathExists = require('fs').existsSync || require('path').existsSync; 4 | 5 | exports.deleteFile = function(name) { 6 | try { 7 | fs.unlinkSync(name); 8 | } catch(err) { 9 | if (err.errno !== process.ENOENT && err.code !== 'ENOENT' && err.syscall !== 'unlink') { 10 | throw err; 11 | } 12 | } 13 | }; 14 | 15 | exports.ensureExists = function(name,cb) { 16 | if (!pathExists(name)) { 17 | fs.mkdirSync(name); 18 | }; 19 | } 20 | 21 | assert.fileDoesNotExist = function(name) { 22 | try { 23 | fs.statSync(name); 24 | } catch(err) { 25 | if (err.errno !== process.ENOENT && err.code !== 'ENOENT' && err.syscall !== 'unlink') { 26 | throw err; 27 | } 28 | } 29 | }; 30 | 31 | assert.fileExists = function(name) { 32 | try { 33 | fs.statSync(name); 34 | } catch(err) { 35 | throw err; 36 | } 37 | }; -------------------------------------------------------------------------------- /test/support/prepare.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/journeyapps/node-sqlcipher/ae62115ba51f596e5366ac8262db57bbc80925a5/test/support/prepare.db -------------------------------------------------------------------------------- /test/support/script.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE IF NOT EXISTS map ( 2 | zoom_level INTEGER, 3 | tile_column INTEGER, 4 | tile_row INTEGER, 5 | tile_id TEXT, 6 | grid_id TEXT 7 | ); 8 | 9 | CREATE TABLE IF NOT EXISTS grid_key ( 10 | grid_id TEXT, 11 | key_name TEXT 12 | ); 13 | 14 | CREATE TABLE IF NOT EXISTS keymap ( 15 | key_name TEXT, 16 | key_json TEXT 17 | ); 18 | 19 | CREATE TABLE IF NOT EXISTS grid_utfgrid ( 20 | grid_id TEXT, 21 | grid_utfgrid TEXT 22 | ); 23 | 24 | CREATE TABLE IF NOT EXISTS images ( 25 | tile_data blob, 26 | tile_id text 27 | ); 28 | 29 | CREATE TABLE IF NOT EXISTS metadata ( 30 | name text, 31 | value text 32 | ); 33 | 34 | 35 | CREATE UNIQUE INDEX IF NOT EXISTS map_index ON map (zoom_level, tile_column, tile_row); 36 | CREATE UNIQUE INDEX IF NOT EXISTS grid_key_lookup ON grid_key (grid_id, key_name); 37 | CREATE UNIQUE INDEX IF NOT EXISTS keymap_lookup ON keymap (key_name); 38 | CREATE UNIQUE INDEX IF NOT EXISTS grid_utfgrid_lookup ON grid_utfgrid (grid_id); 39 | CREATE UNIQUE INDEX IF NOT EXISTS images_id ON images (tile_id); 40 | CREATE UNIQUE INDEX IF NOT EXISTS name ON metadata (name); 41 | 42 | 43 | CREATE VIEW IF NOT EXISTS tiles AS 44 | SELECT 45 | map.zoom_level AS zoom_level, 46 | map.tile_column AS tile_column, 47 | map.tile_row AS tile_row, 48 | images.tile_data AS tile_data 49 | FROM map 50 | JOIN images ON images.tile_id = map.tile_id; 51 | 52 | CREATE VIEW IF NOT EXISTS grids AS 53 | SELECT 54 | map.zoom_level AS zoom_level, 55 | map.tile_column AS tile_column, 56 | map.tile_row AS tile_row, 57 | grid_utfgrid.grid_utfgrid AS grid 58 | FROM map 59 | JOIN grid_utfgrid ON grid_utfgrid.grid_id = map.grid_id; 60 | 61 | CREATE VIEW IF NOT EXISTS grid_data AS 62 | SELECT 63 | map.zoom_level AS zoom_level, 64 | map.tile_column AS tile_column, 65 | map.tile_row AS tile_row, 66 | keymap.key_name AS key_name, 67 | keymap.key_json AS key_json 68 | FROM map 69 | JOIN grid_key ON map.grid_id = grid_key.grid_id 70 | JOIN keymap ON grid_key.key_name = keymap.key_name; 71 | -------------------------------------------------------------------------------- /test/trace.test.js: -------------------------------------------------------------------------------- 1 | var sqlite3 = require('..'); 2 | var assert = require('assert'); 3 | 4 | describe('tracing', function() { 5 | it('Database tracing', function(done) { 6 | var db = new sqlite3.Database(':memory:'); 7 | var create = false; 8 | var select = false; 9 | 10 | db.on('trace', function(sql) { 11 | if (sql.match(/^SELECT/)) { 12 | assert.ok(!select); 13 | assert.equal(sql, "SELECT * FROM foo"); 14 | select = true; 15 | } 16 | else if (sql.match(/^CREATE/)) { 17 | assert.ok(!create); 18 | assert.equal(sql, "CREATE TABLE foo (id int)"); 19 | create = true; 20 | } 21 | else { 22 | assert.ok(false); 23 | } 24 | }); 25 | 26 | db.serialize(function() { 27 | db.run("CREATE TABLE foo (id int)"); 28 | db.run("SELECT * FROM foo"); 29 | }); 30 | 31 | db.close(function(err) { 32 | if (err) throw err; 33 | assert.ok(create); 34 | assert.ok(select); 35 | done(); 36 | }); 37 | }); 38 | 39 | 40 | it('test disabling tracing #1', function(done) { 41 | var db = new sqlite3.Database(':memory:'); 42 | 43 | db.on('trace', function(sql) {}); 44 | db.removeAllListeners('trace'); 45 | db._events['trace'] = function(sql) { 46 | assert.ok(false); 47 | }; 48 | 49 | db.run("CREATE TABLE foo (id int)"); 50 | db.close(done); 51 | }); 52 | 53 | 54 | it('test disabling tracing #2', function(done) { 55 | var db = new sqlite3.Database(':memory:'); 56 | 57 | var trace = function(sql) {}; 58 | db.on('trace', trace); 59 | db.removeListener('trace', trace); 60 | db._events['trace'] = function(sql) { 61 | assert.ok(false); 62 | }; 63 | 64 | db.run("CREATE TABLE foo (id int)"); 65 | db.close(done); 66 | }); 67 | }); 68 | -------------------------------------------------------------------------------- /test/unicode.test.js: -------------------------------------------------------------------------------- 1 | var sqlite3 = require('..'); 2 | var assert = require('assert'); 3 | 4 | describe('unicode', function() { 5 | var first_values = [], 6 | trailing_values = [], 7 | chars = [], 8 | subranges = new Array(2), 9 | len = subranges.length, 10 | db, 11 | i; 12 | 13 | before(function(done) { db = new sqlite3.Database(':memory:', done); }); 14 | 15 | for (i = 0x20; i < 0x80; i++) { 16 | first_values.push(i); 17 | } 18 | 19 | for (i = 0xc2; i < 0xf0; i++) { 20 | first_values.push(i); 21 | } 22 | 23 | for (i = 0x80; i < 0xc0; i++) { 24 | trailing_values.push(i); 25 | } 26 | 27 | for (i = 0; i < len; i++) { 28 | subranges[i] = []; 29 | } 30 | 31 | for (i = 0xa0; i < 0xc0; i++) { 32 | subranges[0].push(i); 33 | } 34 | 35 | for (i = 0x80; i < 0xa0; i++) { 36 | subranges[1].push(i); 37 | } 38 | 39 | function random_choice(arr) { 40 | return arr[Math.random() * arr.length | 0]; 41 | } 42 | 43 | function random_utf8() { 44 | var first = random_choice(first_values); 45 | 46 | if (first < 0x80) { 47 | return String.fromCharCode(first); 48 | } else if (first < 0xe0) { 49 | return String.fromCharCode((first & 0x1f) << 0x6 | random_choice(trailing_values) & 0x3f); 50 | } else if (first == 0xe0) { 51 | return String.fromCharCode(((first & 0xf) << 0xc) | ((random_choice(subranges[0]) & 0x3f) << 6) | random_choice(trailing_values) & 0x3f); 52 | } else if (first == 0xed) { 53 | return String.fromCharCode(((first & 0xf) << 0xc) | ((random_choice(subranges[1]) & 0x3f) << 6) | random_choice(trailing_values) & 0x3f); 54 | } else if (first < 0xf0) { 55 | return String.fromCharCode(((first & 0xf) << 0xc) | ((random_choice(trailing_values) & 0x3f) << 6) | random_choice(trailing_values) & 0x3f); 56 | } 57 | } 58 | 59 | function randomString() { 60 | var str = '', 61 | i; 62 | 63 | for (i = Math.random() * 300; i > 0; i--) { 64 | str += random_utf8(); 65 | } 66 | 67 | return str; 68 | } 69 | 70 | 71 | // Generate random data. 72 | var data = []; 73 | var length = Math.floor(Math.random() * 1000) + 200; 74 | for (var i = 0; i < length; i++) { 75 | data.push(randomString()); 76 | } 77 | 78 | var inserted = 0; 79 | var retrieved = 0; 80 | 81 | it('should create the table', function(done) { 82 | db.run("CREATE TABLE foo (id int, txt text)", done); 83 | }); 84 | 85 | it('should insert all values', function(done) { 86 | var stmt = db.prepare("INSERT INTO foo VALUES(?, ?)"); 87 | for (var i = 0; i < data.length; i++) { 88 | stmt.run(i, data[i], function(err) { 89 | if (err) throw err; 90 | inserted++; 91 | }); 92 | } 93 | stmt.finalize(done); 94 | }); 95 | 96 | it('should retrieve all values', function(done) { 97 | db.all("SELECT txt FROM foo ORDER BY id", function(err, rows) { 98 | if (err) throw err; 99 | 100 | for (var i = 0; i < rows.length; i++) { 101 | assert.equal(rows[i].txt, data[i]); 102 | retrieved++; 103 | } 104 | done(); 105 | }); 106 | }); 107 | 108 | it('should have inserted and retrieved the correct amount', function() { 109 | assert.equal(inserted, length); 110 | assert.equal(retrieved, length); 111 | }); 112 | 113 | after(function(done) { db.close(done); }); 114 | }); 115 | -------------------------------------------------------------------------------- /test/upsert.test.js: -------------------------------------------------------------------------------- 1 | var sqlite3 = require('..'); 2 | var assert = require('assert'); 3 | 4 | describe('query properties', function() { 5 | var db; 6 | before(function(done) { 7 | db = new sqlite3.Database(':memory:'); 8 | db.run("CREATE TABLE foo (id INT PRIMARY KEY, count INT)", done); 9 | }); 10 | 11 | (sqlite3.VERSION_NUMBER < 3024000 ? it.skip : it)('should upsert', function(done) { 12 | var stmt = db.prepare("INSERT INTO foo VALUES(?, ?)"); 13 | stmt.run(1, 1, function(err) { // insert 1 14 | if (err) throw err; 15 | var upsert_stmt = db.prepare("INSERT INTO foo VALUES(?, ?) ON CONFLICT (id) DO UPDATE SET count = count + excluded.count"); 16 | upsert_stmt.run(1, 2, function(err) { // add 2 17 | if (err) throw err; 18 | var select_stmt = db.prepare("SELECT count FROM foo WHERE id = ?"); 19 | select_stmt.get(1, function(err, row) { 20 | if (err) throw err; 21 | assert.equal(row.count, 3); // equals 3 22 | }); 23 | }) 24 | }); 25 | db.wait(done); 26 | }); 27 | }); 28 | -------------------------------------------------------------------------------- /test/verbose.test.js: -------------------------------------------------------------------------------- 1 | var sqlite3 = require('..'); 2 | var assert = require('assert'); 3 | 4 | var invalid_sql = 'update non_existent_table set id=1'; 5 | 6 | var originalMethods = { 7 | Database: {}, 8 | Statement: {}, 9 | }; 10 | 11 | function backupOriginalMethods() { 12 | for (var obj in originalMethods) { 13 | for (var attr in sqlite3[obj].prototype) { 14 | originalMethods[obj][attr] = sqlite3[obj].prototype[attr]; 15 | } 16 | } 17 | } 18 | 19 | function resetVerbose() { 20 | for (var obj in originalMethods) { 21 | for (var attr in originalMethods[obj]) { 22 | sqlite3[obj].prototype[attr] = originalMethods[obj][attr]; 23 | } 24 | } 25 | } 26 | 27 | describe('verbose', function() { 28 | it('Shoud add trace info to error when verbose is called', function(done) { 29 | var db = new sqlite3.Database(':memory:'); 30 | backupOriginalMethods(); 31 | sqlite3.verbose(); 32 | 33 | db.run(invalid_sql, function(err) { 34 | assert(err instanceof Error); 35 | 36 | assert( 37 | err.stack.indexOf(`Database#run('${invalid_sql}'`) > -1, 38 | `Stack shoud contain trace info, stack = ${err.stack}` 39 | ); 40 | 41 | done(); 42 | resetVerbose(); 43 | }); 44 | }); 45 | 46 | it('Shoud not add trace info to error when verbose is not called', function(done) { 47 | var db = new sqlite3.Database(':memory:'); 48 | 49 | db.run(invalid_sql, function(err) { 50 | assert(err instanceof Error); 51 | 52 | assert( 53 | err.stack.indexOf(invalid_sql) === -1, 54 | `Stack shoud not contain trace info, stack = ${err.stack}` 55 | ); 56 | 57 | done(); 58 | }); 59 | }); 60 | }); 61 | -------------------------------------------------------------------------------- /tools/docker/architecture/linux-arm/Dockerfile: -------------------------------------------------------------------------------- 1 | #!/bin/echo docker build . -f 2 | # -*- coding: utf-8 -*- 3 | # SPDX-License-Identifier: ISC 4 | # Copyright 2019-present Samsung Electronics Co., Ltd. and other contributors 5 | #{ 6 | # ISC License 7 | # Copyright (c) 2004-2010 by Internet Systems Consortium, Inc. ("ISC") 8 | # Copyright (c) 1995-2003 by Internet Software Consortium 9 | # Permission to use, copy, modify, and /or distribute this software 10 | # for any purpose with or without fee is hereby granted, 11 | # provided that the above copyright notice 12 | # and this permission notice appear in all copies. 13 | # THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES 14 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES 15 | # OF MERCHANTABILITY AND FITNESS. 16 | # IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, 17 | # OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 18 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 19 | # WHETHER IN AN ACTION OF CONTRACT, 20 | # NEGLIGENCE OR OTHER TORTIOUS ACTION, 21 | # ARISING OUT OF OR IN CONNECTION WITH THE USE 22 | # OR PERFORMANCE OF THIS SOFTWARE. 23 | #} 24 | 25 | FROM resin/rpi-raspbian:stretch 26 | MAINTAINER Philippe Coval (p.coval@samsung.com) 27 | 28 | RUN [ "cross-build-start" ] 29 | 30 | ENV DEBIAN_FRONTEND noninteractive 31 | ENV LC_ALL en_US.UTF-8 32 | ENV LANG ${LC_ALL} 33 | 34 | RUN echo "#log: Configuring locales" \ 35 | && set -x \ 36 | && apt-get update -y \ 37 | && apt-get install -y locales \ 38 | && echo "${LC_ALL} UTF-8" | tee /etc/locale.gen \ 39 | && locale-gen ${LC_ALL} \ 40 | && dpkg-reconfigure locales \ 41 | && sync 42 | 43 | ENV project node-sqlite3 44 | 45 | RUN echo "#log: ${project}: Setup system" \ 46 | && set -x \ 47 | && apt-get update -y \ 48 | && apt-get install -y \ 49 | curl \ 50 | sudo \ 51 | build-essential \ 52 | python \ 53 | && apt-get clean \ 54 | && NVM_VERSION="v0.33.8" \ 55 | && NODE_VERSION="--lts=carbon" \ 56 | && curl -o- https://raw.githubusercontent.com/creationix/nvm/${NVM_VERSION}/install.sh | bash \ 57 | && which nvm || . ~/.bashrc \ 58 | && nvm install ${NODE_VERSION} \ 59 | && nvm use ${NODE_VERSION} \ 60 | && sync 61 | 62 | ADD . /usr/local/opt/${project}/src/${project} 63 | WORKDIR /usr/local/opt/${project}/src/${project} 64 | RUN echo "#log: ${project}: Preparing sources" \ 65 | && set -x \ 66 | && which npm || . ~/.bashrc \ 67 | && npm install || cat npm-debug.log \ 68 | && npm install \ 69 | && npm install --unsafe-perm --build-from-source \ 70 | && sync 71 | 72 | WORKDIR /usr/local/opt/${project}/src/${project} 73 | RUN echo "#log: ${project}: Building sources" \ 74 | && set -x \ 75 | && which npm || . ~/.bashrc \ 76 | && npm run pack \ 77 | && npm pack \ 78 | && find ${PWD}/build/stage/ -type f \ 79 | && sync 80 | 81 | RUN [ "cross-build-end" ] 82 | -------------------------------------------------------------------------------- /tools/docker/architecture/linux-arm/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # -*- coding: utf-8 -*- 3 | # SPDX-License-Identifier: ISC 4 | # Copyright 2019-present Samsung Electronics Co., Ltd. and other contributors 5 | #{ 6 | # ISC License 7 | # Copyright (c) 2004-2010 by Internet Systems Consortium, Inc. ("ISC") 8 | # Copyright (c) 1995-2003 by Internet Software Consortium 9 | # Permission to use, copy, modify, and /or distribute this software 10 | # for any purpose with or without fee is hereby granted, 11 | # provided that the above copyright notice 12 | # and this permission notice appear in all copies. 13 | # THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES 14 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES 15 | # OF MERCHANTABILITY AND FITNESS. 16 | # IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, 17 | # OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 18 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 19 | # WHETHER IN AN ACTION OF CONTRACT, 20 | # NEGLIGENCE OR OTHER TORTIOUS ACTION, 21 | # ARISING OUT OF OR IN CONNECTION WITH THE USE 22 | # OR PERFORMANCE OF THIS SOFTWARE. 23 | #} 24 | 25 | set -e 26 | set -x 27 | 28 | this_dir=$(dirname -- "$0") 29 | this_dir=$(realpath "${this_dir}") 30 | this_name=$(basename -- "$0") 31 | top_dir="${this_dir}/../../.." 32 | 33 | module_name="sqlite3" 34 | project="node-${module_name}" 35 | arch="arm" 36 | architecture=$(basename "${this_dir}") 37 | name="${project}-${architecture}" 38 | dir="/usr/local/opt/${project}/" 39 | dist_dir="${dir}/src/${project}/build" 40 | tag=$(git describe --tags || echo v0.0.0) 41 | version=$(echo "${tag}" | cut -dv -f2 | cut -d'-' -f1) 42 | 43 | mkdir -p "${this_dir}/local" "${this_dir}/tmp" 44 | cp -a "/usr/bin/qemu-${arch}-static" "${this_dir}/local" 45 | time docker build -t "${name}" -f "${this_dir}/Dockerfile" . 46 | container=$(docker create "${name}") 47 | mkdir -p "${this_dir}/tmp/${dist_dir}" 48 | rm -rf "${this_dir}/tmp/${dist_dir}" 49 | docker cp "${container}:${dist_dir}" "${this_dir}/tmp/${dist_dir}" 50 | file=$(ls "${this_dir}/tmp/${dist_dir}/stage/${module_name}/"*/*".tar.gz" | head -n1 \ 51 | || echo "/tmp/${USER}/failure.tmp") 52 | 53 | sha256sum "${file}" 54 | -------------------------------------------------------------------------------- /tools/docker/architecture/linux-arm64/Dockerfile: -------------------------------------------------------------------------------- 1 | #!/bin/echo docker build . -f 2 | # -*- coding: utf-8 -*- 3 | # SPDX-License-Identifier: ISC 4 | # Copyright 2019-present Samsung Electronics Co., Ltd. and other contributors 5 | #{ 6 | # ISC License 7 | # Copyright (c) 2004-2010 by Internet Systems Consortium, Inc. ("ISC") 8 | # Copyright (c) 1995-2003 by Internet Software Consortium 9 | # Permission to use, copy, modify, and /or distribute this software 10 | # for any purpose with or without fee is hereby granted, 11 | # provided that the above copyright notice 12 | # and this permission notice appear in all copies. 13 | # THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES 14 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES 15 | # OF MERCHANTABILITY AND FITNESS. 16 | # IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, 17 | # OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 18 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 19 | # WHETHER IN AN ACTION OF CONTRACT, 20 | # NEGLIGENCE OR OTHER TORTIOUS ACTION, 21 | # ARISING OUT OF OR IN CONNECTION WITH THE USE 22 | # OR PERFORMANCE OF THIS SOFTWARE. 23 | #} 24 | 25 | FROM arm64v8/node:carbon 26 | ADD tools/docker/architecture/linux-arm64/local/qemu-aarch64-static /usr/bin/qemu-aarch64-static 27 | 28 | MAINTAINER Philippe Coval (p.coval@samsung.com) 29 | 30 | ENV DEBIAN_FRONTEND noninteractive 31 | ENV LC_ALL en_US.UTF-8 32 | ENV LANG ${LC_ALL} 33 | 34 | RUN echo "#log: Configuring locales" \ 35 | && set -x \ 36 | && apt-get update -y \ 37 | && apt-get install -y locales \ 38 | && echo "${LC_ALL} UTF-8" | tee /etc/locale.gen \ 39 | && locale-gen ${LC_ALL} \ 40 | && dpkg-reconfigure locales \ 41 | && sync 42 | 43 | ENV project node-sqlite3 44 | 45 | RUN echo "#log: ${project}: Setup system" \ 46 | && set -x \ 47 | && apt-get update -y \ 48 | && apt-get install -y \ 49 | curl \ 50 | sudo \ 51 | build-essential \ 52 | python \ 53 | && apt-get clean \ 54 | && NVM_VERSION="v0.33.8" \ 55 | && NODE_VERSION="--lts=carbon" \ 56 | && curl -o- https://raw.githubusercontent.com/creationix/nvm/${NVM_VERSION}/install.sh | bash \ 57 | && which nvm || . ~/.bashrc \ 58 | && nvm install ${NODE_VERSION} \ 59 | && nvm use ${NODE_VERSION} \ 60 | && sync 61 | 62 | ADD . /usr/local/opt/${project}/src/${project} 63 | WORKDIR /usr/local/opt/${project}/src/${project} 64 | RUN echo "#log: ${project}: Preparing sources" \ 65 | && set -x \ 66 | && which npm || . ~/.bashrc \ 67 | && npm install || cat npm-debug.log \ 68 | && npm install \ 69 | && npm install --unsafe-perm --build-from-source \ 70 | && sync 71 | 72 | WORKDIR /usr/local/opt/${project}/src/${project} 73 | RUN echo "#log: ${project}: Building sources" \ 74 | && set -x \ 75 | && which npm || . ~/.bashrc \ 76 | && npm run pack \ 77 | && npm pack \ 78 | && find ${PWD}/build/stage/ -type f \ 79 | && sync 80 | 81 | -------------------------------------------------------------------------------- /tools/docker/architecture/linux-arm64/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # -*- coding: utf-8 -*- 3 | # SPDX-License-Identifier: ISC 4 | # Copyright 2019-present Samsung Electronics Co., Ltd. and other contributors 5 | #{ 6 | # ISC License 7 | # Copyright (c) 2004-2010 by Internet Systems Consortium, Inc. ("ISC") 8 | # Copyright (c) 1995-2003 by Internet Software Consortium 9 | # Permission to use, copy, modify, and /or distribute this software 10 | # for any purpose with or without fee is hereby granted, 11 | # provided that the above copyright notice 12 | # and this permission notice appear in all copies. 13 | # THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES 14 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES 15 | # OF MERCHANTABILITY AND FITNESS. 16 | # IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, 17 | # OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 18 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 19 | # WHETHER IN AN ACTION OF CONTRACT, 20 | # NEGLIGENCE OR OTHER TORTIOUS ACTION, 21 | # ARISING OUT OF OR IN CONNECTION WITH THE USE 22 | # OR PERFORMANCE OF THIS SOFTWARE. 23 | #} 24 | 25 | set -e 26 | set -x 27 | 28 | this_dir=$(dirname -- "$0") 29 | this_dir=$(realpath "${this_dir}") 30 | this_name=$(basename -- "$0") 31 | top_dir="${this_dir}/../../.." 32 | 33 | module_name="sqlite3" 34 | project="node-${module_name}" 35 | arch="aarch64" # AKA: arm64, arm64v8 36 | architecture=$(basename "${this_dir}") 37 | name="${project}-${architecture}" 38 | dir="/usr/local/opt/${project}/" 39 | dist_dir="${dir}/src/${project}/build" 40 | tag=$(git describe --tags || echo v0.0.0) 41 | version=$(echo "${tag}" | cut -dv -f2 | cut -d'-' -f1) 42 | 43 | mkdir -p "${this_dir}/local" "${this_dir}/tmp" 44 | cp -a "/usr/bin/qemu-${arch}-static" "${this_dir}/local" 45 | time docker build -t "${name}" -f "${this_dir}/Dockerfile" . 46 | container=$(docker create "${name}") 47 | mkdir -p "${this_dir}/tmp/${dist_dir}" 48 | rm -rf "${this_dir}/tmp/${dist_dir}" 49 | docker cp "${container}:${dist_dir}" "${this_dir}/tmp/${dist_dir}" 50 | file=$(ls "${this_dir}/tmp/${dist_dir}/stage/${module_name}/"*/*".tar.gz" | head -n1 \ 51 | || echo "/tmp/${USER}/failure.tmp") 52 | 53 | sha256sum "${file}" 54 | --------------------------------------------------------------------------------