|
| 1 | +diff -Nru mbedtls-2.28.10-orig/library/entropy_poll.c mbedtls-2.28.10/library/entropy_poll.c |
| 2 | +--- mbedtls-2.28.10-orig/library/entropy_poll.c 2025-03-24 08:49:00 |
| 3 | ++++ mbedtls-2.28.10/library/entropy_poll.c 2026-04-25 20:09:41 |
| 4 | +@@ -34,7 +34,7 @@ |
| 5 | + |
| 6 | + #if !defined(unix) && !defined(__unix__) && !defined(__unix) && \ |
| 7 | + !defined(__APPLE__) && !defined(_WIN32) && !defined(__QNXNTO__) && \ |
| 8 | +- !defined(__HAIKU__) && !defined(__midipix__) |
| 9 | ++ !defined(__HAIKU__) && !defined(__midipix__) && !defined(__PPU__) |
| 10 | + #error \ |
| 11 | + "Platform entropy sources only work on Unix and Windows, see MBEDTLS_NO_PLATFORM_ENTROPY in config.h" |
| 12 | + #endif |
| 13 | +@@ -148,6 +148,10 @@ |
| 14 | + |
| 15 | + #include <stdio.h> |
| 16 | + |
| 17 | ++#if defined(__PPU__) |
| 18 | ++#include <lv2/system.h> |
| 19 | ++#endif |
| 20 | ++ |
| 21 | + int mbedtls_platform_entropy_poll(void *data, |
| 22 | + unsigned char *output, size_t len, size_t *olen) |
| 23 | + { |
| 24 | +@@ -155,6 +159,15 @@ |
| 25 | + size_t read_len; |
| 26 | + int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; |
| 27 | + ((void) data); |
| 28 | ++ |
| 29 | ++#if defined(__PPU__) |
| 30 | ++ if (sysGetRandomNumber(output, len) == 0) { |
| 31 | ++ *olen = len; |
| 32 | ++ return 0; |
| 33 | ++ } else { |
| 34 | ++ return MBEDTLS_ERR_ENTROPY_SOURCE_FAILED; |
| 35 | ++ } |
| 36 | ++#endif |
| 37 | + |
| 38 | + #if defined(HAVE_GETRANDOM) |
| 39 | + ret = getrandom_wrapper(output, len, 0); |
| 40 | +diff -Nru mbedtls-2.28.10-orig/library/net_sockets.c mbedtls-2.28.10/library/net_sockets.c |
| 41 | +--- mbedtls-2.28.10-orig/library/net_sockets.c 2025-03-24 08:49:00 |
| 42 | ++++ mbedtls-2.28.10/library/net_sockets.c 2026-04-25 19:37:20 |
| 43 | +@@ -15,13 +15,16 @@ |
| 44 | + #define _XOPEN_SOURCE 600 /* sockaddr_storage */ |
| 45 | + #endif |
| 46 | + |
| 47 | ++#define sockaddr_storage sockaddr_in |
| 48 | ++#include <net/select.h> |
| 49 | ++ |
| 50 | + #include "common.h" |
| 51 | + |
| 52 | + #if defined(MBEDTLS_NET_C) |
| 53 | + |
| 54 | + #if !defined(unix) && !defined(__unix__) && !defined(__unix) && \ |
| 55 | + !defined(__APPLE__) && !defined(_WIN32) && !defined(__QNXNTO__) && \ |
| 56 | +- !defined(__HAIKU__) && !defined(__midipix__) |
| 57 | ++ !defined(__HAIKU__) && !defined(__midipix__) && !defined(__PPU__) |
| 58 | + #error "This module only works on Unix and Windows, see MBEDTLS_NET_C in config.h" |
| 59 | + #endif |
| 60 | + |
| 61 | +@@ -30,6 +33,9 @@ |
| 62 | + #include "mbedtls/net_sockets.h" |
| 63 | + #include "mbedtls/error.h" |
| 64 | + |
| 65 | ++#include <machine/endian.h> |
| 66 | ++#include <net/select.h> |
| 67 | ++ |
| 68 | + #include <string.h> |
| 69 | + |
| 70 | + #if (defined(_WIN32) || defined(_WIN32_WCE)) && !defined(EFIX64) && \ |
| 71 | +@@ -163,6 +169,7 @@ |
| 72 | + int mbedtls_net_connect(mbedtls_net_context *ctx, const char *host, |
| 73 | + const char *port, int proto) |
| 74 | + { |
| 75 | ++#if 0 |
| 76 | + int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; |
| 77 | + struct addrinfo hints, *addr_list, *cur; |
| 78 | + |
| 79 | +@@ -202,6 +209,37 @@ |
| 80 | + freeaddrinfo(addr_list); |
| 81 | + |
| 82 | + return ret; |
| 83 | ++#endif |
| 84 | ++ /* Legacy IPv4-only version */ |
| 85 | ++ |
| 86 | ++ int ret; |
| 87 | ++ struct sockaddr_in server_addr; |
| 88 | ++ struct hostent *server_host; |
| 89 | ++ |
| 90 | ++ if( ( ret = net_prepare() ) != 0 ) |
| 91 | ++ return( ret ); |
| 92 | ++ |
| 93 | ++ if( ( server_host = gethostbyname( host ) ) == NULL ) |
| 94 | ++ return( MBEDTLS_ERR_NET_UNKNOWN_HOST ); |
| 95 | ++ |
| 96 | ++ if( ( ctx->fd = (int) socket( AF_INET, SOCK_STREAM, IPPROTO_IP ) ) < 0 ) |
| 97 | ++ return( MBEDTLS_ERR_NET_SOCKET_FAILED ); |
| 98 | ++ |
| 99 | ++ memcpy( (void *) &server_addr.sin_addr, |
| 100 | ++ (void *) server_host->h_addr, |
| 101 | ++ server_host->h_length ); |
| 102 | ++ |
| 103 | ++ server_addr.sin_family = AF_INET; |
| 104 | ++ server_addr.sin_port = htons( atoi(port) ); |
| 105 | ++ |
| 106 | ++ if( connect( ctx->fd, (struct sockaddr *) &server_addr, |
| 107 | ++ sizeof( server_addr ) ) < 0 ) |
| 108 | ++ { |
| 109 | ++ close( ctx->fd ); |
| 110 | ++ return( MBEDTLS_ERR_NET_CONNECT_FAILED ); |
| 111 | ++ } |
| 112 | ++ |
| 113 | ++ return( 0 ); |
| 114 | + } |
| 115 | + |
| 116 | + /* |
| 117 | +@@ -209,6 +247,7 @@ |
| 118 | + */ |
| 119 | + int mbedtls_net_bind(mbedtls_net_context *ctx, const char *bind_ip, const char *port, int proto) |
| 120 | + { |
| 121 | ++#if 0 |
| 122 | + int n, ret; |
| 123 | + struct addrinfo hints, *addr_list, *cur; |
| 124 | + |
| 125 | +@@ -270,7 +309,57 @@ |
| 126 | + freeaddrinfo(addr_list); |
| 127 | + |
| 128 | + return ret; |
| 129 | ++#endif |
| 130 | ++ /* Legacy IPv4-only version */ |
| 131 | ++ |
| 132 | ++ int ret, n, c[4]; |
| 133 | ++ struct sockaddr_in server_addr; |
| 134 | + |
| 135 | ++ if( ( ret = net_prepare() ) != 0 ) |
| 136 | ++ return( ret ); |
| 137 | ++ |
| 138 | ++ if( ( ctx->fd = (int) socket( AF_INET, SOCK_STREAM, IPPROTO_IP ) ) < 0 ) |
| 139 | ++ return( MBEDTLS_ERR_NET_SOCKET_FAILED ); |
| 140 | ++ |
| 141 | ++ n = 1; |
| 142 | ++ setsockopt( ctx->fd, SOL_SOCKET, SO_REUSEADDR, |
| 143 | ++ (const char *) &n, sizeof( n ) ); |
| 144 | ++ |
| 145 | ++ server_addr.sin_addr.s_addr = htonl( INADDR_ANY ); |
| 146 | ++ server_addr.sin_family = AF_INET; |
| 147 | ++ server_addr.sin_port = htons( atoi(port) ); |
| 148 | ++ |
| 149 | ++ if( bind_ip != NULL ) |
| 150 | ++ { |
| 151 | ++ memset( c, 0, sizeof( c ) ); |
| 152 | ++ sscanf( bind_ip, "%d.%d.%d.%d", &c[0], &c[1], &c[2], &c[3] ); |
| 153 | ++ |
| 154 | ++ for( n = 0; n < 4; n++ ) |
| 155 | ++ if( c[n] < 0 || c[n] > 255 ) |
| 156 | ++ break; |
| 157 | ++ |
| 158 | ++ if( n == 4 ) |
| 159 | ++ server_addr.sin_addr.s_addr = htonl( |
| 160 | ++ ( (uint32_t) c[0] << 24 ) | |
| 161 | ++ ( (uint32_t) c[1] << 16 ) | |
| 162 | ++ ( (uint32_t) c[2] << 8 ) | |
| 163 | ++ ( (uint32_t) c[3] ) ); |
| 164 | ++ } |
| 165 | ++ |
| 166 | ++ if( bind( ctx->fd, (struct sockaddr *) &server_addr, |
| 167 | ++ sizeof( server_addr ) ) < 0 ) |
| 168 | ++ { |
| 169 | ++ close( ctx->fd ); |
| 170 | ++ return( MBEDTLS_ERR_NET_BIND_FAILED ); |
| 171 | ++ } |
| 172 | ++ |
| 173 | ++ if( listen( ctx->fd, MBEDTLS_NET_LISTEN_BACKLOG ) != 0 ) |
| 174 | ++ { |
| 175 | ++ close( ctx->fd ); |
| 176 | ++ return( MBEDTLS_ERR_NET_LISTEN_FAILED ); |
| 177 | ++ } |
| 178 | ++ |
| 179 | ++ return( 0 ); |
| 180 | + } |
| 181 | + |
| 182 | + #if (defined(_WIN32) || defined(_WIN32_WCE)) && !defined(EFIX64) && \ |
| 183 | +@@ -389,7 +478,7 @@ |
| 184 | + n = sizeof(struct sockaddr_storage); |
| 185 | + if (getsockname(client_ctx->fd, |
| 186 | + (struct sockaddr *) &local_addr, &n) != 0 || |
| 187 | +- (bind_ctx->fd = (int) socket(local_addr.ss_family, |
| 188 | ++ (bind_ctx->fd = (int) socket(local_addr.sin_family, |
| 189 | + SOCK_DGRAM, IPPROTO_UDP)) < 0 || |
| 190 | + setsockopt(bind_ctx->fd, SOL_SOCKET, SO_REUSEADDR, |
| 191 | + (const char *) &one, sizeof(one)) != 0) { |
| 192 | +@@ -402,7 +491,7 @@ |
| 193 | + } |
| 194 | + |
| 195 | + if (client_ip != NULL) { |
| 196 | +- if (client_addr.ss_family == AF_INET) { |
| 197 | ++ if (client_addr.sin_family == AF_INET) { |
| 198 | + struct sockaddr_in *addr4 = (struct sockaddr_in *) &client_addr; |
| 199 | + *cip_len = sizeof(addr4->sin_addr.s_addr); |
| 200 | + |
| 201 | +@@ -411,6 +500,7 @@ |
| 202 | + } |
| 203 | + |
| 204 | + memcpy(client_ip, &addr4->sin_addr.s_addr, *cip_len); |
| 205 | ++#if 0 |
| 206 | + } else { |
| 207 | + struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *) &client_addr; |
| 208 | + *cip_len = sizeof(addr6->sin6_addr.s6_addr); |
| 209 | +@@ -420,6 +510,7 @@ |
| 210 | + } |
| 211 | + |
| 212 | + memcpy(client_ip, &addr6->sin6_addr.s6_addr, *cip_len); |
| 213 | ++#endif |
| 214 | + } |
| 215 | + } |
| 216 | + |
| 217 | +diff -Nru mbedtls-2.28.10-orig/library/ps3-build.sh mbedtls-2.28.10/library/ps3-build.sh |
| 218 | +--- mbedtls-2.28.10-orig/library/ps3-build.sh 1969-12-31 21:00:00 |
| 219 | ++++ mbedtls-2.28.10/library/ps3-build.sh 2026-04-25 20:45:12 |
| 220 | +@@ -0,0 +1,20 @@ |
| 221 | ++#!/bin/sh -e |
| 222 | ++ |
| 223 | ++echo "Please stand by..." |
| 224 | ++ |
| 225 | ++export PS3DEV=$PSL1GHT |
| 226 | ++export CC=$PS3DEV/ppu/bin/powerpc64-ps3-elf-gcc |
| 227 | ++export LD=$PS3DEV/ppu/bin/powerpc64-ps3-elf-ld |
| 228 | ++export CPP=$PS3DEV/ppu/bin/powerpc64-ps3-elf-cpp |
| 229 | ++export CXX=$PS3DEV/ppu/bin/powerpc64-ps3-elf-g++ |
| 230 | ++export AR=$PS3DEV/ppu/bin/powerpc64-ps3-elf-ar |
| 231 | ++export AS=$PS3DEV/ppu/bin/powerpc64-ps3-elf-as |
| 232 | ++export NM=$PS3DEV/ppu/bin/powerpc64-ps3-elf-nm |
| 233 | ++export CXXCPP=$PS3DEV/ppu/bin/powerpc64-ps3-elf-cpp |
| 234 | ++export RANLIB=$PS3DEV/ppu/bin/powerpc64-ps3-elf-ranlib |
| 235 | ++export LDFLAGS="-L$PS3DEV/ppu/powerpc64-ps3-elf/lib -L$PSL1GHT/ppu/lib -L$PS3DEV/portlibs/ppu/lib -lrt -llv2" |
| 236 | ++export CFLAGS="-I../include -I$PS3DEV/ppu/powerpc64-ps3-elf/include -I$PSL1GHT/ppu/include -I$PS3DEV/portlibs/ppu/include -mcpu=cell" |
| 237 | ++ |
| 238 | ++echo "Build library..." |
| 239 | ++## Compile and install. |
| 240 | ++${MAKE:-make} |
| 241 | +diff -Nru mbedtls-2.28.10-orig/library/timing.c mbedtls-2.28.10/library/timing.c |
| 242 | +--- mbedtls-2.28.10-orig/library/timing.c 2025-03-24 08:49:00 |
| 243 | ++++ mbedtls-2.28.10/library/timing.c 2026-04-25 20:02:39 |
| 244 | +@@ -19,7 +19,7 @@ |
| 245 | + |
| 246 | + #if !defined(unix) && !defined(__unix__) && !defined(__unix) && \ |
| 247 | + !defined(__APPLE__) && !defined(_WIN32) && !defined(__QNXNTO__) && \ |
| 248 | +- !defined(__HAIKU__) && !defined(__midipix__) |
| 249 | ++ !defined(__HAIKU__) && !defined(__midipix__) && !defined(__PPU__) |
| 250 | + #error "This module only works on Unix and Windows, see MBEDTLS_TIMING_C in config.h" |
| 251 | + #endif |
| 252 | + |
| 253 | +@@ -298,7 +298,7 @@ |
| 254 | + { |
| 255 | + mbedtls_timing_alarmed = 0; |
| 256 | + signal(SIGALRM, sighandler); |
| 257 | +- alarm(seconds); |
| 258 | ++// alarm(seconds); |
| 259 | + if (seconds == 0) { |
| 260 | + /* alarm(0) cancelled any previous pending alarm, but the |
| 261 | + handler won't fire, so raise the flag straight away. */ |
0 commit comments