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
|
|
|
|
|
|
|
#if USE_X64 |
7
|
|
|
|
|
|
|
#include "curve25519-donna-c64.c" |
8
|
|
|
|
|
|
|
#else |
9
|
|
|
|
|
|
|
#include "curve25519-donna.c" |
10
|
|
|
|
|
|
|
#endif |
11
|
|
|
|
|
|
|
|
12
|
80037
|
|
|
|
|
|
static u8* S_get_buffer(pTHX_ SV* variable, const char* name) { |
13
|
|
|
|
|
|
|
STRLEN len; |
14
|
80037
|
50
|
|
|
|
|
u8* ret = (u8*) SvPV(variable, len); |
15
|
80037
|
100
|
|
|
|
|
if (len != 32) |
16
|
3
|
|
|
|
|
|
Perl_croak(aTHX_ "%s requires 32 bytes", name); |
17
|
80034
|
|
|
|
|
|
return ret; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
#define get_buffer(variable, name) S_get_buffer(aTHX_ variable, name) |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
typedef u8 keybuffer[32]; |
22
|
|
|
|
|
|
|
typedef const u8* keyptr; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
static const keybuffer basepoint = {9}; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
MODULE = Crypt::Curve25519 PACKAGE = Crypt::Curve25519 |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
PROTOTYPES: DISABLED |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
keybuffer |
31
|
|
|
|
|
|
|
curve25519_public_key(secret, base = 9) |
32
|
|
|
|
|
|
|
keyptr secret = get_buffer(ST(0), "Secret key"); |
33
|
|
|
|
|
|
|
keyptr base = items > 1 ? get_buffer(ST(1), "Basepoint") : basepoint; |
34
|
|
|
|
|
|
|
CODE: |
35
|
20008
|
|
|
|
|
|
curve25519_donna(RETVAL, secret, base); |
36
|
|
|
|
|
|
|
OUTPUT: |
37
|
|
|
|
|
|
|
RETVAL |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
keybuffer |
40
|
|
|
|
|
|
|
curve25519_shared_secret(secret, public) |
41
|
|
|
|
|
|
|
keyptr secret = get_buffer(ST(0), "Secret key"); |
42
|
|
|
|
|
|
|
keyptr public = get_buffer(ST(1), "Public key"); |
43
|
|
|
|
|
|
|
ALIAS: |
44
|
|
|
|
|
|
|
curve25519 = 1 |
45
|
|
|
|
|
|
|
CODE: |
46
|
20012
|
|
|
|
|
|
curve25519_donna(RETVAL, secret, public); |
47
|
|
|
|
|
|
|
OUTPUT: |
48
|
|
|
|
|
|
|
RETVAL |