start	end	text
0	8820	I'm going to go ahead without you necessarily seeing my smiling face, but it is indeed, well, except for technical difficulties, it's otherwise smiling.
9260	14020	So, hello and welcome to Saturday at Hack to C.
14720	23060	So let me get around to my PowerPoint presentation here. And let me just basically go through this and I've got some other things to show you.
23160	28840	So, I'm going to talk today about some work that I'm doing on something called Protected AIS.
28840	38620	And I'll just quickly give you a little bit of an overview of what I'm working on and what the problem is and what quasi-solution I worked on.
38840	45880	So, automatic identification system is the system used by vessels at sea for situational awareness.
45980	56020	We'll see some examples of this coming up in a minute. But obviously, this is the way ships let each other know where they are and what kind of ship they are and those kind of things.
56020	65240	And as we've discussed, and certainly part of the talk yesterday, and you may know from other sources, AIS suffers from a number of security vulnerabilities.
65780	76100	And so, because of those vulnerabilities, it makes it prone to some spoofing type attacks, replay type attacks, and things like that.
76100	80020	And so, basically, a bad guy can send bogus messages.
80020	89200	So, I came up with a proof of concept that uses some public key cryptography methods and provides something that I call Protected AIS.
89200	106280	And it addresses some of the vulnerabilities, but one of the keys that I also wanted to be able to employ was that whatever solution I designed needed to be backward compatible with the existing protocols, or else it really wouldn't be very much of a demonstration capability.
107030	110260	So, here are acronyms and abbreviations.
110620	117660	So, again, for those of you who didn't sit in yesterday, a quick two-minute overview.
117660	130160	AIS, as I said, it's a situational awareness system used between vessels and ground stations so that vessel traffic management systems know where vessels are that are in their area of responsibility.
130340	133880	Maritime administrations know about vessels in their AOR.
134440	136540	Ports can keep track, things like that.
136540	144000	But also, equally, and possibly even more importantly, vessels can keep track of other vessels with whom they are in proximity.
144040	161880	And they can get some idea from those other vessels what type of vessel they're looking at, possibly information about their cargo, the size of the vessel, speed, course, bearing, rate of turn, current position, destination, all that kind of stuff.
161880	171160	And there are a class of vessels, mostly big ones, that are required to transmit AIS information.
171600	182360	And for the work that I'm doing, this is important because there's two different types of AIS position information broadcasts, Class A and Class B.
182420	189520	The vessels listed here, the big vessels, are the ones that are required to transmit Class A.
189520	194940	And Class A really gives more information than Class B.
194940	200100	Actually, for some of the work I was doing, I needed to know stuff like rate of turn, and Class B didn't say that.
200100	204780	But Class A and Class B gives me sufficient information about vessels.
205280	214700	Warships are exempted from being required to use AIS, so warships can transmit AIS, but they are not required to.
216060	225000	So here's an example of an ECTIS display. I'm going to try, actually, another display. Let's hope I have the right screen up. I don't.
225640	234960	This is a display coming from the feed that I have at Emory Riddle Aeronautical University in Daytona Beach.
234960	246200	And so you can see right now, here's the university, we can see right now about 10 vessels. A second ago, we could see 11.
246220	252740	Anyway, and the furthest vessel we can see is only actually about 14 kilometers away.
252740	258620	But if I mouse over, it tells me, well, it tells me that there's that vessel there.
258620	266220	But if I click on it, I can actually get a lot more information.
266560	274700	So this is a Pleasurecraft. You can see it's only about a 33 footer. Right now, it's offshore, a little bit in Daytona.
274700	284120	But you can get an idea of where it's located, when we last saw it, course, heading, speed, latitude and longitude.
284120	290800	Tells us that last saw us a minute ago. And we're getting everything here from terrestrial AIS as opposed to satellite.
292920	304420	And the name of this boat is Fishizzle. So anyway, here's the other vessel I was seeing that for some reason just disappeared for a moment.
308000	311060	Give it a second. You know, it'll come up, hopefully.
311720	315340	OK, this is something called the Janus. This is a sailing vessel, sailboat.
316560	322780	And again, you know, we can get additional information. Note in this case, we can find out it's from Fort Lauderdale.
323180	330420	They may not have programmed in what their destination is, but sometimes, you know, we will get that information as well.
330420	343320	And then I spent a lot of time the last day talking to you about OpenCPN. And OpenCPN, again, here's the Fishizzle.
343320	348580	That other boat may be right around in here. I've been losing boats underneath that marker.
351600	354420	Let me just go back here. OK.
357360	361480	Anyway, so like I said, this is an example of what you see in an ECDIS display.
361540	368740	There are a variety of other applications you can use. This is FindShip. It's a mobile app that I have on my phone.
368760	375000	I'm getting AIS information from here as well. I can use a web browser application.
375000	386260	This is again from FindShip. And, you know, again, you look up a boat by name or MMSI or IMO number and you can, you know, find out where they are.
387740	396280	Now, the AIS communication protocol largely, it's defined in a couple of international telecommunication union recommendations.
396280	403520	And generally for radio, it employs this self-organized time division multiple access scheme.
404320	414100	And so basically each vessel is finding its slot and is transmitting during its slot times, pretty short.
414820	425620	And during its slot transmissions, it can also reserve other slots that it wants to use that are presumably haven't already been reserved by other boats.
427740	435960	Now, I told you that, again, just to give a real brief high level overview of what matters for AIS as far as my little project here is concerned.
436640	446940	The other thing that my project obviously needed was encryption. And so here, you know, real quick, we have three different types of crypto functions.
446980	452900	And I'm classifying them in a pretty standard way based upon the number of keys that they use.
452900	460520	So a hash function doesn't really have a key. It's one way encryption and it's used for message integrity.
460900	465260	And secret key cryptography uses a single key for both encryption and decryption.
465480	470900	And we largely use secret key crypto for privacy and confidentiality.
470960	477620	The stuff that I'm working on, I have no desire to keep private or confidential, so I don't even really use any secret key crypto.
477620	485680	And then public key crypto, which is really the most interesting out of this. We've got two keys.
485680	490400	One key is used for encryption. The other key is used for decryption.
490700	500960	And the keys are mathematically related. But, of course, knowledge of one key doesn't yield knowledge of another key.
500960	512060	So, therefore, what we can do is we can keep one key a secret, but, you know, my own personal secret, my private key.
512060	515200	And then the other key I can put out there for the rest of the world to use.
516220	524020	Public key crypto generally used for authentication as well as non-repudiation and secret key exchange.
524320	529760	For purposes of my work, all I really care about is message integrity and sender authentication.
529760	535860	So we'll see a little bit more with hashes or something like that and a little bit more with public key crypto.
537200	544100	So, again, hash functions and checksums, for that matter, cyclic redundancy checks, you know, do the same thing.
544140	551580	Basically, these are just mathematical formulas that provide you with the digital fingerprint, if you will, of any sort of binary string.
551580	562460	It can be a message, a file, a frame, frame in the terms of, you know, like a data link layer transmission, a message packet segment, whatever you whatever you want to call it.
562460	581880	The cool part about hash functions and, again, checksums as well, is that a particularly sized checksum, like a CRC16 or an MD5, is going to give you the same size hash value or checksum value, regardless of the size of the input.
582020	588700	So if you're using MD5, you're going to get a 128-bit output. Use a CRC16, you're going to get a 16-bit output.
589610	604060	The value of your checksum or your hash makes it impossible to determine what was the length of the original message and certainly makes it impossible to figure out the contents of the original message.
604060	607940	So that's, of course, why they always call these things one-way encryption.
608840	613280	Now, public key crypto, of course, is a tad more complicated.
613280	619240	But as I suggested before, I can keep one of the keys, my own closely held secret.
619240	623460	So, again, that's my private key. The other key I can post anywhere I want.
623460	628700	So, for example, on my website, I have posted my public GPG key.
628960	631780	I also have it posted at multiple key servers.
632630	640080	And so the idea is this. If I've got two parties to a communication, Alice and Bob, we always have Alice and Bob.
640420	652520	If Alice uses Bob's public key to encrypt a message and send it to Bob, Bob presumably is the only one that can decrypt the message by using his own private key.
652520	656240	So that's one way of having secure communication from Alice to Bob.
656240	666280	Now, if Alice encrypts a message with her own private key, anybody who can get to her public key could decrypt it.
666280	671200	But what that does is it proves that Alice is the only one who could have sent it.
671680	682640	So, despite the little typo that I have here, that method can be used to authenticate Alice as the sender.
682640	689240	And if you like pictures, I know these look like Lois and Clark, but that's supposed to be Alice and Bob.
689240	697360	So, presumably, everybody has their own private keychain. And in their private keychain, they have their private keys.
697560	704300	Now, they can also have a public keychain, and there may be a shared database of public keychains.
704300	707160	And that's really the direction I want to go in.
707260	711380	But again, this page sort of replicates what I said on the previous page.
711380	720520	If Alice sends a message encrypted with her own private key, Bob can decrypt it using her public key, and he can get the public key from the database.
720520	722980	And again, that authenticates Alice as the sender.
723040	733580	If she wants to send a message to Bob, she can use that same database to get Bob's public key, send it to Bob, Bob's the only one who can decrypt it.
733580	737940	And again, that's where I get my private... that's one way of getting privacy.
737940	745360	Although, typically, we don't use public key cryptography for, you know, that kind of communication.
747280	751160	Now, I told you all of that so I can tell you this.
751160	752820	Here's my problem statement.
753080	758060	AIS, as we've described before, has a number of security weaknesses.
758160	762820	One of them is there's no geographic validity check for the sender.
763560	767760	There is no timing check on when the message was sent.
767940	771720	There's no authentication of who the sender actually was.
771720	774840	And there's no message integrity check.
774840	781500	So, in fact, there's no way to prove that the message that you received is the message that I sent.
781600	784760	Now, there are a number of issues that this brings up.
784900	790660	Obviously, I can spoof messages, make bogus vessels if I want.
790660	794860	I showed an example yesterday of making virtual ATONs that were bogus.
794860	800680	I can also send out false SOS messages via AIS.
800680	807580	I can send out closest point of approach messages that are fake, fake weather reports, all that kind of stuff.
808580	815580	So, this page is also another way of looking at this.
815580	827800	This is all the message pathways from vessel to vessel or to AIS gateways, vessel traffic management, that kind of stuff.
827800	835420	And the two hooded fellows there on the chart are supposed to represent bad guys.
835420	838080	And this is merely showing different attack vectors.
838480	849420	So, if you're attacking a vessel or, in some cases, some of the land shore facilities as well, you can do this via radio.
849740	857960	In some cases, you can also attack the system using software-based threats just via the Internet.
858640	862960	And actually, for my purposes, it doesn't really matter what your vector is.
866720	876370	The National Marine Electronics Association, NMEA, is one of the organizations that standardizes what these messages look like
876370	884730	and is certainly the go-to place internationally for connecting devices to each other on board vessels.
885010	892550	A lot of the NMEA work has gone forward as an international organization for standardization ISO work.
892550	907770	But in any case, the NMEA 0183 specification, which has been around now for about 35 years, is probably the most commonly used over the air because that's what the ITU is using.
908230	914930	There is, of course, a significant embedded base of 183 equipment, particularly on large ships.
914930	922830	And there are newer standards, NMEA 2000 and OneNet, which is coming out sometime this year.
923050	928890	Right now, they're not used so much over the air. They're used within a vessel.
929450	940570	And NMEA 2000 actually is used quite a lot on recreational vessels or personally owned vessels, much more than it is in the commercial world.
942570	953610	Now, I told you all of that so I could show you... I want to show you what an AIS message actually looks like, because that's important to the protocol work that I did.
954590	957570	And again, if I go back here to OpenCPN...
959050	968790	So, oh, this is an interesting... there's Fishizzle again. I'm going to go right here because, unfortunately, it's a Class B, so it's not telling me my rate of turn.
968790	979210	But you can see here, this is its course, 172. Its head... actually, I'm sorry, its course is 172. Its heading is 217 degrees.
979670	987490	I mean, I would be very interested in knowing its rate of turn right now, particularly since it's been a couple minutes since we heard from them.
987850	994890	But in any case, if I go up here and I show my NMEA debug window...
996830	1000990	I can see the messages that are coming out over the air.
1005290	1009410	And actually, I normally can. I'm not sure why I am not now.
1010830	1014490	Well, again, the hazards of doing a live demonstration.
1015030	1018170	Okay, we'll come back. We'll have some data in here later, I hope.
1018170	1023610	But in any case, this is what the messages look like.
1023610	1027270	So let me try to interpret a little bit what you're looking at here.
1027710	1035790	So a 0183 AIS sentence has, for purposes of my discussions, it has a header.
1035790	1043350	And in the header, there is a prefix. There is an identifier of what type of device you are looking at.
1043350	1050270	And then there's some sequencing information, if it's AIS, and a channel number, so you know what channel the transmission is on.
1050270	1056470	Then you have the content. The content in AIS, it's called an encapsulated payload.
1057110	1060290	And we'll talk a little bit about that. And then there's a trailer.
1060290	1067670	And the trailer mainly has information telling me how many padding bits am I going to have to make sure that I have six bit alignment.
1067690	1073670	And what is the checksum for this particular transmission?
1073670	1078090	Not the message as a whole, but the individual transmission.
1078090	1082790	And the padding bits and the checksum just covers the content area.
1082870	1089790	So put another way, here is a standard AIS message.
1089790	1099590	So, for example, the exclamation point at the beginning says this is an NMEA formatted message and it has special encapsulation.
1099590	1105930	So, for example, if you look at a GPS message, GPS messages start, I think, with a dollar sign.
1106630	1112430	That just indicates, yeah, this is an NMEA formatted message, but there's nothing special about the format.
1112430	1116650	You can basically just read everything. You don't have to translate it to a different format.
1117370	1124250	The next field, the AIVDM, identifies the talker ID. That's the device.
1124250	1132010	In this case, AI means AIS. And then the encapsulation format is identified in the next three characters.
1132010	1140090	That's the VDM. In this case, VDM stands for VHF data link message. That means it's a message coming from another source.
1141250	1147310	Now, the transmission that I'm showing you here is referred to as a sentence.
1147890	1156430	A message may be composed or will be composed of one or more sentences, usually never more than five sentences.
1156430	1165910	But in any case, the first number here tells me how many sentences are required to fully compose this message.
1165910	1174010	In this case, there's only one sentence. The next number is the sentence or the fragment number of the message.
1174010	1178910	Now, in this case, there's only one sentence, so this is going to be sentence number one.
1178910	1186310	But as you can imagine, if the number of sentences, say, were three, well, then I'm going to have a sentence number one, two, and three.
1186370	1198610	But how do I reassemble that? Well, that's the next field, which is usually null when you only have a one-sentence message, but it's a serial number.
1198790	1204430	So you could use pretty much any number you want here. This provides for the reassembly of the fragments.
1204430	1211670	So if I had that message I just mentioned, you know, a three-sentence message, let's say it's got serial number seven,
1211670	1216810	I would have something here that would be a 317-327-337.
1217330	1225330	The next identifier is going to be an A or a B. It tells me which channel number, which frequency I'm using for AIS.
1225550	1230790	Then I actually have the content. I'm not going to get into what the encapsulated payload looks like,
1230790	1235310	but it's in something called Armored ASCII and everything's put into six-bit bytes.
1236870	1247170	Then I have a number telling me what is the number of padding bits that I need to add to get six-bit alignment for my content.
1247490	1252170	And then lastly, I have a checksum. The checksum is actually a pretty naive checksum.
1252170	1257570	It basically is nothing more than an exclusive OR of everything in the content field.
1259710	1265490	Now, I told you that so I can tell you this. Some of the tools that I've mentioned,
1265490	1273770	one of the tools I have allows me to create any, pretty much, AIS message I want.
1273770	1279790	I can create most messages. There are some message types I actually just have not built in yet,
1279790	1284630	largely because they're not commonly used and largely because I just haven't added them yet.
1284630	1291330	But if I go around here, so here's this menu program that I have.
1291750	1296170	So, for example, let's say I want to create a type one message.
1296170	1300930	A type one message, as you can see there, is a position report, class A position report.
1300930	1308530	So there we go. It wants to know the talker ID. I can choose all sorts of different talker IDs.
1309230	1314570	And in this case, I'm just going to accept the defaults because I want an AIVDM message.
1315230	1320930	And then I need to have an MMSI. That's the Maritime Mobile Service Identifier.
1321310	1329070	And actually, for purposes of what I'm doing, you can choose any nine digit number you want.
1329150	1333570	For the protected part, you have to choose ones for which there are key pairs.
1334210	1345590	And I'm just going to take all the defaults here, with the exception of when I get to my latitude and longitude.
1345950	1351270	My latitude, I'm going to put it 29.1 because I wanted to match the example in the book.
1351590	1356410	The longitude is minus eight zero, zero eight zero.
1356410	1361250	This is actually off the coast of Daytona Beach. I'm not going to use protected mode for this.
1361770	1366090	And I'm just going to let this go out channel A. And I get a message that looks like this.
1366250	1374830	Now, what this allows me to do is I could then copy this and paste it as a command, and it will now create for me the message that I want.
1374850	1383570	Now, you can actually batch all this together so that you don't have to, you know, do this all stepwise.
1383570	1392350	But when I just ran that command, the PAIS underscore ping command, it then created, you know, the binary of the encapsulated payload.
1392350	1395190	Anyway, that's what I'm showing here.
1395310	1403390	So I ran that ping command. Then I ran the other command that gives me the encapsulated payload.
1403390	1410770	And now I can run another program called AIS NMEA, and it now creates for me an AIS message.
1410770	1417670	And so from here, I can either transmit this, I can put it into a file with some timestamps, and I can make things happen.
1418310	1424170	Some of you, if you heard me talk yesterday and you saw that I created some virtual ATONs,
1424170	1431930	well, basically what I did is I determined what's the latitude and longitude of where I wanted the ATON to be, what type of ATON did I want it to be,
1431930	1439230	and I just created a bunch of these messages, put them in a file, and just sent it up to OpenCPN so that they would appear.
1441750	1445610	Now, once I've created the message, I need to be able to parse it.
1445830	1452070	So here, again, is the AIS message right there.
1452830	1463730	And so this parser shows, basically, obviously parsing it, telling me what the talker ID is, verifying the checksum, and then, you know, showing me what all the contents were.
1463730	1470710	And you'll notice the only contents of real interest, well, it's a message type one. That's the one we put in.
1470710	1478470	There's the latitude and the longitude. And again, if you wanted, you could take that URL and, you know, look it up in Google Maps or something like that.
1478470	1482310	But in any case, that's the tool that I have.
1482470	1498450	Now, where I'm going with this is this. I could take that same message, I could go to a public AIS message parser, like I've done here at AGGsoft, put in the message, decode it, and it tells me all the stuff that's there.
1498650	1506690	One thing I would like you to notice is it is telling me that it is showing all 26 of 26 entries.
1507870	1512310	And this will be important later on when I talk about the backward compatibility stuff.
1514570	1519790	Here, by the way, are the 27 different AIS message types.
1520750	1526090	Like I said, my tools deal right now, I think, with 17 or 18 of these.
1526450	1531550	But in any case, what I'm also showing you here is the length of the message.
1532470	1536490	A lot of the messages are exactly 168 bits.
1536730	1542430	Some of the messages are different sizes. Some are variable length.
1542990	1550010	And anyway, I mention this because, again, this will be something that will come up a little bit later on.
1552270	1557210	So here is what my demonstration and capability tool did.
1557210	1565890	First thing, I decided that I can use crypto methods to deal with the problem of message bit integrity.
1565890	1569050	Again, not just individual sentence integrity.
1569090	1577130	If I've got a message that's 1,000 bits, well, a standard message can only be about 168 bits.
1577150	1582490	So a 1,000-bit message is going to need multiple fragments, multiple sentences.
1582490	1591250	The way the checksum works in NMEA right now is there's a checksum on each sentence, but there's no checksum on the message as a whole.
1592250	1595790	There's no timing integrity, so I needed a timestamp.
1595790	1604210	There's no validity and authentication of the sender, so this sounds like public-key cryptography is just screaming for that.
1604210	1606850	But I also needed to have backward compatibility.
1606850	1613090	I needed to have a method that I could apply, and it wouldn't screw up the system just by being used.
1613450	1616070	So here is my proposed solution.
1616310	1619250	I call this working in protected mode.
1619250	1622290	So I'm a sender, and I have a message to send.
1622290	1635250	What my equipment will do is it creates a 16-character what I call protect string, and the protect string comprises a timestamp and a checksum for the entire payload.
1635250	1650850	That protect string is now encrypted with the sender's private key, and that protection string is now just appended to the normal content of an NMEA sentence.
1651030	1660350	If you're a receiver and you're operating in protected mode, when you get a message and you detect that there is a protect string,
1660350	1669090	what you do is the first thing is you know the MIMSY of the sender, so you can decrypt it with the sender's public key.
1669090	1672750	That allows you then to recover the timestamp and the checksum.
1672750	1688270	You now compute a checksum, make sure it matches the received checksum, and then you compare the timestamp to the current time to see, well, is this message arriving anywhere near in a reasonable time?
1689830	1703490	Now, as far as public key cryptography is concerned, I decided to use the MIMSY as the key, and the reason being was MIMSYs are different from the IMO number of a vessel.
1704490	1711370	IMO numbers are attached to a vessel. MIMSYs are pretty much attached to AIS equipment.
1711750	1728730	And so my idea was, well, if each MIMSY has an assigned private-public key pair, then the AIS device keeps as a closely held secret its private key, and the public key we now have to make somehow available.
1728890	1730810	And we'll talk about that later.
1731830	1736050	So anyway, graphically, here again is the example.
1736050	1740270	I've got my AIS device there on the left.
1740270	1744510	It has some sort of certificate where it has its own private key.
1744510	1756550	It has access to a public key database when it prepares its outgoing messages, just like it always has, if it's going to be using this so-called protect mode.
1756550	1761790	It creates the protect string, encrypted again with the device's private key.
1761790	1765050	It gets appended to the AIS message.
1765150	1770570	And now it needs to get all of the time slots that it needs to send out the entire message.
1770710	1785210	When it receives an incoming message and it detects the presence of a protect string, it can then, you know, again, it knows the MIMSY, go get the public key of the sender, and it can then decrypt everything.
1786070	1789710	So my new sentence structure then looks like this.
1789770	1791470	I still have a header.
1791750	1793550	I have content.
1794210	1801950	And if the message were small enough, actually, there would be a protect string, and then there would be trailer.
1802050	1809030	I actually think I've misdrawn this picture, and I will actually redraw it before it gets out into the wild.
1809030	1811210	The sentence structure doesn't change.
1811210	1813870	The protect string gets added to the content.
1813870	1819310	And if it requires more than one sentence, every sentence looks the same, header, content, trailer.
1819310	1822450	But now the protect string is part of the content.
1824670	1826790	So what does my protect string look like?
1826790	1828470	Well, I mentioned it's a timestamp.
1828730	1830530	I've got a four-digit year.
1830670	1834910	I've been writing Y2K-compliant code since 1973.
1835250	1841170	Anyway, I've got a four-digit year, month, day, hour, minute, second, all that kind of stuff.
1841170	1844330	It should be clear that you need to have the year.
1844330	1851310	If you don't have the year, if you only had month and day, somebody could do a replay attack one year later.
1851690	1855790	And so, like I said, you need to have a complete timestamp.
1856870	1858390	Then I have a checksum.
1858650	1865870	Right now, I've only used an 8-bit exclusive or checksum because it's the same as that's used for the rest of the NME message.
1865870	1867850	And I figured, well, you know, code reuse.
1868230	1870530	It'd be trivial to put in a CRC8.
1870530	1872090	I'll talk about that in a minute.
1872150	1881290	Anyway, and then I use a 256-bit RSA key to encrypt the timestamp and checksum.
1881370	1887410	Now, I need to slow down here for a second because there really is a reason that I chose this.
1887410	1900510	I chose RSA because when I was looking at the various crypto libraries, the RSA library had a feature that I wasn't finding in any of the other libraries.
1900510	1904030	And when we talk about the library in a minute, I'll tell you what that feature was.
1904030	1915990	The second thing is when I use a 256-bit key, I generate a 258-bit encrypted string.
1915990	1926850	And as you can see here from the slide, that generates a 26 to 154% protocol overhead, which is awful.
1926970	1940070	But the first time I ran this, when I was doing my experiments and I had a standard RSA key, you know, two kilobits, four kilobits, I was generating a several thousand-bit encrypted string.
1940070	1949590	Well, if 258 bits is 154% overhead, you can imagine what a, you know, 3000-bit encrypted string was.
1949610	1958590	So I found the 256-bit key was the shortest length key that would encrypt the 16-byte protection string.
1958610	1963710	If I used a 128-bit key, I could only encrypt a 5-byte string.
1963710	1969410	And if I used a 512-bit key, I got a 540-bit protect string.
1969410	1982010	So, again, you can see what I was trying to do here was trade off getting the protection of encryption, but at the same time not overwhelming the protocol with a ton of overhead.
1983550	1993270	So the OpenSSL RSA Crypto library has the functions that are listed there that generate key functions, encrypt, decrypt, and all that kind of stuff.
1993270	2003090	But when you use the encrypt function, it not defaulted, it meant you encrypted using the public key.
2003370	2006830	And when you decrypted, you decrypted with the private key.
2006930	2011890	If you wanted message authentication, you had to use the sign function.
2012190	2020010	But a digital signature is huge because they add all sorts of other things that I didn't want to add.
2020010	2033390	What I wanted was merely the feature of a signature that provided me authentication for the sender, but I didn't need everything and all the baggage that came with the signature.
2033390	2041990	So the OpenSSL RSA library also has functions called private encrypt and public decrypt.
2041990	2052850	So that allowed me to encrypt with my private key so that you could decrypt with my public key and now you would know that I was the real sender.
2052850	2062070	So the only functions out of this Crypto library that I use are the generate key, so I can generate a public-private key pair, and private encrypt and public decrypt.
2062190	2067570	Those were, no pun intended, those were the keys to making this all work.
2068430	2078930	Anyway, so here's another example. This is the same message that we had before, but when I do the ping command, everything differents in red.
2078930	2086650	So what I did is I added a switch called the protect switch. So this tells me we're in protected mode.
2086650	2097570	So now what happens when I ran this program, or ran this particular message, it tells me that the payload is going to be appended with a timestamp and a checksum.
2097570	2104450	So there's the timestamp and the checksum, and it's going to be encrypted with the private key associated with that particular MNSI.
2104730	2112830	Now, if I go back here for a second, I always forget where I put these things. You'd think that after all this time I would know.
2112830	2120950	I have my public and private key ring. So if I do an ls-la of my public key ring...
2120950	2130050	So here are all the public keys that I have stored in my experimentation. I just needed numbers.
2130050	2138130	And you can probably imagine that I have their private keys in a different key ring, and so there's the private keys.
2138130	2149010	So in any case, when I run the program, that's why it's important that I use a key that I have my public and my private keys for.
2149010	2154810	In any case, so now I run my next program that's going to create my binary string.
2155090	2162910	If you were to go back to the other slide and do a comparison, everything here in black matches what was in example number one.
2162910	2172670	Everything here in red has been appended. So now, when I create this message, it's now 426 bits.
2172670	2177870	It's going to be using two fragments. I've decided to use serial number seven. I don't know why seven's so hot.
2177870	2182770	But in any case, you can see down here, here are the two sentences that get generated.
2184250	2190190	And when I parse it, again, I have now two sentences that need to be parsed.
2190190	2200370	The first sentence now is sentence number one of two, and again has jazz that we didn't see before.
2200650	2203510	The checksum, you know, works. That's good.
2203510	2212090	And if I go down here, you'll notice that when I parse the message, everything in black is the exact same as it was before.
2212090	2216730	But now we have some additional information. We've got the protected AIS information.
2216730	2223430	So I know my sender is Mimsy. I know that it's authenticated because I compared it to the certificate that I have.
2224150	2227890	There's the timestamp. I compare it to the received timestamp.
2227890	2233950	Well, you can see it got there about six months later, but or at least six months later.
2234710	2239850	Now, I guess I'm sorry. That's only about 10 days later. I have some examples that are even worse.
2239850	2247290	I just set a threshold saying here's a I'll tell you how many seconds since the message was sent to when you received it.
2247530	2252790	If it's over 30, I just say it's over 30. You could actually tune that, presumably.
2253450	2256850	But in any case, and then I've got the checksum and it's verified.
2256930	2262230	And again, that's the checksum over the entire message. So then I know the message hasn't been screwed with.
2263070	2274270	When I take these two sentences and I poke them in to the AGGsoft decoder, you will notice I get the same AIS information I got before.
2274270	2283990	And if you recall, the last time we saw this, I wanted you to pay attention to the fact that it was giving me one to 26 of 26 entries.
2284030	2286650	That's what the software is telling me now as well.
2286650	2300150	So basically, a Type 1 message is 168 bits. The AGGsoft software and OpenCPN as well will just say, oh, Type 1. Type 1 is 168 bits.
2300150	2304310	That's all I'm looking at. And it ignored all the other bits.
2304330	2309150	So this was a way of saying, OK, I can demonstrate I've got some backward compatibility.
2311110	2314890	So what my little project was able to show was this.
2314890	2321770	I can solve the message integrity problem using a checksum. I can solve timing integrity by using a timestamp.
2321770	2329910	I can deal with validity and authentication because I have public key cryptography and I can use the sender's private key.
2329910	2340210	I can get backward compatibility because it appears that what my experimentation so far is that software and devices will ignore any of the excess bits.
2340230	2343410	Geographic integrity, I didn't even try to work on that.
2343410	2355290	Because geographic integrity needs to say, you know, I'm a device telling you that I'm at latitude 29 north, 80 degrees longitude west or longitude 80 west.
2355290	2360230	How do I prove that? And I need to have some other methods to do that.
2361350	2369210	So obviously, the big problem is key distribution. This only works if you can figure out how to distribute your public and private key pairs.
2369670	2376270	However, the method that I've described isn't dependent upon your key distribution method.
2376270	2378970	It just observes, yeah, you probably need to have one.
2380090	2394630	So the other nice thing is this. Let's say your device, and it's going to take you 10 seconds to figure out somebody else's or get access to their public key.
2394910	2403710	The fact is, I can accept the message for what it's worth and display it, even though it's taking me 10 seconds to go figure out whether the message is valid or not.
2403710	2410610	So, you know, in my ideal world, I see that you could have messages that you have authenticated, and they're in one color.
2410610	2420930	You've got other messages that are being authenticated, they're in another color, and messages that cannot be authenticated, they're in third color.
2421610	2425610	But in any case, there are a variety of ways of doing key distribution.
2425610	2434710	We could use existing public key infrastructure methods, such as, you know, X.509 certificates that we use today with things like SSL.
2434750	2439610	We could use a model, a distributed hierarchical database, such as the DNS.
2439650	2450630	There are currently a billion hosts in the DNS, and yet we can get an IP address from a host name in, you know, milliseconds.
2450630	2454670	Well, there's way less than a billion assigned MIMSIs.
2454790	2458150	So maybe we could do some sort of database like that.
2458150	2463390	And that probably is the way a lot of the literature suggests we could go.
2463930	2466550	You could do something like PGP's Web of Trust.
2466550	2470270	I will observe that a Web of Trust just isn't scalable.
2470270	2480850	I mean, PGP Web of Trust is barely scalable between me and the other, you know, couple hundred people I know that use PGP.
2481230	2487770	But it's certainly not going to be scalable to a very mobile industry, such as maritime.
2488650	2493110	And I mentioned here, there's some other papers that have talked about a number of other things.
2493830	2502470	And in terms of using public key crypto or using some sort of identity based crypto, there are all sorts of ways of doing this.
2502530	2507190	Most are observing if they don't want to change the entire AIS protocol.
2507290	2513210	We don't want to have a centralized certificate authority that doles it out to everybody.
2513210	2515630	And you have to go back to that central CA.
2515650	2518590	Most are talking about having some sort of hierarchy.
2518910	2521390	So, for example, and I'm making this up.
2521390	2524670	I haven't talked to anybody about this, certainly in a formal way.
2524670	2527750	But let's say you use the MIMSI.
2527830	2531190	Well, every country has its own maritime authority.
2531190	2535350	And within the MIMSI, there is an identifier that identifies the country.
2535350	2537970	So maybe every country has its own database.
2538210	2540710	So I'm able to look at the MIMSI.
2540710	2542610	I can figure out the country ID.
2542610	2544030	I go to that country ID.
2544030	2546610	It's been pre-programmed in where their database is.
2546610	2548470	You know, all ships are connected to the Internet.
2548470	2549890	So they could be able to do that.
2549890	2553530	So anyway, like I said, I'm just sort of making that up as a possible example.
2554010	2556870	There are still open issues with this.
2557410	2567290	What I've described here certainly does not protect me against a bad actor who legitimately has an AIS device that can operate in protected mode.
2568450	2574630	And it also doesn't stop anybody who's got a device from sending purposely false information.
2574690	2579050	Now, presumably, they're only going to be able to do it once.
2580050	2585310	Because, you know, once they've started to send bad information, everybody's on them.
2585590	2593250	The other thing is backward compatibility means I'm willing to accept messages that can't be authenticated.
2593250	2598350	Well, that means nothing stops a bad actor from just never being authenticated.
2598350	2612970	But if you're differentiating between authenticated messages being authenticated and unauthenticated, so, you know, it puts the bad actor in the unauthenticated space.
2613390	2616990	Anyway, any number of places to go for future research with this.
2617170	2620530	Right now, like I said, I use a checksum that's a bitwise exclusive.
2620530	2622590	Or I could use a CRC8.
2622590	2624690	Hell, I could use a CRC16.
2625090	2626590	Both would be better.
2626590	2633150	Both would keep the protect string well within what a 128-bit key could manage.
2633270	2636770	My current timestamp is 112 bits.
2636810	2644010	I could use a Unix epic time and not human readable time if I wanted to make it smaller.
2644010	2653970	It turns out if I make it smaller, it still doesn't make the protect string any smaller because I still have to use a 128-bit key.
2653970	2656310	A 256-bit key, rather, sorry.
2656610	2660590	I still end up with a 258-bit protected string.
2662010	2665690	So, like I said, I could manipulate that, make it a little bit less human readable.
2666490	2668310	Public sharing I'm doing.
2668310	2671070	My public key sharing is done via a web of trust.
2671070	2676670	I think at some really official level, you need something way more dynamic and distributed.
2676670	2679470	But this is sort of where I ended doing my research.
2679570	2686030	And I was able to get this to work with almost all message types that I support.
2686030	2692270	I couldn't get it to work with message types that were hugely of variable length.
2692270	2702870	Because the problem is one way in which you detect that you've got a protect string, like on a type one message, is you see I'm expecting 168 bits.
2702870	2711290	Anything beyond that, I'm just going to assume is a protect string, particularly if it is whatever 168 plus 258 is.
2711290	2714610	You know, if that's how long the message is, I've got a protect string.
2714610	2723270	If I've got a variable length message, though, I don't know, well, was the message, you know, a thousand bits?
2723270	2728750	Or was the message 650 bits and I've got another 350 bits of protect string out there?
2728750	2730330	You know, you got the idea.
2730330	2735490	Variable length was a little bit difficult, unless I could flag that I had a protected string attached.
2735490	2738830	But there's no way within the current protocol to do that.
2739970	2745770	So anyway, I've got some references for further reading, if people would like to furtherly read.
2746530	2749390	And obviously, here's my contact information.
2749390	2754890	I've not yet put this software up online, although I'm being incented.
2754890	2758550	Well, not incented. I'm being encouraged to do so, and I probably will.
2758550	2769550	One thing I do have to say, though, is that the tools that I currently have up on my website, I believe, are usable by people.
2769550	2774330	If they can read my readme.txt file, they'll be usable.
2774590	2778530	The protected AIS is not quite as ready for primetime.
2778530	2786170	But if people want to play with it, like I said, I will put it up at one of the sites I've been talking to to read out about that.
2786170	2791590	But if you want to ping me earlier, I'm at the point of not minding sharing them.
2792970	2799990	In any case, that's pretty much what I had to say about that.
2800310	2804070	And so let me come back around to here.
2805570	2809790	And I've got, well, let's see, I've got a number of comments.
2810770	2817610	Okay, they can see my desktop now. Let me see what readout's got here for me.
2821360	2825480	Yeah, readout makes the point that I could have used elliptic curve.
2827480	2832480	I'd have to look at elliptic curve. Again, the real...
2832480	2835700	Again, I hesitate to use the word key here.
2835700	2847140	The issue that I have is I need a library that will allow me to encrypt with a private key and decrypt with a public key.
2847380	2857660	But other than that, absolutely. And I, you know, I will freely admit, though, I never got around to looking at the ECC libraries, because as soon as I found RSA, I got real excited.
2857660	2863740	But clearly, ECC will give me the same level of protection with a far smaller key.
2868840	2876940	And let me go back to here. And let's see.
2877100	2879900	There's a message here somewhere. I just don't know where it is.
2882680	2887480	Anyway, if there are other questions, absolutely let me know.
2887480	2897600	I will have these slides. There are a couple of corrections. I'm embarrassed about this. Believe it or not, you probably will believe it, I was editing this slide deck up until about 15 minutes before the talk.
2898340	2908140	So there are a couple errors that I found as I was going through. I will fix them and I will get these slides out and so that they get posted as soon as they can get posted.
2930450	2932370	I'm hearing lots of beeps.
2943820	2947600	Well, I've got another talk coming up in about five minutes.
2950300	2958840	And so what I will do is, well, I'll hang out here for a couple minutes. They'll reset me in a few minutes.
2958900	2964280	And I have a little like challenge problem that I want to share with people.
2964520	2969900	It'll only take about 15 or 20 minutes to go through that. But otherwise, you know, thank you all very, very much.
2969900	2980180	And like I said, ping me one way or another if you've got questions or comments and, you know, my pleasure to be here and thanks for listening to this.
3452820	3456520	Okay, folks, I think we are back.
3456960	3460560	Let me try once again sharing my screen.
3466100	3471620	And once again, I'm going to live dangerously and show the whole thing.
3473160	3490500	So when we were talking about ideas for talks and projects and things like that, one of the things that I just happened to mention and somebody said, well, this seems like it'd be an interesting, you know, little challenge type of project to do.
3490500	3495700	And I'm going to talk to you about something called AIS point prediction.
3496160	3502660	So so here's the general idea. And if I was better at drawing graphics, I could have drawn you some graphics.
3502760	3509180	So I'm going to try going out here to OpenCPN to see what kind of things we got going out here.
3509700	3513820	What I really need and I probably don't have. Well, actually, I probably do have.
3513820	3518820	But you see these vessels out here.
3519660	3527600	This vessel right here, the Janus, we know is a sailboat. It looks like it's about to come in Ponce Inlet. The Sea King, I don't know anything about the Sea King.
3527740	3530540	It's also a Type B. That's too bad, but that's OK.
3531400	3543060	On AIS messages, vessels that are by Code of Federal Regulations required to transmit, Class A type of vessels.
3543060	3549960	So the really big ones have a lot of passengers, have a certain tonnage or horsepower.
3549980	3556840	They're Class A. And a Class A is going to be telling me all the information that's down here.
3556840	3560940	They'll be telling me a speed, course, heading and turn rate.
3561260	3567080	They'll also be communicating relatively frequently.
3567440	3573940	Class B vessels, the smaller ones, aren't required to transmit.
3574160	3580660	And in fact, in a Class B position report, there's no way to even tell me about a turn rate.
3580660	3583980	So the reason I'm telling you that is so that I can tell you this.
3583980	3593040	My question is, and here's an example of Louisiana, which was just offshore pretty recently, a tanker, offshore Daytona.
3593040	3603080	So if I know a ship's latitude, longitude, speed over ground, course over ground and turn rate,
3603080	3608700	can I predict where they will be the next time they give me a position report?
3609440	3613880	And in some ways, this sounds like a trivial exercise.
3614440	3619920	I fooled around a little bit with it. Not a lot. It's a really interesting exercise.
3621660	3630100	And the idea came to me some time ago, the idea being, you know, I'm at a particular place.
3630100	3636320	And suppose a bad guy spooks their AIS latitude, longitude of a vessel.
3636320	3641760	And they try to, let's say, knock Louisiana off the air. And now they spook, bing, Louisiana.
3642220	3651080	Well, suppose their next position report puts me five miles away.
3651320	3656420	Well, there's no way that I can move five miles in a minute.
3656420	3667720	So my AIS receiver could maybe flash red to say, we just got something that just doesn't seem right.
3668640	3676920	Now, the other thing, by the way, that this AIS message will tell us, this position message, this and other things,
3676920	3682680	is you'll notice that this is also giving me the destination and ETA of when I plan on getting there.
3682680	3687200	So this vessel, which I saw the other day, probably about four or five days ago,
3687200	3693280	is expected tomorrow morning at seven in the morning UTC to be in Texas.
3693280	3697580	So it must have, well, it must have been several days ago.
3697860	3706680	Anyway, so where I'm going with this is this. Again, an AIS type one, two or three message is a class A position report.
3706760	3710900	And the information that matters to me is it's going to give me a latitude.
3711580	3720240	For those of you that are not familiar with the relationship between latitude, longitude and distance, it is vaguely as follows.
3720240	3727180	One degree of latitude is 60 nautical miles. One minute of latitude is one nautical mile.
3728900	3737720	Longitude is about, one degree of longitude is about 60 nautical miles at the equator, which is zero degrees latitude, of course.
3737720	3748800	But for every other, any other latitude, a degree of longitude, the linear distance is going to be some function of the latitude.
3749220	3760080	And think about a globe. And of course, as you get closer and closer to the North Pole, one degree of longitude gets to be almost nothing.
3760140	3764940	Whereas one degree of longitude at the equator is 60 nautical miles.
3764940	3767420	Anyway, I mentioned that later on.
3767880	3772160	Then we're going to have the course in degrees, zero degrees being true north.
3772160	3776780	And so an actual course will be somewhere between zero and 359.
3776920	3785160	The speed in knots, a knot, of course, is a nautical mile per hour, which translates to about 1.15 miles per hour.
3785580	3790840	I'm going to have a rate of turn, which is generally expressed in the number of degrees per minute, left or right.
3790840	3799200	And the time between transmission is going to be a function of what is your speed and what is your rate of turn.
3800060	3805860	And it turns out there's a standard for this. And if only the standard matched the reality, life would be a good thing.
3806280	3813040	But here is actually an example and talks about some of the additional issues related to the problem.
3813340	3818980	So I only care about the class A transponder types, although I'm showing you class Bs as well.
3818980	3825760	So technically speaking, if you're a class A vessel and you're an anchor, you just need to transmit every three minutes.
3825920	3830180	Now, you may be saying, but I'm an anchor. I'm not moving.
3830180	3838320	Well, again, AIS class A devices, you might be talking about a vessel that is several hundred meters in length.
3838320	3858540	If it's anchored or moored, the position of the bridge might be actually composing a circle that if that ship were to swing around its anchor in a 360 degree circle, you might be talking about a radius of many hundreds of meters.
3858540	3871860	Well, a nautical mile is about 2,000 yards. So I might, like I said, I might have a pretty big swing radius.
3871860	3881680	In any case, if I'm sailing, not sailing, obviously, but underway, between zero and 14 knots, I'm supposed to be transmitting every 10 seconds.
3881700	3890700	If I am sailing at a speed of zero to 14 knots and changing course, I need to be transmitting every 3.33 seconds.
3890700	3894360	So that's how you read the chart in terms of transmission rate.
3894440	3901220	What I did is I then translated this and said, well, what's the maximum distance I can travel in that amount of time?
3901220	3911480	Well, if I'm going 14 knots and I'm transmitting every 10 seconds, I'm only going to be traveling 77 yards. That's not very far.
3911780	3924920	And you can sort of see as my, as I progressed here, what I was trying to give was an idea of exactly how far might I be going between transmissions.
3925580	3931900	Now, I mentioned, I wish the reality were, you know, match the standard.
3931960	3936920	Sometimes we will see vessels going by that are class A vessels and they're pretty big class A vessels.
3936920	3943640	And like the Louisiana, the Louisiana was going at 15 knots.
3943640	3948700	Well, at 15 knots, even in a straight line, they should be transmitting every six seconds.
3948720	3953220	But we had like a minute, that slide that I showed.
3953220	3961960	So in any case, you know, so the distance or rather the rate between transmissions is something else we need to take into account.
3962280	3966780	So then I said, well, okay, I've got, I've got a ship here.
3967380	3973460	That's supposed to be a ship. And it's at some latitude and longitude, which I'm calling lat zero and long zero.
3973500	3977380	I know my course over ground. I know my rate of turn.
3977680	3981840	And so the question is, all right, well, I've got a triangle in here.
3981840	3988980	I've got some angle theta. Now, this may or may not be the right approach to go, by the way, but I've got some angle theta.
3989260	3997900	And so at some T time later on, I've got my new latitude and longitude, lat one and long one.
3998260	4009340	And so I will observe that I can figure out the radius of this circle because it's going to be related to the speed over ground and the rate of turn.
4009340	4017920	I can figure out the distance that I've traveled, that circular distance, that arc, if you will.
4017920	4023600	That's going to be somehow related to the velocity times the time between the transmissions, the actual time.
4023600	4035920	And then I've got this delta x and delta y. Well, delta x is going to be a function of the angle of the circle, the speed over ground and the time, which as will my delta y.
4035920	4051820	But then my actual change in latitude and longitude has got to be a function of the course plus theta, meaning that if I was just going due north or due anything, it'd be easy.
4051820	4066880	But as we start to change off of zero degrees, we start to see, you know, some complications because, again, a degree of latitude is the same everywhere in terms of linear length.
4066880	4076540	But the linear length of a degree of longitude is not going to be the same. So, like I said, we have, you know, that issue to deal with.
4078940	4092600	So, again, my targets that I'm going for is if there's no rotation of the ship and the ship is moving in a straight line, well, that's almost easy to do.
4093220	4111300	If the rate of turn is not zero, my ship is turning. And so then the other thing I was thinking of is not only can I, how well can I predict my next point, but, you know, we just had a tropical storm down here last week, went up the East Coast.
4111300	4163600	And so we always look at the National Hurricane Center and they give us this cone of certainty for, so that if my next point is in the box, do I claim victory? And am I looking for, well, a really small box or how big will I let my box be?
4163600	4175900	If I'm going in a straight line, they really are sort of boxes. If my rate of turn isn't zero, then the boxes actually become a cone. Am I anywhere in the right range at all?
4177200	4191740	So, like I said, in terms of a problem, I was just thinking that this sounds like an interesting problem to tinker with. And, and there's all sorts of places to look at historical information.
4191740	4209440	What you need to work on, though, if you get historical information, and I could even provide you some, is you need type one, type two, or type three position reports from the same vessel. And, and the type one, again, because you need rate of turn.
4209440	4227320	Now, I mentioned something about the length of the degree of latitude and longitude. So, again, the length of the degree of latitude in meters, there's, there's a formula that I know is used at a number of the government sites.
4227320	4244400	It was actually easy to find the formula because they have these pages where they have like a JavaScript and you can, you know, put in, you know, what your latitude is. It will tell you the length of a degree of latitude in meters. Well, of course, if you right click and look at the page source, you can see their formula.
4244400	4264420	But it's been used a lot and I've seen it documented in a few places. In any case, the length of the degree of longitude, again, you will also notice is a function of the latitude. The length of the degree of latitude and longitude, here, here's, here's a table that I produced largely from those formulas.
4264420	4283280	And you will notice that a degree of latitude, in terms of nautical miles, it almost doesn't matter where you are. It's about 60 miles, 60 nautical miles to a degree. If you look at a degree of longitude, the number of nautical miles, again, at the equator, it's about 60.
4283280	4303020	And then as you go towards the poles, it increasingly gets smaller and smaller, and then rapidly gets smaller once you get above about, you know, 45 degrees, either north or south. And that actually, you know, makes sense. Until, of course, you get to the pole and then the degree of longitude is zero nautical miles.
4305000	4331720	And again, I've given you some websites where they have more information about this. And that, more or less, was the challenge. And as I said, I think it's sort of an interesting problem. And for a few people, I don't know where we sort of go from there. I, like I said, I talked to Reid out about this, and I think he talked to a couple of other people.
4331720	4349300	Interesting problem. I think what we're looking for is maybe to have some intermediaries, intermediate solutions at some point in the next year. Maybe revisit this at, have to see, 3.0 next year. And anyway, so that's where I am.
4350880	4353380	So, questions, comments?
4353960	4357720	Let me go back up here. I...
4359240	4363120	I'm no longer at Hack the C village.
4369860	4373040	So I'll sit here for a couple of minutes while we go into Q&A.
4400390	4403090	Well, where I'm sitting is a lot of dead air.
4403810	4409290	I'm going to hang out for another few minutes. Clearly, if anybody's got anything, let me know.
4409570	4415110	And again, contact me by email or, you know, whatever seems to work.
4417150	4422150	And, you know, let me know if you have questions and how we might, you know, go forward with this.
4422310	4430370	And other than that, I thank everybody for attending whatever talks of mine you attended. I had a blast. Hope you had a blast. And go from there.
