Tuesday, May 29, 2012

New Improved Military Training Routes KML File -- Includes Puppies

After noticing that the FAA had reduced the line length of their Military Training Route text file from 553 characters to 520 characters in their April release, I knew that I had some cleanup work. They also created a new type of record, separating out the agency data from the base MTR record into its own type. Database folks would call these tables. Who says they government can't change? This makes creating the KML a little easier, because I'd rather parse more record types with fewer fields than fewer record types with more fields.



Fun facts:

  • Pretty much everything the FAA writes is in ALL CAPS.

  • There are about 400 "noise-sensitive" areas that our military pilots need to know about, including at least nine chicken farms.

  • There are about 39 "CONGRESSIONAL" noise-sensitive areas, including several "CONGRESSIONAL (EXTREMELY) NOISE SENSITIVE AREA".

  • There is at least one "CONGRESSIONAL NOISE SENSITIVE AREA (CATTLE FARM)" at N36-28.8 W80-27.5. Who knew that sonic booms make milk go sour?

  • Puppies! "ROUTE SEGMENTS A TO B AND B TO C CLOSED 1 MARCH THROUGH 30 MAY ANNUALLY DUE TO NEW BORN SILVER FOX PUPS." We'll forgive the grammar for puppies.


I am working on creating a KML sub-set to include just Congressional noise-sensitive areas, so we can all know which areas to avoid.

File Format Improvements:

  • SOP and other data are not commingled between IR and VR routes with the same number. Route Type and the number are a composite key.

  • Now includes terrain-following operations notes, if applicable

  • When you click on a line, you get a table of data rather than all freeform text.

  • When you click on a waypoint, you can see the Navaid distance and radial.

  • Waypoints are now star shapes instead of the stock pushpins.


The new Military Training Route file is in the KML Archive. The filename starts with "MTR".

NOT FOR NAVIGATION. CONTAINS UNVERIFIED DATA.

Wednesday, May 23, 2012

Not for Navigation: FAA Navaid File for Google Earth KML

I parsed and plotted the FAA's navigation aid file into KML for Google Earth. This includes VORs, VORTACs, and NDBs, among others. Even decommissioned VOTs are listed because they're still in the database. Other VOTs are still listed as operational. I thought they were obsolete. Seeing all the different navaids in Google Earth is pretty impressive. There are a lot of them. (File is in the KML folder if you can't be bothered to read the rest. It's called US_NAVAIDS, but it includes some foreign navaids, too.)

I tried to include as much data as possible about each navaid, but I left out the details on the Fan markers, because there are only eight of them unless there's a bug in my code someplace.

This file has not been checked, so take a look the VORs near your base and let me know if they're off.

Some of you may be thinking that radio navigation is becoming obsolete and that it's expensive to maintain 2,615 ground-based aids to navigation now that we have GPS, GLONASS, and Galileo. Certainly, many pilots rely on GPS exclusively, but I think that's a mistake. GPS signals are extraordinarily easy to jam. Jammers are cheap, but they're generally not strong enough to reach the altitude required.

Traditional radio-navigation has been working for years. It fails well. One NDB or VOR is not linked to any others, so if one fails, all the others still work. Given that there are thousands of them, it's hard to imagine not being able to tune in any VOR/VORTAC/NDB at all but the lowest altitudes.

With GPS, it's a little easier to imagine widespread failures now that incidents have been documented.

NOT FOR NAVIGATION.

Not for Navigation: FAA Parachute Jump Zones KML

I got around to parsing the FAA's parachute file. At first, the data elements looked good enough to do a proper circle in Google Earth. However, most jump zones have a null radius or no radius. Nevertheless, where there is a radius, it's listed in the area comments. There's a similar problem throughout the data -- elements are missing in many records.

Another mystery: Some areas are charted, some are in the A/FD, and some are listed in neither. (FAA's Airport/Facility Directory This link will expire.).

If you've ever wanted to see all the jump zones in the US in Google Earth, the file is in the archive. Hint: It's called dropzones in the kml directory.

Another mystery: Why I can't get the lat/long math correct on multiple hemispheres the first time I try.

NOT FOR NAVIGATION

Thursday, May 17, 2012

Not for Navigation: FAA Communications Outlets

If you've ever wondered where all the FAA Radio communications outlets are located, here you go. These are not tower frequencies, nor ARTCC or TRACON frequencies. These are the ways to connect to Flight Service Stations, that are sometimes co-located with VORs or airports. They are not unique -- outlet stations associated with an FSS can have multiple locations with the same ID. So says the FAA.

The file is in the usual place. I link to the folder rather than a specific file because the filenames will change with each release cycle.

Thanks to Nicolas Mollet for the icons. I was getting sick of the default Google pushpin

NOT FOR NAVIGATION.

Wednesday, May 16, 2012

Not for Navigation: Airports KML File Updated

I updated the Airport KML file with all US Airports. It still needs edits for cleanliness of the comments. The FAA updated the layout of the file back in April (2012) to include more data. The updates moved the location of a lot of data. All my code merely looks at the right place on each line for the data points, so there was some work to be done.

As usual, it's in the KML folder on my webserver.

NOT FOR NAVIGATION

Tuesday, May 8, 2012

Not for Navigation: KML Files Updated Again

I have updated the Special Use Airspace, Military Training Routes, and AWOS KML files. There have been significant changes in the FAA Data Files. It looks like the FAA Airports file is now providing data to other agencies in the Executive Branch, so there are several more record types to sort out. It looks interesting, so I'm going to take a look at it. I need to rewrite a little code and adjust the SQL tables. Thus the airports KML file is not done yet. (It's not a big deal -- the entire codebase is just string manipulation and SQL queries.)

Also, Military Training Routes are still not validated. I have no idea how accurate they are because I can't find the data in other forms.

Finally, the new AWOS file is AWOS data from the AWOS file only. Previously, it had included airports' AWOS data. Now it doesn't. On the upside, it does inlclude previously not-included AWOS-only stations. If you're wondering what those are, open it up and look at the Gulf of Mexico. There are two entries for each comment.

I really need to figure out the new XML airspace schema.

NOT FOR NAVIGATION.

Monday, March 5, 2012

OpenVPN with smart cards: Not just for pfSense

One day I became curious to see if I could use a security token/smart card with pfSense to log into OpenVPN. Why not? It beats storing unencrypted keys and/or passwords on mobile computers. If you can't get users to change their passwords as often as you'd like, smart cards are one kind of mitigation. You'll just need card readers or USB ports on client devices and the open-source pkcs11 dll or shared object. And get your users not to leave the tokens/cards in their computers. (Which is why it's great to also make them proximity cards for doors.) If you needed your smart card to go to the restroom, I'm guessing you wouldn't leave it in the computer.

This does NOT cover Windows domain authentication, or one-time-password tokens such as inSecureID.

It turns out that it is possible -- provided you follow some simple steps. The best part is that smartcard authentication to pfSense's implementation of OpenVPN doesn't require any server-side configuration changes. (Assuming you're already doing certificate-based authentication -- tls key too, if you want.) That's right. If you've got certificate-based authentication working, you don't need to change a single parameter on the pfSense side. You can also use your smart card to log in via SSH with Putty-SC and via https with Firefox.

Smart cards and tokens are often misunderstood. Mention "hardware security module" and people start to think you're a security geek. But smart cards are mini-HSMs. The card stores your certificate and key. It protects your key with a PIN. Some cards can store more certificates and keys than others, but that's the main concept. It separates your private key from the computer and protects it. Get the PIN wrong a few times and your card gets locked. Forget the PIN unlock code (PUK) and you may lock out the card permanently, which is exactly what should happen in a hardware security module.

But this is IT, where simple concepts are blown up by implementations. Every smart card brand and model is different. The middleware is all different. You have to get married to a card and its vendor's middleware to make it work. Even the HSPD-12/PIV standard is a standard for reading cards only. Administration is different for all vendor PIV implementations, creating millions of dollars in opportunities for card middleware vendors. (Hmmm, I wonder what the US national ID card is going to look like.)

Until OpenSC. OpenSC is the Smart Card project that's been open-sourcing card solutions for a number of years, and it pretty much works if you stick to cards they support.

Problem: they don't support that many cards and the cards they do support aren't sold many places. But you can buy ones that work for shipment to the US and Wassenar countries. I chose Aventra and it worked. Gooze's 2003 PKI USB tokens are up next for testing.

One key point: pkcs15 is a file structure for cards. pkcs11 is a software interface for cards. Read the OpenSC documentation twice before starting -- once for concepts and again for details.

When you buy the cards, you'll be offered a proprietary driver and middleware. Don't use it. Everything you need is at OpenSC-project.org. Stick with those drivers and their process. OpenSSL has an engine for cards: the PKCS11 engine. That lets you issue OpenSSL commands to get a CSR from the card's key. The other software component is pkcs11 shared object/dll file, or "driver." You point your smartcard-aware application at that so it knows where to find the software interface, which knows where to find certificates and ask for keys. (In windows, it's c:\windows\system32\opensc-pkcs11.dll; in Linux, it's wherever you stuck opensc-pkcs11.so.)

Once you get the card, install Open-SC, and stick the card in the reader. (You can install Open-SC on Linux or Windows and maybe Mac.)

1. Initialize the card:
pkcs15-init --create-pkcs15 --profile pkcs15 --use-default-transport-key --pin xxxxxxx --puk xxxxxxxxxx --label "larry" --so-pin xxxxx --so-puk xxxxxxx

(There are many different options, you'll need to read the documentation...)

2. Get the certificates on the card:
Method 1: Fast using your existing OpenVPN certificates:
In a nutshell, here's what you do. Take your OpenVPN client certificate and key, (and your CA chain if necessary), and export it using OpenSSL into a pkcs12 file. Then use OpenSC's pkcs15-init tool to get the pkcs12 file onto the card.

The command below exports your certificate and private key in the same form you can get it out of pfSense. It contains your private key, so don't leave it lying around.

openssl pkcs12 -export -out larry.p12 -in larry.pem -inkey larry.key

Once you've got that, get it on the card thus:

pkcs15-init --store-private-key larry.p12 --format pkcs12 --auth-id 01 --pin xxxxx

Method 2: Create a new card-only key, use your own CA
For advanced users with their own CA, there's another way: issue the command to the card to create a private key, then use the OpenSSL pkcs11 engine and the pkcs11 interface to generate a certificate request.

pkcs15-init --generate-key rsa2048 --auth-id 01 --pin xxxxx

This should take about 40 seconds on the MyEID card. Then get the slot ID for the key:
pkcs15-tool --list-keys

Using reader with a card: SCM SCR 3310 [CCID Interface] 00 00
Private RSA Key [Private Key]
Object Flags : [0x3], private, modifiable
Usage : [0x10E], decrypt, sign, signRecover, derive
Access Flags : [0x0]
ModLength : 2048
Key ref : 1 (0x1)
Native : yes
Path : 3f0050154b01
Auth ID : 01
ID : d5e583c9fc7835231e94369f0f066d5ca5039814
GUID : {d5e583c9-fc78-3523-1e94-369f0f066d5c}

The fire up OpenSSL:
openssl
And then load the pkcs11 engine. (This is what requires you to install the extra engine.)
engine dynamic -pre SO_PATH:/usr/lib64/openssl/engines/engine_pkcs11.so -pre ID:pkcs11 -pre LIST_ADD:1 -pre LOAD -pre MODULE_PATH:/usr/local/lib/opensc-pkcs11.so

If all is successful, you can forge ahead. If not, figure out what's wrong with your compile.
(dynamic) Dynamic engine loading support
[Success]: SO_PATH:/usr/lib/engines/engine_pkcs11.so
[Success]: ID:pkcs11
[Success]: LIST_ADD:1
[Success]: LOAD
[Success]: MODULE_PATH:opensc-pkcs11.so
Loaded: (pkcs11) pkcs11 engine

Using the key ID from above, you can create a certificate signing request without getting the key off the card. Just put "slot_x-id_" in front of the number.

OpenSSL>req -engine pkcs11 -new -key slot_1-id_d5e583c9fc7835231e94369f0f066d5ca5039814 -keyform engine -out mynewrequest.csr

Then sign the CSR with your CA and import the certificate to the card. If you don't know how to sign a CSR, then Google it... Once you have the certificate, get it onto the card:

pkcs15-init --store-certificate larry.crt --auth-id 01 --id d5e583c9fc7835231e94369f0f066d5ca5039814 --format pem

Notice that the private key never leaves the card. (My dream is to get TinyCA working and store the CA key on a smart card....)

Now you're ready to test using the card:

OpenVPN:
Then change your client OpenVPN configuration file to use pkcs11. One catch is that the OepnVPN client supports pkcs11 but doesn't give you any way to input the PIN. Nor does OpenVPN-GUI. Viscosity does, but it's proprietary. OpenVPN-GUI has a modded version that supports it that I have not tested yet. Thus I use Viscosity. You'll need to load your pkcs11 module. In windows, it's c:\windows\system32\opensc-pkcs11.dll.

Once you get OpenVPN working, you can try using the key to access logins via SSH using Putty's smart card version. To get your public key off the card in ssh form, just try:
ssh-keygen -D /usr/lib/opensc-pkcs11.so

You can also configure Apache's httpd to use client certificates for authentication. Just change your /etc/httpd/conf.d/ssl.conf to include these two lines:
SSLCACertificateFile /etc/httpd/conf.d/mycafile.pem
where mycafile.pem is your cert authority's public cert.
and then
SSLVerifyClient require
And all your SSL connections will then require client certificates. Apache tends to reset the connection when you don't have a client certificate available.

Firefox has security token support built in. Go to options | encryption | security devices, and load your pkcs11 module. In windows it's c:\windows\system32\opensc-pkcs11.dll. Then you'll be able to choose a client certificate from the card.

When you're done configuring and testing the card, issue the following command to finalize the card:
pkcs15-init --finalize

TrueCrypt supports smart cards, but I have not figured out how to store a keyfile on the card. Yet.

And this assumes OpenVPN, Viscosity, and the cards are all engineered secure.