1 #******************************************************************
3 # Copyright 2016 Samsung Electronics All Rights Reserved.
5 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
11 # http://www.apache.org/licenses/LICENSE-2.0
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
19 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
26 target_os = env.get('TARGET_OS')
27 root_dir = env.get('SRC_DIR')
28 mbedtls_dir = os.path.join(root_dir, 'extlibs','mbedtls','mbedtls/')
29 libs_list = ['libmbedcrypto','libmbedtls','libmbedx509']
32 """Run a command and decipher the return code. Exit by default."""
34 # Assumes that if a process doesn't call exit, it was successful
35 if (os.WIFEXITED(res)):
36 code = os.WEXITSTATUS(res)
38 print "Error: return code: " + str(code)
39 if SCons.Script.keep_going_on_error == 0:
43 if not os.path.exists(mbedtls_dir):
45 *********************************** Error: ****************************************
46 * Please download mbedtls using the following command: *
47 * $ git clone https://github.com/ARMmbed/mbedtls.git extlibs/mbedtls/mbedtls *
48 ***********************************************************************************
51 #Apply patch to enable TLS_ECDH_ANON_WITH_AES_128_CBC_SHA256 ciphersuite and server identity hint
52 start_dir = os.getcwd()
54 cmd = 'git reset --hard ad249f509fd62a3bbea7ccd1fef605dbd482a7bd && git apply ../ocf.patch'
59 mbedtls_env = env.Clone()
60 mbedtls_env.PrependUnique(CPPPATH = [mbedtls_dir])
61 mbedtls_env.AppendUnique(CPPPATH = [mbedtls_dir+'include/'])
62 mbedtls_env.AppendUnique(CFLAGS = ['-fPIC', '-Wall', '-Wextra', '-W', '-Wdeclaration-after-statement', '-Wwrite-strings'])
64 ######################################################################
65 # Source files and Target(s)
66 ######################################################################
68 'mbedtls/library/debug.c',
69 'mbedtls/library/net.c',
70 'mbedtls/library/ssl_cache.c',
71 'mbedtls/library/ssl_ciphersuites.c',
72 'mbedtls/library/ssl_cli.c',
73 'mbedtls/library/ssl_cookie.c',
74 'mbedtls/library/ssl_srv.c',
75 'mbedtls/library/ssl_ticket.c',
76 'mbedtls/library/ssl_tls.c'
81 'mbedtls/library/aes.c',
82 'mbedtls/library/aesni.c',
83 'mbedtls/library/arc4.c',
84 'mbedtls/library/asn1parse.c',
85 'mbedtls/library/asn1write.c',
86 'mbedtls/library/base64.c',
87 'mbedtls/library/bignum.c',
88 'mbedtls/library/blowfish.c',
89 'mbedtls/library/camellia.c',
90 'mbedtls/library/ccm.c',
91 'mbedtls/library/cipher.c',
92 'mbedtls/library/cipher_wrap.c',
93 'mbedtls/library/ctr_drbg.c',
94 'mbedtls/library/des.c',
95 'mbedtls/library/dhm.c',
96 'mbedtls/library/ecdh.c',
97 'mbedtls/library/ecdsa.c',
98 'mbedtls/library/ecjpake.c',
99 'mbedtls/library/ecp.c',
100 'mbedtls/library/ecp_curves.c',
101 'mbedtls/library/entropy.c',
102 'mbedtls/library/entropy_poll.c',
103 'mbedtls/library/error.c',
104 'mbedtls/library/gcm.c',
105 'mbedtls/library/havege.c',
106 'mbedtls/library/hmac_drbg.c',
107 'mbedtls/library/md.c',
108 'mbedtls/library/md2.c',
109 'mbedtls/library/md4.c',
110 'mbedtls/library/md5.c',
111 'mbedtls/library/md_wrap.c',
112 'mbedtls/library/memory_buffer_alloc.c',
113 'mbedtls/library/oid.c',
114 'mbedtls/library/padlock.c',
115 'mbedtls/library/pem.c',
116 'mbedtls/library/pk.c',
117 'mbedtls/library/pk_wrap.c',
118 'mbedtls/library/pkcs12.c',
119 'mbedtls/library/pkcs5.c',
120 'mbedtls/library/pkparse.c',
121 'mbedtls/library/pkwrite.c',
122 'mbedtls/library/platform.c',
123 'mbedtls/library/ripemd160.c',
124 'mbedtls/library/rsa.c',
125 'mbedtls/library/sha1.c',
126 'mbedtls/library/sha256.c',
127 'mbedtls/library/sha512.c',
128 'mbedtls/library/threading.c',
129 'mbedtls/library/timing.c',
130 'mbedtls/library/version.c',
131 'mbedtls/library/version_features.c',
132 'mbedtls/library/xtea.c'
136 'mbedtls/library/certs.c',
137 'mbedtls/library/pkcs11.c',
138 'mbedtls/library/x509.c',
139 'mbedtls/library/x509_create.c',
140 'mbedtls/library/x509_crl.c',
141 'mbedtls/library/x509_crt.c',
142 'mbedtls/library/x509_csr.c',
143 'mbedtls/library/x509write_crt.c',
144 'mbedtls/library/x509write_csr.c'
147 mbedcrypto_env = mbedtls_env.Clone()
148 static_libmbedcrypto = mbedcrypto_env.StaticLibrary('mbedcrypto', mbedcrypto_src)
149 mbedcrypto_env.InstallTarget(static_libmbedcrypto, 'mbedcrypto')
151 mbex509_env = mbedtls_env.Clone()
152 mbex509_env.AppendUnique(LIBS = ['mbedcrypto'])
153 static_libmbedx509 = mbex509_env.StaticLibrary('mbedx509', mbeX509_src)
154 mbex509_env.InstallTarget(static_libmbedx509, 'mbedx509')
157 mbedtls_env.AppendUnique(LIBS = ['mbedx509', 'mbedcrypto'])
158 static_libmbedtls = mbedtls_env.StaticLibrary('mbedtls', mbedtls_src)
159 mbedtls_env.InstallTarget(static_libmbedtls, 'mbedtls')