line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#define PERL_NO_GET_CONTEXT |
2
|
|
|
|
|
|
|
#include "EXTERN.h" |
3
|
|
|
|
|
|
|
#include "perl.h" |
4
|
|
|
|
|
|
|
#include "XSUB.h" |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
#include "curve25519_i64.h" |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
typedef unsigned char BYTE; |
9
|
|
|
|
|
|
|
|
10
|
54
|
|
|
|
|
|
static BYTE *S_get_key_buffer(SV *var, const char *name, bool null) |
11
|
|
|
|
|
|
|
{ |
12
|
|
|
|
|
|
|
STRLEN len; |
13
|
|
|
|
|
|
|
dTHX; |
14
|
54
|
100
|
|
|
|
|
if (!SvOK(var) && null) { |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
15
|
10
|
|
|
|
|
|
return NULL; |
16
|
|
|
|
|
|
|
} |
17
|
44
|
50
|
|
|
|
|
if (!SvOK(var)) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
18
|
0
|
|
|
|
|
|
croak("%s cannot be undefined", name); |
19
|
|
|
|
|
|
|
} |
20
|
44
|
50
|
|
|
|
|
BYTE* buff = (BYTE*) SvPV(var, len); |
21
|
44
|
50
|
|
|
|
|
if (len != 32) { |
22
|
0
|
|
|
|
|
|
croak("%s requires 32 bytes", name); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
54
|
|
|
|
|
|
return buff; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
MODULE = HEAT::Crypto PACKAGE = HEAT::Crypto |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
PROTOTYPES: DISABLED |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
void _clamp(key) |
33
|
|
|
|
|
|
|
CODE: |
34
|
6
|
|
|
|
|
|
BYTE *key = S_get_key_buffer(ST(0), "key", false); |
35
|
6
|
|
|
|
|
|
clamp25519(key); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
void _core(p, s, k, g) |
38
|
|
|
|
|
|
|
CODE: |
39
|
10
|
|
|
|
|
|
BYTE *p = S_get_key_buffer(ST(0), "p", false); |
40
|
10
|
|
|
|
|
|
BYTE *s = S_get_key_buffer(ST(1), "s", true); |
41
|
10
|
|
|
|
|
|
BYTE *k = S_get_key_buffer(ST(2), "k", false); |
42
|
10
|
|
|
|
|
|
BYTE *g = S_get_key_buffer(ST(3), "g", true); |
43
|
10
|
|
|
|
|
|
core25519(p, s, k, g); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
int _sign(v, h, x, s) |
46
|
|
|
|
|
|
|
CODE: |
47
|
1
|
|
|
|
|
|
BYTE *v = S_get_key_buffer(ST(0), "v", false); |
48
|
1
|
|
|
|
|
|
BYTE *h = S_get_key_buffer(ST(1), "h", false); |
49
|
1
|
|
|
|
|
|
BYTE *x = S_get_key_buffer(ST(2), "x", false); |
50
|
1
|
|
|
|
|
|
BYTE *s = S_get_key_buffer(ST(3), "s", false); |
51
|
1
|
|
|
|
|
|
RETVAL = sign25519(v, h, x, s); |
52
|
|
|
|
|
|
|
OUTPUT: |
53
|
|
|
|
|
|
|
RETVAL |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
void _verify(y, v, h, p) |
56
|
|
|
|
|
|
|
CODE: |
57
|
1
|
|
|
|
|
|
BYTE *y = S_get_key_buffer(ST(0), "y", false); |
58
|
1
|
|
|
|
|
|
BYTE *v = S_get_key_buffer(ST(1), "v", false); |
59
|
1
|
|
|
|
|
|
BYTE *h = S_get_key_buffer(ST(2), "h", false); |
60
|
1
|
|
|
|
|
|
BYTE *p = S_get_key_buffer(ST(3), "p", false); |
61
|
1
|
|
|
|
|
|
verify25519(y, v, h, p); |