Result:
found 274 distributions and 1006 files matching your query ! ( run in 1.829 )


Bitcoin-Secp256k1

 view release on metacpan or  search on metacpan

lib/Bitcoin/Secp256k1.pm  view on Meta::CPAN


# HIGH LEVEL API
# These methods are implemented in Perl and deliver more convenient API to
# interact with. They are stable and public.

sub verify_private_key
{
	my ($self, $private_key) = @_;

	return $self->_verify_privkey($private_key);
}

sub verify_public_key
{
	my ($self, $public_key) = @_;

lib/Bitcoin/Secp256k1.pm  view on Meta::CPAN

	return !!$success;
}

sub create_public_key
{
	my ($self, $private_key) = @_;

	$self->_create_pubkey($private_key);
	return $self->_pubkey;
}

sub normalize_signature
{

lib/Bitcoin/Secp256k1.pm  view on Meta::CPAN

	return $self->_pubkey($public_key, $compressed);
}

sub sign_message
{
	my ($self, $private_key, $message) = @_;

	return $self->sign_digest($private_key, sha256(sha256($message)));
}

sub sign_message_schnorr
{
	my ($self, $private_key, $message) = @_;

	return $self->sign_digest_schnorr($private_key, sha256($message));
}

sub sign_digest
{
	my ($self, $private_key, $digest) = @_;

	$self->_sign($private_key, $digest);
	return $self->_signature;
}

sub sign_digest_schnorr
{
	my ($self, $private_key, $digest) = @_;

	$self->_sign_schnorr($private_key, $digest);
	return $self->_signature_schnorr;
}

sub verify_message
{

lib/Bitcoin/Secp256k1.pm  view on Meta::CPAN

	$self->_pubkey_negate;

	return $self->_pubkey;
}

sub negate_private_key
{
	my ($self, $private_key) = @_;

	return $self->_privkey_negate($private_key);
}

sub xonly_public_key
{
	my ($self, $public_key) = @_;

lib/Bitcoin/Secp256k1.pm  view on Meta::CPAN

	$self->_pubkey_add($tweak);

	return $self->_pubkey;
}

sub add_private_key
{
	my ($self, $private_key, $tweak) = @_;

	return $self->_privkey_add($private_key, $tweak);
}

sub multiply_public_key
{
	my ($self, $public_key, $tweak) = @_;

lib/Bitcoin/Secp256k1.pm  view on Meta::CPAN

	$self->_pubkey_mul($tweak);

	return $self->_pubkey;
}

sub multiply_private_key
{
	my ($self, $private_key, $tweak) = @_;

	return $self->_privkey_mul($private_key, $tweak);
}

sub combine_public_keys
{
	my ($self, @public_keys) = @_;

lib/Bitcoin/Secp256k1.pm  view on Meta::CPAN


	# first, create a context
	my $secp256k1 = Bitcoin::Secp256k1->new;

	# then, use it to perform ECC operations
	my $public_key = $secp256k1->create_public_key($private_key);
	my $signature = $secp256k1->sign_message($private_key, $message);
	my $valid = $secp256k1->verify_message($public_key, $signature, $message);

	# Schnorr signatures are implemented
	my $schnorr_signature = $secp256k1->sign_message_schnorr($private_key, $message);
	my $xonly_public_key = $secp256k1->xonly_public_key($public_key);
	my $valid = $secp256k1->verify_message_schnorr($xonly_public_key, $schnorr_signature, $message);

=head1 DESCRIPTION

lib/Bitcoin/Secp256k1.pm  view on Meta::CPAN

	$secp256k1 = Bitcoin::Secp256k1->new()

Object constructor. All methods in this package require this object to work
properly. It accepts no arguments.

=head3 verify_private_key

	$valid = $secp256k1->verify_private_key($private_key)

Checks whether bytestring C<$private_key> is a valid private key. Private key
is valid if its length is exactly C<32> and it is below curve order (when
interpreted as a big-endian integer).

Some methods in this module may die if their private key is not valid, but a
chance of picking an invalid 32-byte private key at random are extremely slim.

lib/Bitcoin/Secp256k1.pm  view on Meta::CPAN

Checks whether bytestring C<$public_key> is a valid public key. Some methods in
this module may die if their public key is not valid.

=head3 create_public_key

	$public_key = $secp256k1->create_public_key($private_key)

Creates a public key from a bytestring C<$private_key> and returns a bytestring
C<$public_key>. C<$private_key> must have exact length of C<32>.

The public key is always returned in compressed form, use L</compress_public_key> to get uncompressed form.

=head3 normalize_signature

lib/Bitcoin/Secp256k1.pm  view on Meta::CPAN

signature verification, they produce different Bitcoin addresses (because
address is a hashed public key).

=head3 sign_message

	$signature = $secp256k1->sign_message($private_key, $message)

Signs C<$message>, which may be a bytestring of any length, with
C<$private_key>, which must be a bytestring of length C<32>. Returns
DER-encoded C<$signature> as a bytestring.

C<$message> is first hashed with double SHA256 (known an HASH256 in Bitcoin)
before passing it to signing algorithm (which expects length C<32> bytestrings).

This method always produces normalized, deterministic signatures suitable to
use inside a Bitcoin transaction.

=head3 sign_message_schnorr

	$signature = $secp256k1->sign_message_schnorr($private_key, $message)

Signs C<$message>, which may be a bytestring of any length, with
C<$private_key>, which must be a bytestring of length C<32>. Returns
a Schnorr C<$signature> as a bytestring.

C<$message> is first hashed with SHA256 before passing it to signing algorithm.

This signature is not deterministic, since signing with Schnorr uses 32 bytes

lib/Bitcoin/Secp256k1.pm  view on Meta::CPAN

C<$Bitcoin::Secp256k1::FORCED_SCHNORR_AUX_RAND> to any bytestring of length
C<32>.

=head3 sign_digest

	$signature = $secp256k1->sign_digest($private_key, $message_digest)

Same as L</sign_message>, but it does not perform double SHA256 on its input.
Because of that, C<$message_digest> must be a bytestring of length C<32>.

=head3 sign_digest_schnorr

	$signature = $secp256k1->sign_digest_schnorr($private_key, $message_digest)

Same as L</sign_message_schnorr>, but it does not perform SHA256 on its input.
While Schnorr allows any length message, this method requires
C<$message_digest> to be a bytestring of length C<32>.

lib/Bitcoin/Secp256k1.pm  view on Meta::CPAN


	$xonly_public_key = $secp256k1->xonly_public_key($public_key)

Returns a xonly form of C<$public_key>. This form is used in Taproot.

=head3 negate_private_key

	$negated_private_key = $secp256k1->negated_private_key($private_key)

Negates a private key and returns it.

=head3 negate_public_key

	$negated_public_key = $secp256k1->negate_public_key($public_key)

Negates a public key and returns it.

=head3 add_private_key

	$tweaked = $secp256k1->add_private_key($private_key, $tweak)

Add a C<$tweak> (bytestring of length C<32>) to C<$private_key> (bytestring of
length C<32>). The result is a bytestring containing tweaked private key.

If the arguments or the resulting key are not valid, an exception will be thrown.

=head3 add_public_key

lib/Bitcoin/Secp256k1.pm  view on Meta::CPAN

compressed or uncompressed public key). The result is a bytestring containing
tweaked public key in compressed form.

If the arguments or the resulting key are not valid, an exception will be thrown.

=head3 multiply_private_key

	$tweaked = $secp256k1->multiply_private_key($private_key, $tweak)

Same as L</add_private_key>, but performs multiplication instead of addition.

=head3 multiply_public_key

	$tweaked = $secp256k1->multiply_public_key($public_key, $tweak)

 view all matches for this distribution


Blockchain-Ethereum-Keystore

 view release on metacpan or  search on metacpan

lib/Blockchain/Ethereum/Keystore.pm  view on Meta::CPAN

        ...
    );

    my $keyfile = Blockchain::Ethereum::Keystore::Keyfile->new;
    $keyfile->import_file("...");
    $keyfile->private_key->sign_transaction($transaction);

Export private key:

    my $keyfile = Blockchain::Ethereum::Keystore::Keyfile->new;
    $keyfile->import_file("...");

    # private key bytes
    print $keyfile->private_key->export;

=head1 OVERVIEW

This module provides a collection of Ethereum wallet management utilities.

 view all matches for this distribution


Blockchain-Ethereum-Transaction

 view release on metacpan or  search on metacpan

lib/Blockchain/Ethereum/Transaction.pm  view on Meta::CPAN

        chain_id                 => '0x539'
    );

    # github.com/refeco/perl-ethereum-keystore
    my $key = Blockchain::Ethereum::Keystore::Key->new(
        private_key => pack "H*",
        '4646464646464646464646464646464646464646464646464646464646464646'
    );

    $key->sign_transaction($transaction);

 view all matches for this distribution


Business-OnlinePayment-BitPay-KeyUtils

 view release on metacpan or  search on metacpan

key_utils.c  view on Meta::CPAN


    const char *cPem = pemstring;
    in = BIO_new(BIO_s_mem());
    BIO_puts(in, cPem);
    key = PEM_read_bio_ECPrivateKey(in, NULL, NULL, NULL);
    res = EC_KEY_get0_private_key(key);
    eckey = EC_KEY_new_by_curve_name(NID_secp256k1);
    group = EC_KEY_get0_group(eckey);
    pub_key = EC_POINT_new(group);

    EC_KEY_set_private_key(eckey, res);

    if (!EC_POINT_mul(group, pub_key, res, NULL, NULL, ctx)) {
        return ERROR;
    }

 view all matches for this distribution


Business-OnlinePayment-Braintree

 view release on metacpan or  search on metacpan

lib/Business/OnlinePayment/Braintree.pm  view on Meta::CPAN

    use Business::OnlinePayment;

    $tx = new Business::OnlinePayment('Braintree',
                                      merchant_id => 'your merchant id',
                                      public_key => 'your public key',
                                      private_key => 'your private key',
                                     );

    $tx->test_transaction(1); # sandbox transaction for development and tests
  
    $tx->content(amount => 100,

lib/Business/OnlinePayment/Braintree.pm  view on Meta::CPAN


    $self->build_subs(qw(card_token));

    $config->merchant_id($opts{merchant_id});
    $config->public_key($opts{public_key});
    $config->private_key($opts{private_key});

    return;
}

=head1 AUTHOR

 view all matches for this distribution


Business-OnlinePayment-CardFortress

 view release on metacpan or  search on metacpan

lib/Business/OnlinePayment/CardFortress.pm  view on Meta::CPAN

  $self->port('443') unless $self->port;
  $self->path('/bop/index.html') unless $self->path;

  $self->build_subs(qw( order_number avs_code cvv2_response
                        response_page response_code response_headers
                        card_token private_key txn_date
                   ));
}

sub submit {
  my $self = shift;

lib/Business/OnlinePayment/CardFortress.pm  view on Meta::CPAN

  # response_page()

  #handle the challenge/response handshake
  if ( $self->error_message eq '_challenge' ) { #XXX infinite loop protection?

    my $private_key = $self->private_key
      or die "no private key available";

    $private_key = read_file($private_key)
      if $private_key !~ /-----BEGIN/ && -r $private_key;

    #decrypt the challenge with the private key
    my $challenge = decode_base64($response{'card_challenge'});

    #here is the hardest part to implement at each client side
    my $rsa_priv = Crypt::OpenSSL::RSA->new_private_key($private_key);
    my $response = $rsa_priv->decrypt($challenge);

    #try the transaction again with the challenge response
    # (B:OP could sure use a better way to alter one value)
    my %content = $self->content;

lib/Business/OnlinePayment/CardFortress.pm  view on Meta::CPAN

  my $tx = new Business::OnlinePayment(
    'CardFortress',
      'gateway'          => 'ProcessingGateway',
      'gateway_login'    => 'gwlogin',
      'gateway_password' => 'gwpass',
      #private_key not necessary
  );

  $tx->content(
      type           => 'VISA',
      login          => 'cardfortress_login',

lib/Business/OnlinePayment/CardFortress.pm  view on Meta::CPAN

  my $rx = new Business::OnlinePayment(
    'CardFortress',
      'gateway'          => 'ProcessingGateway',
      'gateway_login'    => 'gwlogin',
      'gateway_password' => 'gwpass',
      'private_key'      => $private_key_string, #or filename
      'bop_options'      => join('/', map "$_=".$options{$_}, keys %options),
  );

  $rx->content(
      type           => 'VISA',

 view all matches for this distribution


Business-OnlinePayment-StoredTransaction

 view release on metacpan or  search on metacpan

lib/Business/OnlinePayment/StoredTransaction/Unstore.pm  view on Meta::CPAN

our @EXPORT = ();

our $VERSION = '0.01';

#takes private RSA key and string returned by StoredTransaction->authorization
#takes arguments (private_key => $privkey, authorization => $auth)
sub new {
    my $invocant = shift;
    my $class = ref($invocant) || $invocant;
    my $self = {
        @_,
    };
    bless $self, $class;

    croak "missing 'private_key'" unless $self->{'private_key'};
    my $privkey = $self->{'private_key'};
    croak "missing 'authorization'" unless $self->{'authorization'};
    croak "bad authorization" unless $self->{'authorization'} =~ /:/;
    my ($seckey, $ciphertext) = split /:/, $self->{'authorization'};
    $seckey = decode_base64($seckey);
    $ciphertext = decode_base64($ciphertext);
    my $rsa_priv;
    eval {$rsa_priv = Crypt::OpenSSL::RSA->new_private_key($privkey)};
    croak $@ if $@;
    eval {$seckey = $rsa_priv->decrypt($seckey)};
    croak $@ if $@;
    my $cipher = Crypt::CBC->new( {'key' => $seckey,
                                   'cipher' => 'Blowfish',

lib/Business/OnlinePayment/StoredTransaction/Unstore.pm  view on Meta::CPAN


=head1 SYNOPSIS

  use Business::OnlinePayment::StoredTransaction::Unstore;
  my $bitz = Business::OnlinePayment::StoredTransaction::Unstore->new(
      private_key => '-----BEGIN RSA PRIVATE KEY-----
MIICXQIBAAKBgQDqCih9AmZurFhxoOEsoIpL7wHnA0vi8eopVGfJiFSXldnemIxC
UY8tdk0hXSUwtEogQ2yeFB8+Wsl4S0oStFb2kGPrH2cDF9UjWTWFMjvE+4GO0Asz  
q3Ek0gnAQazVs89AjFlDuaDiCGHryhIprbA7wbZVWmCQKyXcCavSgf0Y0QIDAP//
AoGABlQEpEXw4vbz6yZwvRGkTunpSxRV5ZzIHZ4x3JjYQmGDoZRpf0SLz5p+eGFp
HtY+x1YaCfA9OIDU62GUhk3+l+QIuhjV0/2cnAQ8x81r82zmbioWcmkAyLYKrkgS

 view all matches for this distribution


Business-TrueLayer

 view release on metacpan or  search on metacpan

lib/Business/TrueLayer.pm  view on Meta::CPAN


        # required constructor arguments
        client_id     => $truelayer_client_id,
        client_secret => $truelauer_client_secret,
        kid           => $truelayer_kid,
        private_key   => '/path/to/private/key',

        # optional constructor arguments (with defaults)
        host          => 'truelayer.com',
        api_host      => 'api.truelayer.com',
        auth_host     => 'auth.truelayer.com',

 view all matches for this distribution



CPAN-Testers-API

 view release on metacpan or  search on metacpan

Rexfile  view on Meta::CPAN


#######################################################################
# Settings

user 'cpantesters';
private_key '~/.ssh/cpantesters-rex';

# Used to find local, dev copies of the dist
set 'dist_name' => 'CPAN-Testers-API';

#######################################################################

 view all matches for this distribution


CPAN-Testers-Backend

 view release on metacpan or  search on metacpan

Rexfile  view on Meta::CPAN


#######################################################################
# Settings

user 'cpantesters';
private_key '~/.ssh/cpantesters-rex';

# Used to find local, dev copies of the dist
set 'dist_name' => 'CPAN-Testers-Backend';

#######################################################################

 view all matches for this distribution


CPAN-Testers-Metabase-AWS

 view release on metacpan or  search on metacpan

t/config/profiles.conf  view on Meta::CPAN

default = cpantesters
[cpantesters]
access_key_id = XXXXXXXXXXXXXXXXXXXX
secret_access_key = XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
certificate_file = my-cert.pem
private_key_file = my-key.pem
ec2_keypair_name = my-ec2-keypair
ec2_keypair_file = ec2-private-key.pem
aws_account_id = 0123-4567-8901
canonical_user_id = 64-character-string

 view all matches for this distribution


CPAN-Testers-Schema

 view release on metacpan or  search on metacpan

Rexfile  view on Meta::CPAN


#######################################################################
# Settings

user 'cpantesters';
private_key '~/.ssh/cpantesters-rex';

# Used to find local, dev copies of the dist
set 'dist_name' => 'CPAN-Testers-Schema';

#######################################################################

 view all matches for this distribution


Captcha-NocaptchaMailru

 view release on metacpan or  search on metacpan

lib/Captcha/NocaptchaMailru.pm  view on Meta::CPAN

    return join('&', @pairs);
}

sub _generate_check_url {
    my ($key, $id, $val) = @_;
    return API_SERVER . '/check?' . _pack_params({'private_key' => $key,
                                                  'captcha_id' => $id,
                                                  'captcha_value' => $val});
}

sub check_detailed {

 view all matches for this distribution


Captcha-reCaptcha

 view release on metacpan or  search on metacpan

lib/Captcha/reCAPTCHA.pm  view on Meta::CPAN


    # Version 1 (not recommended)
    print $c->get_html( 'your public key here' );

    # Verify submission
    my $result $c->check_answer_v2($private_key, $response, $ENV{REMOTE_ADDR});

    # Verify submission (Old Version)
    my $result = $c->check_answer(
        'your private key here', $ENV{'REMOTE_ADDR'},
        $challenge, $response

 view all matches for this distribution


Catalyst-Model-WebService-MyGengo

 view release on metacpan or  search on metacpan

lib/Catalyst/Model/WebService/MyGengo.pm  view on Meta::CPAN

    use parent qw( Catalyst::Model::WebService::MyGengo );
    
    __PACKAGE__->config({
        class           => 'WebService::MyGengo::Client'
        , public_key    => 'your API public key'
        , private_key   => 'your API private key'
        , use_sandbox   => 0    # Whether to use the production site or the sandbox
        # See WebService::MyGengo::Client for other options
        });
    
    1;

lib/Catalyst/Model/WebService/MyGengo.pm  view on Meta::CPAN

characters in your keys (eg \#) ):

    <Model::MyGengo>
        class           WebService::MyGengo::Client
        public_key      my-sandbox-pubkey
        private_key     my-sandbox-privkey
        use_sandbox     1
    </Model::MyGengo>

Then, in a controller:

 view all matches for this distribution


Catalyst-View-APNS

 view release on metacpan or  search on metacpan

lib/Catalyst/View/APNS.pm  view on Meta::CPAN

use Data::Dumper;
use Carp;
use Catalyst::Exception;
our $VERSION = '0.01';

__PACKAGE__->mk_accessors(qw(apns cv certification private_key passwd));

sub new {
    my ( $class, $c, $arguments ) = @_;
    my $self = $class->next::method($c);

lib/Catalyst/View/APNS.pm  view on Meta::CPAN

        }
    }
    unless ( $self->certification ) {
        croak "Invalied certification";
    }
    unless ( $self->private_key ) {
        croak "Invalied private_key";
    }
    return $self;
}

sub process {
    my ( $self, $c ) = @_;
    my $apns   = Net::APNS->new;
    my $notify = $apns->notify(
        {
            cert => $self->certification,
            key  => $self->private_key,
        }
    );
    if ( $self->passwd ) {
        $notify->passwd( $self->passwd );
    }

lib/Catalyst/View/APNS.pm  view on Meta::CPAN

# Configure in lib/MyApp.pm
MyApp->config(
    {
        apns => {
            certification => cert    #require to specify
              private_key => key     #require to specify
        }
    }
);

sub hello : Local {

 view all matches for this distribution


Chef-REST-Client

 view release on metacpan or  search on metacpan

lib/Chef.pm  view on Meta::CPAN

    my ($self,$hosted_chef) = (@_);
       $self->{ 'HOSTED_CHEF_' } = $hosted_chef if defined $server;;
    return $self->{ 'HOSTED_CHEF' };
  }
  
  sub private_key {
    my ($self,$private_key) = (@_);
           $self->{ 'CHEF_CLIENT_PRIVATE_KEY' } = $private_key if defined $private_key;
    return $self->{ 'CHEF_CLIENT_PRIVATE_KEY' };
  }
}#nwe

__DATA__

 view all matches for this distribution


Class-Struct-FIELDS

 view release on metacpan or  search on metacpan

FIELDS.pm  view on Meta::CPAN

Fields starting with a leading underscore, C<_>, are private: they are
still valid fields, but C<Class::Struct::FIELDS> does not create
subroutines to access them.  Instead, you should access them the usual
way for hash members:

    $self->{_private_key}; # ok
    $self->_private_key; # Compilation error

See L<fields> for more details.

=head2 Extra magic: auto-stringify

 view all matches for this distribution


CloudCron

 view release on metacpan or  search on metacpan

t/crontab  view on Meta::CPAN

#
# Tplanas daily provision workfacts report
45 23 * * 1-5 bash -c /opt/deploy/code/portal/script/report_daily_provision_workfacts.pl

## Import CAPSiDE aliases to show in portal.capside.com
#3-59/10 * * * * /usr/bin/scp -i /home/portal/ialonso/private_key/portal.key portal@n020125.sys.capside.net:/home/portal/output.file /home/portal/ialonso/output.file
#

# CAPSiDE Ops Team Almighty Ticket Dispatching Tool (tm)
0,15,30,45 * * * 1-5 bash -c /opt/deploy/code/portal/script/dispatcher_unclassified_tickets
5 14 * * 1-5 bash -c /opt/deploy/code/portal/script/dispatcher_backup_patching_tickets

 view all matches for this distribution


Convert-ASN1

 view release on metacpan or  search on metacpan

examples/tsa3161  view on Meta::CPAN

	open TSAKEY, "<$filename" or &dieif(1,"cannot open TSAKeyFile '$filename'");
	binmode TSAKEY;
        my $tsa_key_pem;
	read TSAKEY, $tsa_key_pem, $size;  
	close TSAKEY;
        $tsa_key = Crypt::OpenSSL::RSA->new_private_key($tsa_key_pem) or &dieif(1,"TSAKeyFile '$filename' cannot be decoded");
  }

# some magic
my $time = Time::HiRes::gettimeofday() ;
my $now = int($time);

 view all matches for this distribution


Crypt-Bear

 view release on metacpan or  search on metacpan

lib/Crypt/Bear/EC/PrivateKey.pm  view on Meta::CPAN


version 0.002

=head1 SYNOPSIS

my $private_key = Crypt::Bear::EC::PrivateKey->generate('secp256r1', $prng);
my $signature = $private_key->ecdsa_sign('sha256', $hash);
my $shared = $private_key->ecdh_key_exchange($some_public_key);

=head1 DESCRIPTION

This represents a elliptic curve private key. The curve type can be one of the following:

 view all matches for this distribution


Crypt-Cryptoki

 view release on metacpan or  search on metacpan

t/cryptoki.t  view on Meta::CPAN

	unwrap => 1,
	label => 'test',
	id => pack('C*', 0x01, 0x02, 0x03)
);

my ( $public_key, $private_key ) = $session->generate_key_pair($t_public,$t_private);

try {
	my $plain_text = 'plain text';
	my ( $encrypted_text_ref, $len ) = $public_key->encrypt(\$plain_text, length($plain_text));

	( $encrypted_text_ref ) = $private_key->decrypt($encrypted_text_ref, $len);
	diag $$encrypted_text_ref;

	diag explain $public_key->get_attributes(1);
	diag $public_key->export_as_string;

	diag explain $private_key->get_attributes(1);

} catch { diag $_; 0 };

ok $public_key->destroy;
ok $private_key->destroy;

done_testing();

 view all matches for this distribution


Crypt-ECDH_ES

 view release on metacpan or  search on metacpan

lib/Crypt/ECDH_ES.pm  view on Meta::CPAN

	my $mac = hmac_sha256($iv . $ciphertext, $sign_key);
	return pack $format_unauthenticated, '', $public, $mac, $ciphertext;
}

sub ecdhes_decrypt {
	my ($private_key, $packed_data) = @_;

	my ($options, $public, $mac, $ciphertext) = unpack $format_unauthenticated, $packed_data;
	croak 'Unknown options' if $options ne '';

	my $shared = curve25519_shared_secret($private_key, $public);
	my ($encrypt_key, $sign_key) = unpack 'a16 a16', sha256($shared);
	my $iv     = substr sha256($public), 0, 16;
	croak 'MAC is incorrect' if hmac_sha256($iv . $ciphertext, $sign_key) ne $mac;
	my $cipher = Crypt::Rijndael->new($encrypt_key, Crypt::Rijndael::MODE_CBC);

lib/Crypt/ECDH_ES.pm  view on Meta::CPAN

}

my $format_authenticated = 'C/a C/a C/a C/a N/a';

sub ecdhes_encrypt_authenticated {
	my ($public_key_other, $private_key_self, $data) = @_;

	my $public_key_self = curve25519_public_key($private_key_self);
	my $private_ephemeral = curve25519_secret_key(random_bytes(32));
	my $ephemeral_public  = curve25519_public_key($private_ephemeral);
	my $primary_shared  = curve25519_shared_secret($private_ephemeral, $public_key_other);

	my ($primary_encrypt_key, $primary_iv) = unpack 'a16 a16', sha256($primary_shared);
	my $primary_cipher = Crypt::Rijndael->new($primary_encrypt_key, Crypt::Rijndael::MODE_CBC);
	my $encrypted_public_key = $primary_cipher->encrypt($public_key_self, $primary_iv);

	my $secondary_shared = $primary_shared . curve25519_shared_secret($private_key_self, $public_key_other);
	my ($secondary_encrypt_key, $sign_key) = unpack 'a16 a16', sha256($secondary_shared);
	my $cipher = Crypt::Rijndael->new($secondary_encrypt_key, Crypt::Rijndael::MODE_CBC);
	my $iv     = substr sha256($ephemeral_public), 0, 16;

	my $pad_length = 16 - length($data) % 16;

lib/Crypt/ECDH_ES.pm  view on Meta::CPAN

	my $mac = hmac_sha256($iv . $ciphertext, $sign_key);
	return pack $format_authenticated, "\x{1}", $ephemeral_public, $encrypted_public_key, $mac, $ciphertext;
}

sub ecdhes_decrypt_authenticated {
	my ($private_key, $packed_data) = @_;

	my ($options, $ephemeral_public, $encrypted_public_key, $mac, $ciphertext) = unpack $format_authenticated, $packed_data;
	croak 'Unknown options' if $options ne "\x{1}";

	my $primary_shared = curve25519_shared_secret($private_key, $ephemeral_public);
	my ($primary_encrypt_key, $primary_iv) = unpack 'a16 a16', sha256($primary_shared);
	my $primary_cipher = Crypt::Rijndael->new($primary_encrypt_key, Crypt::Rijndael::MODE_CBC);
	my $public_key = $primary_cipher->decrypt($encrypted_public_key, $primary_iv);

	my $secondary_shared = $primary_shared . curve25519_shared_secret($private_key, $public_key);
	my ($secondary_encrypt_key, $sign_key) = unpack 'a16 a16', sha256($secondary_shared);
	my $cipher = Crypt::Rijndael->new($secondary_encrypt_key, Crypt::Rijndael::MODE_CBC);
	my $iv     = substr sha256($ephemeral_public), 0, 16;

	croak 'MAC is incorrect' if hmac_sha256($iv . $ciphertext, $sign_key) ne $mac;

lib/Crypt/ECDH_ES.pm  view on Meta::CPAN

version 0.006

=head1 SYNOPSIS

 my $ciphertext = ecdhes_encrypt($public_key, $data);
 my $plaintext = ecdhes_decrypt($private_key, $ciphertext);

=head1 DESCRIPTION

This module uses elliptic curve cryptography in an ephemerical-static configuration combined with the AES cipher to achieve a hybrid cryptographical system. Both the public and the private key are simply 32 byte blobs.

lib/Crypt/ECDH_ES.pm  view on Meta::CPAN


This will encrypt C<$plaintext> using C<$public_key>. This is a non-deterministic encryption: the result will be different for every invocation.

=head2 ecdhes_decrypt

 my $plaintext = ecdhes_decrypt($private_key, $ciphertext)

This will decrypt C<$ciphertext> (as encrypted using C<ecdhes_encrypt>) using C<$private_key> and return the plaintext.

=head2 ecdhes_encrypt_authenticated

 my $ciphertext = ecdhes_encrypt_authenticated($receiver_public_key, $sender_private_key, $plaintext)

This will encrypt C<$plaintext> using C<$receiver_public_key> and C<$sender_private_key>. This is a non-deterministic encryption: the result will be different for every invocation.

=head2 ecdhes_decrypt_authenticated

 my ($plaintext, $sender_public_key) = ecdhes_decrypt_authenticated($receiver_private_key, $ciphertext)

This will decrypt C<$ciphertext> (as encrypted using C<ecdhes_encrypt_authenticated>) using C<$receiver_private_key> and return the plaintext and the public key of the sender.

=head2 ecdhes_generate_key

 my ($public_key, $private_key) = ecdhes_generate_key()

This function generates a new random curve25519 keypair.

=head1 SEE ALSO

 view all matches for this distribution


Crypt-Ed25519

 view release on metacpan or  search on metacpan

Ed25519.pm  view on Meta::CPAN


=head1 Ed25519 API

=over 4

=item ($public_key, $private_key) = Crypt::Ed25519::generate_keypair

Creates and returns a new random public and private key pair. The public
key is always 32 octets, the private key is always 64 octets long.

=item ($public_key, $private_key) = Crypt::Ed25519::generate_keypair $secret_key

Instead of generating a random keypair, generate them from the given
C<$secret_key> (e.g. as returned by C<Crypt::Ed25519::eddsa_secret_key>.
The derivation is deterministic, i.e. a specific C<$secret_key> will
always result in the same keypair.

A secret key is simply a random bit string, so if you have a good source
of key material, you can simply generate 32 octets from it and use this as
your secret key.

=item $signature = Crypt::Ed25519::sign $message, $public_key, $private_key

Generates a signature for the given message using the public and private
keys. The signature is always 64 octets long and deterministic, i.e. it is
always the same for a specific combination of C<$message>, C<$public_key>
and C<$private_key>, i.e. no external source of randomness is required for
signing.

=item $valid = Crypt::Ed25519::verify $message, $public_key, $signature

Checks whether the C<$signature> is valid for the C<$message> and C<$public_ke>.

Ed25519.pm  view on Meta::CPAN

EdDSA takes a secret and generates a public key from it.

You can convert an EdDSA secret to an Ed25519 private/public key pair
using C<Crypt::Ed25519::generate_keypair>:

   ($public_key, $private_key) = Crypt::Ed25519::generate_keypair $secret

As such, the EdDSA-style API allows you to store only the secret key and
derive the public key as needed. On the other hand, signing using the
private key is faster than using the secret key, so converting the secret
key to a public/private key pair allows you to sign a small message, or

Ed25519.pm  view on Meta::CPAN

and send their public key to the other side. Then both sides can generate
the same shared secret using this function:

=over

=item $shared_secret = Crypt::Ed25519::key_exchange $other_public_key, $own_private_key

Return the 32 octet shared secret generated from the given public and
private key. See SYNOPSIS for an actual example.

=back

 view all matches for this distribution


Crypt-HSM

 view release on metacpan or  search on metacpan

t/softhsm.t  view on Meta::CPAN

	'public-exponent' => [ 1, 0, 1 ],
	label => 'test_pub',
	id => [ 1, 2, 3 ],
);

my %private_key_template = (
	class => 'private-key',
	'key-type' => 'rsa',
	token => 0,
	private => 1,
	sensitive => 1,

t/softhsm.t  view on Meta::CPAN

	unwrap => 1,
	label => 'test',
	id => [ 4, 5, 6 ],
);

my ($public_key, $private_key) = $session->generate_keypair('rsa-pkcs-key-pair-gen', \%public_key_template, \%private_key_template);

note $public_key;
note $private_key;

my $plain_text = 'plain text';
my $encrypted_text = $session->encrypt('rsa-pkcs', $public_key, $plain_text);
note unpack('H*', $encrypted_text);

my $decrypted_text = $session->decrypt('rsa-pkcs', $private_key, $encrypted_text);

is $decrypted_text, $plain_text, 'decrypt: "plain text"';

{
my $signature = $session->sign('sha256-rsa-pkcs', $private_key, $plain_text);
note unpack('H*', $signature);

ok $session->verify('sha256-rsa-pkcs', $public_key, $plain_text, $signature);
}

{
my $signature = $session->sign('sha256-rsa-pkcs-pss', $private_key, $plain_text);
note unpack('H*', $signature);

ok $session->verify('sha256-rsa-pkcs-pss', $public_key, $plain_text, $signature);
}

t/softhsm.t  view on Meta::CPAN


note 'modulus: ', unpack('H*', $attributes->{modulus});
note 'exponent: ', unpack('H*', $attributes->{'public-exponent'});

$public_key->destroy_object;
$private_key->destroy_object;

my $aes_key = $session->generate_key('aes-key-gen', { 'value-len' => 32, token => 0 });

ok $aes_key;

 view all matches for this distribution


Crypt-JWT

 view release on metacpan or  search on metacpan

lib/Crypt/JWT.pm  view on Meta::CPAN

  return Crypt::PK::RSA->new(@$key) if ref($key) eq 'ARRAY';
  # handle also: Crypt::OpenSSL::RSA, Crypt::X509, Crypt::OpenSSL::X509
  my $str;
  if (ref($key) eq 'Crypt::OpenSSL::RSA') {
    # https://metacpan.org/pod/Crypt::OpenSSL::RSA
    $str = $key->is_private ? $key->get_private_key_string : $key->get_public_key_string;
  }
  elsif (ref($key) =~ /^Crypt::(X509|OpenSSL::X509)$/) {
    # https://metacpan.org/pod/Crypt::X509
    # https://metacpan.org/pod/Crypt::OpenSSL::X509
    $str = $key->pubkey;

lib/Crypt/JWT.pm  view on Meta::CPAN

 #instance of Crypt::PK::RSA
 my $data = decode_jwt(token=>$t, key=>Crypt::PK::RSA->new('keyfile.pem'));
 my $data = decode_jwt(token=>$t, key=>Crypt::PK::RSA->new(\$pem_key_string));

 #instance of Crypt::OpenSSL::RSA
 my $data = decode_jwt(token=>$t, key=>Crypt::OpenSSL::RSA->new_private_key($pem_key_string));

 #instance of Crypt::X509 (public key only)
 my $data = decode_jwt(token=>$t, key=>Crypt::X509->new(cert=>$cert));

 #instance of Crypt::OpenSSL::X509 (public key only)

 view all matches for this distribution


Crypt-LE

 view release on metacpan or  search on metacpan

lib/Crypt/LE.pm  view on Meta::CPAN

    my ($self, $file) = @_;
    $self->_reset_key;
    my $key = $self->_file($file);
    return $self->_status(READ_ERROR, "Key reading error.") unless $key;
    eval {
        $key = Crypt::OpenSSL::RSA->new_private_key($self->_convert($key, 'RSA PRIVATE KEY'));
    };
    return $self->_status(LOAD_ERROR, "Key loading error.") if $@;
    return $self->_set_key($key, "Account key loaded.");
}

lib/Crypt/LE.pm  view on Meta::CPAN


sub generate_account_key {
    my $self = shift;
    my ($pk, $err, $code) = _key();
    return $self->_status(INVALID_DATA, $err||"Could not generate account key") unless $pk;
    my $key = Crypt::OpenSSL::RSA->new_private_key(Net::SSLeay::PEM_get_string_PrivateKey($pk));
    _free(k => $pk);
    return $self->_set_key($key, "Account key generated.");
}

=head2 account_key()

lib/Crypt/LE.pm  view on Meta::CPAN

}

sub _set_key {
    my $self = shift;
    my ($key, $msg) = @_;
    my $pem = $key->get_private_key_string;
    my ($n, $e) = $key->get_key_parameters;
    return $self->_status(INVALID_DATA, "Key modulus is divisible by a small prime and will be rejected.") if $self->_is_divisible($n);
    $key->use_pkcs1_padding;
    $key->use_sha256_hash;
    $self->{key_params} = { n => $n, e => $e };

 view all matches for this distribution


Crypt-LibSCEP

 view release on metacpan or  search on metacpan

LibSCEP.xs  view on Meta::CPAN

        }
        BIO_free(b);
    }
    else {
        //we got an engine
        if(!(key = ENGINE_load_private_key(config->handle->configuration->engine, key_str, NULL, NULL))) {
            scep_log(config->handle, ERROR, "Loading private key from engine failed");
            create_err_msg(config, NULL);
        }
    }
    return key;

 view all matches for this distribution


Crypt-MatrixSSL3

 view release on metacpan or  search on metacpan

lib/Crypt/MatrixSSL3.pm  view on Meta::CPAN

                                                                        #                         based on the requested hostname
        # virtual host 0 (also referred in the code as SNI entry 0)
        {
            'hostname' => 'hostname',                                   # regular expression for matching the hostname
            'cert' => '/path/to/certificate;/path/to/CA-chain',         # KEY - certificate (the CA-chain is optional)
            'key' => '/path/to/private_key',                            # KEY - private key
            'DH_param' => /path/to/DH_params',                          # KEY - file containing the DH parameter used with DH ciphers
            'session_ticket_keys' => {                                  # session tickets setup
                'id' => '1234567890123456',                             # KEY - TLS session tickets - 16 bytes unique identifier
                'encrypt_key' => '12345678901234567890123456789012',    # KEY - TLS session tickets - 128/256 bit encryption key
                'hash_key' => '12345678901234567890123456789012',       # KEY - TLS session tickets - 256 bit hash key

 view all matches for this distribution


( run in 1.829 second using v1.01-cache-2.11-cpan-a5abf4f5562 )