]> Dogcows Code - chaz/p5-File-KDBX-XS/blob - XS.xs
set a version in repo Makefile.PL
[chaz/p5-File-KDBX-XS] / XS.xs
1 #define PERL_NO_GET_CONTEXT
2 #include "EXTERN.h"
3 #include "perl.h"
4 #include "XSUB.h"
5 #include "ppport.h"
6
7 #include "tomcrypt.h"
8
9 MODULE = File::KDBX::XS PACKAGE = File::KDBX::XS
10
11 PROTOTYPES: DISABLE
12
13 SV*
14 CowREFCNT(SV* sv)
15 CODE:
16 #ifdef SV_COW_REFCNT_MAX
17 if (SvIsCOW(sv)) XSRETURN_IV(0 < SvLEN(sv) ? CowREFCNT(sv) : 0);
18 #endif
19 XSRETURN_UNDEF;
20 OUTPUT:
21 RETVAL
22
23 SV*
24 kdf_aes_transform_half(const char* key, const char* seed, unsigned int rounds)
25 CODE:
26 symmetric_key skey;
27
28 unsigned char work[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
29 Copy(seed, work, 1, work);
30
31 aes_setup(key, 32, 14, &skey);
32 for (unsigned int i = 0; i < rounds; ++i) {
33 aes_ecb_encrypt(work, work, &skey);
34 }
35
36 SV* result = newSVpvn(work, sizeof(work));
37
38 Zero(&skey, 1, skey);
39 Zero(work, 1, work);
40
41 RETVAL = result;
42 OUTPUT:
43 RETVAL
This page took 0.032019 seconds and 4 git commands to generate.