2017 © Pedro Peláez
 

library rsa-util

Library for generating and verifying RSA signatures

image

togos/rsa-util

Library for generating and verifying RSA signatures

  • Friday, November 13, 2015
  • by TOGoS
  • Repository
  • 0 Watchers
  • 0 Stars
  • 245 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Build Status, (*1)

PHP RSA Util

Utilities for generating and verifying signatures and converting between various key formats., (*2)

Primary operations revolve around TOGoS_RSAUtil_Signature objects, which represent the signing of a specific piece of data with a specific key. A Signature indicates the key and data (either inline or by a hash URI), the algorithm used to calculate the signature, and the signature data itself., (*3)

See http://www.nuke24.net/docs/2012/RSA.html for my personal collection of information about key formats., (*4)

Usage example

/*
 * Assuming $dataStore is an object that the guy verifying also has
 * access to
 */

$privateKey = file_get_contents('private-key.der'); // Will work with 'pem' files, too.
$publicKey  = file_get_contents('public-key.der');
$payload = "Hello!";

$dataStore->store($payload);
$dataStore->store($publicKey);

$publicKeyUri = "urn:sha1:".TOGoS_Base32::encode(hash('sha1',$publicKey,true));
$sig = TOGoS_RSAUtil::sign($payload, $privateKey, OPENSSL_ALGO_SHA1);


$sigCodec = new TOGoS_RSAUtil_XKRTSignatureCodec();
$sigBlob = $sigCodec->encode($sig);

Send $sigBlob to someone, and they can..., (*5)

/*
 * Assuming $dataStore and $sigBlob are input variables
 * Using XKRT codec, the public key and payload data are referenced by
 * but not contained in the signature.  We fetch them from $dataStore.
 */

$sigCodec = new TOGoS_RSAUtil_XKRTSignatureCodec();
$sig = $sigCodec->decode($sigBlob);
TOGoS_RSAUtil::verify($sig, $dataStore);
echo "Signature was valid!  Here's the data!\n";
echo (string)$dataStore->getBlob($sig->getPayloadUri());

The Versions

13/11 2015

dev-master

9999999-dev

Library for generating and verifying RSA signatures

  Sources   Download

MIT

The Requires

  • php >=5.2

 

The Development Requires

13/11 2015

0.1.0

0.1.0.0

Library for generating and verifying RSA signatures

  Sources   Download

MIT

The Requires

  • php >=5.2

 

The Development Requires