blob: 2173e248425fade698d93ba68b4d123933882197 [file] [log] [blame]
Manuel Pégourié-Gonnard39d2adb2012-10-31 09:26:55 +01001/*
2 * Elliptic curves over GF(p)
3 *
4 * Copyright (C) 2012, Brainspark B.V.
5 *
6 * This file is part of PolarSSL (http://www.polarssl.org)
7 * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
8 *
9 * All rights reserved.
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License along
22 * with this program; if not, write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 */
25
26/*
27 * References:
28 *
29 * SEC1-v2 (XXX: insert url)
30 * Guide to Elliptic Curve Cryptography - Hankerson, Menezes, Vanstone
31 */
32
33#include "polarssl/config.h"
34
35#if defined(POLARSSL_ECP_C)
36
37#include "polarssl/ecp.h"
38
Manuel Pégourié-Gonnard1e8c8ec2012-10-31 19:24:21 +010039/*
40 * Unallocate (the components of) a point
41 */
42void ecp_point_free( ecp_point *pt )
43{
44 if( pt == NULL )
45 return;
46
Manuel Pégourié-Gonnard5179e462012-10-31 19:37:54 +010047 pt->is_zero = 1;
Manuel Pégourié-Gonnard1e8c8ec2012-10-31 19:24:21 +010048 mpi_free( &( pt->X ) );
49 mpi_free( &( pt->Y ) );
50}
51
52/*
53 * Unallocate (the components of) a group
54 */
55void ecp_group_free( ecp_group *grp )
56{
57 if( grp == NULL )
58 return;
59
60 mpi_free( &( grp->P ) );
61 mpi_free( &( grp->B ) );
62 mpi_free( &( grp->N ) );
63 ecp_point_free( &( grp->G ) );
64}
Manuel Pégourié-Gonnard39d2adb2012-10-31 09:26:55 +010065
Manuel Pégourié-Gonnard5179e462012-10-31 19:37:54 +010066
67
Manuel Pégourié-Gonnard39d2adb2012-10-31 09:26:55 +010068#if defined(POLARSSL_SELF_TEST)
69
70/*
71 * Checkup routine
72 */
73int ecp_self_test( int verbose )
74{
75 return( verbose++ );
76}
77
78#endif
79
80#endif