Crypt-NamedKeys
view release on metacpan or search on metacpan
{
"abstract" : "A Crypt::CBC wrapper with key rotation support",
"author" : [
"binary.com <BINARY@cpan.org>"
],
"dynamic_config" : 0,
"generated_by" : "Dist::Zilla version 6.024, CPAN::Meta::Converter version 2.150010",
"license" : [
"perl_5"
],
"meta-spec" : {
"url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
"Test::NoTabs" : "0",
"Test::Perl::Critic" : "0",
"Test::Pod" : "1.41",
"Test::Portability::Files" : "0",
"Test::Version" : "1"
}
},
"runtime" : {
"requires" : {
"Carp" : "0",
"Crypt::CBC" : ">= 0, <= 2.37",
"Crypt::Rijndael" : "0",
"Digest::SHA" : "0",
"Encode" : "0",
"JSON::MaybeXS" : "0",
"MIME::Base64" : "0",
"Moo" : "0",
"String::Compare::ConstantTime" : "0",
"YAML::XS" : "0",
"perl" : "5.006",
"strict" : "0",
---
abstract: 'A Crypt::CBC wrapper with key rotation support'
author:
- 'binary.com <BINARY@cpan.org>'
build_requires:
Data::Dumper: '0'
ExtUtils::MakeMaker: '0'
File::Spec: '0'
IO::Handle: '0'
IPC::Open3: '0'
Test::CheckDeps: '0.010'
Test::Differences: '0'
- share
- shares
- t
- xt
provides:
Crypt::NamedKeys:
file: lib/Crypt/NamedKeys.pm
version: '1.13'
requires:
Carp: '0'
Crypt::CBC: '>= 0, <= 2.37'
Crypt::Rijndael: '0'
Digest::SHA: '0'
Encode: '0'
JSON::MaybeXS: '0'
MIME::Base64: '0'
Moo: '0'
String::Compare::ConstantTime: '0'
YAML::XS: '0'
perl: '5.006'
strict: '0'
Makefile.PL view on Meta::CPAN
# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v6.024.
use strict;
use warnings;
use 5.006;
use ExtUtils::MakeMaker 7.64;
my %WriteMakefileArgs = (
"ABSTRACT" => "A Crypt::CBC wrapper with key rotation support",
"AUTHOR" => "binary.com <BINARY\@cpan.org>",
"CONFIGURE_REQUIRES" => {
"ExtUtils::MakeMaker" => "7.64"
},
"DISTNAME" => "Crypt-NamedKeys",
"LICENSE" => "perl",
"MIN_PERL_VERSION" => "5.006",
"NAME" => "Crypt::NamedKeys",
"PREREQ_PM" => {
"Carp" => 0,
"Crypt::CBC" => ">= 0, <= 2.37",
"Crypt::Rijndael" => 0,
"Digest::SHA" => 0,
"Encode" => 0,
"JSON::MaybeXS" => 0,
"MIME::Base64" => 0,
"Moo" => 0,
"String::Compare::ConstantTime" => 0,
"YAML::XS" => 0,
"strict" => 0,
"warnings" => 0
Makefile.PL view on Meta::CPAN
},
"VERSION" => "1.13",
"test" => {
"TESTS" => "t/*.t"
}
);
my %FallbackPrereqs = (
"Carp" => 0,
"Crypt::CBC" => ">= 0, <= 2.37",
"Crypt::Rijndael" => 0,
"Data::Dumper" => 0,
"Digest::SHA" => 0,
"Encode" => 0,
"ExtUtils::MakeMaker" => 0,
"File::Spec" => 0,
"IO::Handle" => 0,
"IPC::Open3" => 0,
"JSON::MaybeXS" => 0,
"MIME::Base64" => 0,
NAME
Crypt::NamedKeys - A Crypt::CBC wrapper with key rotation support
SYNOPSYS
use Crypt::NamedKeys;
my $crypt = Crypt::NamedKeys->new(keyname => 'href');
my $encrypted = $crypt->encrypt_data(data => $href);
my $restored_href = $crypt->decrypt_data(
data => $encrypted->{data},
mac => $encrypted->{mac},
);
requires 'Carp';
# Crypt::CBC v3.01 will deprecate opensslv1 PBKDF, which is used in the code
# Maybe we need to change our code to upgrade this dep
requires 'Crypt::CBC', '<= 2.37';
requires 'Crypt::Rijndael';
requires 'Digest::SHA';
requires 'JSON::MaybeXS';
requires 'MIME::Base64';
requires 'Moo';
requires 'String::Compare::ConstantTime';
requires 'YAML::XS';
requires 'perl', '5.006';
on configure => sub {
lib/Crypt/NamedKeys.pm view on Meta::CPAN
package Crypt::NamedKeys;
use strict;
use warnings;
use Moo;
=head1 NAME
Crypt::NamedKeys - A Crypt::CBC wrapper with key rotation support
=head1 SYNOPSYS
use Crypt::NamedKeys;
my $crypt = Crypt::NamedKeys->new(keyname => 'href');
my $encrypted = $crypt->encrypt_data(data => $href);
my $restored_href = $crypt->decrypt_data(
data => $encrypted->{data},
mac => $encrypted->{mac},
);
lib/Crypt/NamedKeys.pm view on Meta::CPAN
row.
=head2 The Special 'none' keynum
For aes keys before the key versioning was introduced, there is no keynum
associated with the cyphertext, so we use this key.
=cut
use Carp;
use Crypt::CBC;
use Digest::SHA qw(hmac_sha256_base64 sha256);
use Encode;
use JSON::MaybeXS;
use MIME::Base64;
use String::Compare::ConstantTime;
use YAML::XS;
our $VERSION = '1.13';
=head1 CONFIGURATION PARAMETERS
lib/Crypt/NamedKeys.pm view on Meta::CPAN
=cut
my $json = JSON::MaybeXS->new;
sub encrypt_data {
my ($self, %args) = @_;
croak "data argument is required and must be a reference" unless $args{data} and ref $args{data};
my $json_data = Encode::encode_utf8($json->encode($args{data}));
my $cypher = $args{cypher} || 'Rijndael';
# Crypt::CBC generates random 8 bytes salt that it uses to
# derive IV and encryption key from $args{secret}. It uses
# the same algorythm as OpenSSL, the output is identical to
# openssl enc -e -aes-256-cbc -k $args{secret} -salt
my $cbc = Crypt::CBC->new(
-key => &$get_secret(
keyname => $self->keyname,
keynum => $self->keynum,
),
-cipher => $cypher,
-salt => 1,
);
my $data = encode_base64($cbc->encrypt($json_data), '');
my $mac = hmac_sha256_base64(
$data,
lib/Crypt/NamedKeys.pm view on Meta::CPAN
);
return unless ($cyphertext and $secret);
my $msg_mac = hmac_sha256_base64(
$cyphertext,
&$mac_secret(
keynum => $keynum,
keyname => $self->keyname,
));
return unless String::Compare::ConstantTime::equals($msg_mac, $args{mac});
my $cbc = Crypt::CBC->new(
-key => &$get_secret(
keynum => $keynum,
keyname => $self->keyname
),
-cipher => 'Rijndael',
-salt => 1,
);
my $decrypted = $cbc->decrypt(decode_base64($cyphertext));
warn "Unable to decrypt $args{data} with keynum $keynum and keyname " . $self->keyname unless defined $decrypted;
my $data = $json->decode(Encode::decode_utf8($decrypted));
lib/Crypt/NamedKeys.pod view on Meta::CPAN
this file, but rather the original, inline with Crypt::NamedKeys
at lib/Crypt/NamedKeys.pm
(on the system that originally ran this).
If you do edit this file, and don't want your changes to be removed, make
sure you change the first line.
=cut
=head1 NAME
Crypt::NamedKeys - A Crypt::CBC wrapper with key rotation support
=head1 SYNOPSYS
use Crypt::NamedKeys;
my $crypt = Crypt::NamedKeys->new(keyname => 'href');
my $encrypted = $crypt->encrypt_data(data => $href);
my $restored_href = $crypt->decrypt_data(
data => $encrypted->{data},
mac => $encrypted->{mac},
);
t/00-report-prereqs.dd view on Meta::CPAN
'Test::NoTabs' => '0',
'Test::Perl::Critic' => '0',
'Test::Pod' => '1.41',
'Test::Portability::Files' => '0',
'Test::Version' => '1'
}
},
'runtime' => {
'requires' => {
'Carp' => '0',
'Crypt::CBC' => '>= 0, <= 2.37',
'Crypt::Rijndael' => '0',
'Digest::SHA' => '0',
'Encode' => '0',
'JSON::MaybeXS' => '0',
'MIME::Base64' => '0',
'Moo' => '0',
'String::Compare::ConstantTime' => '0',
'YAML::XS' => '0',
'perl' => '5.006',
'strict' => '0',
( run in 1.310 second using v1.01-cache-2.11-cpan-df04353d9ac )