From fdcf309f477e8bd50179b8dad482b16b1598a5a8 Mon Sep 17 00:00:00 2001 From: Charles McGarvey Date: Tue, 19 Apr 2022 19:36:45 -0600 Subject: [PATCH] move functions to the File::KDBX::XS module --- XS.xs | 8 ++------ lib/File/KDBX/XS.pm | 13 +++++++++++++ t/kdf-aes.t | 2 +- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/XS.xs b/XS.xs index e6b7b22..48f3077 100644 --- a/XS.xs +++ b/XS.xs @@ -6,7 +6,7 @@ #include "tomcrypt.h" -MODULE = File::KDBX::XS PACKAGE = File::KDBX::Util +MODULE = File::KDBX::XS PACKAGE = File::KDBX::XS PROTOTYPES: DISABLE @@ -20,12 +20,8 @@ CowREFCNT(SV* sv) OUTPUT: RETVAL -MODULE = File::KDBX::XS PACKAGE = File::KDBX::KDF::AES - -PROTOTYPES: DISABLE - SV* -_transform_half_xs(const char* key, const char* seed, unsigned int rounds) +kdf_aes_transform_half(const char* key, const char* seed, unsigned int rounds) CODE: symmetric_key skey; diff --git a/lib/File/KDBX/XS.pm b/lib/File/KDBX/XS.pm index 57facc9..6c8d4bd 100644 --- a/lib/File/KDBX/XS.pm +++ b/lib/File/KDBX/XS.pm @@ -4,10 +4,16 @@ package File::KDBX::XS; use warnings; use strict; +use Exporter qw(import); use XSLoader; our $VERSION = '999.999'; # VERSION +our @EXPORT_OK = qw( + CowREFCNT + kdf_aes_transform_half +); + XSLoader::load(__PACKAGE__, $VERSION); 1; @@ -38,4 +44,11 @@ bundled according to their own licensing terms (which are also permissive). =end HTML +=func CowREFCNT + +Get the copy-on-write (COW) reference count of a scalar, or C if the perl does not support scalar COW +or if the scalar is not COW. + +See also L. + =cut diff --git a/t/kdf-aes.t b/t/kdf-aes.t index 94ddf82..3256899 100644 --- a/t/kdf-aes.t +++ b/t/kdf-aes.t @@ -11,7 +11,7 @@ my $seed = "\1" x 16; my $rounds = 123; my $expected = pack('H*', '7deb990760f2ff0f9b8248d63bfb7264'); -my $result = File::KDBX::KDF::AES::_transform_half_xs($key, $seed, $rounds); +my $result = File::KDBX::XS::kdf_aes_transform_half($key, $seed, $rounds); is $result, $expected, 'AES KDF transform works' or diag unpack('H*', $result); done_testing; -- 2.45.2