ReactOS  0.4.15-dev-499-g1f31905
ecdsa.h
Go to the documentation of this file.
1 
12 /*
13  * Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved
14  * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
15  *
16  * This file is provided under the Apache License 2.0, or the
17  * GNU General Public License v2.0 or later.
18  *
19  * **********
20  * Apache License 2.0:
21  *
22  * Licensed under the Apache License, Version 2.0 (the "License"); you may
23  * not use this file except in compliance with the License.
24  * You may obtain a copy of the License at
25  *
26  * http://www.apache.org/licenses/LICENSE-2.0
27  *
28  * Unless required by applicable law or agreed to in writing, software
29  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
30  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31  * See the License for the specific language governing permissions and
32  * limitations under the License.
33  *
34  * **********
35  *
36  * **********
37  * GNU General Public License v2.0 or later:
38  *
39  * This program is free software; you can redistribute it and/or modify
40  * it under the terms of the GNU General Public License as published by
41  * the Free Software Foundation; either version 2 of the License, or
42  * (at your option) any later version.
43  *
44  * This program is distributed in the hope that it will be useful,
45  * but WITHOUT ANY WARRANTY; without even the implied warranty of
46  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
47  * GNU General Public License for more details.
48  *
49  * You should have received a copy of the GNU General Public License along
50  * with this program; if not, write to the Free Software Foundation, Inc.,
51  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
52  *
53  * **********
54  *
55  * This file is part of Mbed TLS (https://tls.mbed.org)
56  */
57 
58 #ifndef MBEDTLS_ECDSA_H
59 #define MBEDTLS_ECDSA_H
60 
61 #if !defined(MBEDTLS_CONFIG_FILE)
62 #include "config.h"
63 #else
64 #include MBEDTLS_CONFIG_FILE
65 #endif
66 
67 #include "ecp.h"
68 #include "md.h"
69 
70 /*
71  * RFC-4492 page 20:
72  *
73  * Ecdsa-Sig-Value ::= SEQUENCE {
74  * r INTEGER,
75  * s INTEGER
76  * }
77  *
78  * Size is at most
79  * 1 (tag) + 1 (len) + 1 (initial 0) + ECP_MAX_BYTES for each of r and s,
80  * twice that + 1 (tag) + 2 (len) for the sequence
81  * (assuming ECP_MAX_BYTES is less than 126 for r and s,
82  * and less than 124 (total len <= 255) for the sequence)
83  */
84 #if MBEDTLS_ECP_MAX_BYTES > 124
85 #error "MBEDTLS_ECP_MAX_BYTES bigger than expected, please fix MBEDTLS_ECDSA_MAX_LEN"
86 #endif
87 
88 #define MBEDTLS_ECDSA_MAX_LEN ( 3 + 2 * ( 3 + MBEDTLS_ECP_MAX_BYTES ) )
89 
94 
95 #ifdef __cplusplus
96 extern "C" {
97 #endif
98 
126  const mbedtls_mpi *d, const unsigned char *buf, size_t blen,
127  int (*f_rng)(void *, unsigned char *, size_t), void *p_rng );
128 
129 #if defined(MBEDTLS_ECDSA_DETERMINISTIC)
130 
172  mbedtls_mpi *s, const mbedtls_mpi *d,
173  const unsigned char *buf, size_t blen,
174  mbedtls_md_type_t md_alg );
215  mbedtls_mpi *s, const mbedtls_mpi *d,
216  const unsigned char *buf, size_t blen,
217  mbedtls_md_type_t md_alg,
218  int (*f_rng_blind)(void *, unsigned char *,
219  size_t),
220  void *p_rng_blind );
221 #endif /* MBEDTLS_ECDSA_DETERMINISTIC */
222 
248  const unsigned char *buf, size_t blen,
249  const mbedtls_ecp_point *Q, const mbedtls_mpi *r, const mbedtls_mpi *s);
250 
293  const unsigned char *hash, size_t hlen,
294  unsigned char *sig, size_t *slen,
295  int (*f_rng)(void *, unsigned char *, size_t),
296  void *p_rng );
297 
298 #if defined(MBEDTLS_ECDSA_DETERMINISTIC)
299 #if ! defined(MBEDTLS_DEPRECATED_REMOVED)
300 #if defined(MBEDTLS_DEPRECATED_WARNING)
301 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
302 #else
303 #define MBEDTLS_DEPRECATED
304 #endif
305 
345  const unsigned char *hash, size_t hlen,
346  unsigned char *sig, size_t *slen,
348 #undef MBEDTLS_DEPRECATED
349 #endif /* MBEDTLS_DEPRECATED_REMOVED */
350 #endif /* MBEDTLS_ECDSA_DETERMINISTIC */
351 
377  const unsigned char *hash, size_t hlen,
378  const unsigned char *sig, size_t slen );
379 
395  int (*f_rng)(void *, unsigned char *, size_t), void *p_rng );
396 
409 
416 
423 
424 #ifdef __cplusplus
425 }
426 #endif
427 
428 #endif /* ecdsa.h */
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
void mbedtls_ecdsa_free(mbedtls_ecdsa_context *ctx)
This function frees an ECDSA context.
Elliptic curves over GF(p)
ECP key pair structure.
Definition: ecp.h:200
void mbedtls_ecdsa_init(mbedtls_ecdsa_context *ctx)
This function initializes an ECDSA context.
int mbedtls_ecdsa_verify(mbedtls_ecp_group *grp, const unsigned char *buf, size_t blen, const mbedtls_ecp_point *Q, const mbedtls_mpi *r, const mbedtls_mpi *s)
This function verifies the ECDSA signature of a previously-hashed message.
ECP group structure.
Definition: ecp.h:173
int mbedtls_ecdsa_sign(mbedtls_ecp_group *grp, mbedtls_mpi *r, mbedtls_mpi *s, const mbedtls_mpi *d, const unsigned char *buf, size_t blen, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng)
This function computes the ECDSA signature of a previously-hashed message.
int mbedtls_ecdsa_from_keypair(mbedtls_ecdsa_context *ctx, const mbedtls_ecp_keypair *key)
This function sets an ECDSA context from an EC key pair.
#define d
Definition: ke_i.h:81
int mbedtls_ecdsa_sign_det_ext(mbedtls_ecp_group *grp, mbedtls_mpi *r, mbedtls_mpi *s, const mbedtls_mpi *d, const unsigned char *buf, size_t blen, mbedtls_md_type_t md_alg, int(*f_rng_blind)(void *, unsigned char *, size_t), void *p_rng_blind)
This function computes the ECDSA signature of a previously-hashed message, deterministic version.
int mbedtls_ecdsa_sign_det(mbedtls_ecp_group *grp, mbedtls_mpi *r, mbedtls_mpi *s, const mbedtls_mpi *d, const unsigned char *buf, size_t blen, mbedtls_md_type_t md_alg)
This function computes the ECDSA signature of a previously-hashed message, deterministic version....
mbedtls_ecp_keypair mbedtls_ecdsa_context
The ECDSA context structure.
Definition: ecdsa.h:93
mbedtls_ecp_group_id
Definition: ecp.h:97
int mbedtls_ecdsa_genkey(mbedtls_ecdsa_context *ctx, mbedtls_ecp_group_id gid, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng)
This function generates an ECDSA keypair on the given curve.
GLdouble s
Definition: gl.h:2039
The generic message-digest wrapper.
int mbedtls_ecdsa_write_signature_det(mbedtls_ecdsa_context *ctx, const unsigned char *hash, size_t hlen, unsigned char *sig, size_t *slen, mbedtls_md_type_t md_alg) MBEDTLS_DEPRECATED
This function computes an ECDSA signature and writes it to a buffer, serialized as defined in RFC-449...
MPI structure.
Definition: bignum.h:207
int mbedtls_ecdsa_read_signature(mbedtls_ecdsa_context *ctx, const unsigned char *hash, size_t hlen, const unsigned char *sig, size_t slen)
This function reads and verifies an ECDSA signature.
ECP point structure (jacobian coordinates)
Definition: ecp.h:141
mbedtls_md_type_t
Enumeration of supported message digests.
Definition: md.h:83
Definition: _hash_fun.h:40
#define MBEDTLS_DEPRECATED
Definition: ecdsa.h:303
int mbedtls_ecdsa_write_signature(mbedtls_ecdsa_context *ctx, mbedtls_md_type_t md_alg, const unsigned char *hash, size_t hlen, unsigned char *sig, size_t *slen, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng)
This function computes the ECDSA signature and writes it to a buffer, serialized as defined in RFC-44...
Definition: path.c:41