Skip to content

vinpel/php-Crypto

Repository files navigation

PHP Crypto library

Build Status

You will find the integration of :

This library is created for the gaspSync projet

unit Test

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

Sign / check signature

Function definition :

public function sign($privateKeyPem,$data,$signature_alg=OPENSSL_ALGO_DSS1)
public function verifySign($publicKeyPem,$data,$signature,$signature_alg=OPENSSL_ALGO_DSS1){

Expand function

$hkdf = \Crypto\Crypto::HKDF($secretToken, $hashmode,null,$hashmod_digest_size,self::HKDF_INFO_SIGNING);

rfc5869 : HKDF

$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)

Key manipulation

  • 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)

Copyright

When not explicitly set, files are placed under a 3 clause BSD license

About

HKDF, scrypt tools

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages