updated makefiles
[gnutls.git] / lib / nettle / ecc_points.c
blobc5ae2155303e5f1afe5a4369ef72f7a764594e37
1 /*
2 * Copyright (C) 2011-2012 Free Software Foundation, Inc.
4 * This file is part of GNUTLS.
6 * The GNUTLS library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public License
8 * as published by the Free Software Foundation; either version 3 of
9 * the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>
21 /* Based on public domain code of LibTomCrypt by Tom St Denis.
22 * Adapted to gmp and nettle by Nikos Mavrogiannopoulos.
25 #include "ecc.h"
28 @file ecc_points.c
29 ECC Crypto, Tom St Denis
33 Allocate a new ECC point
34 @return A newly allocated point or NULL on error
36 ecc_point *
37 ecc_new_point (void)
39 ecc_point *p;
40 p = calloc (1, sizeof (*p));
41 if (p == NULL)
43 return NULL;
45 if (mp_init_multi (&p->x, &p->y, &p->z, NULL) != 0)
47 free (p);
48 return NULL;
50 return p;
53 /* Free an ECC point from memory
54 @param p The point to free
56 void
57 ecc_del_point (ecc_point * p)
59 /* prevents free'ing null arguments */
60 if (p != NULL)
62 mp_clear_multi (&p->x, &p->y, &p->z, NULL); /* note: p->z may be NULL but that's ok with this function anyways */
63 free (p);
67 /* $Source: /cvs/libtom/libtomcrypt/src/pk/ecc/ecc_points.c,v $ */
68 /* $Revision: 1.7 $ */
69 /* $Date: 2007/05/12 14:32:35 $ */