wanderingjew
Well-known member
I have successfully compiled MbedTLS (or PolarSSL) for the classic Mac environment using Codewarrior Pro 4 on a machine running OS 8.6.
That's the clickbait. It doesn't _work_, oh no. I've been trying to connect to my server via HTTPS for a few weeks now, and I'm really, really tired of this project. I didn't think I would need to port the _entire_ MbedTLS library to make this thing work, but here I am.
The original idea for this was to build a 'client' of sorts for https://640by480.com/, a weird little 'instagram for digital cameras' thing I have. With the client you'd be able to login, upload photos, view pics, leave comments... basically instagram for the first digital camera. Except it'll run on a quadra or something. This of course means I need an SSL implementation to work with the API. So I started on this little project of trying to pull data into a text box from the API.
Mbedtls was written for C99 compilers, but my version of CodeWarrior only supports C89/C90. The transition required significant code modifications:
The biggest problem? C89 doesn’t support variadic macros or method overloading. 64-bit ints are completely unknown on this platform Holy hell this is annoying as shit. The mbedtls library uses 64-bit data types. int64_t, uint64_t, and the like. My compiler doesn’t know what those are. So I need to create them. Out of fucking thin air and structs, I guess. I made a shim library that does all of the 64-bit arithmetic, but that also means I need to port the code, and there's a lot of 64-bit math in the crypto libraries.
I’ve discovered a great plot hole in an Asimov short story. If you’re wondering how can the net amount of entropy of the universe be massively decreased, the answer isn’t to use a computer trillions of years in the future, the answer is to use a computer built thirty years ago.
The classic Mac OS has very little entropy, something required for high-quality randomness. This meant my SSL implementation gave the error code MBEDTLS_ERR_ENTROPY_SOURCE_FAILED. I created a custom entropy collection system that draws from multiple sources:
CURRENT STATUS:
Right now the current state of this port is that portions of MbedTLS compile (not everything, it's just a minimal system), and I SHOULD be getting data from my server, but all I get is SSL handshake failures. Yes, I've tried to reconfigure my server to work with the ciphersuites I have. It didn't work.
I'm putting all of my work up in a Github for people to look at. I'm pretty burnt out on this project, and I would have loved to pull data over HTTPS for #Marchintosh, but... yeah this sucks. I'm not against picking it up again and making it work, but I think I need a few more eyes on this. I know @cy384 has done similar work, but with cross-compilation under Retro68, whereas I'm going for a full native compile.
So if you're interested, take a look LOOK AT THE GITHUB: https://github.com/bbenchoff/Milipixel-App THERE'S A .SIT FILE IN THERE SO GO NUTS
I'm a weird state of burnt out but still want to get this done so I encourage you to ask questions about this. Yes, it's TLS1.3, so wow, amazeballs.

That's the clickbait. It doesn't _work_, oh no. I've been trying to connect to my server via HTTPS for a few weeks now, and I'm really, really tired of this project. I didn't think I would need to port the _entire_ MbedTLS library to make this thing work, but here I am.
The original idea for this was to build a 'client' of sorts for https://640by480.com/, a weird little 'instagram for digital cameras' thing I have. With the client you'd be able to login, upload photos, view pics, leave comments... basically instagram for the first digital camera. Except it'll run on a quadra or something. This of course means I need an SSL implementation to work with the API. So I started on this little project of trying to pull data into a text box from the API.
Mbedtls was written for C99 compilers, but my version of CodeWarrior only supports C89/C90. The transition required significant code modifications:
- Creating compatibility layers for modern C integer types
- Implementing 64-bit integer emulation
- Restructuring code to declare variables at block beginnings (C89 requirement)
- Addressing include path limitations in Mac’s un-*NIX-like file system
The biggest problem? C89 doesn’t support variadic macros or method overloading. 64-bit ints are completely unknown on this platform Holy hell this is annoying as shit. The mbedtls library uses 64-bit data types. int64_t, uint64_t, and the like. My compiler doesn’t know what those are. So I need to create them. Out of fucking thin air and structs, I guess. I made a shim library that does all of the 64-bit arithmetic, but that also means I need to port the code, and there's a lot of 64-bit math in the crypto libraries.
I’ve discovered a great plot hole in an Asimov short story. If you’re wondering how can the net amount of entropy of the universe be massively decreased, the answer isn’t to use a computer trillions of years in the future, the answer is to use a computer built thirty years ago.
The classic Mac OS has very little entropy, something required for high-quality randomness. This meant my SSL implementation gave the error code MBEDTLS_ERR_ENTROPY_SOURCE_FAILED. I created a custom entropy collection system that draws from multiple sources:
- System clock and tick counts at microsecond resolution
- Mouse movement tracking
- Memory states and allocation patterns
- Hardware timing variations
- Network packet timing with OTGetTimeStamp()
- TCP sequence numbers and connection statistics
- Time delays between user interactions
- The amount of time it takes for the screensaver to activate
CURRENT STATUS:
Right now the current state of this port is that portions of MbedTLS compile (not everything, it's just a minimal system), and I SHOULD be getting data from my server, but all I get is SSL handshake failures. Yes, I've tried to reconfigure my server to work with the ciphersuites I have. It didn't work.
I'm putting all of my work up in a Github for people to look at. I'm pretty burnt out on this project, and I would have loved to pull data over HTTPS for #Marchintosh, but... yeah this sucks. I'm not against picking it up again and making it work, but I think I need a few more eyes on this. I know @cy384 has done similar work, but with cross-compilation under Retro68, whereas I'm going for a full native compile.
So if you're interested, take a look LOOK AT THE GITHUB: https://github.com/bbenchoff/Milipixel-App THERE'S A .SIT FILE IN THERE SO GO NUTS
I'm a weird state of burnt out but still want to get this done so I encourage you to ask questions about this. Yes, it's TLS1.3, so wow, amazeballs.