avoid "return undef"
Karel Miko
10 years ago
43 | 43 |
|
44 | 44 |
sub _crypt {
|
45 | 45 |
my $self = shift;
|
46 | |
return $self->_encrypt(@_) if $self->_get_dir == 1;
|
47 | |
return $self->_decrypt(@_) if $self->_get_dir == -1;
|
48 | |
return undef;
|
|
46 |
my $dir = $self->_get_dir;
|
|
47 |
return $self->_encrypt(@_) if $dir == 1;
|
|
48 |
return $self->_decrypt(@_) if $dir == -1;
|
|
49 |
return;
|
49 | 50 |
}
|
50 | 51 |
|
51 | 52 |
sub _finish {
|
52 | 53 |
my $self = shift;
|
53 | |
return $self->_finish_enc(@_) if $self->_get_dir == 1;
|
54 | |
return $self->_finish_dec(@_) if $self->_get_dir == -1;
|
55 | |
return undef;
|
|
54 |
my $dir = $self->_get_dir;
|
|
55 |
return $self->_finish_enc(@_) if $dir == 1;
|
|
56 |
return $self->_finish_dec(@_) if $dir == -1;
|
|
57 |
return;
|
56 | 58 |
}
|
57 | 59 |
|
58 | 60 |
sub CLONE_SKIP { 1 } # prevent cloning
|
23 | 23 |
sub export_key_pem {
|
24 | 24 |
my ($self, $type, $password, $cipher) = @_;
|
25 | 25 |
my $key = $self->export_key_der($type||'');
|
26 | |
return undef unless $key;
|
|
26 |
return unless $key;
|
27 | 27 |
return Crypt::PK::_asn1_to_pem($key, "DSA PRIVATE KEY", $password, $cipher) if $type eq 'private';
|
28 | 28 |
return Crypt::PK::_asn1_to_pem($key, "DSA PUBLIC KEY") if $type eq 'public';
|
29 | 29 |
return Crypt::PK::_asn1_to_pem($key, "PUBLIC KEY") if $type eq 'public_x509';
|
336 | 336 |
sub export_key_pem {
|
337 | 337 |
my ($self, $type, $password, $cipher) = @_;
|
338 | 338 |
my $key = $self->export_key_der($type||'');
|
339 | |
return undef unless $key;
|
|
339 |
return unless $key;
|
340 | 340 |
return Crypt::PK::_asn1_to_pem($key, "EC PRIVATE KEY", $password, $cipher) if $type eq 'private';
|
341 | 341 |
return Crypt::PK::_asn1_to_pem($key, "PUBLIC KEY") if $type eq 'public' || $type eq 'public_compressed';
|
342 | 342 |
}
|
23 | 23 |
sub export_key_pem {
|
24 | 24 |
my ($self, $type, $password, $cipher) = @_;
|
25 | 25 |
my $key = $self->export_key_der($type||'');
|
26 | |
return undef unless $key;
|
|
26 |
return unless $key;
|
27 | 27 |
|
28 | 28 |
# PKCS#1 RSAPrivateKey** (PEM header: BEGIN RSA PRIVATE KEY)
|
29 | 29 |
# PKCS#8 PrivateKeyInfo* (PEM header: BEGIN PRIVATE KEY)
|