Skip to content
This repository was archived by the owner on Mar 5, 2024. It is now read-only.

Commit c214460

Browse files
author
Constanza Heath
committed
Updating micro-ecc to more current algorithms to improve performance of the generation of shared secrets
Signed-off-by: Constanza Heath <[email protected]>
1 parent 3ab37e5 commit c214460

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+3856
-2876
lines changed

Diff for: AUTHORS

+15-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,15 @@
1-
Open Source Maintainer: Constanza Heath <[email protected]>
2-
Author: Rafael Misoczki <[email protected]>
1+
Architect:
2+
Rafael Misoczki <[email protected]>
3+
4+
Open Source Maintainer:
5+
Constanza Heath <[email protected]>
6+
Rafael Misoczki <[email protected]>
7+
8+
Contributors:
9+
Constanza Heath <[email protected]>
10+
Rafael Misoczki <[email protected]>
11+
Flavio Santes <[email protected]>
12+
Jarkko Sakkinen <[email protected]>
13+
Chris Morrison
14+
Marti Bolivar
15+
Colin Ian King

Diff for: LICENSE

+2-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
================================================================================
77

8-
Copyright (c) 2015, Intel Corporation. All rights reserved.
8+
Copyright (c) 2017, Intel Corporation. All rights reserved.
99

1010
Redistribution and use in source and binary forms, with or without modification,
1111
are permitted provided that the following conditions are met:
@@ -34,8 +34,7 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3434
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3535

3636
================================================================================
37-
38-
Copyright (c) 2013, Kenneth MacKay
37+
Copyright (c) 2014, Kenneth MacKay
3938
All rights reserved.
4039

4140
https://github.com/kmackay/micro-ecc

Diff for: Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
################################################################################
22
#
3-
# Copyright (C) 2015 by Intel Corporation, All Rights Reserved.
3+
# Copyright (C) 2017 by Intel Corporation, All Rights Reserved.
44
#
55
# Global Makefile.
66
# See lib/Makefile and tests/Makefile for further configuration.

Diff for: README

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
================================================================================
77

8-
Copyright (c) 2015, Intel Corporation. All rights reserved.
8+
Copyright (c) 2017, Intel Corporation. All rights reserved.
99

1010
Redistribution and use in source and binary forms, with or without modification,
1111
are permitted provided that the following conditions are met:
@@ -50,6 +50,7 @@ cryptographic primitive.
5050
Organization:
5151

5252
/lib: C source code of the cryptographic primitives.
53+
/lib/include/tinycrypt: C header files of the cryptographic primitives.
5354
/tests: Test vectors of the cryptographic primitives.
5455
/doc: Documentation of TinyCrypt.
5556

@@ -60,6 +61,7 @@ Building:
6061
1) In Makefile.conf set:
6162
- CFLAGS for compiler flags.
6263
- CC for compiler.
64+
- ENABLE_TESTS for enabling (true) or disabling (false) tests compilation.
6365
2) In lib/Makefile select the primitives required by your project.
6466
3) In tests/Makefile select the corresponding tests of the selected primitives.
6567
4) make

Diff for: VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.2.6
1+
0.2.7

Diff for: config.mk

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
################################################################################
22
#
3-
# Copyright (C) 2015 by Intel Corporation, All Rights Reserved.
3+
# Copyright (C) 2017 by Intel Corporation, All Rights Reserved.
44
#
55
# Global configuration Makefile. Included everywhere.
66
#
77
################################################################################
88

9+
# EDIT HERE:
910
CC:=gcc
1011
CFLAGS:=-Os -std=c99 -Wall -Wextra -D_ISOC99_SOURCE -MMD -I../lib/include/ -I../lib/source/ -I../tests/include/
1112
vpath %.c ../lib/source/
@@ -19,11 +20,16 @@ ifeq ($(OS),Windows_NT)
1920
DOTEXE:=.exe
2021
endif
2122

22-
# DO NOT EDIT THIS:
23+
# DO NOT EDIT AFTER THIS POINT:
2324
ifeq ($(ENABLE_TESTS), true)
2425
CFLAGS += -DENABLE_TESTS
2526
else
2627
CFLAGS += -DDISABLE_TESTS
2728
endif
2829

30+
export CC
31+
export CFLAGS
32+
export VPATH
33+
export ENABLE_TESTS
34+
2935
################################################################################

Diff for: documentation/tinycrypt.rst

+26-16
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
TinyCrypt Cryptographic Library
33
###############################
4-
Copyright (C) 2015 by Intel Corporation, All Rights Reserved.
4+
Copyright (C) 2017 by Intel Corporation, All Rights Reserved.
55

66
Overview
77
********
@@ -72,13 +72,13 @@ corresponding header file.
7272

7373
* ECC-DH:
7474

75-
* Type of primitive: Key exchange.
75+
* Type of primitive: Key exchange based on curve NIST p-256.
7676
* Standard Specification: RFC 6090.
7777
* Requires: ECC auxiliary functions (ecc.h/c).
7878

7979
* ECC-DSA:
8080

81-
* Type of primitive: Digital signature.
81+
* Type of primitive: Digital signature based on curve NIST p-256.
8282
* Standard Specification: RFC 6090.
8383
* Requires: ECC auxiliary functions (ecc.h/c).
8484

@@ -102,15 +102,17 @@ Important Remarks
102102

103103
The cryptographic implementations in TinyCrypt library have some limitations.
104104
Some of these limitations are inherent to the cryptographic primitives
105-
themselves, while others are specific to TinyCrypt. Some of these limitations
106-
are discussed in-depth below.
105+
themselves, while others are specific to TinyCrypt. These limitations were accepted
106+
in order to meet its design goals (in special, minimal code size) and to better
107+
serve applications targeting constrained devices in general. Some of these
108+
limitations are discussed in-depth below.
107109

108110
General Remarks
109111
***************
110112

111113
* TinyCrypt does **not** intend to be fully side-channel resistant. Due to the
112-
variety of side-channel attacks, many of them making certain platforms
113-
vulnerable. In this sense, instead of penalizing all library users with
114+
variety of side-channel attacks, many of them only relevant to certain
115+
platforms. In this sense, instead of penalizing all library users with
114116
side-channel countermeasures such as increasing the overall code size,
115117
TinyCrypt only implements certain generic timing-attack countermeasures.
116118

@@ -134,7 +136,9 @@ Specific Remarks
134136

135137
* The tc_hmac_final function, responsible for computing the message tag,
136138
cleans the state context before exiting. Thus, applications do not need to
137-
clean the TCHmacState_t ctx after calling tc_hmac_final.
139+
clean the TCHmacState_t ctx after calling tc_hmac_final. This should not
140+
be changed in future versions of the library as there are applications
141+
currently relying on this good-practice/feature of TinyCrypt.
138142

139143
* HMAC-PRNG:
140144

@@ -160,7 +164,7 @@ Specific Remarks
160164
* The AES-CTR mode limits the size of a data message they encrypt to 2^32
161165
blocks. If you need to encrypt larger data sets, your application would
162166
need to replace the key after 2^32 block encryptions.
163-
167+
164168
* CTR-PRNG:
165169

166170
* Before using CTR-PRNG, you *must* find an entropy source to produce a seed.
@@ -231,18 +235,24 @@ Specific Remarks
231235

232236
* ECC-DH and ECC-DSA:
233237

234-
* TinyCrypt ECC implementation is based on nano-ecc (see
235-
https://github.com/iSECPartners/nano-ecc) which in turn is based on
236-
mciro-ecc (see https://github.com/kmackay/micro-ecc). In the original
237-
nano and micro-ecc documentation, there is an important remark about the
238-
way integers are represented:
238+
* TinyCrypt ECC implementation is based on micro-ecc (see
239+
https://github.com/kmackay/micro-ecc). In the original micro-ecc
240+
documentation, there is an important remark about the way integers are
241+
represented:
239242

240243
"Integer representation: To reduce code size, all large integers are
241244
represented using little-endian words - so the least significant word is
242245
first. You can use the 'ecc_bytes2native()' and 'ecc_native2bytes()'
243246
functions to convert between the native integer representation and the
244247
standardized octet representation."
245248

249+
Note that the assumed bit layout is: {31, 30, ..., 0}, {63, 62, ..., 32},
250+
{95, 94, ..., 64}, {127, 126, ..., 96} for a very-long-integer (vli)
251+
consisting of 4 unsigned integers (as an example).
252+
253+
* A cryptographically-secure PRNG function must be set (using uECC_set_rng())
254+
before calling uECC_make_key() or uECC_sign().
255+
246256
Examples of Applications
247257
************************
248258
It is possible to do useful cryptography with only the given small set of
@@ -321,9 +331,9 @@ References
321331
.. _NIST SP 800-38C (AES-CCM):
322332
http://csrc.nist.gov/publications/nistpubs/800-38C/SP800-38C_updated-July20_2007.pdf
323333

324-
* `NIST Statistical Test Suite`_
334+
* `NIST Statistical Test Suite (useful for testing HMAC-PRNG)`_
325335

326-
.. _NIST Statistical Test Suite:
336+
.. _NIST Statistical Test Suite (useful for testing HMAC-PRNG):
327337
http://csrc.nist.gov/groups/ST/toolkit/rng/documentation_software.html
328338

329339
* `NIST Cryptographic Algorithm Validation Program (CAVP) site`_

Diff for: lib/Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
################################################################################
22
#
3-
# Copyright (C) 2015 by Intel Corporation, All Rights Reserved.
3+
# Copyright (C) 2017 by Intel Corporation, All Rights Reserved.
44
#
5-
# Cryptographic Primitives Makefile.
5+
# Cryptographic Primitives Makefile.
66
#
77
################################################################################
88

Diff for: lib/include/tinycrypt/aes.h

+11-14
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* aes.h - TinyCrypt interface to an AES-128 implementation */
22

33
/*
4-
* Copyright (C) 2015 by Intel Corporation, All Rights Reserved.
4+
* Copyright (C) 2017 by Intel Corporation, All Rights Reserved.
55
*
66
* Redistribution and use in source and binary forms, with or without
77
* modification, are permitted provided that the following conditions are met:
@@ -61,10 +61,9 @@ extern "C" {
6161
#define TC_AES_BLOCK_SIZE (Nb*Nk)
6262
#define TC_AES_KEY_SIZE (Nb*Nk)
6363

64-
struct tc_aes_key_sched_struct {
65-
uint32_t words[Nb*(Nr+1)];
66-
};
67-
typedef struct tc_aes_key_sched_struct *TCAesKeySched_t;
64+
typedef struct tc_aes_key_sched_struct {
65+
unsigned int words[Nb*(Nr+1)];
66+
} *TCAesKeySched_t;
6867

6968
/**
7069
* @brief Set AES-128 encryption key
@@ -77,7 +76,7 @@ typedef struct tc_aes_key_sched_struct *TCAesKeySched_t;
7776
* @param s IN/OUT -- initialized struct tc_aes_key_sched_struct
7877
* @param k IN -- points to the AES key
7978
*/
80-
int32_t tc_aes128_set_encrypt_key(TCAesKeySched_t s, const uint8_t *k);
79+
int tc_aes128_set_encrypt_key(TCAesKeySched_t s, const uint8_t *k);
8180

8281
/**
8382
* @brief AES-128 Encryption procedure
@@ -91,9 +90,8 @@ int32_t tc_aes128_set_encrypt_key(TCAesKeySched_t s, const uint8_t *k);
9190
* @param in IN -- a plaintext block to encrypt
9291
* @param s IN -- initialized AES key schedule
9392
*/
94-
int32_t tc_aes_encrypt(uint8_t *out,
95-
const uint8_t *in,
96-
const TCAesKeySched_t s);
93+
int tc_aes_encrypt(uint8_t *out, const uint8_t *in,
94+
const TCAesKeySched_t s);
9795

9896
/**
9997
* @brief Set the AES-128 decryption key
@@ -109,7 +107,7 @@ int32_t tc_aes_encrypt(uint8_t *out,
109107
* @param s IN/OUT -- initialized struct tc_aes_key_sched_struct
110108
* @param k IN -- points to the AES key
111109
*/
112-
int32_t tc_aes128_set_decrypt_key(TCAesKeySched_t s, const uint8_t *k);
110+
int tc_aes128_set_decrypt_key(TCAesKeySched_t s, const uint8_t *k);
113111

114112
/**
115113
* @brief AES-128 Encryption procedure
@@ -122,12 +120,11 @@ int32_t tc_aes128_set_decrypt_key(TCAesKeySched_t s, const uint8_t *k);
122120
* @param in IN -- a plaintext block to encrypt
123121
* @param s IN -- initialized AES key schedule
124122
*/
125-
int32_t tc_aes_decrypt(uint8_t *out,
126-
const uint8_t *in,
127-
const TCAesKeySched_t s);
123+
int tc_aes_decrypt(uint8_t *out, const uint8_t *in,
124+
const TCAesKeySched_t s);
128125

129126
#ifdef __cplusplus
130127
}
131128
#endif
132129

133-
#endif
130+
#endif /* __TC_AES_H__ */

Diff for: lib/include/tinycrypt/cbc_mode.h

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* cbc_mode.h - TinyCrypt interface to a CBC mode implementation */
22

33
/*
4-
* Copyright (C) 2015 by Intel Corporation, All Rights Reserved.
4+
* Copyright (C) 2017 by Intel Corporation, All Rights Reserved.
55
*
66
* Redistribution and use in source and binary forms, with or without
77
* modification, are permitted provided that the following conditions are met:
@@ -107,9 +107,9 @@ extern "C" {
107107
* @param iv IN -- the IV for the this encrypt/decrypt
108108
* @param sched IN -- AES key schedule for this encrypt
109109
*/
110-
int32_t tc_cbc_mode_encrypt(uint8_t *out, uint32_t outlen, const uint8_t *in,
111-
uint32_t inlen, const uint8_t *iv,
112-
const TCAesKeySched_t sched);
110+
int tc_cbc_mode_encrypt(uint8_t *out, unsigned int outlen, const uint8_t *in,
111+
unsigned int inlen, const uint8_t *iv,
112+
const TCAesKeySched_t sched);
113113

114114
/**
115115
* @brief CBC decryption procedure
@@ -140,12 +140,12 @@ int32_t tc_cbc_mode_encrypt(uint8_t *out, uint32_t outlen, const uint8_t *in,
140140
* @param sched IN -- AES key schedule for this decrypt
141141
*
142142
*/
143-
int32_t tc_cbc_mode_decrypt(uint8_t *out, uint32_t outlen, const uint8_t *in,
144-
uint32_t inlen, const uint8_t *iv,
145-
const TCAesKeySched_t sched);
143+
int tc_cbc_mode_decrypt(uint8_t *out, unsigned int outlen, const uint8_t *in,
144+
unsigned int inlen, const uint8_t *iv,
145+
const TCAesKeySched_t sched);
146146

147147
#ifdef __cplusplus
148148
}
149149
#endif
150150

151-
#endif
151+
#endif /* __TC_CBC_MODE_H__ */

0 commit comments

Comments
 (0)