Skip to content

Instantly share code, notes, and snippets.

View Spomky's full-sized avatar
🚀
Stay hungry, stay foolish - SJ

Florent Morselli Spomky

🚀
Stay hungry, stay foolish - SJ
View GitHub Profile
<?php
require_once("vendor/autoload.php");
use Base64Url\Base64Url;
use MIME\Base64URLSafe;
$test = "Hello world";
$time_start = microtime(true);
{
"name": "test",
"description": "TOTP test",
"require": {
"spomky-labs/otphp": "~4.0"
}
}
{
"name": "my/example",
"require": {
"spomky-labs/jose-service": "~0.0.6"
},
"authors": [
{
"name": "John Smith",
"email": "[email protected]"
}
@Spomky
Spomky / ClientInterface.php
Last active January 31, 2018 10:12
Secured Resource Owner Password Credentials Grant Type (proof of concept)
<?php
// src/Acme/ApiBundle/OAuth/SROCGrantType.php
namespace Acme\ApiBundle\OAuth;
use FOS\OAuthServerBundle\Storage\GrantExtensionInterface;
use OAuth2\Model\IOAuth2Client;
/**
<?php
namespace Lexik\Bundle\JWTAuthenticationBundle\Exception;
/**
* Base class for exceptions thrown during JWTEncoderInterface::decode().
*
* @author Robin Chalas <[email protected]>
*/
class JWTDecodeFailureException extends JWTFailureException
@Spomky
Spomky / apn.php
Last active September 24, 2024 14:37
Generate JWT for Apple Push Notification
<?php
require_once 'vendor/autoload.php';
use Jose\Factory\JWKFactory;
use Jose\Factory\JWSFactory;
$key_file = '/PATH/TO/KEY/FILE';
$secret = null; // If the key is encrypted, the secret must be set in this variable
@Spomky
Spomky / ECDH-ES.md
Last active August 9, 2017 22:10
Performance Test Report

Jose Performance Test Suite

suite: 133c83918c0211f8eb71010e6d5b9ee5bf6851e1, date: 2017-08-09, stime: 23:53:25

Only for ECDH-ES encryption process.

benchmark groups subject params mean best worst
ECDHESBench JWE,ECDHES benchEncryption {"payload":"It\u2019s a dangerous business, Frodo, going out your door. You step onto the road, and if you don't keep your feet, there\u2019s no knowing where you might be swept off to.","shared_protected_headers":{"alg":"ECDH-ES","enc":"A128CBC-HS256"},"shared_headers":[],"recipient_headers":[],"recipient_key":{"crv":"P-256","kty":"EC","x":"Kuh77MGkweIENgR_3WjzJ4gEF47yn6yQWAeeNqYC5qo","y":"1koAqIfb5C2PkCT1GYEcW4IcIEdrgOdMcua6G0Eyhtc"}} 37,363.520μs 37,363.520μs 37,363.520μs
@Spomky
Spomky / 2017-08-11_15-08-30.md
Last active August 11, 2017 13:38
Jose Library Performance Reports

Jose Performance Test Suite

suite: 133c83be6080429a71d966ecec21128d31dd5692, date: 2017-08-11, stime: 15:08:30

benchmark groups subject mean best worst params
A128GCMKWBench JWE,A128GCMKW benchEncryption 193.550μs 193.550μs 193.550μs {"payload":"It\u2019s a dangerous business, Frodo, going out your door. You step onto the road, and if you don't keep your feet, there\u2019s no knowing where you might be swept off to.","shared_protected_headers":{"alg":"A128GCMKW","enc":"A128CBC-HS256"},"shared_headers":[],"recipient_headers":[],"recipient_key":{"kty":"oct","k":"GZy6sIZ6wl9NJOKB-jnmVQ"}}
A128GCMKWBench JWE,A128GCMKW benchEncryption 191.550μs 191.550μs 191.550μs {"payload":"It\u2019s a dangerous business, Frodo, going out your door. You step onto the road, and if you don't keep your feet, there\u2019s no knowing where you might be swept off to.","shared_protected_headers":{"alg":"A128GCMKW","enc":"A192
@Spomky
Spomky / truncate.php
Created August 15, 2017 13:59
Truncate
<?php
function truncate($value, $length = 30, $preserve = false, $separator = '...')
{
if ($length < strlen($value)) {
if (true === $preserve) {
if (false === ($breakpoint = strpos($value, ' ', $length))) {
return $value;
}
$length = $breakpoint;
@Spomky
Spomky / Signature algorithms - 2017-09-21.md
Created September 21, 2017 22:35
Jose Performance Test Suite

Jose Performance Test Suite

suite: 133c8a9a843fad997c79f19106136b23269c56fc, date: 2017-09-21, stime: 23:54:29

subject groups revs best mean mode worst params
sign JWS,EdDSA,Ed25519 4096 293.045μs 293.045μs 293.045μs 293.045μs {"algorithm":"EdDSA"}
verify JWS,EdDSA,Ed25519 4096 398.441μs 398.441μs 398.441μs 398.441μs {"input":"eyJhbGciOiJFZERTQSJ9.SXTigJlzIGEgZGFuZ2Vyb3VzIGJ1c2luZXNzLCBGcm9kbywgZ29pbmcgb3V0IHlvdXIgZG9vci4gWW91IHN0ZXAgb250byB0aGUgcm9hZCwgYW5kIGlmIHlvdSBkb24ndCBrZWVwIHlvdXIgZmVldCwgdGhlcmXigJlzIG5vIGtub3dpbmcgd2hlcmUgeW91IG1pZ2h0IGJlIHN3ZXB0IG9mZiB0by4.zwhKxTMnLVgl0KSn9GT2ongThN0hOZkp046k3S296_TKwAXZH3n4OGMavgUgmuhXER3_zRz-nBqJMfUDIoRHBQ"}
sign JWS,ECDSA,ES256 4096 1,676.358μs 1,676.358μs 1,676.358μs 1,676.358μs {"algorithm":"ES256"}