Manuel Pégourié-Gonnard | 2aea141 | 2013-01-26 16:33:44 +0100 | [diff] [blame] | 1 | /** |
| 2 | * \file ecdsa.h |
| 3 | * |
| 4 | * \brief Elliptic curve DSA |
| 5 | * |
| 6 | * Copyright (C) 2006-2013, Brainspark B.V. |
| 7 | * |
| 8 | * This file is part of PolarSSL (http://www.polarssl.org) |
| 9 | * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org> |
| 10 | * |
| 11 | * All rights reserved. |
| 12 | * |
| 13 | * This program is free software; you can redistribute it and/or modify |
| 14 | * it under the terms of the GNU General Public License as published by |
| 15 | * the Free Software Foundation; either version 2 of the License, or |
| 16 | * (at your option) any later version. |
| 17 | * |
| 18 | * This program is distributed in the hope that it will be useful, |
| 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 21 | * GNU General Public License for more details. |
| 22 | * |
| 23 | * You should have received a copy of the GNU General Public License along |
| 24 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 25 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 26 | */ |
| 27 | #ifndef POLARSSL_ECDSA_H |
| 28 | #define POLARSSL_ECDSA_H |
| 29 | |
| 30 | #include "polarssl/ecp.h" |
| 31 | |
| 32 | #ifdef __cplusplus |
| 33 | extern "C" { |
| 34 | #endif |
| 35 | |
| 36 | /** |
Manuel Pégourié-Gonnard | b309ab2 | 2013-01-26 17:24:59 +0100 | [diff] [blame] | 37 | * \brief Compute ECDSA signature of a previously hashed message |
| 38 | * |
| 39 | * \param grp ECP group |
| 40 | * \param r First output integer |
| 41 | * \param s Second output integer |
| 42 | * \param d Private signing key |
| 43 | * \param buf Message hash |
| 44 | * \param blen Length of buf |
| 45 | * \param f_rng RNG function |
| 46 | * \param p_rng RNG parameter |
| 47 | * |
| 48 | * \return 0 if successful, |
| 49 | * or a POLARSSL_ERR_ECP_XXX or POLARSSL_MPI_XXX error code |
| 50 | */ |
| 51 | int ecdsa_sign( const ecp_group *grp, mpi *r, mpi *s, |
| 52 | const mpi *d, const unsigned char *buf, size_t blen, |
| 53 | int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ); |
| 54 | |
| 55 | /** |
Manuel Pégourié-Gonnard | 3aeb5a7 | 2013-01-26 18:05:50 +0100 | [diff] [blame] | 56 | * \brief Verify ECDSA signature of a previously hashed message |
| 57 | * |
| 58 | * \param grp ECP group |
| 59 | * \param buf Message hash |
| 60 | * \param blen Length of buf |
| 61 | * \param Q Public key to use for verification |
| 62 | * \param r First integer of the signature |
| 63 | * \param s Second integer of the signature |
| 64 | * |
| 65 | * \return 0 if successful, |
| 66 | * POLARSSL_ERR_ECP_BAD_INPUT_DATA if signature is invalid |
| 67 | * or a POLARSSL_ERR_ECP_XXX or POLARSSL_MPI_XXX error code |
| 68 | */ |
| 69 | int ecdsa_verify( const ecp_group *grp, |
| 70 | const unsigned char *buf, size_t blen, |
| 71 | const ecp_point *Q, const mpi *r, const mpi *s); |
| 72 | |
| 73 | /** |
Manuel Pégourié-Gonnard | 2aea141 | 2013-01-26 16:33:44 +0100 | [diff] [blame] | 74 | * \brief Checkup routine |
| 75 | * |
| 76 | * \return 0 if successful, or 1 if the test failed |
| 77 | */ |
| 78 | int ecdsa_self_test( int verbose ); |
| 79 | |
| 80 | #ifdef __cplusplus |
| 81 | } |
| 82 | #endif |
| 83 | |
| 84 | #endif |