mbed TLS upgraded to 2.6.0

Fork of mbedtls by Mark Radbourne

Committer:
Jasper Wallace
Date:
Fri Sep 29 19:50:30 2017 +0100
Revision:
2:bbdeda018a3c
Parent:
1:9ebc941037d5
Update to mbedtls 2.6.0, many changes.

Changes to mbedtls sources made:

in include/mbedtls/config.h comment out:

#define MBEDTLS_FS_IO
#define MBEDTLS_NET_C
#define MBEDTLS_TIMING_C

uncomment:

#define MBEDTLS_NO_PLATFORM_ENTROPY

remove the following directorys:

programs
yotta
visualc

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Jasper Wallace 1:9ebc941037d5 1 #!/usr/bin/perl
Jasper Wallace 1:9ebc941037d5 2
Jasper Wallace 1:9ebc941037d5 3 # Generate files for MS Visual Studio:
Jasper Wallace 1:9ebc941037d5 4 # - for VS6: main project (library) file, individual app files, workspace
Jasper Wallace 1:9ebc941037d5 5 # - for VS2010: main file, individual apps, solution file
Jasper Wallace 1:9ebc941037d5 6 #
Jasper Wallace 1:9ebc941037d5 7 # Must be run from mbedTLS root or scripts directory.
Jasper Wallace 1:9ebc941037d5 8 # Takes no argument.
Jasper Wallace 1:9ebc941037d5 9
Jasper Wallace 1:9ebc941037d5 10 use warnings;
Jasper Wallace 1:9ebc941037d5 11 use strict;
Jasper Wallace 1:9ebc941037d5 12 use Digest::MD5 'md5_hex';
Jasper Wallace 1:9ebc941037d5 13
Jasper Wallace 1:9ebc941037d5 14 my $vsx_dir = "visualc/VS2010";
Jasper Wallace 1:9ebc941037d5 15 my $vsx_ext = "vcxproj";
Jasper Wallace 1:9ebc941037d5 16 my $vsx_app_tpl_file = "scripts/data_files/vs2010-app-template.$vsx_ext";
Jasper Wallace 1:9ebc941037d5 17 my $vsx_main_tpl_file = "scripts/data_files/vs2010-main-template.$vsx_ext";
Jasper Wallace 1:9ebc941037d5 18 my $vsx_main_file = "$vsx_dir/mbedTLS.$vsx_ext";
Jasper Wallace 1:9ebc941037d5 19 my $vsx_sln_tpl_file = "scripts/data_files/vs2010-sln-template.sln";
Jasper Wallace 1:9ebc941037d5 20 my $vsx_sln_file = "$vsx_dir/mbedTLS.sln";
Jasper Wallace 1:9ebc941037d5 21
Jasper Wallace 1:9ebc941037d5 22 my $programs_dir = 'programs';
Jasper Wallace 1:9ebc941037d5 23 my $header_dir = 'include/mbedtls';
Jasper Wallace 1:9ebc941037d5 24 my $source_dir = 'library';
Jasper Wallace 1:9ebc941037d5 25
Jasper Wallace 1:9ebc941037d5 26 # Need windows line endings!
Jasper Wallace 1:9ebc941037d5 27 my $vsx_hdr_tpl = <<EOT;
Jasper Wallace 1:9ebc941037d5 28 <ClInclude Include="..\\..\\{NAME}" />\r
Jasper Wallace 1:9ebc941037d5 29 EOT
Jasper Wallace 1:9ebc941037d5 30 my $vsx_src_tpl = <<EOT;
Jasper Wallace 1:9ebc941037d5 31 <ClCompile Include="..\\..\\{NAME}" />\r
Jasper Wallace 1:9ebc941037d5 32 EOT
Jasper Wallace 1:9ebc941037d5 33
Jasper Wallace 1:9ebc941037d5 34 my $vsx_sln_app_entry_tpl = <<EOT;
Jasper Wallace 1:9ebc941037d5 35 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "{APPNAME}", "{APPNAME}.vcxproj", "{GUID}"\r
Jasper Wallace 1:9ebc941037d5 36 ProjectSection(ProjectDependencies) = postProject\r
Jasper Wallace 1:9ebc941037d5 37 {46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554}\r
Jasper Wallace 1:9ebc941037d5 38 EndProjectSection\r
Jasper Wallace 1:9ebc941037d5 39 EndProject\r
Jasper Wallace 1:9ebc941037d5 40 EOT
Jasper Wallace 1:9ebc941037d5 41
Jasper Wallace 1:9ebc941037d5 42 my $vsx_sln_conf_entry_tpl = <<EOT;
Jasper Wallace 1:9ebc941037d5 43 {GUID}.Debug|Win32.ActiveCfg = Debug|Win32\r
Jasper Wallace 1:9ebc941037d5 44 {GUID}.Debug|Win32.Build.0 = Debug|Win32\r
Jasper Wallace 1:9ebc941037d5 45 {GUID}.Debug|x64.ActiveCfg = Debug|x64\r
Jasper Wallace 1:9ebc941037d5 46 {GUID}.Debug|x64.Build.0 = Debug|x64\r
Jasper Wallace 1:9ebc941037d5 47 {GUID}.Release|Win32.ActiveCfg = Release|Win32\r
Jasper Wallace 1:9ebc941037d5 48 {GUID}.Release|Win32.Build.0 = Release|Win32\r
Jasper Wallace 1:9ebc941037d5 49 {GUID}.Release|x64.ActiveCfg = Release|x64\r
Jasper Wallace 1:9ebc941037d5 50 {GUID}.Release|x64.Build.0 = Release|x64\r
Jasper Wallace 1:9ebc941037d5 51 EOT
Jasper Wallace 1:9ebc941037d5 52
Jasper Wallace 1:9ebc941037d5 53 exit( main() );
Jasper Wallace 1:9ebc941037d5 54
Jasper Wallace 1:9ebc941037d5 55 sub check_dirs {
Jasper Wallace 1:9ebc941037d5 56 return -d $vsx_dir
Jasper Wallace 1:9ebc941037d5 57 && -d $header_dir
Jasper Wallace 1:9ebc941037d5 58 && -d $source_dir
Jasper Wallace 1:9ebc941037d5 59 && -d $programs_dir;
Jasper Wallace 1:9ebc941037d5 60 }
Jasper Wallace 1:9ebc941037d5 61
Jasper Wallace 1:9ebc941037d5 62 sub slurp_file {
Jasper Wallace 1:9ebc941037d5 63 my ($filename) = @_;
Jasper Wallace 1:9ebc941037d5 64
Jasper Wallace 1:9ebc941037d5 65 local $/ = undef;
Jasper Wallace 1:9ebc941037d5 66 open my $fh, '<', $filename or die "Could not read $filename\n";
Jasper Wallace 1:9ebc941037d5 67 my $content = <$fh>;
Jasper Wallace 1:9ebc941037d5 68 close $fh;
Jasper Wallace 1:9ebc941037d5 69
Jasper Wallace 1:9ebc941037d5 70 return $content;
Jasper Wallace 1:9ebc941037d5 71 }
Jasper Wallace 1:9ebc941037d5 72
Jasper Wallace 1:9ebc941037d5 73 sub content_to_file {
Jasper Wallace 1:9ebc941037d5 74 my ($content, $filename) = @_;
Jasper Wallace 1:9ebc941037d5 75
Jasper Wallace 1:9ebc941037d5 76 open my $fh, '>', $filename or die "Could not write to $filename\n";
Jasper Wallace 1:9ebc941037d5 77 print $fh $content;
Jasper Wallace 1:9ebc941037d5 78 close $fh;
Jasper Wallace 1:9ebc941037d5 79 }
Jasper Wallace 1:9ebc941037d5 80
Jasper Wallace 1:9ebc941037d5 81 sub gen_app_guid {
Jasper Wallace 1:9ebc941037d5 82 my ($path) = @_;
Jasper Wallace 1:9ebc941037d5 83
Jasper Wallace 1:9ebc941037d5 84 my $guid = md5_hex( "mbedTLS:$path" );
Jasper Wallace 1:9ebc941037d5 85 $guid =~ s/(.{8})(.{4})(.{4})(.{4})(.{12})/\U{$1-$2-$3-$4-$5}/;
Jasper Wallace 1:9ebc941037d5 86
Jasper Wallace 1:9ebc941037d5 87 return $guid;
Jasper Wallace 1:9ebc941037d5 88 }
Jasper Wallace 1:9ebc941037d5 89
Jasper Wallace 1:9ebc941037d5 90 sub gen_app {
Jasper Wallace 1:9ebc941037d5 91 my ($path, $template, $dir, $ext) = @_;
Jasper Wallace 1:9ebc941037d5 92
Jasper Wallace 1:9ebc941037d5 93 my $guid = gen_app_guid( $path );
Jasper Wallace 1:9ebc941037d5 94 $path =~ s!/!\\!g;
Jasper Wallace 1:9ebc941037d5 95 (my $appname = $path) =~ s/.*\\//;
Jasper Wallace 1:9ebc941037d5 96
Jasper Wallace 1:9ebc941037d5 97 my $content = $template;
Jasper Wallace 1:9ebc941037d5 98 $content =~ s/<PATHNAME>/$path/g;
Jasper Wallace 1:9ebc941037d5 99 $content =~ s/<APPNAME>/$appname/g;
Jasper Wallace 1:9ebc941037d5 100 $content =~ s/<GUID>/$guid/g;
Jasper Wallace 1:9ebc941037d5 101
Jasper Wallace 1:9ebc941037d5 102 content_to_file( $content, "$dir/$appname.$ext" );
Jasper Wallace 1:9ebc941037d5 103 }
Jasper Wallace 1:9ebc941037d5 104
Jasper Wallace 1:9ebc941037d5 105 sub get_app_list {
Jasper Wallace 1:9ebc941037d5 106 my $app_list = `cd $programs_dir && make list`;
Jasper Wallace 1:9ebc941037d5 107 die "make list failed: $!\n" if $?;
Jasper Wallace 1:9ebc941037d5 108
Jasper Wallace 1:9ebc941037d5 109 return split /\s+/, $app_list;
Jasper Wallace 1:9ebc941037d5 110 }
Jasper Wallace 1:9ebc941037d5 111
Jasper Wallace 1:9ebc941037d5 112 sub gen_app_files {
Jasper Wallace 1:9ebc941037d5 113 my @app_list = @_;
Jasper Wallace 1:9ebc941037d5 114
Jasper Wallace 1:9ebc941037d5 115 my $vsx_tpl = slurp_file( $vsx_app_tpl_file );
Jasper Wallace 1:9ebc941037d5 116
Jasper Wallace 1:9ebc941037d5 117 for my $app ( @app_list ) {
Jasper Wallace 1:9ebc941037d5 118 gen_app( $app, $vsx_tpl, $vsx_dir, $vsx_ext );
Jasper Wallace 1:9ebc941037d5 119 }
Jasper Wallace 1:9ebc941037d5 120 }
Jasper Wallace 1:9ebc941037d5 121
Jasper Wallace 1:9ebc941037d5 122 sub gen_entry_list {
Jasper Wallace 1:9ebc941037d5 123 my ($tpl, @names) = @_;
Jasper Wallace 1:9ebc941037d5 124
Jasper Wallace 1:9ebc941037d5 125 my $entries;
Jasper Wallace 1:9ebc941037d5 126 for my $name (@names) {
Jasper Wallace 1:9ebc941037d5 127 (my $entry = $tpl) =~ s/{NAME}/$name/g;
Jasper Wallace 1:9ebc941037d5 128 $entries .= $entry;
Jasper Wallace 1:9ebc941037d5 129 }
Jasper Wallace 1:9ebc941037d5 130
Jasper Wallace 1:9ebc941037d5 131 return $entries;
Jasper Wallace 1:9ebc941037d5 132 }
Jasper Wallace 1:9ebc941037d5 133
Jasper Wallace 1:9ebc941037d5 134 sub gen_main_file {
Jasper Wallace 1:9ebc941037d5 135 my ($headers, $sources, $hdr_tpl, $src_tpl, $main_tpl, $main_out) = @_;
Jasper Wallace 1:9ebc941037d5 136
Jasper Wallace 1:9ebc941037d5 137 my $header_entries = gen_entry_list( $hdr_tpl, @$headers );
Jasper Wallace 1:9ebc941037d5 138 my $source_entries = gen_entry_list( $src_tpl, @$sources );
Jasper Wallace 1:9ebc941037d5 139
Jasper Wallace 1:9ebc941037d5 140 my $out = slurp_file( $main_tpl );
Jasper Wallace 1:9ebc941037d5 141 $out =~ s/SOURCE_ENTRIES\r\n/$source_entries/m;
Jasper Wallace 1:9ebc941037d5 142 $out =~ s/HEADER_ENTRIES\r\n/$header_entries/m;
Jasper Wallace 1:9ebc941037d5 143
Jasper Wallace 1:9ebc941037d5 144 content_to_file( $out, $main_out );
Jasper Wallace 1:9ebc941037d5 145 }
Jasper Wallace 1:9ebc941037d5 146
Jasper Wallace 1:9ebc941037d5 147 sub gen_vsx_solution {
Jasper Wallace 1:9ebc941037d5 148 my (@app_names) = @_;
Jasper Wallace 1:9ebc941037d5 149
Jasper Wallace 1:9ebc941037d5 150 my ($app_entries, $conf_entries);
Jasper Wallace 1:9ebc941037d5 151 for my $path (@app_names) {
Jasper Wallace 1:9ebc941037d5 152 my $guid = gen_app_guid( $path );
Jasper Wallace 1:9ebc941037d5 153 (my $appname = $path) =~ s!.*/!!;
Jasper Wallace 1:9ebc941037d5 154
Jasper Wallace 1:9ebc941037d5 155 my $app_entry = $vsx_sln_app_entry_tpl;
Jasper Wallace 1:9ebc941037d5 156 $app_entry =~ s/{APPNAME}/$appname/g;
Jasper Wallace 1:9ebc941037d5 157 $app_entry =~ s/{GUID}/$guid/g;
Jasper Wallace 1:9ebc941037d5 158
Jasper Wallace 1:9ebc941037d5 159 $app_entries .= $app_entry;
Jasper Wallace 1:9ebc941037d5 160
Jasper Wallace 1:9ebc941037d5 161 my $conf_entry = $vsx_sln_conf_entry_tpl;
Jasper Wallace 1:9ebc941037d5 162 $conf_entry =~ s/{GUID}/$guid/g;
Jasper Wallace 1:9ebc941037d5 163
Jasper Wallace 1:9ebc941037d5 164 $conf_entries .= $conf_entry;
Jasper Wallace 1:9ebc941037d5 165 }
Jasper Wallace 1:9ebc941037d5 166
Jasper Wallace 1:9ebc941037d5 167 my $out = slurp_file( $vsx_sln_tpl_file );
Jasper Wallace 1:9ebc941037d5 168 $out =~ s/APP_ENTRIES\r\n/$app_entries/m;
Jasper Wallace 1:9ebc941037d5 169 $out =~ s/CONF_ENTRIES\r\n/$conf_entries/m;
Jasper Wallace 1:9ebc941037d5 170
Jasper Wallace 1:9ebc941037d5 171 content_to_file( $out, $vsx_sln_file );
Jasper Wallace 1:9ebc941037d5 172 }
Jasper Wallace 1:9ebc941037d5 173
Jasper Wallace 1:9ebc941037d5 174 sub main {
Jasper Wallace 1:9ebc941037d5 175 if( ! check_dirs() ) {
Jasper Wallace 1:9ebc941037d5 176 chdir '..' or die;
Jasper Wallace 1:9ebc941037d5 177 check_dirs or die "Must but run from mbedTLS root or scripts dir\n";
Jasper Wallace 1:9ebc941037d5 178 }
Jasper Wallace 1:9ebc941037d5 179
Jasper Wallace 1:9ebc941037d5 180 my @app_list = get_app_list();
Jasper Wallace 1:9ebc941037d5 181 my @headers = <$header_dir/*.h>;
Jasper Wallace 1:9ebc941037d5 182 my @sources = <$source_dir/*.c>;
Jasper Wallace 1:9ebc941037d5 183 map { s!/!\\!g } @headers;
Jasper Wallace 1:9ebc941037d5 184 map { s!/!\\!g } @sources;
Jasper Wallace 1:9ebc941037d5 185
Jasper Wallace 1:9ebc941037d5 186 gen_app_files( @app_list );
Jasper Wallace 1:9ebc941037d5 187
Jasper Wallace 1:9ebc941037d5 188 gen_main_file( \@headers, \@sources,
Jasper Wallace 1:9ebc941037d5 189 $vsx_hdr_tpl, $vsx_src_tpl,
Jasper Wallace 1:9ebc941037d5 190 $vsx_main_tpl_file, $vsx_main_file );
Jasper Wallace 1:9ebc941037d5 191
Jasper Wallace 1:9ebc941037d5 192 gen_vsx_solution( @app_list );
Jasper Wallace 1:9ebc941037d5 193
Jasper Wallace 1:9ebc941037d5 194 return 0;
Jasper Wallace 1:9ebc941037d5 195 }