File Coverage

EC.xs
Criterion Covered Total %
statement 17 27 62.9
branch n/a
condition n/a
subroutine n/a
pod n/a
total 17 27 62.9


line stmt bran cond sub pod time code
1             /* Silence compound-token-split-by-macro warnings from perl.h when
2             * building for Perl < 5.35.2 with Clang >= 12
3             * See https://github.com/radiator-software/p5-net-ssleay/issues/383
4             */
5             #if NET_SSLEAY_PERL_VERSION < 5035002 && defined(__clang__) && defined(__clang_major__) && __clang_major__ >= 12
6             #pragma clang diagnostic ignored "-Wunknown-warning-option"
7             #pragma clang diagnostic ignored "-Wcompound-token-split-by-macro"
8             #pragma clang diagnostic warning "-Wunknown-warning-option"
9             #endif
10              
11             #include "EXTERN.h"
12             #include "perl.h"
13             #include "XSUB.h"
14              
15             #include "ppport.h"
16              
17             #include
18             #include
19             #include
20              
21             #include "const-c.inc"
22              
23             MODULE = Crypt::OpenSSL::EC PACKAGE = Crypt::OpenSSL::EC
24              
25             PROTOTYPES: ENABLE
26             INCLUDE: const-xs.inc
27              
28             BOOT:
29 2           ERR_load_crypto_strings();
30 2           ERR_load_EC_strings();
31              
32             const EC_METHOD *
33             EC_GFp_simple_method()
34              
35             const EC_METHOD *
36             EC_GFp_mont_method()
37              
38             const EC_METHOD *
39             EC_GFp_nist_method()
40              
41             #ifndef OPENSSL_NO_EC2M
42              
43             const EC_METHOD *
44             EC_GF2m_simple_method()
45              
46             #endif
47              
48             #ifndef OPENSSL_NO_BIO
49             int
50             ECParameters_print(BIO *bp, const EC_KEY *key)
51              
52             int
53             EC_KEY_print(BIO *bp, const EC_KEY *key, int off)
54              
55             #endif
56              
57             #ifndef OPENSSL_NO_FP_API
58             int
59             ECParameters_print_fp(FILE *fp, const EC_KEY *key)
60              
61             int
62             EC_KEY_print_fp(FILE *fp, const EC_KEY *key, int off)
63              
64             #endif
65              
66             unsigned long
67             ERR_get_error()
68              
69             char *
70             ERR_error_string(error,buf=NULL)
71             unsigned long error
72             char * buf
73             CODE:
74 0           RETVAL = ERR_error_string(error,buf);
75             OUTPUT:
76             RETVAL
77              
78              
79              
80             MODULE = Crypt::OpenSSL::EC PACKAGE = Crypt::OpenSSL::EC::EC_GROUP PREFIX=EC_GROUP_
81              
82             EC_GROUP *
83             EC_GROUP_new(const EC_METHOD *meth)
84             CODE:
85 10           RETVAL = EC_GROUP_new(meth);
86             OUTPUT:
87             RETVAL
88              
89             void
90             EC_GROUP_DESTROY(EC_GROUP * group)
91             CODE:
92 12           EC_GROUP_free(group);
93              
94             void
95             EC_GROUP_free(EC_GROUP * group)
96              
97             int
98             EC_GROUP_copy(EC_GROUP *dst, const EC_GROUP *src)
99              
100             EC_GROUP *
101             EC_GROUP_dup(const EC_GROUP *src)
102              
103             const EC_METHOD *
104             EC_GROUP_method_of(const EC_GROUP *group)
105              
106             int
107             EC_METHOD_get_field_type(const EC_METHOD *meth)
108              
109             int
110             EC_GROUP_set_generator(EC_GROUP *group, const EC_POINT *generator, const BIGNUM *order, const BIGNUM *cofactor)
111              
112             const EC_POINT *
113             EC_GROUP_get0_generator(const EC_GROUP *group)
114             CODE:
115 0           RETVAL = EC_POINT_dup(EC_GROUP_get0_generator(group), group);
116             OUTPUT:
117             RETVAL
118              
119             int
120             EC_GROUP_get_order(const EC_GROUP *group, BIGNUM *order, BN_CTX *ctx)
121              
122             int
123             EC_GROUP_get_cofactor(const EC_GROUP *group, BIGNUM *cofactor, BN_CTX *ctx)
124              
125             void
126             EC_GROUP_set_curve_name(EC_GROUP *group, int nid)
127              
128             int
129             EC_GROUP_get_curve_name(const EC_GROUP *group)
130              
131             void
132             EC_GROUP_set_asn1_flag(EC_GROUP *group, int flag)
133              
134             int
135             EC_GROUP_get_asn1_flag(const EC_GROUP *group);
136              
137             void
138             EC_GROUP_set_point_conversion_form(EC_GROUP *group, point_conversion_form_t theform)
139              
140             point_conversion_form_t
141             EC_GROUP_get_point_conversion_form(const EC_GROUP *group)
142              
143             char *
144             EC_GROUP_get0_seed(const EC_GROUP *group)
145             CODE:
146 0           RETVAL = (char*)EC_GROUP_get0_seed(group); /* signedness issues */
147             OUTPUT:
148             RETVAL
149              
150             size_t
151             EC_GROUP_get_seed_len(const EC_GROUP *group)
152              
153             size_t
154             EC_GROUP_set_seed(EC_GROUP *group, const unsigned char *theseed, size_t length(theseed))
155              
156             int
157             EC_GROUP_set_curve_GFp(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
158              
159             int
160             EC_GROUP_get_curve_GFp(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx)
161              
162             #ifndef OPENSSL_NO_EC2M
163              
164             int
165             EC_GROUP_set_curve_GF2m(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
166              
167             int
168             EC_GROUP_get_curve_GF2m(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx)
169              
170             #endif
171              
172             int
173             EC_GROUP_get_degree(const EC_GROUP *group)
174              
175             int
176             EC_GROUP_check(const EC_GROUP *group, BN_CTX *ctx)
177              
178             int
179             EC_GROUP_check_discriminant(const EC_GROUP *group, BN_CTX *ctx)
180              
181             int
182             EC_GROUP_cmp(const EC_GROUP *a, const EC_GROUP *b, BN_CTX *ctx)
183              
184             EC_GROUP *
185             EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
186              
187             #ifndef OPENSSL_NO_EC2M
188              
189             EC_GROUP *
190             EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
191              
192             #endif
193              
194             EC_GROUP *
195             EC_GROUP_new_by_curve_name(int nid)
196              
197             int
198             EC_GROUP_precompute_mult(EC_GROUP *group, BN_CTX *ctx)
199              
200             int
201             EC_GROUP_have_precompute_mult(const EC_GROUP *group)
202              
203              
204             int
205             EC_GROUP_get_basis_type(const EC_GROUP *group)
206              
207             #ifndef OPENSSL_NO_EC2M
208              
209             int
210             EC_GROUP_get_trinomial_basis(const EC_GROUP *group, IN_OUT unsigned int k)
211             CODE:
212 0           RETVAL = EC_GROUP_get_trinomial_basis(group, &k);
213             OUTPUT:
214             k sv_setiv(ST(1), k);
215             RETVAL
216              
217             int
218             EC_GROUP_get_pentanomial_basis(const EC_GROUP *group, IN_OUT unsigned int k1, IN_OUT unsigned int k2, IN_OUT unsigned int k3)
219             CODE:
220 0           RETVAL = EC_GROUP_get_pentanomial_basis(group, &k1, &k2, &k3);
221             OUTPUT:
222             k1 sv_setiv(ST(1), k1);
223             k2 sv_setiv(ST(2), k2);
224             k3 sv_setiv(ST(3), k3);
225             RETVAL
226              
227             #endif
228              
229             #EC_GROUP *
230             #d2i_ECPKParameters(EC_GROUP **group, const unsigned char **in, long len)
231              
232             #int
233             #i2d_ECPKParameters(const EC_GROUP *group, unsigned char **out)
234              
235             MODULE = Crypt::OpenSSL::EC PACKAGE = Crypt::OpenSSL::EC::EC_POINT PREFIX=EC_POINT_
236              
237             EC_POINT *
238             EC_POINT_new(const EC_GROUP *group)
239             CODE:
240 17           RETVAL = EC_POINT_new(group);
241             OUTPUT:
242             RETVAL
243              
244             void
245             EC_POINT_DESTROY(EC_POINT *point)
246             CODE:
247 19           EC_POINT_free(point);
248              
249             void
250             EC_POINT_free(EC_POINT *point)
251              
252             void
253             EC_POINT_clear_free(EC_POINT *point)
254              
255             int
256             EC_POINT_copy(EC_POINT *dst, const EC_POINT *src)
257              
258             EC_POINT *
259             EC_POINT_dup(const EC_POINT *src, const EC_GROUP *group)
260            
261             const EC_METHOD *
262             EC_POINT_method_of(const EC_POINT *point)
263              
264             int
265             EC_POINT_set_to_infinity(const EC_GROUP *group, EC_POINT *point)
266              
267             int
268             EC_POINT_set_Jprojective_coordinates_GFp(const EC_GROUP *group, EC_POINT *p, const BIGNUM *x, const BIGNUM *y, const BIGNUM *z, BN_CTX *ctx)
269              
270             int
271             EC_POINT_get_Jprojective_coordinates_GFp(const EC_GROUP *group, const EC_POINT *p, BIGNUM *x, BIGNUM *y, BIGNUM *z, BN_CTX *ctx)
272              
273             int
274             EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *group, EC_POINT *p, const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx)
275              
276             int
277             EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group, const EC_POINT *p, BIGNUM *x, BIGNUM *y, BN_CTX *ctx)
278              
279             int
280             EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group, EC_POINT *p, const BIGNUM *x, int y_bit, BN_CTX *ctx)
281              
282             #ifndef OPENSSL_NO_EC2M
283              
284             int
285             EC_POINT_set_affine_coordinates_GF2m(const EC_GROUP *group, EC_POINT *p, const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx)
286              
287             int
288             EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *group, const EC_POINT *p, BIGNUM *x, BIGNUM *y, BN_CTX *ctx)
289              
290             int
291             EC_POINT_set_compressed_coordinates_GF2m(const EC_GROUP *group, EC_POINT *p, const BIGNUM *x, int y_bit, BN_CTX *ctx)
292              
293             #endif
294              
295             SV *
296             EC_POINT_point2oct(const EC_GROUP *group, const EC_POINT *p, point_conversion_form_t theform, BN_CTX *ctx)
297             PREINIT:
298             STRLEN len;
299             char* buf;
300             CODE:
301 3           len = EC_POINT_point2oct(group, p, theform, NULL, 0, ctx);
302 3           Newx(buf, len, char);
303 3           len = EC_POINT_point2oct(group, p, theform, (unsigned char*)buf, len, ctx);
304 3           RETVAL = newSVpv(buf, len);
305 3           Safefree(buf);
306             OUTPUT:
307             RETVAL
308              
309             int
310             EC_POINT_oct2point(const EC_GROUP *group, EC_POINT *p, const unsigned char *buf, BN_CTX *ctx)
311             PREINIT:
312             STRLEN len;
313             CODE:
314 4           SvPV(ST(2), len);
315 4           RETVAL = EC_POINT_oct2point(group, p, buf, len, ctx);
316             OUTPUT:
317             RETVAL
318              
319              
320             BIGNUM *
321             EC_POINT_point2bn(const EC_GROUP *group, const EC_POINT *point, point_conversion_form_t theform, BIGNUM *bn, BN_CTX *ctx)
322              
323             EC_POINT *
324             EC_POINT_bn2point(const EC_GROUP *group, const BIGNUM *bn, EC_POINT *point, BN_CTX *ctx)
325              
326             char *
327             EC_POINT_point2hex(const EC_GROUP *group, const EC_POINT *point, point_conversion_form_t theform, BN_CTX *ctx)
328             PREINIT:
329             char* hex;
330             CODE:
331 0           hex = EC_POINT_point2hex(group, point, theform, ctx);
332 0           sv_setpv(TARG, hex);
333 0           Safefree(hex);
334 0           ST(0) = TARG;
335            
336              
337             EC_POINT *
338             EC_POINT_hex2point(const EC_GROUP *group, const char *buf, EC_POINT *point, BN_CTX *ctx)
339              
340             int
341             EC_POINT_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx)
342              
343             int
344             EC_POINT_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, BN_CTX *ctx)
345              
346             int
347             EC_POINT_invert(const EC_GROUP *group, EC_POINT *a, BN_CTX *ctx)
348              
349             int
350             EC_POINT_is_at_infinity(const EC_GROUP *group, const EC_POINT *p)
351              
352             int
353             EC_POINT_is_on_curve(const EC_GROUP *group, const EC_POINT *point, BN_CTX *ctx)
354              
355             int
356             EC_POINT_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx)
357              
358             int
359             EC_POINT_make_affine(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx)
360              
361             int
362             EC_POINT_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n, const EC_POINT *q, const BIGNUM *m, BN_CTX *ctx)
363              
364              
365             #ifndef OPENSSL_NO_BIO
366              
367             int
368             ECPKParameters_print(BIO *bp, const EC_GROUP *x, int off)
369              
370             #endif
371             #ifndef OPENSSL_NO_FP_API
372              
373             int
374             ECPKParameters_print_fp(FILE *fp, const EC_GROUP *x, int off)
375              
376             #endif
377              
378             MODULE = Crypt::OpenSSL::EC PACKAGE = Crypt::OpenSSL::EC::EC_KEY PREFIX=EC_KEY_
379              
380             # EC_KEY functions
381              
382             EC_KEY *
383             EC_KEY_new()
384             CODE:
385 3           RETVAL = EC_KEY_new();
386             OUTPUT:
387             RETVAL
388              
389             EC_KEY *
390             EC_KEY_new_by_curve_name(int nid)
391             CODE:
392 0           RETVAL = EC_KEY_new_by_curve_name(nid);
393             OUTPUT:
394             RETVAL
395              
396             void
397             EC_KEY_DESTROY(EC_KEY * key)
398             CODE:
399 3           EC_KEY_free(key);
400              
401             void
402             EC_KEY_free(EC_KEY *key)
403              
404             EC_KEY *
405             EC_KEY_copy(EC_KEY *dst, const EC_KEY *src)
406              
407             EC_KEY *
408             EC_KEY_dup(const EC_KEY *src)
409              
410             int
411             EC_KEY_up_ref(EC_KEY *key)
412              
413             const EC_GROUP *
414             EC_KEY_get0_group(const EC_KEY *key)
415              
416             int
417             EC_KEY_set_group(EC_KEY *key, const EC_GROUP *group)
418              
419             const BIGNUM *
420             EC_KEY_get0_private_key(const EC_KEY *key)
421             CODE:
422 2           RETVAL = BN_dup(EC_KEY_get0_private_key(key));
423             OUTPUT:
424             RETVAL
425              
426             int
427             EC_KEY_set_private_key(EC_KEY *key, const BIGNUM *prv)
428              
429             const EC_POINT *
430             EC_KEY_get0_public_key(const EC_KEY *key)
431             CODE:
432 2           RETVAL = EC_POINT_dup(EC_KEY_get0_public_key(key), EC_KEY_get0_group(key));
433             OUTPUT:
434             RETVAL
435              
436             int
437             EC_KEY_set_public_key(EC_KEY *key, const EC_POINT *pub)
438              
439             unsigned
440             EC_KEY_get_enc_flags(const EC_KEY *key)
441              
442             void
443             EC_KEY_set_enc_flags(EC_KEY *key, unsigned int flags)
444              
445             point_conversion_form_t
446             EC_KEY_get_conv_form(const EC_KEY *key)
447              
448             void
449             EC_KEY_set_conv_form(EC_KEY *key, point_conversion_form_t theform)
450              
451             #void *
452             #EC_KEY_get_key_method_data(EC_KEY *key, void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *))
453              
454             #void
455             #EC_KEY_insert_key_method_data(EC_KEY *key, void *data, void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *))
456              
457             void
458             EC_KEY_set_asn1_flag(EC_KEY *key, int flag)
459              
460             int
461             EC_KEY_precompute_mult(EC_KEY *key, BN_CTX *ctx)
462              
463             int
464             EC_KEY_generate_key(EC_KEY *key)
465              
466             int
467             EC_KEY_check_key(const EC_KEY *key)
468              
469             # de- and encoding functions for SEC1 ECPrivateKey */
470              
471             #EC_KEY *
472             #d2i_ECPrivateKey(EC_KEY **key, const unsigned char **in, long len)
473              
474             #int
475             #i2d_ECPrivateKey(EC_KEY *key, unsigned char **out)
476              
477              
478             # de- and encoding functions for EC parameters */
479             #EC_KEY *
480             #d2i_ECParameters(EC_KEY **key, const unsigned char **in, long len)
481              
482             #int
483             #i2d_ECParameters(EC_KEY *key, unsigned char **out)
484              
485             # de- and encoding functions for EC public key */
486              
487             #EC_KEY *
488             #o2i_ECPublicKey(EC_KEY **key, const unsigned char **in, long len)
489              
490             #int
491             #i2o_ECPublicKey(EC_KEY *key, unsigned char **out)
492