Skip to content

Commit

Permalink
Remove OpenSSL XS Binding
Browse files Browse the repository at this point in the history
  • Loading branch information
oliwel committed Jun 9, 2020
1 parent 60d54b2 commit e38076c
Show file tree
Hide file tree
Showing 11 changed files with 2 additions and 727 deletions.
9 changes: 0 additions & 9 deletions core/server/MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ OpenXPKI/Crypto/Backend/OpenSSL/Command.pm
OpenXPKI/Crypto/Backend/OpenSSL/Config.pm
OpenXPKI/Crypto/Backend/OpenSSL/ECDH.pm
OpenXPKI/Crypto/Backend/OpenSSL/Engine.pm
OpenXPKI/Crypto/Backend/OpenSSL/XS.pm

OpenXPKI/Crypto/Backend/OpenSSL/Engine/GOST.pm
OpenXPKI/Crypto/Backend/OpenSSL/Engine/nCipher.pm
Expand Down Expand Up @@ -175,14 +174,6 @@ OpenXPKI/Crypto/Backend/OpenSSL/Command/pkcs7_sign.pm
OpenXPKI/Crypto/Backend/OpenSSL/Command/pkcs7_verify.pm
OpenXPKI/Crypto/Backend/OpenSSL/Command/verify_cert.pm

## XS sources

typemap
OpenXPKI.xs
OpenXPKI/Crypto/Backend/OpenSSL.xs
OpenXPKI/Crypto/Backend/OpenSSL/XS/CRL.xs
OpenXPKI/Crypto/Backend/OpenSSL/XS/ECDH.xs

## database interface of the server

OpenXPKI/Server/Database.pm
Expand Down
2 changes: 0 additions & 2 deletions core/server/OpenXPKI.pm
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ use OpenXPKI::VERSION;
our $VERSION = $OpenXPKI::VERSION::VERSION;

use English qw (-no_match_vars);
use XSLoader;
XSLoader::load ("OpenXPKI", $VERSION);

use OpenXPKI::Debug;
require OpenXPKI::Exception;
Expand Down
24 changes: 0 additions & 24 deletions core/server/OpenXPKI.xs

This file was deleted.

110 changes: 0 additions & 110 deletions core/server/OpenXPKI/Crypto/Backend/API.pm
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ use English;
## - "" => {...} (these are the default parameters
## - "TYPE:EC" => {...} means parameters if TYPE => "EC" is used


my %object_cache_of :ATTR; # the object cache attribute

sub __init_command_params : PRIVATE {
##! 16: 'start'
my $self = shift;
Expand Down Expand Up @@ -206,112 +203,6 @@ sub get_cmd_param {
return \%rc;
}

sub get_object {
my $self = shift;
my $ident = ident $self;
my $keys = shift;

foreach my $param (keys %{$keys})
{
if ($param ne "DATA" and
$param ne "FORMAT" and
$param ne "TYPE")
{
OpenXPKI::Exception->throw (
message => "I18N_OPENXPKI_CRYPTO_BACKEND_API_GET_OBJECT_ILLEGAL_PARAM",
params => {NAME => $param, VALUE => $keys->{$param}});
}
}

if (not defined $keys->{DATA} or
not length $keys->{DATA})
{
OpenXPKI::Exception->throw (
message => "I18N_OPENXPKI_CRYPTO_BACKEND_API_GET_OBJECT_MISSING_DATA");
}

if ($keys->{TYPE} ne "CRL")
{
OpenXPKI::Exception->throw (
message => "I18N_OPENXPKI_CRYPTO_BACKEND_API_GET_OBJECT_ILLEGAL_TYPE",
params => {TYPE => $keys->{TYPE}});
}

my $ref = $self->get_instance()->get_object($keys);
$object_cache_of{$ident}->{$ref} = $keys->{TYPE};
return $ref;
}

sub get_object_function {
my $self = shift;
my $ident = ident $self;
my $keys = shift;

foreach my $param (keys %{$keys})
{
if ($param ne "OBJECT" and
$param ne "FUNCTION")
{
OpenXPKI::Exception->throw (
message => "I18N_OPENXPKI_CRYPTO_BACKEND_API_GET_OBJECT_FUNCTION_ILLEGAL_PARAM",
params => {NAME => $param, VALUE => $keys->{$param}});
}
}

if (not ref $keys->{OBJECT})
{
OpenXPKI::Exception->throw (
message => "I18N_OPENXPKI_CRYPTO_BACKEND_API_GET_OBJECT_FUNCTION_OBJECT_NO_REF");
}

if (not exists $object_cache_of{$ident} or
not exists $object_cache_of{$ident}->{$keys->{OBJECT}})
{
OpenXPKI::Exception->throw (
message => "I18N_OPENXPKI_CRYPTO_BACKEND_API_GET_OBJECT_FUNCTION_OBJECT_NOT_IN_CACHE");
}

my $type = $object_cache_of{$ident}->{$keys->{OBJECT}};

my @functions = ();
if ($type eq "CRL")
{
@functions = ("version", "issuer", "next_update", "last_update",
"signature_algorithm", "revoked", "serial", "itemcnt", "extensions");
}

if (not grep (/$keys->{FUNCTION}/, @functions))
{
OpenXPKI::Exception->throw (
message => "I18N_OPENXPKI_CRYPTO_BACKEND_API_GET_OBJECT_FUNCTION_ILLEGAL_FUNCTION",
params => {FUNCTION => $keys->{FUNCTION}, TYPE => $type});
}

return $self->get_instance()->get_object_function($keys);
}

sub free_object {
my $self = shift;
my $ident = ident $self;
my $object = shift;

if (not ref $object)
{
OpenXPKI::Exception->throw (
message => "I18N_OPENXPKI_CRYPTO_BACKEND_API_FREE_OBJECT_NO_REF");
}

if (not exists $object_cache_of{$ident} or
not exists $object_cache_of{$ident}->{$object})
{
OpenXPKI::Exception->throw (
message => "I18N_OPENXPKI_CRYPTO_BACKEND_API_FREE_OBJECT_NOT_IN_CACHE");
}

delete $object_cache_of{$ident}->{$object};
return $self->get_instance()->free_object ($object);
}

sub get_key_info
{
##! 1: 'start'
Expand Down Expand Up @@ -363,4 +254,3 @@ is the constructor.
=head2 get_cmd_param
get the command_params entry for the specified command
41 changes: 0 additions & 41 deletions core/server/OpenXPKI/Crypto/Backend/OpenSSL.pm
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@ use warnings;
use English;

use OpenXPKI::Crypto::Backend::OpenSSL::Config;
use OpenXPKI::Crypto::Backend::OpenSSL::XS;
use OpenXPKI::Server::Context qw( CTX );

use OpenXPKI::Debug;
use OpenXPKI::Exception;

my %xs_of :ATTR; # the XS object
my %config_of :ATTR; # the Config object

use Data::Dumper;
Expand All @@ -28,8 +26,6 @@ sub START {
sub __init_local {
my $self = shift;
my $ident = ident $self;

$xs_of{$ident} = OpenXPKI::Crypto::Backend::OpenSSL::XS->new();
$self->__init_config ();
}

Expand All @@ -39,7 +35,6 @@ sub __init_config {

$config_of{$ident} = OpenXPKI::Crypto::Backend::OpenSSL::Config->new({
TMP => $self->get_tmp_dir(),
XS => $xs_of{$ident},
});
}

Expand All @@ -55,7 +50,6 @@ sub __instantiate_engine {
my $engine_obj = eval {
$engine->new(
%{$self->get_params()},
XS => $xs_of{$ident},
)
};
if (my $exc = OpenXPKI::Exception->caught())
Expand Down Expand Up @@ -118,7 +112,6 @@ sub __init_command {

$self->get_command_params()->{ENGINE} = $self->get_engine();
$self->get_command_params()->{CONFIG} = $config_of{$ident};
$self->get_command_params()->{XS} = $xs_of{$ident};
##! 16: 'end'
}

Expand All @@ -133,40 +126,6 @@ sub __prepare_cli {
});
}


###########################
## BEGIN XS code ##
###########################

sub get_object
{
##! 1: "start"
my $self = shift;
my $ident = ident $self;
return $xs_of{$ident}->get_object(@_);
}

sub get_object_function
{
##! 1: "start"
my $self = shift;
my $ident = ident $self;
return $xs_of{$ident}->get_object_function(@_);
}

sub free_object
{
##! 1: "start"
my $self = shift;
my $ident = ident $self;
return $xs_of{$ident}->free_object(@_);
}

#########################
## END XS code ##
#########################


1;
__END__
Expand Down
14 changes: 0 additions & 14 deletions core/server/OpenXPKI/Crypto/Backend/OpenSSL.xs

This file was deleted.

8 changes: 0 additions & 8 deletions core/server/OpenXPKI/Crypto/Backend/OpenSSL/Command.pm
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,6 @@ sub new
message => "I18N_OPENXPKI_CRYPTO_OPENSSL_COMMAND_MISSING_CONFIG");
}

##! 2: "check XS availability"
if (not exists $self->{XS} or not ref $self->{XS})
{
OpenXPKI::Exception->throw (
message => "I18N_OPENXPKI_CRYPTO_OPENSSL_COMMAND_MISSING_XS");
}

##! 2: "$self->{TMP} will be checked by the central OpenSSL module"
if (not $self->{TMP})
{
Expand Down Expand Up @@ -245,4 +238,3 @@ expects a RFC2253 compliant DN and returns an OpenSSL DN.
The default handler returns the content of OUTFILE. Must be overriden
in the child class if a different handling is required. Will throw an
exception if OUTFILE is not set, not readable or zero size.
17 changes: 2 additions & 15 deletions core/server/OpenXPKI/Crypto/Backend/OpenSSL/Config.pm
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,6 @@ sub new
my $self = shift;
bless $self, $class;

##! 2: "check XS availability"
if (not exists $self->{XS} or not ref $self->{XS})
{
OpenXPKI::Exception->throw (
message => "I18N_OPENXPKI_CRYPTO_OPENSSL_CONFIG_MISSING_XS");
}

##! 2: "$self->{TMP} will be checked by the central OpenSSL module"
if (not $self->{TMP})
{
Expand Down Expand Up @@ -230,14 +223,8 @@ sub dump

}


##! 16: 'config: ' . $config
##! 2: "set the configuration to the XS library"
##! 2: "should we integrate this into the get_config function?"
OpenXPKI::Crypto::Backend::OpenSSL::set_config ($self->{FILENAME}->{CONFIG});

##! 1: "end"
return 1;
##! 16: 'config: ' . $config ##! 1: "end"
return $self->{FILENAME}->{CONFIG};
}

sub __get_openssl_common
Expand Down

0 comments on commit e38076c

Please sign in to comment.