SecureSockets Bounty
Malcolm Hussain-Gambles (1596) 811 posts |
I think the first step would be to define what the bounty is. For example what I have in mind does not necessarily fit what other people have in mind and far exceeds the scope of just SSL/TLS |
Rick Murray (539) 13840 posts |
SSH as both client and server would be good; as would be the ability to work with server fingerprinting (akin to PuTTY) instead of the current SSL setup of (mostly) blindly trusting third party certificates. |
Malcolm Hussain-Gambles (1596) 811 posts |
Unfortunately SSH and SSL are quite different. But I would agree we need to use CACertificates, it’s a fundamental part of SSL. |
Rick Murray (539) 13840 posts |
Following on from SSH would be SFTP… All the plain unencrypted protocols just don’t cut it these days1. 1 By way of example, I can only access my website using WinSCP as it is SFTP with a freakishly long line-noise style password, and then secondary authentication using a key pair known only to the server and my machine. Paranoid? Maybe. But spend long enough reading The Register, you come to understand that security measures are important. |
David Feugey (2125) 2709 posts |
You have Putty on RISC OS? I’m agree, that a SecureSockets Bounty should just address the SSL problem, both as server or client. |
Malcolm Hussain-Gambles (1596) 811 posts |
You should be able to use sftp and ssh using the openssh package in packman. Start Rant…so ignore if you wish! |
David Feugey (2125) 2709 posts |
IMHO, it’s not really a good idea to multiply entry points. I use sftp server from ssh for the main account, and restricts the others to ‘sftp only + root = userdir’.
Yeah, that’s a pity, since it would be very fun to convert HTTP services to RISC OS applications. Oh, wait, that’s exactly what 80% of Android apps do :) |
Matthew Phillips (473) 721 posts |
There is a nice set of modules which were part of Acorn’s Browse called URL and AcornHTTP which simplify HTTP fetching. But there is currently no HTTPS equivalent. We use the AcornHTTP module in RiscOSM — with HTTPS supported we could add one or two more nice features. So I would support a bounty that got SecureSockets updated and also introduced an HTTPS equivalent of AcornHTTP. I think Justin Fletcher did this for ROL using the curl library: I read it in one of his rambles. |
Malcolm Hussain-Gambles (1596) 811 posts |
My aims would be to have a pluggable module library. For me, implementing any of these individually is relatively easy. The big problem comes when you have to integrate it into something. |
Rick Murray (539) 13840 posts |
Okay, can somebody confirm something for me. I know that SMTP, POP and HTTP are basically simplified telnet-like1 data exchanges because I have performed both manually from a terminal by connecting to the intended port and issuing the relevant commands. Is SSH, HTTPS, encrypted POP, IMAP, etc basically the same thing with the addition of an encrypted channel in between? In other words, if I had an SSL module I could open my socket to the https port and then start up the SSL stuff, then issue the exact same commands as I would on HTTP? I am asking this because what concerns me about the post is that the idea says There is a lot more than http(s) to support. (imap/pop/nntp/ftp) and I can’t help but wonder if a “secure socket” service should concentrate purely on doing that, and not getting involved in the specifics of any particular protocol unless such involvement is unavoidable.
Would be nice to have a built in wget (or a simplified version, at least) but this should be a separate thing and not part of the base networking protocols.
I’m not familiar with Jabber, but something that concerns me is that RISC OS does lack sensible debugging tools that work in a complex multitasking environment where one doesn’t have the luxury of freezing the entire machine in order to examine something. 1 Telnet LIKE in that it is an exchange of (usually) readable information in a predefined form; there are plenty of guides of how to access a POP3 server using a terminal… |
Malcolm Hussain-Gambles (1596) 811 posts |
SSH is completely different to the others. My point was not that we should support ALL protocols etc. just that we should bear it in mind, so protocols can be added. The first thing for me is to support SSL/TLS as this is the most crucial to ALL methods. I’ve managed to get aes.o created – small steps, but it’s nice to see! I’ll provide a link to what I’ve done once I can at least get the library compiling. |
Malcolm Hussain-Gambles (1596) 811 posts |
If anyone is interested my “interesting” makefile and my attempts so far is at: https://www.paymentlabs.com/mbedtls_r.zip I’ve managed to get most of the libraries compiled. Looks like there are some includes required that I’ve missed for types.h and others. Got to say it’s looking very promising at getting at least the ability to use the library on RISC OS fairly soon. I should really bother to read up on Makefiles, it would save me a lot of effort. |
Theo Markettos (89) 919 posts |
I’m on a train with patchy wifi so I can’t look at your archive, but mbedtls was pretty painless to crosscompile for me – it’s in the autobuilder here. I do agree it’s a much more sane way forward than OpenSSL. To revise what I said previously, after a discussion on the GCCSDK list it turns out that using shared libraries from supervisor mode is somewhat tricky. So if we want to implement the SecureSockets API, reluctantly we’re looking at running mbedTLS in supervisor mode as a module. Ideally application level programs (C at least) would use the shared library rather than the module, for the added security and reliability that provides. It would also be good to gain a way to do that from BASIC (there may be trickiness here too). In terms of the SecureSockets API, the bits that require work are:
Having a module that’s easily updatable fixes one of the vulnerabilities, that of the code being ancient. It still means the code runs with all the privileges in the world, but the RISC OS API is already fundamentally broken in that respect, so it won’t be easily fixed. |
Malcolm Hussain-Gambles (1596) 811 posts |
From mine and a Norcroft/DDE perspective: I’ve not yet looked at the code, so this is just a guess at this point – but I think a reasonable one. As regards this thread, I’m going to duck out. Not sure how using shared libraries provides any more security or reliability – on the whole for RISC OS I’d say less on both counts personally – but hey! If anyone is interested in helping me out though, I’d be more than grateful. |
Jeffrey Lee (213) 6048 posts |
The Internet event is your friend. For code running as a module you basically want to enable event generation for the event, claim EventV, and then whenever “something interesting” happens to the socket (RX data arrived, TX space available, error) you’ll receive a call for that socket. Within the event handler you then register a callback so that you can process the data as soon as the OS returns to the foreground (although it may be possible to directly interact with the socket from within the event handler in some cases – I’m not sure what the rules are) I recently implemented support for this in vncserver in order to improve the TX throughput, so you could take a look at that for a simple example (sockevent.c/.h and the EventV handler in mcode.s) |
Richard Walker (2090) 431 posts |
I would have thought that the huge benefit of using GCSSDK and the autobulder, coupled with shared libraries, is that we would be more like to get timely fixes which ‘just work’ in all applications. If each person does their own thing, through static linking and/or heavily modified bespoke library builds, then we risk delays and inconsistencies. For example, Messenger Pro might have a 3 month old SSL codebase, but Store might be 2 weeks old. |
Malcolm Hussain-Gambles (1596) 811 posts |
Modules are effectively shared libraries. That’s really the point of them |
Rick Murray (539) 13840 posts |
I suspect we may run into issues porting anything complicated from a POSIX style system due to differences in how the operating systems work internally.
If I was going to write something that needed to retrieve data from a socket quickly, I would do the following:
The Wimp part will retrieve data from the DA, independently of the lower level socket reading code. You might ask why I don’t make a module. It isn’t intended to be a module, just a bit of code that can be called regardless of what task is currently running (doesn’t get paged out).
I’ve not looked as I have zero interest in GCCSDK’s shared libraries (doesn’t work with the DDE), however a statement like that would suggest to me that shared library code most likely works in USR mode; unlike every SWI which is entered in SVC mode.
ALL applications?
I think this depends greatly on whether or not the code is open. It’s nice that the SSL module code is available, it’s just a shame it is a decade too late. The important thing for any new implementation is to touch the original source code as little as possible (break rules if need be to leave the original code alone) and document every change made to the original code. Back when these things were young, people actually used 40 bit SSL, and Google didn’t exist, it probably made sense to make an SSL module and, well, that’s that. Now? Now it’s a different game where an outdated bit of encryption software is worse than none at all, to the ability to merge in updated code (to patch flaws) needs to be one of the main design considerations.
Remember that those from a Linux background will be looking at it from the DLL Hell perspective, namely the ability to have lots of independent versions of the ame library, like MehLib 1.5.6.4 for this program and MehLib 1.6.1.1 for that program. Don’t look at me, it it was my ABI, I’d consider MehLib 1.6.x to be broken if it couldn’t work with software expecting MehLib 1.5.x unless there were insurmountable reasons preventing it. I mean, you don’t see the latest CLib baulking at APCS-R software, on platforms capable of running such. |
Malcolm Hussain-Gambles (1596) 811 posts |
I tried the internet event, looks like I misunderstood it’s implementation. That explains the disaster I had. |
Malcolm Hussain-Gambles (1596) 811 posts |
OK, now I’m seriously impressed. I theorised that using the event_handler or IRQ’s would be the best way, no idea you could combine the two! Which seems to be what dark magic you are up too from a quick glance. |
Theo Markettos (89) 919 posts |
Malcolm, If you want to carry on using DDE, don’t let me stop you. I’m happy to help out with the build system side to make sure we have something that can be easily rebuilt using whatever tools (DDE, GCCSDK, Jenkins, whatever). But at this stage it’s more important to have some code that does something useful than worrying about build systems (mbedtls is relatively germane in that respect, so the build system isn’t the barrier that it is in other projects). Your progress so far looks fine. I haven’t looked in the code in great detail but I think that threading will probably become a problem when you try and link – it’s calling pthread functions which aren’t there. UnixLib supports that in user-mode programs using callbacks, but not in modules. SCL has never heard of the concept of threads. Unfortunately a lot of porting existing codebases to RISC OS stumbles on scheduling. Not much pre-existing application code (with the exception perhaps of some very asynchronous Javascript) expects an event-driven/interrupt-driven environment – it expects to be pre-empted. In addition, some crypto such as RSA is slow (can be a second or more), which makes it harder to break up into event-sized chunks (to make this more fun, changing this code is also security critical). It would need some more understanding of the mbedtls source code to work out whether there is a sensible way to run it in a module in an interrupt-driven way. Possibly the pthread interface is enough, but I suspect you’d end up reimplementing your own pthreads to run the rest of the code in user mode out of a module. Which kind of brings us back to the beginning… userland avoids some of these problems, unfortunately the API we already have is a module API. So it looks like we’re stuck with it :( |
Malcolm Hussain-Gambles (1596) 811 posts |
Theo, I’m undecided about the DDE or GCCSDK, I keep on being certain on one then on the other! But thankfully it largely doesn’t matter as you said, the main barriers are getting a scheduler done. I’m just really glad that mbedtls is so portable. One thing I would really like is to have the ability to use other cores for the data processing. Quite a lot of arm hardware has hardware acceleration for AES, a shame that can’t be used or looked at when selecting the “next” arm hardware for RISC OS. Also I’m not so interested in keeping to the current API more defining a new one that allows me to abstract far beyond sockets and ssl. Hence why I think at this point I need to forget about SSL and get the bare bones done. Either way it’s not wasted work. |
Jeffrey Lee (213) 6048 posts |
Module code should be pretty much the same on both compilers. There’ll be some differences due to Norcroft using CMHG for generating the module header code & .h file, while GCC uses cmunge, but the tools should broadly be compatible with one another (cmunge effectively started off as a free clone of CMHG).
TBH that’s probably the best approach in terms of (network) security. Have a microkernel running on another core which provides a nicely sandboxed environment for running the TLS code. If bad data is received over the network then it won’t be able to do a thing to break out of that sandboxed environment.
Citation needed ;-) ARMv8 has AES instructions as an (optional) extension to the instruction set. If you can find an ARMv8 board with support for the crypto extensions then we should be able to use it. if it’s some other AES hardware which is present then using it would obviously be dependent on documentation from the SoC manufacturer. Hence why I think at this point I need to forget about SSL and get the bare bones done. If you’re interested in getting other cores working, you’ll have a bit of an uphill struggle, as there are some features that the OS is lacking (mainly, proper handling of shareable memory). But then again I think it’s possible to get a multi-core taskwindow module working on Pi 2/3 without needing to change the OS sources, so it’s not an insurmountable task to get something multi-core running (ignoring task windows and rolling your own scheduler may even be easier, as then you wouldn’t have to bodge the code into the taskwindow module!). |
Malcolm Hussain-Gambles (1596) 811 posts |
Thanks Jeffrey, appreciate the education. The thought of me using GCC on RISC OS, just seems wrong to me – but being wrong is what I enjoy most in life. I also like toolbox too, so that may show how warped I am? OK, possibly perspective error on my part of “quite a lot” of arm hardware, I’ve used a few that have it – and I’ve only used a few. It was more of a nudge to be honest, so anyone looking at porting to anything new, put’s it on a “nice to have” list. I was more thinking from a multi core perspective (this is at a dumb persons level – i.e. mine) if you could copy a segment of memory to a specific area then say to the other core(s) go do stuff, use this memory. So is it possible to not use shared memory, as long as it’s allocated in the main OS as “in use” so nothing else uses it whilst the other core is “in use” if the cores are locked to a certain memory segment? If not I don’t mind digging around, it’s vaguely interesting – something I should really know about to be honest, at least I’d know more than multi core means more than one core! |
Rick Murray (539) 13840 posts |
In a way it is good that both are working for you.
? I didn’t think his code was bad…?
I have a horrible suspicion you’re going to need a wodge of ARM code for that. While you can, no doubt, set up the memory areas and stuff in C, you will likely need to set up some sort of environment on the other core, which would mean trapping and dealing with the hardware vectors. Quite possibly initialising the MMU and sorting out memory pages. If the other cores are essentially stalled when RISC OS is running, that means there is no kernel, no environment, nothing.
In a way you’re lucky that you are trying out both. My main objection to GCC is I’m too lazy to bother with learning the intricacies of a different toolkit. I have stubbornly resisted all that shared MakeFile rubbish that has turned up in the DDE in preference to hand-built MakeFiles – while the build process is probably simpler, at least I know what is getting built and how. I absolutely detest setups that pull in data from dozens of directories and files. Okay, this may make sense if you’re building something like the Wimp, but for an application it really ought to be as self contained as possible. Then projects can be moved between machines, and potentially different versions of the DDE, with less risk of breakage due to X not being found.
IPv6? ;-)
I know SFA, but I don’t expect that it would be that difficult once the low level code is running. You should be able to assign an area of memory, copy data/code into it, then instruct the other core to run it. I think that was the basic principle behind how the x86 card worked, and there may be some ideas there regarding how to handle “other cores”. However as Jeffrey points out, RISC OS isn’t really set up for such a thing, despite Acorn machines supporting (possibly alien) coprocessors since long before the concept was even understood on home micros (and networking, and proper I/O, and…). This said, I think before any of this begins, we ought to have a protocol devised for the claim/use/release of any additional cores. You want to use core(s) for the socket stuff. Jeffrey has mentioned the TaskWindow doing so. We may arrive at a day when the Wimp itself is able to spread tasks among the available cores. Well, how does any of this know if a core is in use or is available? We need some sort of protocol, even if it piggybacks on the Device Claim, to prevent this becoming a free for all.
There is a lot of hardware acceleration in many ARM based SoCs. My little PVR chip has hardware Huffman tables, hardware bright/contrast/focus, hardware realtime scaling, a powerful DSP, and some other stuff I forget. I have no doubt that there are many good things lurking within the Pi silicon, perhaps as co-processors, perhaps as things located in the memory map.
Well, there would be some interesting experiments to do with a module that could schedule pieces of code to run on a co-processor (other core). There is also lots of fun involved in writing a decent schedular. Have you read the MINIX book? It talks about these sorts of things in detail (though not multicore, I think it predates that sort of technology), so it’s worth a look if you can find a copy (the one linked is one Google found on somebody’s Google Drive, it’s a ~9MiB PDF).
Smoothly is one thing, but your idea may hit obstacles if it isn’t able to sensibly degrade to something that will run (even if less effectively) on a single core machine. How do you define “old”?
If you’re writing most of this yourself, either toolchain ought to work. ;-) |