togos/rsa-util 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

togos/rsa-util

最新稳定版本:0.1.0

Composer 安装命令:

composer require togos/rsa-util

包简介

Library for generating and verifying RSA signatures

README 文档

README

Build Status

PHP RSA Util

Utilities for generating and verifying signatures and converting between various key formats.

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.

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

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...

/*
 * 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());

统计信息

  • 总下载量: 256
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-11-06