blob: 6b88aeeddc79993bc159f47229a9bdc859d023d8 [file] [log] [blame]
Jarno Lamsa18987a42019-04-24 15:40:43 +03001/* ecc.h - TinyCrypt interface to common ECC functions */
2
Simon Butcher92c3d1f2019-09-09 17:25:08 +01003/*
4 * Copyright (c) 2019, Arm Limited (or its affiliates), All Rights Reserved.
5 * SPDX-License-Identifier: BSD-3-Clause
6 */
7
Jarno Lamsa18987a42019-04-24 15:40:43 +03008/* Copyright (c) 2014, Kenneth MacKay
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions are met:
13 *
14 * * Redistributions of source code must retain the above copyright notice, this
15 * list of conditions and the following disclaimer.
16 *
17 * * Redistributions in binary form must reproduce the above copyright notice,
18 * this list of conditions and the following disclaimer in the documentation
19 * and/or other materials provided with the distribution.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
32 */
33
34/*
35 * Copyright (C) 2017 by Intel Corporation, All Rights Reserved.
36 *
37 * Redistribution and use in source and binary forms, with or without
38 * modification, are permitted provided that the following conditions are met:
39 *
40 * - Redistributions of source code must retain the above copyright notice,
41 * this list of conditions and the following disclaimer.
42 *
43 * - Redistributions in binary form must reproduce the above copyright
44 * notice, this list of conditions and the following disclaimer in the
45 * documentation and/or other materials provided with the distribution.
46 *
47 * - Neither the name of Intel Corporation nor the names of its contributors
48 * may be used to endorse or promote products derived from this software
49 * without specific prior written permission.
50 *
51 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
52 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
53 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
54 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
55 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
56 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
57 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
58 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
59 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
60 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
61 * POSSIBILITY OF SUCH DAMAGE.
62 */
63
64/**
65 * @file
66 * @brief -- Interface to common ECC functions.
67 *
68 * Overview: This software is an implementation of common functions
69 * necessary to elliptic curve cryptography. This implementation uses
70 * curve NIST p-256.
71 *
72 * Security: The curve NIST p-256 provides approximately 128 bits of security.
73 *
74 */
75
Manuel Pégourié-Gonnardafdc1b52019-05-09 11:24:11 +020076#if defined(MBEDTLS_USE_TINYCRYPT)
Jarno Lamsa18987a42019-04-24 15:40:43 +030077#ifndef __TC_UECC_H__
78#define __TC_UECC_H__
79
80#include <stdint.h>
81
82#ifdef __cplusplus
83extern "C" {
84#endif
85
Manuel Pégourié-Gonnardc05f1502019-11-06 10:15:26 +010086/* Return values for functions, chosen with large Hamming distances between
87 * them (especially to SUCESS) to mitigate the impact of fault injection
88 * attacks flipping a low number of bits. */
89#define UECC_SUCCESS 0
90#define UECC_FAILURE 0x75555555
91#define UECC_ATTACK_DETECTED 0x7aaaaaaa
92
Jarno Lamsa18987a42019-04-24 15:40:43 +030093/* Word size (4 bytes considering 32-bits architectures) */
94#define uECC_WORD_SIZE 4
95
96/* setting max number of calls to prng: */
97#ifndef uECC_RNG_MAX_TRIES
98#define uECC_RNG_MAX_TRIES 64
99#endif
100
101/* defining data types to store word and bit counts: */
102typedef int8_t wordcount_t;
103typedef int16_t bitcount_t;
104/* defining data type for comparison result: */
105typedef int8_t cmpresult_t;
106/* defining data type to store ECC coordinate/point in 32bits words: */
107typedef unsigned int uECC_word_t;
108/* defining data type to store an ECC coordinate/point in 64bits words: */
109typedef uint64_t uECC_dword_t;
110
111/* defining masks useful for ecc computations: */
112#define HIGH_BIT_SET 0x80000000
113#define uECC_WORD_BITS 32
114#define uECC_WORD_BITS_SHIFT 5
115#define uECC_WORD_BITS_MASK 0x01F
116
117/* Number of words of 32 bits to represent an element of the the curve p-256: */
118#define NUM_ECC_WORDS 8
119/* Number of bytes to represent an element of the the curve p-256: */
120#define NUM_ECC_BYTES (uECC_WORD_SIZE*NUM_ECC_WORDS)
Manuel Pégourié-Gonnard78a7e352019-11-04 12:31:06 +0100121#define NUM_ECC_BITS 256
Jarno Lamsa18987a42019-04-24 15:40:43 +0300122
123/* structure that represents an elliptic curve (e.g. p256):*/
124struct uECC_Curve_t;
125typedef const struct uECC_Curve_t * uECC_Curve;
126struct uECC_Curve_t {
Manuel Pégourié-Gonnardffd13992019-11-21 10:39:06 +0100127 unsigned char dummy;
Jarno Lamsa18987a42019-04-24 15:40:43 +0300128};
129
130/*
131 * @brief computes doubling of point ion jacobian coordinates, in place.
132 * @param X1 IN/OUT -- x coordinate
133 * @param Y1 IN/OUT -- y coordinate
134 * @param Z1 IN/OUT -- z coordinate
135 * @param curve IN -- elliptic curve
136 */
137void double_jacobian_default(uECC_word_t * X1, uECC_word_t * Y1,
138 uECC_word_t * Z1, uECC_Curve curve);
139
140/*
Jarno Lamsa18987a42019-04-24 15:40:43 +0300141 * @brief Computes result = product % curve_p
142 * from http://www.nsa.gov/ia/_files/nist-routines.pdf
143 * @param result OUT -- product % curve_p
144 * @param product IN -- value to be reduced mod curve_p
145 */
146void vli_mmod_fast_secp256r1(unsigned int *result, unsigned int *product);
147
148/* Bytes to words ordering: */
149#define BYTES_TO_WORDS_8(a, b, c, d, e, f, g, h) 0x##d##c##b##a, 0x##h##g##f##e
150#define BYTES_TO_WORDS_4(a, b, c, d) 0x##d##c##b##a
151#define BITS_TO_WORDS(num_bits) \
152 ((num_bits + ((uECC_WORD_SIZE * 8) - 1)) / (uECC_WORD_SIZE * 8))
153#define BITS_TO_BYTES(num_bits) ((num_bits + 7) / 8)
154
Manuel Pégourié-Gonnard4d8777c2019-11-21 10:02:58 +0100155extern const uECC_word_t curve_p[NUM_ECC_WORDS];
Manuel Pégourié-Gonnard356d8592019-11-21 10:23:05 +0100156extern const uECC_word_t curve_n[NUM_ECC_WORDS];
Manuel Pégourié-Gonnarda6115082019-11-21 10:29:14 +0100157extern const uECC_word_t curve_G[2 * NUM_ECC_WORDS];
Manuel Pégourié-Gonnardffd13992019-11-21 10:39:06 +0100158extern const uECC_word_t curve_b[NUM_ECC_WORDS];
Manuel Pégourié-Gonnard4d8777c2019-11-21 10:02:58 +0100159
Jarno Lamsa18987a42019-04-24 15:40:43 +0300160/* definition of curve NIST p-256: */
161static const struct uECC_Curve_t curve_secp256r1 = {
Manuel Pégourié-Gonnardffd13992019-11-21 10:39:06 +0100162 0
Jarno Lamsa18987a42019-04-24 15:40:43 +0300163};
164
165uECC_Curve uECC_secp256r1(void);
166
167/*
168 * @brief Generates a random integer in the range 0 < random < top.
169 * Both random and top have num_words words.
170 * @param random OUT -- random integer in the range 0 < random < top
171 * @param top IN -- upper limit
172 * @param num_words IN -- number of words
173 * @return a random integer in the range 0 < random < top
174 */
175int uECC_generate_random_int(uECC_word_t *random, const uECC_word_t *top,
176 wordcount_t num_words);
177
178
179/* uECC_RNG_Function type
180 * The RNG function should fill 'size' random bytes into 'dest'. It should
181 * return 1 if 'dest' was filled with random data, or 0 if the random data could
182 * not be generated. The filled-in values should be either truly random, or from
183 * a cryptographically-secure PRNG.
184 *
185 * A correctly functioning RNG function must be set (using uECC_set_rng())
186 * before calling uECC_make_key() or uECC_sign().
187 *
188 * Setting a correctly functioning RNG function improves the resistance to
189 * side-channel attacks for uECC_shared_secret().
190 *
191 * A correct RNG function is set by default. If you are building on another
192 * POSIX-compliant system that supports /dev/random or /dev/urandom, you can
193 * define uECC_POSIX to use the predefined RNG.
194 */
195typedef int(*uECC_RNG_Function)(uint8_t *dest, unsigned int size);
196
197/*
198 * @brief Set the function that will be used to generate random bytes. The RNG
199 * function should return 1 if the random data was generated, or 0 if the random
200 * data could not be generated.
201 *
202 * @note On platforms where there is no predefined RNG function, this must be
203 * called before uECC_make_key() or uECC_sign() are used.
204 *
205 * @param rng_function IN -- function that will be used to generate random bytes
206 */
207void uECC_set_rng(uECC_RNG_Function rng_function);
208
209/*
210 * @brief provides current uECC_RNG_Function.
211 * @return Returns the function that will be used to generate random bytes.
212 */
213uECC_RNG_Function uECC_get_rng(void);
214
215/*
216 * @brief computes the size of a private key for the curve in bytes.
217 * @param curve IN -- elliptic curve
218 * @return size of a private key for the curve in bytes.
219 */
220int uECC_curve_private_key_size(uECC_Curve curve);
221
222/*
223 * @brief computes the size of a public key for the curve in bytes.
224 * @param curve IN -- elliptic curve
225 * @return the size of a public key for the curve in bytes.
226 */
227int uECC_curve_public_key_size(uECC_Curve curve);
228
229/*
230 * @brief Compute the corresponding public key for a private key.
231 * @param private_key IN -- The private key to compute the public key for
232 * @param public_key OUT -- Will be filled in with the corresponding public key
233 * @param curve
234 * @return Returns 1 if key was computed successfully, 0 if an error occurred.
235 */
236int uECC_compute_public_key(const uint8_t *private_key,
237 uint8_t *public_key, uECC_Curve curve);
238
239/*
240 * @brief Compute public-key.
241 * @return corresponding public-key.
242 * @param result OUT -- public-key
243 * @param private_key IN -- private-key
244 * @param curve IN -- elliptic curve
245 */
246uECC_word_t EccPoint_compute_public_key(uECC_word_t *result,
247 uECC_word_t *private_key, uECC_Curve curve);
248
249/*
Manuel Pégourié-Gonnardef238282019-11-04 11:19:30 +0100250 * @brief Point multiplication algorithm using Montgomery's ladder with co-Z
251 * coordinates. See http://eprint.iacr.org/2011/338.pdf.
252 * Uses scalar regularization and coordinate randomization (if a global RNG
253 * function is set) in order to protect against some side channel attacks.
254 * @note Result may overlap point.
255 * @param result OUT -- returns scalar*point
256 * @param point IN -- elliptic curve point
257 * @param scalar IN -- scalar
258 * @param curve IN -- elliptic curve
259 */
260int EccPoint_mult_safer(uECC_word_t * result, const uECC_word_t * point,
261 const uECC_word_t * scalar, uECC_Curve curve);
262
263/*
Jarno Lamsa18987a42019-04-24 15:40:43 +0300264 * @brief Constant-time comparison to zero - secure way to compare long integers
265 * @param vli IN -- very long integer
266 * @param num_words IN -- number of words in the vli
267 * @return 1 if vli == 0, 0 otherwise.
268 */
Manuel Pégourié-Gonnardf3899fc2019-11-04 12:44:43 +0100269uECC_word_t uECC_vli_isZero(const uECC_word_t *vli);
Jarno Lamsa18987a42019-04-24 15:40:43 +0300270
271/*
272 * @brief Check if 'point' is the point at infinity
273 * @param point IN -- elliptic curve point
274 * @param curve IN -- elliptic curve
275 * @return if 'point' is the point at infinity, 0 otherwise.
276 */
277uECC_word_t EccPoint_isZero(const uECC_word_t *point, uECC_Curve curve);
278
279/*
280 * @brief computes the sign of left - right, in constant time.
281 * @param left IN -- left term to be compared
282 * @param right IN -- right term to be compared
283 * @param num_words IN -- number of words
284 * @return the sign of left - right
285 */
Manuel Pégourié-Gonnard2cb3eea2019-11-04 14:43:35 +0100286cmpresult_t uECC_vli_cmp(const uECC_word_t *left, const uECC_word_t *right);
Jarno Lamsa18987a42019-04-24 15:40:43 +0300287
288/*
289 * @brief computes sign of left - right, not in constant time.
290 * @note should not be used if inputs are part of a secret
291 * @param left IN -- left term to be compared
292 * @param right IN -- right term to be compared
293 * @param num_words IN -- number of words
294 * @return the sign of left - right
295 */
Manuel Pégourié-Gonnarda7521912019-11-04 14:31:35 +0100296cmpresult_t uECC_vli_cmp_unsafe(const uECC_word_t *left, const uECC_word_t *right);
Jarno Lamsa18987a42019-04-24 15:40:43 +0300297
298/*
299 * @brief Computes result = (left - right) % mod.
300 * @note Assumes that (left < mod) and (right < mod), and that result does not
301 * overlap mod.
302 * @param result OUT -- (left - right) % mod
303 * @param left IN -- leftright term in modular subtraction
304 * @param right IN -- right term in modular subtraction
305 * @param mod IN -- mod
306 * @param num_words IN -- number of words
307 */
308void uECC_vli_modSub(uECC_word_t *result, const uECC_word_t *left,
Manuel Pégourié-Gonnard1b0875d2019-11-04 14:50:54 +0100309 const uECC_word_t *right, const uECC_word_t *mod);
Jarno Lamsa18987a42019-04-24 15:40:43 +0300310
311/*
312 * @brief Computes P' = (x1', y1', Z3), P + Q = (x3, y3, Z3) or
313 * P => P', Q => P + Q
314 * @note assumes Input P = (x1, y1, Z), Q = (x2, y2, Z)
315 * @param X1 IN -- x coordinate of P
316 * @param Y1 IN -- y coordinate of P
317 * @param X2 IN -- x coordinate of Q
318 * @param Y2 IN -- y coordinate of Q
319 * @param curve IN -- elliptic curve
320 */
321void XYcZ_add(uECC_word_t * X1, uECC_word_t * Y1, uECC_word_t * X2,
322 uECC_word_t * Y2, uECC_Curve curve);
323
324/*
325 * @brief Computes (x1 * z^2, y1 * z^3)
326 * @param X1 IN -- previous x1 coordinate
327 * @param Y1 IN -- previous y1 coordinate
328 * @param Z IN -- z value
329 * @param curve IN -- elliptic curve
330 */
Manuel Pégourié-Gonnardc3ec14c2019-11-04 12:12:00 +0100331void apply_z(uECC_word_t * X1, uECC_word_t * Y1, const uECC_word_t * const Z);
Jarno Lamsa18987a42019-04-24 15:40:43 +0300332
333/*
334 * @brief Check if bit is set.
335 * @return Returns nonzero if bit 'bit' of vli is set.
336 * @warning It is assumed that the value provided in 'bit' is within the
337 * boundaries of the word-array 'vli'.
338 * @note The bit ordering layout assumed for vli is: {31, 30, ..., 0},
339 * {63, 62, ..., 32}, {95, 94, ..., 64}, {127, 126,..., 96} for a vli consisting
340 * of 4 uECC_word_t elements.
341 */
342uECC_word_t uECC_vli_testBit(const uECC_word_t *vli, bitcount_t bit);
343
344/*
345 * @brief Computes result = product % mod, where product is 2N words long.
346 * @param result OUT -- product % mod
347 * @param mod IN -- module
348 * @param num_words IN -- number of words
349 * @warning Currently only designed to work for curve_p or curve_n.
350 */
351void uECC_vli_mmod(uECC_word_t *result, uECC_word_t *product,
Manuel Pégourié-Gonnard10349e42019-11-04 14:57:53 +0100352 const uECC_word_t *mod);
Jarno Lamsa18987a42019-04-24 15:40:43 +0300353
354/*
355 * @brief Computes modular product (using curve->mmod_fast)
356 * @param result OUT -- (left * right) mod % curve_p
357 * @param left IN -- left term in product
358 * @param right IN -- right term in product
359 * @param curve IN -- elliptic curve
360 */
361void uECC_vli_modMult_fast(uECC_word_t *result, const uECC_word_t *left,
Manuel Pégourié-Gonnardc3ec14c2019-11-04 12:12:00 +0100362 const uECC_word_t *right);
Jarno Lamsa18987a42019-04-24 15:40:43 +0300363
364/*
365 * @brief Computes result = left - right.
366 * @note Can modify in place.
367 * @param result OUT -- left - right
368 * @param left IN -- left term in subtraction
369 * @param right IN -- right term in subtraction
370 * @param num_words IN -- number of words
371 * @return borrow
372 */
373uECC_word_t uECC_vli_sub(uECC_word_t *result, const uECC_word_t *left,
Manuel Pégourié-Gonnard129b42e2019-11-04 14:41:45 +0100374 const uECC_word_t *right);
Jarno Lamsa18987a42019-04-24 15:40:43 +0300375
376/*
377 * @brief Constant-time comparison function(secure way to compare long ints)
378 * @param left IN -- left term in comparison
379 * @param right IN -- right term in comparison
380 * @param num_words IN -- number of words
Manuel Pégourié-Gonnard2b6312b2019-11-06 10:42:02 +0100381 * @return Returns 0 if left == right, non-zero otherwise.
Jarno Lamsa18987a42019-04-24 15:40:43 +0300382 */
Manuel Pégourié-Gonnard2eca3d32019-11-04 14:33:09 +0100383uECC_word_t uECC_vli_equal(const uECC_word_t *left, const uECC_word_t *right);
Jarno Lamsa18987a42019-04-24 15:40:43 +0300384
385/*
386 * @brief Computes (left * right) % mod
387 * @param result OUT -- (left * right) % mod
388 * @param left IN -- left term in product
389 * @param right IN -- right term in product
390 * @param mod IN -- mod
391 * @param num_words IN -- number of words
392 */
393void uECC_vli_modMult(uECC_word_t *result, const uECC_word_t *left,
Manuel Pégourié-Gonnard3e20adf2019-11-04 15:00:43 +0100394 const uECC_word_t *right, const uECC_word_t *mod);
Jarno Lamsa18987a42019-04-24 15:40:43 +0300395
396/*
397 * @brief Computes (1 / input) % mod
398 * @note All VLIs are the same size.
399 * @note See "Euclid's GCD to Montgomery Multiplication to the Great Divide"
400 * @param result OUT -- (1 / input) % mod
401 * @param input IN -- value to be modular inverted
402 * @param mod IN -- mod
403 * @param num_words -- number of words
404 */
405void uECC_vli_modInv(uECC_word_t *result, const uECC_word_t *input,
Manuel Pégourié-Gonnard91353482019-11-04 15:04:20 +0100406 const uECC_word_t *mod);
Jarno Lamsa18987a42019-04-24 15:40:43 +0300407
408/*
409 * @brief Sets dest = src.
410 * @param dest OUT -- destination buffer
411 * @param src IN -- origin buffer
412 * @param num_words IN -- number of words
413 */
Manuel Pégourié-Gonnardcbbb0f02019-11-04 13:02:04 +0100414void uECC_vli_set(uECC_word_t *dest, const uECC_word_t *src);
Jarno Lamsa18987a42019-04-24 15:40:43 +0300415
416/*
417 * @brief Computes (left + right) % mod.
418 * @note Assumes that (left < mod) and right < mod), and that result does not
419 * overlap mod.
420 * @param result OUT -- (left + right) % mod.
421 * @param left IN -- left term in addition
422 * @param right IN -- right term in addition
423 * @param mod IN -- mod
424 * @param num_words IN -- number of words
425 */
426void uECC_vli_modAdd(uECC_word_t *result, const uECC_word_t *left,
Manuel Pégourié-Gonnard0779be72019-11-04 14:48:22 +0100427 const uECC_word_t *right, const uECC_word_t *mod);
Jarno Lamsa18987a42019-04-24 15:40:43 +0300428
429/*
430 * @brief Counts the number of bits required to represent vli.
431 * @param vli IN -- very long integer
432 * @param max_words IN -- number of words
433 * @return number of bits in given vli
434 */
Manuel Pégourié-Gonnard2bf5a122019-11-04 12:56:59 +0100435bitcount_t uECC_vli_numBits(const uECC_word_t *vli);
Jarno Lamsa18987a42019-04-24 15:40:43 +0300436
437/*
438 * @brief Erases (set to 0) vli
439 * @param vli IN -- very long integer
440 * @param num_words IN -- number of words
441 */
Manuel Pégourié-Gonnard94e48492019-11-04 12:47:28 +0100442void uECC_vli_clear(uECC_word_t *vli);
Jarno Lamsa18987a42019-04-24 15:40:43 +0300443
444/*
445 * @brief check if it is a valid point in the curve
446 * @param point IN -- point to be checked
447 * @param curve IN -- elliptic curve
448 * @return 0 if point is valid
449 * @exception returns -1 if it is a point at infinity
450 * @exception returns -2 if x or y is smaller than p,
451 * @exception returns -3 if y^2 != x^3 + ax + b.
452 */
453int uECC_valid_point(const uECC_word_t *point, uECC_Curve curve);
454
455/*
456 * @brief Check if a public key is valid.
457 * @param public_key IN -- The public key to be checked.
458 * @return returns 0 if the public key is valid
459 * @exception returns -1 if it is a point at infinity
460 * @exception returns -2 if x or y is smaller than p,
461 * @exception returns -3 if y^2 != x^3 + ax + b.
462 * @exception returns -4 if public key is the group generator.
463 *
464 * @note Note that you are not required to check for a valid public key before
465 * using any other uECC functions. However, you may wish to avoid spending CPU
466 * time computing a shared secret or verifying a signature using an invalid
467 * public key.
468 */
469int uECC_valid_public_key(const uint8_t *public_key, uECC_Curve curve);
470
471 /*
472 * @brief Converts an integer in uECC native format to big-endian bytes.
473 * @param bytes OUT -- bytes representation
474 * @param num_bytes IN -- number of bytes
475 * @param native IN -- uECC native representation
476 */
477void uECC_vli_nativeToBytes(uint8_t *bytes, int num_bytes,
478 const unsigned int *native);
479
480/*
481 * @brief Converts big-endian bytes to an integer in uECC native format.
482 * @param native OUT -- uECC native representation
483 * @param bytes IN -- bytes representation
484 * @param num_bytes IN -- number of bytes
485 */
486void uECC_vli_bytesToNative(unsigned int *native, const uint8_t *bytes,
487 int num_bytes);
488
489#ifdef __cplusplus
490}
491#endif
492
493#endif /* __TC_UECC_H__ */
Manuel Pégourié-Gonnardafdc1b52019-05-09 11:24:11 +0200494#endif /* MBEDTLS_USE_TINYCRYPT */