sop/aes-kw 问题修复 & 功能扩展

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

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

sop/aes-kw

最新稳定版本:3.0.0

Composer 安装命令:

composer require sop/aes-kw

包简介

A PHP library for AES Key Wrap algorithm with padding support.

README 文档

README

Build Status Scrutinizer Code Quality Coverage Status License

A PHP library for AES Key Wrap (RFC 3394) algorithm with padding (RFC 5649) support.

Supports AES key sizes of 128, 192 and 256 bits.

Requirements

  • PHP >=7.2
  • openssl
  • hash

Installation

This library is available on Packagist.

composer require sop/aes-kw

Code examples

Here are some simple usage examples. Namespaces are omitted for brevity.

Wrap a 128 bit key with AES-128

Wrap a key of 16 bytes using a 16-byte key encryption key.

$kek = '0123456789abcdef'; // 128-bit key encryption key
$key = 'MySecretPassword'; // key to encrypt
$algo = new AESKW128();
$ciphertext = $algo->wrap($key, $kek);
echo bin2hex($ciphertext);

Outputs:

89efdbc3501f1f5e952a4bbae1329c9f1a47b9fd61b48dee

Unwrap a key

Unwrap a key from previous example. $kek and $algo variables are the same. $ciphertext variable contains the output from a wrapping procedure.

$key = $algo->unwrap($ciphertext, $kek);
echo $key;

Outputs:

MySecretPassword

Wrap an arbitrary length passphrase with AES-192

Wrapping a key that is not a multiple of 64 bits requires padding.

$kek = '012345678901234567890123'; // 192-bit key encryption key
$key = 'My hovercraft is full of eels.'; // passphrase to encrypt
$algo = new AESKW192();
$ciphertext = $algo->wrapPad($key, $kek);
echo bin2hex($ciphertext);

Outputs:

f319811450badfe4385b5534bf26fa6f9fdcd1a593b3ae6b707f15c1015bbf3faf58619818bd8784

Unwrap a key with padding

Key that was wrapped with padding must be unwrapped with unwrapPad.

$key = $algo->unwrapPad($ciphertext, $kek);
echo $key;

Outputs:

My hovercraft is full of eels.

License

This project is licensed under the MIT License.

统计信息

  • 总下载量: 232.42k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-04-18