Codebase list libcryptx-perl / d37f9aa
avoid "return undef" Karel Miko 10 years ago
4 changed file(s) with 11 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
4343
4444 sub _crypt {
4545 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;
4950 }
5051
5152 sub _finish {
5253 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;
5658 }
5759
5860 sub CLONE_SKIP { 1 } # prevent cloning
2323 sub export_key_pem {
2424 my ($self, $type, $password, $cipher) = @_;
2525 my $key = $self->export_key_der($type||'');
26 return undef unless $key;
26 return unless $key;
2727 return Crypt::PK::_asn1_to_pem($key, "DSA PRIVATE KEY", $password, $cipher) if $type eq 'private';
2828 return Crypt::PK::_asn1_to_pem($key, "DSA PUBLIC KEY") if $type eq 'public';
2929 return Crypt::PK::_asn1_to_pem($key, "PUBLIC KEY") if $type eq 'public_x509';
336336 sub export_key_pem {
337337 my ($self, $type, $password, $cipher) = @_;
338338 my $key = $self->export_key_der($type||'');
339 return undef unless $key;
339 return unless $key;
340340 return Crypt::PK::_asn1_to_pem($key, "EC PRIVATE KEY", $password, $cipher) if $type eq 'private';
341341 return Crypt::PK::_asn1_to_pem($key, "PUBLIC KEY") if $type eq 'public' || $type eq 'public_compressed';
342342 }
2323 sub export_key_pem {
2424 my ($self, $type, $password, $cipher) = @_;
2525 my $key = $self->export_key_der($type||'');
26 return undef unless $key;
26 return unless $key;
2727
2828 # PKCS#1 RSAPrivateKey** (PEM header: BEGIN RSA PRIVATE KEY)
2929 # PKCS#8 PrivateKeyInfo* (PEM header: BEGIN PRIVATE KEY)