This repository has been archived by the owner on Jul 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create polyfill for libsodium => sodium
- Loading branch information
Smitsel
committed
Sep 12, 2017
0 parents
commit 63aaa70
Showing
6 changed files
with
1,046 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Copyright (c) 2017 Mollie | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Polyfill Libsodium | ||
|
||
A simple Polyfill for giving libsodium compatibility when having sodium installed. | ||
|
||
The new sodium extension has been accepted and will be distributed with PHP >= 7.2. | ||
This will have a few breaking changes: | ||
|
||
- No more `\Sodium\` namespace. Everything must be in the global namespace. | ||
- The extension will be renamed to `sodium`. | ||
|
||
So the current namespaced functions will not work anymore. So we created a polyfill for this. | ||
|
||
Reference: https://github.com/jedisct1/libsodium-php | ||
|
||
# Installation | ||
|
||
**Using Composer:** | ||
|
||
The easiest way to install is to require the polyfill-sodium library with Composer. | ||
`composer require mollie/polyfill-sodium` | ||
|
||
After installation of the package the bootstrap.php file will be autoloaded. | ||
|
||
**Manual installation:** | ||
Checkout or download all the files and include them manually into your project. | ||
|
||
Include the bootstrap file in your project | ||
`require /path/to/vendor/polyfill-sodium/bootstrap.php` | ||
|
||
# License | ||
This software is licensed under the [MIT License](LICENSE) | ||
|
||
© 2017 Mollie |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
if (!defined('\\Sodium\\CRYPTO_AUTH_BYTES')) { | ||
require __DIR__ . "/lib/sodium/constants.php"; | ||
} | ||
|
||
if(!is_callable("\\Sodium\\crypto_aead_aes256gcm_is_available") && is_callable("sodium_crypto_aead_aes256gcm_is_available")) { | ||
require __DIR__ . "/lib/sodium/functions.php"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "mollie/polyfill-libsodium", | ||
"description": "A polyfill package to transition from the libsodium php extension to the sodium extension. Which is included in PHP 7.2", | ||
"type": "library", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Martijn Smit", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"autoload": { | ||
"files": ["./bootstrap.php"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
namespace Sodium; | ||
|
||
const CRYPTO_AEAD_AES256GCM_KEYBYTES = 32; | ||
const CRYPTO_AEAD_AES256GCM_NSECBYTES = 0; | ||
const CRYPTO_AEAD_AES256GCM_NPUBBYTES = 12; | ||
const CRYPTO_AEAD_AES256GCM_ABYTES = 16; | ||
const CRYPTO_AEAD_CHACHA20POLY1305_KEYBYTES = 32; | ||
const CRYPTO_AEAD_CHACHA20POLY1305_NSECBYTES = 0; | ||
const CRYPTO_AEAD_CHACHA20POLY1305_NPUBBYTES = 8; | ||
const CRYPTO_AEAD_CHACHA20POLY1305_ABYTES = 16; | ||
const CRYPTO_AUTH_BYTES = 32; | ||
const CRYPTO_AUTH_KEYBYTES = 32; | ||
const CRYPTO_BOX_SEALBYTES = 16; | ||
const CRYPTO_BOX_SECRETKEYBYTES = 32; | ||
const CRYPTO_BOX_PUBLICKEYBYTES = 32; | ||
const CRYPTO_BOX_KEYPAIRBYTES = 64; | ||
const CRYPTO_BOX_MACBYTES = 16; | ||
const CRYPTO_BOX_NONCEBYTES = 24; | ||
const CRYPTO_BOX_SEEDBYTES = 32; | ||
const CRYPTO_KX_BYTES = 32; | ||
const CRYPTO_KX_PUBLICKEYBYTES = 32; | ||
const CRYPTO_KX_SECRETKEYBYTES = 32; | ||
const CRYPTO_GENERICHASH_BYTES = 32; | ||
const CRYPTO_GENERICHASH_BYTES_MIN = 16; | ||
const CRYPTO_GENERICHASH_BYTES_MAX = 64; | ||
const CRYPTO_GENERICHASH_KEYBYTES = 32; | ||
const CRYPTO_GENERICHASH_KEYBYTES_MIN = 16; | ||
const CRYPTO_GENERICHASH_KEYBYTES_MAX = 64; | ||
const CRYPTO_PWHASH_SCRYPTSALSA208SHA256_SALTBYTES = 32; | ||
const CRYPTO_PWHASH_SCRYPTSALSA208SHA256_STRPREFIX = '$7$'; | ||
const CRYPTO_PWHASH_SCRYPTSALSA208SHA256_OPSLIMIT_INTERACTIVE = 534288; | ||
const CRYPTO_PWHASH_SCRYPTSALSA208SHA256_MEMLIMIT_INTERACTIVE = 16777216; | ||
const CRYPTO_PWHASH_SCRYPTSALSA208SHA256_OPSLIMIT_SENSITIVE = 33554432; | ||
const CRYPTO_PWHASH_SCRYPTSALSA208SHA256_MEMLIMIT_SENSITIVE = 1073741824; | ||
const CRYPTO_SCALARMULT_BYTES = 32; | ||
const CRYPTO_SCALARMULT_SCALARBYTES = 32; | ||
const CRYPTO_SHORTHASH_BYTES = 8; | ||
const CRYPTO_SHORTHASH_KEYBYTES = 16; | ||
const CRYPTO_SECRETBOX_KEYBYTES = 32; | ||
const CRYPTO_SECRETBOX_MACBYTES = 16; | ||
const CRYPTO_SECRETBOX_NONCEBYTES = 24; | ||
const CRYPTO_SIGN_BYTES = 64; | ||
const CRYPTO_SIGN_SEEDBYTES = 32; | ||
const CRYPTO_SIGN_PUBLICKEYBYTES = 32; | ||
const CRYPTO_SIGN_SECRETKEYBYTES = 64; | ||
const CRYPTO_SIGN_KEYPAIRBYTES = 96; | ||
const CRYPTO_STREAM_KEYBYTES = 32; | ||
const CRYPTO_STREAM_NONCEBYTES = 24; | ||
const CRYPTO_PWHASH_OPSLIMIT_INTERACTIVE = 4; | ||
const CRYPTO_PWHASH_MEMLIMIT_INTERACTIVE = 33554432; | ||
const CRYPTO_PWHASH_OPSLIMIT_MODERATE = 6; | ||
const CRYPTO_PWHASH_MEMLIMIT_MODERATE = 134217728; | ||
const CRYPTO_PWHASH_OPSLIMIT_SENSITIVE = 8; | ||
const CRYPTO_PWHASH_MEMLIMIT_SENSITIVE = 536870912; |
Oops, something went wrong.