Path: blob/master/libs/tomcrypt/src/pk/ecc/ltc_ecc_points.c
4396 views
/* LibTomCrypt, modular cryptographic library -- Tom St Denis1*2* LibTomCrypt is a library that provides various cryptographic3* algorithms in a highly modular and flexible manner.4*5* The library is free for all purposes without any express6* guarantee it works.7*/89/* Implements ECC over Z/pZ for curve y^2 = x^3 - 3x + b10*11* All curves taken from NIST recommendation paper of July 199912* Available at http://csrc.nist.gov/cryptval/dss.htm13*/14#include "tomcrypt.h"1516/**17@file ltc_ecc_points.c18ECC Crypto, Tom St Denis19*/2021#ifdef LTC_MECC2223/**24Allocate a new ECC point25@return A newly allocated point or NULL on error26*/27ecc_point *ltc_ecc_new_point(void)28{29ecc_point *p;30p = XCALLOC(1, sizeof(*p));31if (p == NULL) {32return NULL;33}34if (mp_init_multi(&p->x, &p->y, &p->z, NULL) != CRYPT_OK) {35XFREE(p);36return NULL;37}38return p;39}4041/** Free an ECC point from memory42@param p The point to free43*/44void ltc_ecc_del_point(ecc_point *p)45{46/* prevents free'ing null arguments */47if (p != NULL) {48mp_clear_multi(p->x, p->y, p->z, NULL); /* note: p->z may be NULL but that's ok with this function anyways */49XFREE(p);50}51}5253#endif545556