Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
test/unit/File/big-generated-file
*~
/test/unit/File/big-generated-file
/composer.lock
/vendor
defuse-crypto.phar
defuse-crypto.phar.sig
composer.phar
box.phar
phpunit.phar
phpunit.phar.asc
test/unit/File/tmp
11 changes: 10 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,13 @@ sudo: false
matrix:
fast_finish: true

script: ./test.sh
install:
- composer install
- curl -LSs https://box-project.github.io/box2/installer.php | php
- mkdir ~/box
- mv box.phar ~/box/box

script:
- ./test.sh
- PATH=$PATH:~/box/ make -C dist/ build-phar
- ./test.sh dist/defuse-crypto.phar
68 changes: 0 additions & 68 deletions autoload.php

This file was deleted.

15 changes: 11 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,22 @@
"authors": [
{
"name": "Taylor Hornby",
"email": "havoc@defuse.ca"
"email": "taylor@defuse.ca",
"homepage": "https://defuse.ca/"
},
{
"name": "Scott Arciszewski",
"email": "info@paragonie.com",
"homepage": "https://paragonie.com"
}
],
"autoload": {
"files": ["autoload.php"]
"classmap": ["src"]
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@paragonie-scott: Does this change look good to you?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only thing I'm unsure of is the change to using classmap in composer.json. Do we even need to keep autoload.php anymore? If we're keeping autoload.php so that people can require it from a git clone of the repository, then I want composer to use that just so we'll be notified earlier in case it breaks.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'm going to revert this one change.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh wait, we want to get rid of random_compat, so I'll delete that and autoload.php and keep this change.

Copy link
Contributor

@glensc glensc May 15, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, it was all needed, the cleanups were listed as todo items in #258, but somewhy it was closed pointing here, but no back reference to the previous task. i was waiting for base grounds to be settled before actual removing outdated artifacts.

in short: autoload.php file is no longer needed, but change from "files" to "classmap" is needed.

},
"require": {
"php": ">=5.4.0",
"ext-openssl": "*"
"paragonie/random_compat": "~2.0",
"ext-openssl": "*",
"php": ">=5.4.0"
},
"require-dev": {
"nikic/php-parser": "^2.0"
Expand Down
37 changes: 37 additions & 0 deletions dist/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# This builds defuse-crypto.phar. To run this Makefile, `box` and `composer`
# must be installed and in your $PATH. Run it from inside the dist/ directory.

box := $(shell which box)
composer := "composer"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems you broke support for box.phar and box executables (same for other tools). most people have .phar extension when they download stuff, but i also have distro package for composer.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I added corresponding instructions to the developer docs that they have to be called composer and box in your path. I prefer that over adding complexity to the Makefile, since I'm the only one who should be running it anyway.


.PHONY: all
all: sign-phar

.PHONY: sign-phar
sign-phar: build-phar
gpg -u 7B4B2D98 --armor --output defuse-crypto.phar.sig --detach-sig defuse-crypto.phar

# ensure we run in clean tree. export git tree and run there.
.PHONY: build-phar
build-phar:
@echo "Creating .phar from revision $(shell git rev-parse HEAD)."
rm -rf worktree
install -d worktree
(cd $(CURDIR)/..; git archive HEAD) | tar -x -C worktree
$(MAKE) -f $(CURDIR)/Makefile -C worktree defuse-crypto.phar
mv worktree/*.phar .
rm -rf worktree

.PHONY: clean
clean:
rm -vf defuse-crypto.phar defuse-crypto.phar.sig

# Inside workdir/:

defuse-crypto.phar: dist/box.json composer.lock
cp dist/box.json .
php -d phar.readonly=0 $(box) build -c box.json -v

composer.lock:
$(composer) install --no-dev

24 changes: 24 additions & 0 deletions dist/box.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"chmod": "0755",
"finder": [
{
"in": "src",
"name": "*.php"
},
{
"in": "vendor/composer",
"name": "*.php"
},
{
"in": "vendor/paragonie",
"name": "*.php",
"exclude": "other"
}
],
"compactors": [
"Herrera\\Box\\Compactor\\Php"
],
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: I should understand what all the things in this file do, and take a look at box.

"main": "vendor/autoload.php",
"output": "defuse-crypto.phar",
"stub": true
}
Binary file removed dist/defuse-crypto.phar
Binary file not shown.
17 changes: 0 additions & 17 deletions dist/defuse-crypto.phar.sig

This file was deleted.

File renamed without changes.
31 changes: 14 additions & 17 deletions docs/InstallingAndVerifying.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Getting The Code
There are two ways to use this library in your applications. You can either:

1. Use [Composer](https://getcomposer.org/), or
2. `require_once()` a single `.phar` file in your application.
2. `require_once` a single `.phar` file in your application.

Option 1: Using Composer
-------------------------
Expand All @@ -23,16 +23,20 @@ Option 2: Including a PHAR
----------------------------

The `.phar` option lets you include this library into your project simply by
calling `require_once()` on a single file. Simply check out the tag with the
version you want, for example for version 2.0.0 you would do:

```
git checkout v2.0.0
```
calling `require_once` on a single file. Download `defuse-crypto.phar` and
`defuse-crypto.phar.sig` from this project's
[releases](https://github.com/defuse/php-encryption/releases) page.

You should verify the integrity of the `.phar`. The `defuse-crypto.phar.sig`
contains the signature of `defuse-crypto.phar`. It is signed with Taylor
Hornby's PGP key. You can find Taylor's public key in `dist/signingkey.asc`. You
can verify the public key's fingerprint against the Taylor Hornby's [contact
page](https://defuse.ca/contact.htm) and
[twitter](https://twitter.com/DefuseSec/status/723741424253059074).

You'll find the `.phar` file for that release in `dist/defuse-crypto.phar`.
Install it to somewhere on your filesystem, e.g.
`/var/www/lib/defuse-crypto.phar`. You can now use it in your code like this:
Once you have verified the signature, it is safe to use the `.phar`. Place it
somewhere in your file system, e.g. `/var/www/lib/defuse-crypto.phar`, and then
pass that path to `require_once`.

```php
<?php
Expand All @@ -45,10 +49,3 @@ Install it to somewhere on your filesystem, e.g.
// ...
```

You should verify the integrity of the `.phar`. It is signed with Taylor
Hornby's PGP key. The signature file is `dist/defuse-crypto.phar.sig`. You can
find Taylor's public key in `other/signingkey.asc.

You can verify the public key's fingerprint against the Taylor Hornby's [contact
page](https://defuse.ca/contact.htm) and
[twitter](https://twitter.com/DefuseSec/status/723741424253059074).
34 changes: 28 additions & 6 deletions docs/InternalDeveloperDocs.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ following tools installed:

- `php` (with OpenSSL enabled, if you're compiling from source).
- `gpg`
- `composer`

Running the Tests
------------------

Simply run `./test.sh`. This will download a PHPUnit PHAR, verify its
cryptographic signatures, and then use it to run the tests in `test/unit`.
First do `composer install` and then you can run the tests by running
`./test.sh`. This will download a PHPUnit PHAR, verify its cryptographic
signatures, and then use it to run the tests in `test/unit`.

Reporting Bugs
---------------
Expand Down Expand Up @@ -72,6 +74,14 @@ This library is developed around several core values:
Publishing Releases
--------------------

To make a release, you will need to install [composer](https://getcomposer.org/)
and [box](https://github.com/box-project/box2) on your system. They will need to
be available in your `$PATH` so that running the commands `composer` and `box`
in your terminal run them, respectively. You will also need the private key for
signing (ID: 7B4B2D98) available.

Once you have those tools installed and the key available follow these steps:

Make a fresh clone of the repository:

```
Expand All @@ -84,11 +94,23 @@ Check out the branch you want to release:
git checkout <branchname>
```

Run the sign-release script (note this will make a commit on your current
branch):
Generate and sign the `.phar`:

```
./other/sign-release.sh <tagname> <tagmessage>
cd dist
make
```

Push the branch and tag up to GitHub.
Tag the release:

```
git -c user.signingkey=7B4B2D98 tag -s "<TAG NAME>" -m "<TAG MESSAGE>"
```

`<TAG NAME>` should be in the format `v2.0.0` and `<TAG MESSAGE>` should look
like "Release of v2.0.0."

Push the tag to github, then use the
[releases](https://github.com/defuse/php-encryption/releases) page to draft
a new release for that tag. Upload the `.phar` and the `.phar.sig` file to be
included as part of that release.
10 changes: 0 additions & 10 deletions other/build-phar.sh

This file was deleted.

51 changes: 0 additions & 51 deletions other/build_phar.php

This file was deleted.

Loading