JWT Framework
Search…
Algorithm Management

Algorithm Manager Factory Service

The Symfony Bundle provides an Algorithm Manager Factory service. The available algorithms depends on the components installed on your application.
1
<?php
2
3
use Jose\Component\Core\AlgorithmManagerFactory;
4
5
$algorithmManagerFactory = $container->get(AlgorithmManagerFactory::class);
6
$algorithmManager = $algorithmManagerFactory->create(['RS256', 'HS512']);
Copied!

Custom Algorithm

This factory handles all algorithms services tagged with jose.algorithm.
Example:
1
services:
2
Acme\Bundle\Algorithm\FooAlgorihtm:
3
tags:
4
- {'name': 'jose.algorithm', 'alias': 'FOO'}
Copied!
Your algorithm will be available through the algorithm manager factory service and the alias FOO.

PBES2-* Algorithms

When installed, the PBES2-* algorithms available throught the algorithm manager factory. They have the default configuration i.e. salt size = 62 bits and count = 4096. If these values does not fit on your needs, you can create a new algorithm service with your own values:
1
services:
2
my.custom.PBES2HS256A128KW.algorithm:
3
class: Jose\Component\Encryption\Algorithm\KeyEncryption\PBES2HS256A128KW
4
arguments:
5
- 128 # salt size
6
- 10240 # counts
7
tags:
8
- {'name': 'jose.algorithm', 'alias': 'Ultra-Secured PBES2-HS256+A128KW'}
Copied!
You can now use your custom alias:
1
$algorithmManager = $algorithmManagerFactory->create(['Ultra-Secured PBES2-HS256+A128KW']);
Copied!
Last modified 2yr ago