Skip to content

Commit 8828635

Browse files
authored
Merge pull request ARMmbed#4689 from ARMmbed/release-candidate
Release candidate for mbed-os-5.5.2
2 parents c9e63f1 + 597a4a9 commit 8828635

File tree

427 files changed

+30146
-21395
lines changed

Some content is hidden

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

427 files changed

+30146
-21395
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ All changes in code base should originate from GitHub Issues and take advantage
55
Guidelines from this document are created to help new and existing contributors understand process workflow and align to project rules before pull request is submitted. It explains how a participant should do things like format code, test fixes, and submit patches.
66

77
## Where to get more information?
8-
You can read more on our [documentation page](https://docs.mbed.com/).
8+
You can read more on our [documentation page](https://docs.mbed.com/docs/mbed-os-handbook/en/latest/cont/contributing/).
99

1010
# How to contribute
1111
We really appreciate your contributions! We are Open Source project and we need your help. We want to keep it as easy as possible to contribute changes that get things working in your environment. There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things.

TESTS/mbedtls/multi/main.cpp

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
/*
2+
* Copyright (c) 2013-2016, ARM Limited, All Rights Reserved
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License"); you may
6+
* not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
#include <stdio.h>
18+
#include <string.h>
19+
#include "mbed.h"
20+
#include "greentea-client/test_env.h"
21+
#include "unity/unity.h"
22+
#include "utest/utest.h"
23+
24+
#include "mbedtls/sha256.h"
25+
26+
27+
using namespace utest::v1;
28+
29+
#if defined(MBEDTLS_SHA256_C)
30+
/* Tests several call to mbedtls_sha256_update function that are not modulo 64 bytes */
31+
void test_case_sha256_split() {
32+
const unsigned char test_buf[] = {"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopqabcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopqabcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"};
33+
// sha256_output_values for 3*abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq
34+
const unsigned char test_sum[] =
35+
{ 0x50, 0xEA, 0x82, 0x5D, 0x96, 0x84, 0xF4, 0x22,
36+
0x9C, 0xA2, 0x9F, 0x1F, 0xEC, 0x51, 0x15, 0x93,
37+
0xE2, 0x81, 0xE4, 0x6A, 0x14, 0x0D, 0x81, 0xE0,
38+
0x00, 0x5F, 0x8F, 0x68, 0x86, 0x69, 0xA0, 0x6C};
39+
unsigned char outsum[32];
40+
int i;
41+
42+
mbedtls_sha256_context ctx;
43+
printf("test sha256\n");
44+
mbedtls_sha256_init( &ctx );
45+
mbedtls_sha256_starts( &ctx, 0);
46+
#if 0
47+
printf("test not splitted\n");
48+
mbedtls_sha256_update( &ctx, test_buf, 168 );
49+
#else
50+
printf("test splitted into 3 pieces\n");
51+
mbedtls_sha256_update( &ctx, test_buf, 2 );
52+
mbedtls_sha256_update( &ctx, test_buf+2, 66 );
53+
mbedtls_sha256_update( &ctx, test_buf+68, 100 );
54+
#endif
55+
56+
mbedtls_sha256_finish( &ctx, outsum );
57+
mbedtls_sha256_free( &ctx );
58+
59+
printf("\nreceived result : ");
60+
for (i=0;i<32;i++) { printf("%02X",outsum[i]);}
61+
printf("\nawaited result : 50EA825D9684F4229CA29F1FEC511593E281E46A140D81E0005F8F688669A06C\n"); // for abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq
62+
63+
printf("\nend of test sha256\n");
64+
TEST_ASSERT_EQUAL_UINT8_ARRAY(outsum, test_sum,32);
65+
}
66+
67+
/* Tests that treating 2 sha256 objects in // does not impact the result */
68+
void test_case_sha256_multi() {
69+
const unsigned char test_buf[] = {"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopqabcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopqabcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"};
70+
const unsigned char test_buf2[] = {"abcdefghijklmnopqrstuvwxyz012345678901234567890123456789"};
71+
72+
// sha256_output_values for abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq
73+
const unsigned char test_sum1[] =
74+
{ 0x24, 0x8D, 0x6A, 0x61, 0xD2, 0x06, 0x38, 0xB8,
75+
0xE5, 0xC0, 0x26, 0x93, 0x0C, 0x3E, 0x60, 0x39,
76+
0xA3, 0x3C, 0xE4, 0x59, 0x64, 0xFF, 0x21, 0x67,
77+
0xF6, 0xEC, 0xED, 0xD4, 0x19, 0xDB, 0x06, 0xC1 };
78+
// sha256_output_values for 3*abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq
79+
const unsigned char test_sum2[] =
80+
{ 0x50, 0xEA, 0x82, 0x5D, 0x96, 0x84, 0xF4, 0x22,
81+
0x9C, 0xA2, 0x9F, 0x1F, 0xEC, 0x51, 0x15, 0x93,
82+
0xE2, 0x81, 0xE4, 0x6A, 0x14, 0x0D, 0x81, 0xE0,
83+
0x00, 0x5F, 0x8F, 0x68, 0x86, 0x69, 0xA0, 0x6C};
84+
// sha256_output_values for abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopqabcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopqabcdefghijklmnopqrstuvwxyz012345678901234567890123456789
85+
const unsigned char test_sum3[] =
86+
{ 0x6D, 0x5D, 0xDB, 0x5F, 0x4A, 0x94, 0xAB, 0x7E,
87+
0x5C, 0xF7, 0x9A, 0xD8, 0x3F, 0x58, 0xD3, 0x97,
88+
0xFE, 0x79, 0xFB, 0x0D, 0x79, 0xB2, 0x0D, 0x22,
89+
0xFF, 0x95, 0x9F, 0x04, 0xA2, 0xE4, 0x6C, 0x68};
90+
unsigned char outsum1[32], outsum2[32], outsum3[32];
91+
int i;
92+
93+
mbedtls_sha256_context ctx1;
94+
mbedtls_sha256_context ctx2;
95+
mbedtls_sha256_context ctx3;
96+
printf("test sha256_multi\n");
97+
//Init both contexts
98+
mbedtls_sha256_init( &ctx1);
99+
mbedtls_sha256_init( &ctx2);
100+
mbedtls_sha256_init( &ctx3);
101+
//Start both contexts
102+
mbedtls_sha256_starts( &ctx1, 0);
103+
mbedtls_sha256_starts( &ctx2, 0);
104+
105+
printf("upd ctx1\n");
106+
mbedtls_sha256_update( &ctx1, test_buf, 56 );
107+
printf("upd ctx2\n");
108+
mbedtls_sha256_update( &ctx2, test_buf, 66 );
109+
printf("finish ctx1\n");
110+
mbedtls_sha256_finish( &ctx1, outsum1 );
111+
printf("upd ctx2\n");
112+
mbedtls_sha256_update( &ctx2, test_buf+66, 46 );
113+
printf("clone ctx2 in ctx3\n");
114+
mbedtls_sha256_clone(&ctx3, (const mbedtls_sha256_context *)&ctx2);
115+
printf("free ctx1\n");
116+
mbedtls_sha256_free( &ctx1 );
117+
printf("upd ctx2\n");
118+
mbedtls_sha256_update( &ctx2, test_buf+112, 56 );
119+
printf("upd ctx3 with different values than ctx2\n");
120+
mbedtls_sha256_update( &ctx3, test_buf2, 56 );
121+
printf("finish ctx2\n");
122+
mbedtls_sha256_finish( &ctx2, outsum2 );
123+
printf("finish ctx3\n");
124+
mbedtls_sha256_finish( &ctx3, outsum3 );
125+
printf("free ctx2\n");
126+
mbedtls_sha256_free( &ctx2 );
127+
printf("free ctx3\n");
128+
mbedtls_sha256_free( &ctx3 );
129+
130+
printf("\nreceived result ctx1 : ");
131+
for (i=0;i<32;i++) { printf("%02X",outsum1[i]);}
132+
printf("\nawaited result : 248D6A61D20638B8E5C026930C3E6039A33CE45964FF216F6ECEDD19DB06C1\n"); // for abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq
133+
printf("\nreceived result ctx2 : ");
134+
for (i=0;i<32;i++) { printf("%02X",outsum2[i]);}
135+
printf("\nawaited result : 50EA825D9684F4229CA29F1FEC511593E281E46A140D81E0005F8F688669A06C\n"); // for 3*abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq
136+
printf("\nreceived result ctx3 : ");
137+
for (i=0;i<32;i++) { printf("%02X",outsum3[i]);}
138+
printf("\nawaited result : 6D5DDB5F4A94AB7E5CF79AD83F58D397FE79FB0D79B20D22FF959F04A2E46C68\n"); // for 2*abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq+3*0123456789
139+
printf("\nend of test sha256\n");
140+
TEST_ASSERT_EQUAL_UINT8_ARRAY(outsum1, test_sum1,32);
141+
TEST_ASSERT_EQUAL_UINT8_ARRAY(outsum2, test_sum2,32);
142+
TEST_ASSERT_EQUAL_UINT8_ARRAY(outsum3, test_sum3,32);
143+
}
144+
#endif //MBEDTLS_SHA256_C
145+
146+
utest::v1::status_t greentea_failure_handler(const Case *const source, const failure_t reason) {
147+
greentea_case_failure_abort_handler(source, reason);
148+
return STATUS_CONTINUE;
149+
}
150+
151+
Case cases[] = {
152+
#if defined(MBEDTLS_SHA256_C)
153+
Case("Crypto: sha256_split", test_case_sha256_split, greentea_failure_handler),
154+
Case("Crypto: sha256_multi", test_case_sha256_multi, greentea_failure_handler),
155+
#endif
156+
};
157+
158+
utest::v1::status_t greentea_test_setup(const size_t number_of_cases) {
159+
GREENTEA_SETUP(10, "default_auto");
160+
return greentea_test_setup_handler(number_of_cases);
161+
}
162+
163+
Specification specification(greentea_test_setup, cases, greentea_test_teardown_handler);
164+
165+
int main() {
166+
Harness::run(specification);
167+
}

cmsis/TOOLCHAIN_IAR/cmain.S

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
EXTERN exit
4747
EXTERN __iar_dynamic_initialization
4848
EXTERN mbed_sdk_init
49+
EXTERN mbed_main
4950
EXTERN SystemInit
5051

5152
THUMB
@@ -87,6 +88,10 @@ _call_main:
8788
FUNCALL __cmain, __iar_argc_argv
8889
BL __iar_argc_argv ; Maybe setup command line
8990

91+
MOVS r0,#0 ; No parameters
92+
FUNCALL __cmain, mbed_main
93+
BL mbed_main
94+
9095
FUNCALL __cmain, main
9196
BL main
9297
_main:

drivers/BusIn.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "platform/platform.h"
2020
#include "drivers/DigitalIn.h"
2121
#include "platform/PlatformMutex.h"
22+
#include "platform/NonCopyable.h"
2223

2324
namespace mbed {
2425
/** \addtogroup drivers */
@@ -28,7 +29,7 @@ namespace mbed {
2829
* @note Synchronization level: Thread safe
2930
* @ingroup drivers
3031
*/
31-
class BusIn {
32+
class BusIn : private NonCopyable<BusIn> {
3233

3334
public:
3435
/* Group: Configuration Methods */
@@ -115,12 +116,9 @@ class BusIn {
115116

116117
PlatformMutex _mutex;
117118

118-
/* disallow copy constructor and assignment operators */
119119
private:
120120
virtual void lock();
121121
virtual void unlock();
122-
BusIn(const BusIn&);
123-
BusIn & operator = (const BusIn&);
124122
};
125123

126124
} // namespace mbed

drivers/BusInOut.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#include "drivers/DigitalInOut.h"
2020
#include "platform/PlatformMutex.h"
21+
#include "platform/NonCopyable.h"
2122

2223
namespace mbed {
2324
/** \addtogroup drivers */
@@ -27,7 +28,7 @@ namespace mbed {
2728
* @note Synchronization level: Thread safe
2829
* @ingroup drivers
2930
*/
30-
class BusInOut {
31+
class BusInOut : private NonCopyable<BusInOut> {
3132

3233
public:
3334

@@ -135,11 +136,6 @@ class BusInOut {
135136
int _nc_mask;
136137

137138
PlatformMutex _mutex;
138-
139-
/* disallow copy constructor and assignment operators */
140-
private:
141-
BusInOut(const BusInOut&);
142-
BusInOut & operator = (const BusInOut&);
143139
};
144140

145141
} // namespace mbed

drivers/BusOut.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@
1818

1919
#include "drivers/DigitalOut.h"
2020
#include "platform/PlatformMutex.h"
21+
#include "platform/NonCopyable.h"
2122

2223
namespace mbed {
2324
/** \addtogroup drivers */
2425

2526
/** A digital output bus, used for setting the state of a collection of pins
2627
* @ingroup drivers
2728
*/
28-
class BusOut {
29+
class BusOut : private NonCopyable<BusOut> {
2930

3031
public:
3132

@@ -119,11 +120,6 @@ class BusOut {
119120
int _nc_mask;
120121

121122
PlatformMutex _mutex;
122-
123-
/* disallow copy constructor and assignment operators */
124-
private:
125-
BusOut(const BusOut&);
126-
BusOut & operator = (const BusOut&);
127123
};
128124

129125
} // namespace mbed

drivers/CAN.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "hal/can_api.h"
2424
#include "platform/Callback.h"
2525
#include "platform/PlatformMutex.h"
26+
#include "platform/NonCopyable.h"
2627

2728
namespace mbed {
2829
/** \addtogroup drivers */
@@ -78,7 +79,7 @@ class CANMessage : public CAN_Message {
7879
/** A can bus client, used for communicating with can devices
7980
* @ingroup drivers
8081
*/
81-
class CAN {
82+
class CAN : private NonCopyable<CAN> {
8283

8384
public:
8485
/** Creates an CAN interface connected to specific pins.

drivers/Ethernet.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#define MBED_ETHERNET_H
1818

1919
#include "platform/platform.h"
20+
#include "platform/NonCopyable.h"
2021

2122
#if defined (DEVICE_ETHERNET) || defined(DOXYGEN_ONLY)
2223

@@ -54,7 +55,7 @@ namespace mbed {
5455
* @endcode
5556
* @ingroup drivers
5657
*/
57-
class Ethernet {
58+
class Ethernet : private NonCopyable<Ethernet> {
5859

5960
public:
6061

drivers/FlashIAP.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "flash_api.h"
2828
#include "platform/SingletonPtr.h"
2929
#include "platform/PlatformMutex.h"
30+
#include "platform/NonCopyable.h"
3031

3132
namespace mbed {
3233

@@ -37,7 +38,7 @@ namespace mbed {
3738
* @note Synchronization level: Thread safe
3839
* @ingroup drivers
3940
*/
40-
class FlashIAP {
41+
class FlashIAP : private NonCopyable<FlashIAP> {
4142
public:
4243
FlashIAP();
4344
~FlashIAP();

drivers/I2C.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "hal/i2c_api.h"
2424
#include "platform/SingletonPtr.h"
2525
#include "platform/PlatformMutex.h"
26+
#include "platform/NonCopyable.h"
2627

2728
#if DEVICE_I2C_ASYNCH
2829
#include "platform/CThunk.h"
@@ -53,7 +54,7 @@ namespace mbed {
5354
* @endcode
5455
* @ingroup drivers
5556
*/
56-
class I2C {
57+
class I2C : private NonCopyable<I2C> {
5758

5859
public:
5960
enum RxStatus {

drivers/InterruptIn.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "platform/Callback.h"
2626
#include "platform/mbed_critical.h"
2727
#include "platform/mbed_toolchain.h"
28+
#include "platform/NonCopyable.h"
2829

2930
namespace mbed {
3031
/** \addtogroup drivers */
@@ -56,7 +57,7 @@ namespace mbed {
5657
* @endcode
5758
* @ingroup drivers
5859
*/
59-
class InterruptIn {
60+
class InterruptIn : private NonCopyable<InterruptIn> {
6061

6162
public:
6263

drivers/InterruptManager.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "cmsis.h"
2020
#include "platform/CallChain.h"
2121
#include "platform/PlatformMutex.h"
22+
#include "platform/NonCopyable.h"
2223
#include <string.h>
2324

2425
namespace mbed {
@@ -53,7 +54,7 @@ namespace mbed {
5354
* @endcode
5455
* @ingroup drivers
5556
*/
56-
class InterruptManager {
57+
class InterruptManager : private NonCopyable<InterruptManager> {
5758
public:
5859
/** Get the instance of InterruptManager Class
5960
*
@@ -138,12 +139,6 @@ class InterruptManager {
138139
void lock();
139140
void unlock();
140141

141-
// We declare the copy contructor and the assignment operator, but we don't
142-
// implement them. This way, if someone tries to copy/assign our instance,
143-
// he will get an error at compile time.
144-
InterruptManager(const InterruptManager&);
145-
InterruptManager& operator =(const InterruptManager&);
146-
147142
template<typename T>
148143
pFunctionPointer_t add_common(T *tptr, void (T::*mptr)(void), IRQn_Type irq, bool front=false) {
149144
_mutex.lock();

0 commit comments

Comments
 (0)