view release on metacpan or search on metacpan
lib/Crypt/Hill.pm view on Meta::CPAN
use strict; use warnings;
use Crypt::Hill;
my $crypt = Crypt::Hill->new({ key => 'DDCF' });
my $encoded = $crypt->encode('HELP');
my $decoded = $crypt->decode($encoded);
print "Encoded: [$encoded]\n";
print "Decoded: [$decoded]\n";
=cut
sub decode {
my ($self, $message) = @_;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Crypt/JWT.pm view on Meta::CPAN
return if $args{ignore_claims};
if (ref($payload) ne 'HASH') {
# https://github.com/DCIT/perl-Crypt-JWT/issues/31
# payload needs to be decoded into a HASH for checking any verify_XXXX
for my $claim (qw(exp nbf iat iss sub aud jti)) {
if (defined $args{"verify_$claim"} && $args{"verify_$claim"} != 0) {
croak "JWT: cannot check verify_$claim (payload not decoded JSON/HASH)";
}
}
return; # nothing to check
}
lib/Crypt/JWT.pm view on Meta::CPAN
C<undef> (default) - if possible decode payload from JSON string, if decode_json fails return payload as a raw string (octets).
=item decode_header
C<0> (default) - do not return decoded header as a return value of decode_jwt()
C<1> - return decoded header as a return value of decode_jwt()
my $payload = decode_jwt(token=>$t, key=>$k);
#or
my ($header, $payload) = decode_jwt(token=>$t, key=>$k, decode_header=>1);
view all matches for this distribution
view release on metacpan or search on metacpan
Crypt::License
Read INSTALL for information about missing module Crypt::LockTite
This module set provides tools to effectively obfuscate perl source
code and allow it to be decoded and executed based on host server, user,
expiration date and other parameters. Further, decoding and execution can be
set for a system wide key as well as a unique user key.
In addition, there are a set of utilities that provide email notification of
License expiration and indirect use of the encrypted modules by other
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Crypt/MagicSignatures/Envelope.pm view on Meta::CPAN
my $temp;
# Add data type if given
$self->data_type( $temp ) if $temp = $data->attr->{type};
# Add decoded data
$self->data( b64url_decode( $data->text ) );
# The envelope is empty
unless ($self->data) {
carp 'No data payload defined';
lib/Crypt/MagicSignatures/Envelope.pm view on Meta::CPAN
=head2 data
my $data = $me->data;
$me->data('Hello world!');
The decoded data folded in the MagicEnvelope.
=head2 data_type
my $data_type = $me->data_type;
lib/Crypt/MagicSignatures/Envelope.pm view on Meta::CPAN
$me->data_type('application/atom+xml');
print $me->dom->at('author > uri')->text;
# alice@example.com
The L<Mojo::DOM> object of the decoded data,
in the case the MagicEnvelope contains XML.
B<This attribute is experimental and may change without warnings!>
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Crypt/MagicSignatures/Key.pm view on Meta::CPAN
$v =~ s/\=+$// unless (defined $_[1] ? $_[1] : 1);
$v;
};
# Returns the b64 urlsafe decoded string
sub b64url_decode {
my $v = shift;
return '' unless $v;
$v =~ tr{-_}{+/};
view all matches for this distribution
view release on metacpan or search on metacpan
MatrixSSL.pm view on Meta::CPAN
0+constant('SSL_SUCCESS') => 'SSL_SUCCESS Generic success',
0+constant('SSL_ERROR') => 'SSL_ERROR generic ssl error, see error code',
0+constant('SSL_FULL') => 'SSL_FULL must call sslRead before decoding',
0+constant('SSL_PARTIAL') => 'SSL_PARTIAL more data reqired to parse full msg',
0+constant('SSL_SEND_RESPONSE') => 'SSL_SEND_RESPONSE decode produced output data',
0+constant('SSL_PROCESS_DATA') => 'SSL_PROCESS_DATA succesfully decoded application data',
0+constant('SSL_ALERT') => 'SSL_ALERT weve decoded an alert',
0+constant('SSL_FILE_NOT_FOUND')=> 'SSL_FILE_NOT_FOUND File not found',
0+constant('SSL_MEM_ERROR') => 'SSL_MEM_ERROR Memory allocation failure',
);
MatrixSSL.pm view on Meta::CPAN
=item B<matrixSslDecode>( $ssl, $inBuf, $outBuf, $error, $alertLevel, $alertDescription )
$inBuf and $outBuf are usual string scalars, not (sslBuf_t *) as in C interface.
After succesfull decoding one packet, matrixSslDecode() will cut decoded
packet from $inBuf's beginning.
Reply SSL packets or application data will be appended to $outBuf, if any.
To convert error/alert codes into text use exported hashes:
view all matches for this distribution
view release on metacpan or search on metacpan
t/06.client_server.t view on Meta::CPAN
ok length $tmp < length $client2server,
'outbuf grow (client)';
is undef, _decode($Server_SSL, $client2server, $server2client, $buf);
is $buf, $s.$s,
'decoded ok (server)';
ok !length $client2server,
'outbuf empty (client)';
ok !length $server2client,
'outbuf empty (server)';
t/06.client_server.t view on Meta::CPAN
while (length $client2server) {
is undef, _decode($Server_SSL, $client2server, $server2client, $buf),
'decoding';
}
ok $buf eq $s,
'string split into SSL_MAX_PLAINTEXT_LEN chains decoded ok';
ok !length $client2server,
'outbuf empty (client)';
ok !length $server2client,
'outbuf empty (server)';
view all matches for this distribution
view release on metacpan or search on metacpan
retout = SvPV_nolen(ret);
base16_decode_init(&armor);
if (0 == base16_decode_update(&armor, &retlen, retout, sz, buf))
croak("Failed to decode mpz_t");
if (retlen != sz/2)
croak("size of decoded mpz_t was unexpected");
if (0 == base16_decode_final(&armor))
croak("Failed to finalize mpz_t decoding");
Safefree(buf);
return ret;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Crypt/OOEnigma.pm view on Meta::CPAN
first rotor rotates once for every letter that is encoded, the second rotor
once every 26 letters, the third rotor every 26 squared letters and so on.
The Enigma is configured by selecting several rotors from a larger set, placing
them in a particular order and a particular start position. Received messages
are decoded by setting the Enigma to the same state as the encoding Enigma and
processing the message again. The result is clear text with the letter X
instead of spaces.
For a good description of the Enigma, including some interesting exercises, see
Part IV of "The Pleasures of Counting" by T W Korner, Cambridge University
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Crypt/OpenPGP/Armour.pm view on Meta::CPAN
Version => '0.57',
Comment => 'FooBar',
},
);
my $decoded = Crypt::OpenPGP::Armour->unarmour( $armoured ) or
die Crypt::OpenPGP::Armour->errstr;
=head1 DESCRIPTION
This module converts arbitrary-length strings of binary octets into
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Crypt/OpenSSL/Cloner.pm view on Meta::CPAN
my $oid = $ext->{extnID};
my $extname = $oid_2_ext{$oid};
next if !$extname;
my $der = $ext->{extnValue};
my $parser = $PARSERS{$extname};
my $decoded = $parser->decode($der);
if ($extname eq 'SubjectKeyIdentifier') {
$new_cert->set_extension(
"subjectKeyIdentifier", unpack('H*', $decoded));
} elsif ($extname eq 'KeyUsage') {
#Then try to figure that out, too..
#Apparently this module has a different way of doing things...
# Our sample cert doesn't seem to conform to this.. and using
# A parse of another module, seems to be using OIDs for
lib/Crypt/OpenSSL/Cloner.pm view on Meta::CPAN
iPAddress => "IP",
registeredID => "RID",
);
my @altnames;
my $altname = "";
foreach my $h (@$decoded) {
my ($k,$v) = (%$h);
my $new_k = $asn2openssl{$k};
if (!$new_k) {
warn "Found ASN.1 X509 field $k which doesn't have an OpenSSL mapping";
next;
view all matches for this distribution
view release on metacpan or search on metacpan
}
sub _Test_Encrypt_And_Decrypt {
my ( $p_plaintext_length, $p_rsa, $p_check_private_encrypt ) = @_;
my ( $ciphertext, $decoded_text );
my $plaintext = pack(
"C${p_plaintext_length}",
(
1, 255, 0, 128, 4, # Make sure these characters work
map { int( rand 256 ) } ( 1 .. $p_plaintext_length - 5 )
)
);
ok( $ciphertext = $p_rsa->encrypt($plaintext) );
ok( $decoded_text = $p_rsa->decrypt($ciphertext) );
ok( $decoded_text eq $plaintext );
if ($p_check_private_encrypt) {
ok( $ciphertext = $p_rsa->private_encrypt($plaintext) );
ok( $decoded_text = $p_rsa->public_decrypt($ciphertext) );
ok( $decoded_text eq $plaintext );
}
}
sub _Test_Sign_And_Verify {
my ( $plaintext, $rsa, $rsa_pub, $hash ) = @_;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Crypt/OpenToken.pm view on Meta::CPAN
# fixup: convert "_" to "/" (PingId PHP bindings encode this way)
# fixup: convert "-" to "+" (PingId PHP bindings encode this way)
$token_str =~ tr{_-}{/+};
# Base64 decode it, and we're done.
my $decoded = decode_base64($token_str);
return $decoded;
}
# Custom Base64 encoding; OTK has some oddities in how they encode things
# using Base64.
sub _base64_encode {
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Crypt/PKCS10.pm view on Meta::CPAN
return $pkinfo;
}
# OIDs requiring some sort of special handling
#
# Called with decoded value, returns updated value.
# Key is ASN macro name
my %special;
%special =
(
lib/Crypt/PKCS10.pm view on Meta::CPAN
sub _convert_extensionRequest {
my $self = shift;
my( $extensionRequest ) = @_;
my $parser = $self->_init('extensionRequest');
my $decoded = $parser->decode($extensionRequest) or return [];
foreach my $entry (@{$decoded}) {
my $name = $oids{ $entry->{extnID} };
$name = $variantNames{$name} if( defined $name && exists $variantNames{$name} );
if (defined $name) {
my $asnName = $name;
$asnName =~ tr/ //d;
lib/Crypt/PKCS10.pm view on Meta::CPAN
$dec = $action->( $self, $dec, $asnName, $entry );
}
$entry->{extnValue} = $dec;
}
}
@{$decoded} = grep { defined } @{$decoded};
return $decoded;
}
sub _convert_rdn {
my $self = shift;
my $typeandvalue = shift;
lib/Crypt/PKCS10.pm view on Meta::CPAN
my( $tlen, undef, $tag ) = asn_decode_tag2( $self->{signatureAlgorithm}{parameters} );
if( $tlen != 0 && $tag != ASN_NULL ) {
return $self->{signatureAlgorithm}{parameters}
}
# Known algorithm's parameters MAY return a hash of decoded fields.
# For now, leaving that to the caller...
return;
}
lib/Crypt/PKCS10.pm view on Meta::CPAN
=head1 SYNOPSIS
use Crypt::PKCS10;
Crypt::PKCS10->setAPIversion( 1 );
my $decoded = Crypt::PKCS10->new( $csr ) or die Crypt::PKCS10->error;
print $decoded;
@names = $decoded->extensionValue('subjectAltName' );
@names = $decoded->subject unless( @names );
%extensions = map { $_ => $decoded->extensionValue( $_ ) } $decoded->extensions
=head1 DESCRIPTION
C<Crypt::PKCS10> parses PKCS #10 certificate requests (CSRs) and provides accessor methods to extract the data in usable form.
lib/Crypt/PKCS10.pm view on Meta::CPAN
=head1 METHODS
Access methods may exist for subject name components that are not listed here. To test for these, use code of the form:
$locality = $decoded->localityName if( $decoded->can('localityName') );
If a name component exists in a CSR, the method will be present. The converse is not (always) true.
=head2 class method setAPIversion( $version )
lib/Crypt/PKCS10.pm view on Meta::CPAN
The request may be PEM or binary DER encoded. Only one request is processed.
If PEM, other data (such as mail headers) may precede or follow the CSR.
my $decoded = Crypt::PKCS10->new( $csr ) or die Crypt::PKCS10->error;
Returns C<undef> if there is an I/O error or the request can not be parsed successfully.
Call C<error()> to obtain more detail.
lib/Crypt/PKCS10.pm view on Meta::CPAN
=head3 commonName
Returns the common name(s) from the subject.
my $cn = $decoded->commonName();
=head3 organizationalUnitName
Returns the organizational unit name(s) from the subject
lib/Crypt/PKCS10.pm view on Meta::CPAN
=head2 signatureParams
Returns the parameters associated with the B<signatureAlgorithm> as binary.
Returns B<undef> if none, or if B<NULL>.
Note: In the future, some B<signatureAlgorithm>s may return a hashref of decoded fields.
Callers are advised to check for a ref before decoding...
=head2 signature( $format )
The CSR's signature is returned.
If C<$format> is B<1>, in binary.
If C<$format> is B<2>, decoded as an ECDSA signature - returns hashref to C<r> and C<s>.
Otherwise, in its hexadecimal representation.
=head2 attributes( $name )
lib/Crypt/PKCS10.pm view on Meta::CPAN
Special characters are escaped as described in options.
In array context, the value(s) are returned as a list of items, which may be references.
print( " $_: ", scalar $decoded->attributes($_), "\n" )
foreach ($decoded->attributes);
=for readme stop
See the I<Table of known OID names> below for a list of names.
lib/Crypt/PKCS10.pm view on Meta::CPAN
The names vary depending on the API version; however, the returned names are acceptable to C<extensionValue>, C<extensionPresent>, and C<name2oid>.
The values of extensions vary, however the following code fragment will dump most extensions and their value(s).
print( "$_: ", $decoded->extensionValue($_,1), "\n" ) foreach ($decoded->extensions);
The sample code fragment is not guaranteed to handle all cases.
Production code needs to select the extensions that it understands and should respect
the B<critical> boolean. B<critical> can be obtained with extensionPresent.
view all matches for this distribution
view release on metacpan or search on metacpan
pqclean/crypto_kem/hqc-128/clean/reed_muller.c view on Meta::CPAN
* @brief Decodes the received word
*
* Decoding uses fast hadamard transform, for a more complete picture on Reed-Muller decoding, see MacWilliams, Florence Jessie, and Neil James Alexander Sloane.
* The theory of error-correcting codes codes @cite macwilliams1977theory
*
* @param[out] msg Array of size VEC_N1_SIZE_64 receiving the decoded message
* @param[in] cdw Array of size VEC_N1N2_SIZE_64 storing the received word
*/
void PQCLEAN_HQC128_CLEAN_reed_muller_decode(uint8_t *msg, const uint64_t *cdw) {
uint16_t expanded[128];
uint16_t transform[128];
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Crypt/Passphrase.pm view on Meta::CPAN
If your application is deployed by different people than it's developed by it may be helpful to have the configuration for C<Crypt::Passphrase> part of your application configuration file and not be hardcoded so that your users can choose the right s...
=head2 Unicode
C<Crypt::Passphrase> considers passwords to be text, and as such you should ensure any password input is decoded if it contains any non-ascii characters. C<Crypt::Passphrase> will take care of both normalizing and encoding such input.
=head2 DOS attacks
Hashing passwords is by its nature a heavy operations. It can be abused by malignant actors who want to try to DOS your application. It may be wise to do some form of DOS protection such as a proof-of-work scheme or a captcha.
view all matches for this distribution
view release on metacpan or search on metacpan
t/Crypt-Perl-RSA-PKCS1_v1_5.t view on Meta::CPAN
$_->[0] =~ tr<.><>d for values %strs;
for my $hash_alg (sort keys %strs) {
my $binary = pack 'H*', $strs{$hash_alg}[0];
my $decoded;
lives_ok(
sub {
$decoded = Crypt::Perl::RSA::PKCS1_v1_5::decode($binary, $hash_alg);
},
"decode() succeeds ($hash_alg)",
);
is(
sprintf('%v.02x', $decoded),
$strs{$hash_alg}[1],
"decoded $hash_alg payload",
);
}
done_testing();
view all matches for this distribution
view release on metacpan or search on metacpan
t/90_rncryptor.t view on Meta::CPAN
};
TODO: {
local $TODO = q{
The length of encryption/hmac key have to be 32,
but the length of the data decoded each value of "enc_key_hex"/"hmac_key_hex"
is only 16. Maybe this is mistake of the test vector.
Thus, The following tests are failed because I cannot guess the real value.
};
subtest 'key' => sub {
my $vp = t::assets::VectorParser->load(3, 'key');
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Crypt/RSA.pm view on Meta::CPAN
my $key = $params{Key};
return $self->error ($key->errstr, \%params, $key) unless $key->check();
if ($params{Armour} || $params{Armor}) {
my $decoded = $self->{pp}->unarmour ($cyphertext) ||
return $self->error ($self->{pp}->errstr());
$cyphertext = $$decoded{Content}{Cyphertext}
}
my $plaintext;
my $blocksize = blocksize ( $$self{es}->decryptblock (Key => $key),
length($cyphertext)
lib/Crypt/RSA.pm view on Meta::CPAN
sub verify {
my ($self, %params) = @_;
if ($params{Armour} || $params{Armor}) {
my $decoded = $self->{pp}->unarmour ($params{Signature}) ||
return $self->error ($self->{pp}->errstr());
$params{Signature} = $$decoded{Content}{Signature}
}
my $verify = $self->{ss}->verify (%params) ||
return $self->error ($self->{ss}->errstr, $params{Key}, \%params);
view all matches for this distribution
view release on metacpan or search on metacpan
1.14 - 2019-06-14
* Fix UINT32 and UINT8 for musl libc
1.13 - 2015-05-23
* Correctly null-terminate encoded/decoded strings (RT 769/#5)
1.12 - 2014-01-03
* Get rid of MYMETA
1.11 - 2012-07-28
view all matches for this distribution
view release on metacpan or search on metacpan
look for the matching round key from inside the module to do real job.
=head2 Important notes on Encoding
Please, E<lt>DO NOT use encoding 'blah';.E<gt>
I could not figure out how to restore those decoded bytes into an SV variable
in the script where 'use encoding...' inserted.
Do you know ? Let me know, please.
=head2 EXPORT
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Crypt/SaltedHash.pm view on Meta::CPAN
Return corresponding Boolean value
Our job is to split the original digest up into 2 distinct byte arrays, one of the left 20 (0 - 20 including the null terminator) bytes and
the other for the rest of the data. The left 0 20 bytes will represent the salted binary value we will use for a byte-by-byte data
match against the new clear text presented for verification. The string presented for verification will have to be salted as well. The rest
of the bytes (21 32) represent the random salt which when decoded will show the exact hex characters that make up the once randomly
generated seed.
We are now ready to verify some data. Let's start with the 4 hashes presented earlier. We will run them through our code to extract the
random salt and then using that verify the clear text string hashed by slappasswd. First, let's do a verification test with an erroneous
password; this should fail the matching test:
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Crypt/Trifid.pm view on Meta::CPAN
use Crypt::Trifid;
my $crypt = Crypt::Trifid->new;
my $message = 'TRIFID';
my $encoded = $crypt->encode($message);
my $decoded = $crypt->decode($encoded);
print "Encoded message: [$encoded]\n";
print "Decoded message: [$decoded]\n";
=head1 METHODS
=head2 encode($message)
lib/Crypt/Trifid.pm view on Meta::CPAN
return $encoded;
}
=head2 decode($encoded_message)
It takes an encoded message as scalar string and returns the decoded message.
use strict; use warnings;
use Crypt::Trifid;
my $crypt = Crypt::Trifid->new;
my $message = 'TRIFID';
my $encoded = $crypt->encode($message);
my $decoded = $crypt->decode($encoded);
print "Encoded message: [$encoded]\n";
print "Decoded message: [$decoded]\n";
=cut
sub decode {
my ($self, $message) = @_;
lib/Crypt/Trifid.pm view on Meta::CPAN
push @{$_chars->[$i]}, @nodes[$index..($index+$j-1)];
$index += $j;
$i++;
}
my $decoded = '';
foreach (1..$j) {
my $x = $_chars->[0]->[$_-1];
my $y = $_chars->[1]->[$_-1];
my $z = $_chars->[2]->[$_-1];
$decoded .= $_chart->{sprintf("%d%d%d", $x, $y, $z)};
}
return $decoded;
}
#
#
# PRIVATE METHODS
view all matches for this distribution
view release on metacpan or search on metacpan
cmp_ok( $binary, "ne", $encoded, "encoded != binary" );
cmp_ok( length($binary), "<", length($encoded), "encoded is longer" );
is( $c->decrypt_string( string => $encoded, decode => 1 ), $c->decrypt_string( string => $binary ), "decoded == binary" );
}
ok( !$c->has_default_digest, "no default digest" );
my $fallback_digest = eval { $c->fallback_digest };
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Crypt/X509/CRL.pm view on Meta::CPAN
=head1 SYNOPSIS
use Crypt::X509::CRL;
$decoded = Crypt::X509::CRL->new( crl => $crl );
$subject_email = $decoded->subject_email;
print "do not use after: ".gmtime($decoded->not_after)." GMT\n";
=head1 REQUIRES
Convert::ASN1
lib/Crypt/X509/CRL.pm view on Meta::CPAN
=head2 new ( OPTIONS )
Creates and returns a parsed X.509 CRL hash, containing the parsed
contents. The data is organised as specified in RFC 2459.
By default only the first ASN.1 Layer is decoded. Nested decoding
is done automagically through the data access methods.
=over 4
=item crl =E<gt> $crl
lib/Crypt/X509/CRL.pm view on Meta::CPAN
=head3 Example:
use Crypt::X509::CRL;
use Data::Dumper;
$decoded = Crypt::X509::CRL->new( crl => $crl );
print Dumper $decoded;
=cut back
=head1 METHODS
lib/Crypt/X509/CRL.pm view on Meta::CPAN
Returns the last error from parsing, C<undef> when no error occured.
This error is updated on deeper parsing with the data access methods.
=head3 Example:
$decoded= Crypt::X509::CRL->new(crl => $crl);
if ( $decoded->error ) {
warn "Error on parsing Certificate Revocation List: ", $decoded->error;
}
=cut back
=head1 DATA ACCESS METHODS
lib/Crypt/X509/CRL.pm view on Meta::CPAN
Returns either the utcTime or generalTime of the certificate revocation list's date
of publication. Returns undef if not defined.
=head3 Example:
$decoded = Crypt::X509::CRL->new(crl => $crl);
print "CRL was published at ", gmtime( $decoded->this_update ), " GMT\n";
=cut back
=head2 next_update
Returns either the utcTime or generalTime of the certificate revocation list's
date of expiration. Returns undef if not defined.
=head3 Example:
$decoded = Crypt::X509::CRL->new(crl => $crl);
if ( $decoded->next_update < time() ) {
warn "CRL has expired!";
}
=cut back
lib/Crypt/X509/CRL.pm view on Meta::CPAN
Returns the certificate's signature algorithm as an OID string.
=head3 Example:
$decoded = Crypt::X509::CRL->new(crl => $crl);
print "CRL signature is encrypted with:", $decoded->signature_algorithm, "\n";
Example Output: CRL signature is encrypted with: 1.2.840.113549.1.1.5
=cut back
lib/Crypt/X509/CRL.pm view on Meta::CPAN
Returns the signature encryption algorithm (e.g. 'RSA') as a string.
=head3 Example:
$decoded = Crypt::X509::CRL->new(crl => $crl);
print "CRL signature is encrypted with:", $decoded->SigEncAlg, "\n";
Example Output: CRL signature is encrypted with: RSA
=cut back
lib/Crypt/X509/CRL.pm view on Meta::CPAN
Returns the signature hashing algorithm (e.g. 'SHA1') as a string.
=head3 Example:
$decoded = Crypt::X509::CRL->new(crl => $crl);
print "CRL signature is hashed with:", $decoded->SigHashAlg, "\n";
Example Output: CRL signature is encrypted with: SHA1
=cut back
lib/Crypt/X509/CRL.pm view on Meta::CPAN
issuer (= the DN of the CA). Attribute names for the most common Attributes
are translated from the OID-Numbers, unknown numbers are output verbatim.
=head3 Example:
$decoded = Crypt::X509::CRL->new( $crl );
print "CRL was issued by: ", join( ', ' , @{ $decoded->Issuer } ), "\n";
=cut back
=head2 issuer_cn
lib/Crypt/X509/CRL.pm view on Meta::CPAN
Returns the authority key identifier as a bit string.
=head3 Example:
$decoded = Crypt::X509::CRL->new( $crl );
my $s = unpack("H*" , $decoded->key_identifier);
print "The Authority Key Identifier in HEX is: $s\n";
Example output:
The Authority Key Identifier in HEX is: 86595f93caf32da620a4f9595a4a935370e792c9
lib/Crypt/X509/CRL.pm view on Meta::CPAN
OID-Numbers, unknown numbers are output verbatim. Returns undef if the
extension is not set in the certificate.
=head3 Example:
$decoded = Crypt::X509::CRL->new($cert);
print "Certificate was authorised by:", join( ', ', @{ $decoded->authorityCertIssuer } ), "\n";
=cut back
=head2 authority_serial
lib/Crypt/X509/CRL.pm view on Meta::CPAN
Returns the Issuing Distribution Points as a hash providing for the default values.
=head3 Example:
print "Issuing Distribution Points:\n";
my $IDPs = $decoded->IDPs;
for my $key ( sort keys %{ $IDPs } ) {
print "$key = ";
if ( defined $IDPs->{ $key } ) {
print $IDPs->{ $key }, "\n";
} else {
lib/Crypt/X509/CRL.pm view on Meta::CPAN
keys to the hash are the certificate serial numbers in decimal format.
=head3 Example:
print "Revocation List:\n";
my $rls = $decoded->revocation_list;
my $count_of_rls = keys %{ $rls };
print "Found $count_of_rls revoked certificate(s) on this CRL.\n";
for my $key ( sort keys %{ $rls } ) {
print "Certificate: ", DecimalToHex( $key ), "\n";
for my $extn ( sort keys %{ $rls->{ $key } } ) {
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Crypt/X509.pm view on Meta::CPAN
=head1 SYNOPSIS
use Crypt::X509;
$decoded = Crypt::X509->new( cert => $cert );
$subject_email = $decoded->subject_email;
print "do not use after: ".gmtime($decoded->not_after)." GMT\n";
=head1 REQUIRES
Convert::ASN1
lib/Crypt/X509.pm view on Meta::CPAN
=head2 new ( OPTIONS )
Creates and returns a parsed X.509 certificate hash, containing the parsed
contents. The data is organised as specified in RFC 2459.
By default only the first ASN.1 Layer is decoded. Nested decoding
is done automagically through the data access methods.
=over 4
=item cert =E<gt> $certificate
lib/Crypt/X509.pm view on Meta::CPAN
=back
use Crypt::X509;
use Data::Dumper;
$decoded= Crypt::X509->new(cert => $cert);
print Dumper($decoded);
=cut back
sub new {
my ( $class, %args ) = @_;
lib/Crypt/X509.pm view on Meta::CPAN
Returns the last error from parsing, C<undef> when no error occured.
This error is updated on deeper parsing with the data access methods.
$decoded= Crypt::X509->new(cert => $cert);
if ($decoded->error) {
warn "Error on parsing Certificate:".$decoded->error;
}
=cut back
sub error {
lib/Crypt/X509.pm view on Meta::CPAN
returns the serial number (integer or Math::BigInt Object, that gets automagic
evaluated in scalar context) from the certificate
$decoded= Crypt::X509->new(cert => $cert);
print "Certificate has serial number:".$decoded->serial."\n";
=cut back
sub serial {
my $self = shift;
lib/Crypt/X509.pm view on Meta::CPAN
hold the timesamps as "generalTime"-entries. B<The contents of "generalTime"-entries
are not well defined in the RFC and
are returned by this module unmodified>, if no utcTime-entry is found.
$decoded= Crypt::X509->new(cert => $cert);
if ($decoded->notBefore < time()) {
warn "Certificate: not yet valid!";
}
=cut back
lib/Crypt/X509.pm view on Meta::CPAN
hold the timesamps as "generalTime"-entries. B<The contents of "generalTime"-entries
are not well defined in the RFC and
are returned by this module unmodified>, if no utcTime-entry is found.
$decoded= Crypt::X509->new(cert => $cert);
print "Certificate expires on ".gmtime($decoded->not_after)." GMT\n";
=cut back
sub not_after {
my $self = shift;
lib/Crypt/X509.pm view on Meta::CPAN
=head2 PubKeyAlg
returns the subject public key encryption algorithm (e.g. 'RSA') as string.
$decoded= Crypt::X509->new(cert => $cert);
print "Certificate public key is encrypted with:".$decoded->PubKeyAlg."\n";
Example Output: Certificate public key is encrypted with: RSA
=cut back
lib/Crypt/X509.pm view on Meta::CPAN
=head2 sig_algorithm
Returns the certificate's signature algorithm as OID string
$decoded= Crypt::X509->new(cert => $cert);
print "Certificate signature is encrypted with:".$decoded->sig_algorithm."\n";>
Example Output: Certificate signature is encrypted with: 1.2.840.113549.1.1.5
=cut back
lib/Crypt/X509.pm view on Meta::CPAN
=head2 SigEncAlg
returns the signature encryption algorithm (e.g. 'RSA') as string.
$decoded= Crypt::X509->new(cert => $cert);
print "Certificate signature is encrypted with:".$decoded->SigEncAlg."\n";
Example Output: Certificate signature is encrypted with: RSA
=cut back
lib/Crypt/X509.pm view on Meta::CPAN
=head2 SigHashAlg
returns the signature hashing algorithm (e.g. 'SHA1') as string.
$decoded= Crypt::X509->new(cert => $cert);
print "Certificate signature is hashed with:".$decoded->SigHashAlg."\n";
Example Output: Certificate signature is encrypted with: SHA1
=cut back
lib/Crypt/X509.pm view on Meta::CPAN
returns a pointer to an array of strings containing subject nameparts of the
certificate. Attributenames for the most common Attributes are translated
from the OID-Numbers, unknown numbers are output verbatim.
$decoded= Convert::ASN1::X509->new($cert);
print "DN for this Certificate is:".join(',',@{$decoded->Subject})."\n";
=cut back
sub Subject {
my $self = shift;
lib/Crypt/X509.pm view on Meta::CPAN
returns a pointer to an array of strings building the DN of the certificate
issuer (= the DN of the CA). Attributenames for the most common Attributes
are translated from the OID-Numbers, unknown numbers are output verbatim.
$decoded= Crypt::X509->new($cert);
print "Certificate was issued by:".join(',',@{$decoded->Issuer})."\n";
=cut back
sub Issuer {
my $self = shift;
my ( $i, $type );
lib/Crypt/X509.pm view on Meta::CPAN
for this certificate. C<undef> is returned, when the extension is not set in the
certificate.
If the extension is marked critical, this is also reported.
$decoded= Crypt::X509->new(cert => $cert);
print "Allowed usages for this Certificate are:\n".join("\n",@{$decoded->KeyUsage})."\n";
Example Output:
Allowed usages for this Certificate are:
critical
digitalSignature
lib/Crypt/X509.pm view on Meta::CPAN
C<undef> if the extension is not filled. OIDs of the following ExtKeyUsages are known:
serverAuth, clientAuth, codeSigning, emailProtection, timeStamping, OCSPSigning
If the extension is marked critical, this is also reported.
$decoded= Crypt::X509->new($cert);
print "ExtKeyUsage extension of this Certificates is: ", join(", ", @{$decoded->ExtKeyUsage}), "\n";
Example Output: ExtKeyUsage extension of this Certificates is: critical, serverAuth
=cut back
our %oid2extkeyusage = (
lib/Crypt/X509.pm view on Meta::CPAN
C<undef> if the extension is not filled. Usually this Extension holds the e-Mail
address for person-certificates or DNS-Names for server certificates.
It also pre-pends the field type (ie rfc822Name) to the returned value.
$decoded= Crypt::X509->new($cert);
print "E-Mail or Hostnames in this Certificates is/are:", join(", ", @{$decoded->SubjectAltName}), "\n";
Example Output: E-Mail or Hostnames in this Certificates is/are: rfc822Name=user@server.com
=cut back
lib/Crypt/X509.pm view on Meta::CPAN
=head2 DecodedSubjectAltNames
Returns a pointer to an array of strings containing all the alternative subject name
extensions.
Each such extension is represented as a decoded ASN.1 value, i.e. a pointer to a list
of pointers to objects, each object having a single key with the type of the alternative
name and a value specific to that type.
Example return value:
lib/Crypt/X509.pm view on Meta::CPAN
returns a pointer to an array of strings building the DN of the Authority Cert
Issuer. Attributenames for the most common Attributes
are translated from the OID-Numbers, unknown numbers are output verbatim.
undef if the extension is not set in the certificate.
$decoded= Crypt::X509->new($cert);
print "Certificate was authorised by:".join(',',@{$decoded->authorityCertIssuer})."\n";
=cut back
sub authorityCertIssuer {
my $self = shift;
lib/Crypt/X509.pm view on Meta::CPAN
=head2 EntrustVersionInfo
Returns the EntrustVersion as a string
print "Entrust Version: ", $decoded->EntrustVersion, "\n";
Example Output: Entrust Version: V7.0
=cut back
lib/Crypt/X509.pm view on Meta::CPAN
=head2 SubjectDirectoryAttributes
Returns the SubjectDirectoryAttributes as an array of key = value pairs, to include a data type
print "Subject Directory Attributes: ", join( ', ' , @{ $decoded->SubjectDirectoryAttributes } ), "\n";
Example Output: Subject Directory Attributes: 1.2.840.113533.7.68.29 = 7 (integer)
=cut back
lib/Crypt/X509.pm view on Meta::CPAN
=head2 SubjectInfoAccess
Returns the SubjectInfoAccess as an array of hashes with key=value pairs.
print "Subject Info Access: ";
if ( defined $decoded->SubjectInfoAccess ) {
my %SIA = $decoded->SubjectInfoAccess;
for my $key ( keys %SIA ) {
print "\n\t$key: \n\t";
print join( "\n\t" , @{ $SIA{$key} } ), "\n";
}
} else { print "\n" }
lib/Crypt/X509.pm view on Meta::CPAN
Returns the creation timestamp of the corresponding OpenPGP key.
(see http://www.imc.org/ietf-openpgp/mail-archive/msg05320.html)
print "PGPExtension: ";
if ( defined $decoded->PGPExtension ) {
my $creationtime = $decoded->PGPExtension;
printf "\n\tcorresponding OpenPGP Creation Time: ", $creationtime, "\n";
}
Example Output:
PGPExtension:
view all matches for this distribution
view release on metacpan or search on metacpan
inc/CryptX_PK_DSA.xs.inc view on Meta::CPAN
}
else {
rv = pem_decode_pkcs(data, (unsigned long)data_len, &key_from_pem, NULL);
}
if (rv != CRYPT_OK) croak("FATAL: pem_decode_pkcs failed: %s", error_to_string(rv));
if (key_from_pem.id != LTC_PKA_DSA) croak("FATAL: pem_decode_pkcs decoded non-DSA key");
self->key = key_from_pem.u.dsa;
XPUSHs(ST(0)); /* return self */
}
void
inc/CryptX_PK_DSA.xs.inc view on Meta::CPAN
}
else {
rv = pem_decode_openssh(data, (unsigned long)data_len, &key_from_pem, NULL);
}
if (rv != CRYPT_OK) croak("FATAL: pem_decode_openssh failed: %s", error_to_string(rv));
if (key_from_pem.id != LTC_PKA_DSA) croak("FATAL: pem_decode_openssh decoded non-DSA key");
self->key = key_from_pem.u.dsa;
XPUSHs(ST(0)); /* return self */
}
void
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Crypto/NanoRPC.pm view on Meta::CPAN
sub __do_rpc {
my ($self,$json) = @_;
$self->{request}->content($json);
my $response = $self->{ua}->request($self->{request});
if ($response->is_success) {
return decode_json($response->decoded_content);
}
return { error => "RPC call failed" };
}
1;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/CryptoTron/BroadcastTransaction.pm view on Meta::CPAN
sub encode {
# Assign the argument to the local variable.
my $content = $_[0];
# Decode the content from the response.
my $json_decode = $JSON->decode($content);
# Encode the decoded content from the response.
my $json_encode = $JSON->encode($json_decode);
# Return the encoded content.
return $json_encode;
};
view all matches for this distribution
view release on metacpan or search on metacpan
lib/CryptoTron/ClaimReward.pm view on Meta::CPAN
my $content = $_[0];
# Set up the options for the Perl module JSON::PP.
my $json = 'JSON::PP'->new->pretty;
# Decode the content from the response.
my $json_decode = $json->decode($content);
# Encode the decoded content from the response.
my $json_encode = $json->encode($json_decode);
# Return the encoded content.
return $json_encode;
};
lib/CryptoTron/ClaimReward.pm view on Meta::CPAN
# Assign the subroutine argument to the local variable.
my $json_data = $_[0];
# Set up the options for the Perl module JSON::PP.
my $json = 'JSON::PP'->new->pretty;
# Decode the JSON data.
my $decoded = $json->decode($json_data);
# Extract the txID from the JSON data.
my $txID = $decoded->{'txID'};
# Return the extracted txID.
return $txID;
};
# ---------------------------------------------------------------------------- #
lib/CryptoTron/ClaimReward.pm view on Meta::CPAN
# Assign the subroutine argument to the local variable.
my $json_data = $_[0];
# Set up the options for the Perl module JSON::PP.
my $json = 'JSON::PP'->new->pretty;
# Decode the JSON data.
my $decoded = $json->decode($json_data);
# Extract the raw_data from the JSON data.
my $raw_data_hex = $decoded->{'raw_data_hex'};
# Return the extracted raw data.
return $raw_data_hex;
};
# ---------------------------------------------------------------------------- #
lib/CryptoTron/ClaimReward.pm view on Meta::CPAN
# Assign the subroutine argument to the local variable.
my $json_data = $_[0];
# Set up the options for the Perl module JSON::PP.
my $json = 'JSON::PP'->new->pretty;
# Decode the JSON data.
my $decoded = $json->decode($json_data);
# Extract the raw_data from the JSON data.
my $raw_data = $decoded->{'raw_data'};
#$raw_data = to_json($raw_data);
$raw_data = encode_json($raw_data);
# Return the extracted raw data.
return $raw_data;
};
view all matches for this distribution