Skip to content

Commit d327104

Browse files
committed
moved low-level part to Crypt::Cryptoki::Raw
1 parent d9de4fa commit d327104

File tree

10 files changed

+354
-166
lines changed

10 files changed

+354
-166
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ Build
77
_build
88
*.bak
99
MYMETA.*
10-
lib/Crypt/Cryptoki.c
11-
src/Crypt-Cryptoki-FunctionList.c
10+
lib/Crypt/Cryptoki-Raw.c
11+
src/Crypt-Cryptoki-Raw-FunctionList.c
1212
blib

Build.PL

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ my $build_class = Module::Build->subclass(
99
my $self = shift;
1010
require ExtUtils::ParseXS;
1111
ExtUtils::ParseXS::process_file(
12-
filename => 'src/Crypt-Cryptoki-FunctionList.xs',
13-
output => 'src/Crypt-Cryptoki-FunctionList.c'
12+
filename => 'src/Crypt-Cryptoki-Raw-FunctionList.xs',
13+
output => 'src/Crypt-Cryptoki-Raw-FunctionList.c'
1414
);
1515
$self->SUPER::ACTION_code(@_);
1616
}
@@ -33,12 +33,12 @@ my $build = Crypt::Cryptoki::Build->new(
3333
},
3434
extra_compiler_flags => ['-Wall'],
3535
include_dirs => ['include'],
36-
autosplit => 'lib/Crypt/Cryptoki.pm',
36+
autosplit => 'lib/Crypt/Cryptoki/Raw.pm',
3737
xs_files => {
38-
'src/Crypt-Cryptoki.xs' => 'lib/Crypt/Cryptoki.xs'
38+
'src/Crypt-Cryptoki-Raw.xs' => 'lib/Crypt/Cryptoki/Raw.xs'
3939
},
4040
c_source => ['src'],
41-
test_files => [ 't/cryptoki.t' ],
41+
test_files => [ 't/cryptoki.t', 't/cryptoki-raw.t' ],
4242
);
4343

4444
my @names = (qw(

MANIFEST

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ include/cryptoki/pkcs11f.h
77
include/cryptoki/pkcs11t.h
88
include/ppport.h
99
lib/Crypt/Cryptoki.pm
10+
lib/Crypt/Cryptoki/Raw.pm
1011
MANIFEST This list of files
1112
META.json
1213
META.yml
1314
README.pod
14-
src/Crypt-Cryptoki-FunctionList.xs
15-
src/Crypt-Cryptoki.xs
15+
src/Crypt-Cryptoki-Raw-FunctionList.xs
16+
src/Crypt-Cryptoki-Raw.xs
17+
t/cryptoki-raw.t
1618
t/cryptoki.t
1719
t/softhsm.t
1820
typemap

lib/Crypt/Cryptoki.pm

Lines changed: 0 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -3,136 +3,9 @@ package Crypt::Cryptoki;
33
use 5.012005;
44
use strict;
55
use warnings;
6-
use Carp;
7-
8-
require Exporter;
9-
use AutoLoader;
10-
11-
our @ISA = qw(Exporter);
12-
13-
our %EXPORT_TAGS = ( 'all' => [ qw(
14-
rv_to_str
15-
16-
CK_NEED_ARG_LIST
17-
18-
TRUE
19-
NULL_PTR
20-
21-
CKR_OK
22-
CKR_PIN_INCORRECT
23-
CKR_ARGUMENTS_BAD
24-
CKR_ATTRIBUTE_READ_ONLY
25-
CKR_ATTRIBUTE_TYPE_INVALID
26-
CKR_ATTRIBUTE_VALUE_INVALID
27-
CKR_CRYPTOKI_NOT_INITIALIZED
28-
CKR_DEVICE_ERROR
29-
CKR_DEVICE_MEMORY
30-
CKR_DEVICE_REMOVED
31-
CKR_DOMAIN_PARAMS_INVALID
32-
CKR_FUNCTION_CANCELED
33-
CKR_FUNCTION_FAILED
34-
CKR_GENERAL_ERROR
35-
CKR_HOST_MEMORY
36-
CKR_MECHANISM_INVALID
37-
CKR_MECHANISM_PARAM_INVALID
38-
CKR_OPERATION_ACTIVE
39-
CKR_OPERATION_NOT_INITIALIZED
40-
CKR_PIN_EXPIRED
41-
CKR_SESSION_CLOSED
42-
CKR_SESSION_HANDLE_INVALID
43-
CKR_SESSION_READ_ONLY
44-
CKR_SESSION_READ_ONLY_EXISTS
45-
CKR_TEMPLATE_INCOMPLETE
46-
CKR_TEMPLATE_INCONSISTENT
47-
CKR_TOKEN_WRITE_PROTECTED
48-
CKR_USER_NOT_LOGGED_IN
49-
50-
CKF_SERIAL_SESSION
51-
CKF_RW_SESSION
52-
53-
CKU_USER
54-
CKU_SO
55-
56-
CKO_PRIVATE_KEY
57-
CKO_PUBLIC_KEY
58-
59-
CKK_RSA
60-
61-
CKS_RO_PUBLIC_SESSION
62-
CKS_RO_USER_FUNCTIONS
63-
CKS_RW_PUBLIC_SESSION
64-
CKS_RW_USER_FUNCTIONS
65-
CKS_RW_SO_FUNCTIONS
66-
67-
CKA_CLASS
68-
CKA_KEY_TYPE
69-
CKA_TOKEN
70-
CKA_PRIVATE
71-
CKA_SENSITIVE
72-
CKA_DECRYPT
73-
CKA_SIGN
74-
CKA_UNWRAP
75-
CKA_ENCRYPT
76-
CKA_VERIFY
77-
CKA_WRAP
78-
CKA_MODULUS_BITS
79-
CKA_PUBLIC_EXPONENT
80-
CKA_LABEL
81-
CKA_ID
82-
83-
CKM_RSA_PKCS_KEY_PAIR_GEN
84-
CKM_RSA_PKCS
85-
CKM_SHA256_RSA_PKCS
86-
CKM_SHA512_RSA_PKCS
87-
CKM_SHA256
88-
CKM_SHA512
89-
) ] );
90-
91-
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
926

937
our $VERSION = '0.01_07';
948

95-
sub AUTOLOAD {
96-
# This AUTOLOAD is used to 'autoload' constants from the constant()
97-
# XS function.
98-
99-
my $constname;
100-
our $AUTOLOAD;
101-
($constname = $AUTOLOAD) =~ s/.*:://;
102-
croak "&Crypt::Cryptoki::constant not defined" if $constname eq 'constant';
103-
my ($error, $val) = constant($constname);
104-
if ($error) { croak $error; }
105-
{
106-
no strict 'refs';
107-
# Fixed between 5.005_53 and 5.005_61
108-
#XXX if ($] >= 5.00561) {
109-
#XXX *$AUTOLOAD = sub () { $val };
110-
#XXX }
111-
#XXX else {
112-
*$AUTOLOAD = sub { $val };
113-
#XXX }
114-
}
115-
goto &$AUTOLOAD;
116-
}
117-
118-
require XSLoader;
119-
XSLoader::load('Crypt::Cryptoki', $VERSION);
120-
121-
# Preloaded methods go here.
122-
123-
# Autoload methods go after =cut, and are processed by the autosplit program.
124-
125-
my %rv_map;
126-
{
127-
no strict 'refs';
128-
%rv_map = map { $_->() => $_ } grep { /^CKR/ } @EXPORT_OK;
129-
}
130-
131-
sub rv_to_str {
132-
my ( $err_num ) = @_;
133-
return $rv_map{$err_num} || 'n/a ('.$err_num.')';
134-
}
135-
1369
1;
13710
__END__
13811
=head1 NAME

0 commit comments

Comments
 (0)