You will find the integration of :
- scrypt (Zend Framework (http://framework.zend.com/))
- pbkdf2 (Zend Framework (http://framework.zend.com/))
- hdkf
- sign / check signature
This library is created for the gaspSync projet
This library use the codeception tools.
I have implemented the common test vector.
composer dump-autoload
codecept run
The test vector will fail for now, they are in comment but present in test file :
- test scrypt vector 4
- test scrypt vector 5
- test scrypt vector6
- test scrypt vector7
- test scrypt vector4
Function definition :
public function sign($privateKeyPem,$data,$signature_alg=OPENSSL_ALGO_DSS1)
public function verifySign($publicKeyPem,$data,$signature,$signature_alg=OPENSSL_ALGO_DSS1){
$hkdf = \Crypto\Crypto::HKDF($secretToken, $hashmode,null,$hashmod_digest_size,self::HKDF_INFO_SIGNING);
rfc5869 : HKDF
- scrypt function
$scrypt = \Crypto\Crypto::myScrypt($password, $salt,64*1024, 8, 1, 32);
- the function do a hex2bin() for the $password and $salt.
- the function will use DomBlack PHP module if available (don't forget to add it to command line for the tests)
- pbkdf2 function
$crypto = new \Crypto\Crypto();
$key = $crypto->Pbkdf2($hash, $pass=null, $salt=null, $iterations, $length)
- Diverse function :
function hexdecKey($arrayKey){
function bchexdec($hex)
function bcdechex($number)
- Creating private / public key DSA (can be used for the sign / verifySign function):
\CryptoCrypto::generateNewDSAKey('./keyDirectory');
function addPublicHeaderFooter($Key)
function removeHeaderFooter($pemKey)
function PemToDer($Pem)
function DerToKey($der)
function viewPEMElement($PEMKey)
function make_printable($result, $i = 0)
function print_line($start, $depth, $length, $headerlength, $constructed, $type, $extra = false)
When not explicitly set, files are placed under a 3 clause BSD license