… | |
… | |
30 | #include "ed25519/src/ed25519.h" |
30 | #include "ed25519/src/ed25519.h" |
31 | |
31 | |
32 | /*#include "ed25519/src/add_scalar.c"*/ |
32 | /*#include "ed25519/src/add_scalar.c"*/ |
33 | #include "ed25519/src/fixedint.h" |
33 | #include "ed25519/src/fixedint.h" |
34 | #include "ed25519/src/keypair.c" |
34 | #include "ed25519/src/keypair.c" |
35 | /*#include "ed25519/src/key_exchange.c"*/ |
35 | #include "ed25519/src/key_exchange.c" |
36 | #include "ed25519/src/seed.c" |
36 | #include "ed25519/src/seed.c" |
37 | #include "ed25519/src/sha512.c" |
37 | #include "ed25519/src/sha512.c" |
38 | #include "ed25519/src/sha512.h" |
38 | #include "ed25519/src/sha512.h" |
39 | #include "ed25519/src/sign.c" |
39 | #include "ed25519/src/sign.c" |
40 | #include "ed25519/src/verify.c" |
40 | #include "ed25519/src/verify.c" |
… | |
… | |
49 | |
49 | |
50 | MODULE = Crypt::Ed25519 PACKAGE = Crypt::Ed25519 |
50 | MODULE = Crypt::Ed25519 PACKAGE = Crypt::Ed25519 |
51 | |
51 | |
52 | PROTOTYPES: ENABLE |
52 | PROTOTYPES: ENABLE |
53 | |
53 | |
|
|
54 | BOOT: |
|
|
55 | perlmulticore_support (); |
|
|
56 | |
54 | SV * |
57 | SV * |
55 | eddsa_secret_key () |
58 | eddsa_secret_key () |
56 | CODE: |
59 | CODE: |
57 | { |
60 | { |
58 | unsigned char seed[32]; |
61 | unsigned char seed[32]; |
59 | |
62 | |
|
|
63 | perlinterp_release (); |
60 | if (ed25519_create_seed (seed)) |
64 | int err = ed25519_create_seed (seed); |
|
|
65 | perlinterp_acquire (); |
|
|
66 | |
|
|
67 | if (err) |
61 | croak ("Crypt::Ed25519::eddsa_secret_key: ed25519_create_seed failed"); |
68 | croak ("Crypt::Ed25519::eddsa_secret_key: ed25519_create_seed failed"); |
62 | |
69 | |
63 | RETVAL = newSVpvn (seed, sizeof seed); |
70 | RETVAL = newSVpvn (seed, sizeof seed); |
64 | } |
71 | } |
65 | OUTPUT: |
72 | OUTPUT: |
… | |
… | |
179 | croak ("Crypt::Ed25519::verify_croak: signature verification failed"); |
186 | croak ("Crypt::Ed25519::verify_croak: signature verification failed"); |
180 | } |
187 | } |
181 | OUTPUT: |
188 | OUTPUT: |
182 | RETVAL |
189 | RETVAL |
183 | |
190 | |
|
|
191 | SV * |
|
|
192 | key_exchange (SV *public_key, SV *private_key) |
|
|
193 | CODE: |
|
|
194 | { |
|
|
195 | STRLEN public_key_l ; char *public_key_p = SvPVbyte (public_key , public_key_l ); |
|
|
196 | STRLEN private_key_l; char *private_key_p = SvPVbyte (private_key, private_key_l); |
184 | |
197 | |
|
|
198 | if (public_key_l != 32) |
|
|
199 | croak ("Crypt::Ed25519::key_exchange: public key has wrong length (!= 32)"); |
|
|
200 | |
|
|
201 | if (private_key_l != 64) |
|
|
202 | croak ("Crypt::Ed25519::key_exchange: private key has wrong length (!= 64)"); |
|
|
203 | |
|
|
204 | unsigned char shared_secret[32]; |
|
|
205 | |
|
|
206 | perlinterp_release (); |
|
|
207 | ed25519_key_exchange (shared_secret, public_key_p, private_key_p); |
|
|
208 | perlinterp_acquire (); |
|
|
209 | |
|
|
210 | RETVAL = newSVpvn (shared_secret, sizeof shared_secret); |
|
|
211 | } |
|
|
212 | OUTPUT: |
|
|
213 | RETVAL |
|
|
214 | |