Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wine-mirror
GitHub Repository: wine-mirror/wine
Path: blob/master/libs/tomcrypt/src/pk/ecc/ltc_ecc_points.c
4396 views
1
/* LibTomCrypt, modular cryptographic library -- Tom St Denis
2
*
3
* LibTomCrypt is a library that provides various cryptographic
4
* algorithms in a highly modular and flexible manner.
5
*
6
* The library is free for all purposes without any express
7
* guarantee it works.
8
*/
9
10
/* Implements ECC over Z/pZ for curve y^2 = x^3 - 3x + b
11
*
12
* All curves taken from NIST recommendation paper of July 1999
13
* Available at http://csrc.nist.gov/cryptval/dss.htm
14
*/
15
#include "tomcrypt.h"
16
17
/**
18
@file ltc_ecc_points.c
19
ECC Crypto, Tom St Denis
20
*/
21
22
#ifdef LTC_MECC
23
24
/**
25
Allocate a new ECC point
26
@return A newly allocated point or NULL on error
27
*/
28
ecc_point *ltc_ecc_new_point(void)
29
{
30
ecc_point *p;
31
p = XCALLOC(1, sizeof(*p));
32
if (p == NULL) {
33
return NULL;
34
}
35
if (mp_init_multi(&p->x, &p->y, &p->z, NULL) != CRYPT_OK) {
36
XFREE(p);
37
return NULL;
38
}
39
return p;
40
}
41
42
/** Free an ECC point from memory
43
@param p The point to free
44
*/
45
void ltc_ecc_del_point(ecc_point *p)
46
{
47
/* prevents free'ing null arguments */
48
if (p != NULL) {
49
mp_clear_multi(p->x, p->y, p->z, NULL); /* note: p->z may be NULL but that's ok with this function anyways */
50
XFREE(p);
51
}
52
}
53
54
#endif
55
56