Sunday, January 13, 2013

Split PFX Into a Public Cert and a Private Key

Recently I had to setup hMailServer to work with SSL. You know, sending and retrieving email in a secure fashion is a good idea. To use SSL in hMailServer, you have to provide it with a public certificate and a private key. I was supplied a PFX file so I had to extract the public cert and the private key from it. This is quite a common task by the way. To accomplish this, you will need OpenSSL. It is available freely. So, first download it. Once you have the OpenSSL installed, follow these four easy steps:

Step 1. Extract the private key from the PFX file.

openssl pkcs12 -in your_cert_file_name.pfx -nocerts -out private.pem 

Step 2. Remove password protection from the private key extracted in Step 1. We use the same file name, so, basically we are overwriting the private key file.

openssl rsa -in private.pem -out private.pem 

 Step 3. Convert the pfx file to a .pem file. This step can be done by several online tools but we are cooler, so we do this with OpenSSL again.

openssl pkcs12 -in your_cert_file.pfx -out full.pem 

 Step 4. This is the final step. We extract the public key from the full.pem file that we created in step 3.

openssl x509 -inform pem -in full.pem -pubkey -out public.pem -outform pem 

Hope this short posts helps you with your SSL conversions. Keep a couple of points in mind:

1. OpenSSL is available for 32 bit and 64 bit versions of Windows and make sure to download correct one.

2. You will need Visual C++ 2008 binaries and without them OpenSSL will not work. The OpenSSL installer will ask about it if it does not find on your machine.

3. You will need the PFX cert password. Make sure to have it at hand.

4. If you do not have OpenSSL bin folder in your environment variables, the commands will not work directly in the command prompt. The easiest thing you could do is to copy your .pfx file to the OpenSSL's bin folder.

Wednesday, August 29, 2012

Watch How a $50 Device Can Unlock Your Hotel Room

When Cody Brocious, a 24-year old developer from Mozilla, unveiled flow in hotel room keycard locks in July of this year, hotels did not pay much attention. To be more precise, Onity, the manufacturer of these locks, has ignored the fact that their locks could be compromised by a DIY device that anyone can build. Interestingly, these locks are installed at around 10 million hotel rooms.
It did not too much time for hackers to once again remind Onity that the problem needs to be addressed and here we go. In this video, Richard Kindel is demonstrating Brocious' hack at Michigan Hilton.

Brocious has posted a whitepaper on his blog. Well, from what I saw, finding this hack should have been quite a complex task. Ironically, implementation of the device is quite easy. The whole device is based on the Arduino microcontroller and a couple of other components (a resistor and DC barrect connector to be more precise).

Hopefully, after seeing more photos and videos and after Kindel's successful opening of the lock, Onity will pay more attention to this problem.

Trillian Comes to iPad

I don't really remember exactly when, but I started using Trillian quite a long ago. As a matter of fact, Trillian has been a devoted companion of my computer. After all, using a single application for all major instant messaging and (later) social networks is a cool thing. On the other hand, Trillian features one of the best and sleeks GUIs.

iOS version has been around for quite a while but it was an iPhone only version. However, now, with Trillian 2.0 for iOS we get a universal app that works on iPad as well. Up to now, I have been using QIP on iPad. QIP works fine and is a great piece of software. Let's see if Trillian on iPad makes it better.

Wednesday, August 22, 2012

Building the Simplest LM386 Circuit

The LM386 IC is a power amplifier designed for use in low voltage applications. However, capabilities of this chip shall not be underestimated as in vast majority of applications where we need audio amplification the standard 20 gain delivered by the chip is enough. Think about pocket radios, door bells, audio notification devices. The list can go on and on. When I was a kid, I would build small radio receivers and I would spend a lot of time designing amplification circuits. I just wish I had this chip then. With LM386 you get the whole audio amplifier practically ready. Not enough? By some clever tinkering with a couple of peripheral components, a gain of 200 can be achieved! Not bad, not bad at all.

To build the simplest possible circuit with LM386 we need the chip, two capacitors and an 8 omega speaker, a couple of wires, breadboard and a power source. You can power the circuit with a 4 to 12 or 5 to 18 Volts. In this respect the chip is good too and the power consumption is really low at 4mA.

Below you can find the actual breadboard implementation.



The larger capacitor is 250uF and the smaller one is 0.05uF. I have experimented with different values and those seem to be the best. I have also tried removing the smaller one altogether. However, that capacitor makes the circuit more stable and avoids unnecessary oscillations (and thus less noise and better quality). I have deliberately not added the potentiometer to the input (with it you could regulate the volume).

Once the circuit was ready, I tested it on the iPhone. Below is the video showing the actual result. As you can see it takes a couple of minutes to build your own speaker for your very favorite mobile device.


Sunday, August 12, 2012

Arduino vs. Lego Mindstorm NXT

A couple of years ago I started development of an AI project for robots. While the project is really just my hobby, it seems to be coming really powerful. I have reached a stage when I need a physical representation for the AI - yep, time to build a robot.

I have been considering using Lego Mindstorms NXT as the basis for my robot. Lego Mindstorms NXT is a cool thing and I have seen a number of videos on YouTube where people do amazing things with the Lego brick. However, recently, I came across an Arduino microcontroller and I was blown away by it. It was kind of a love at first site. The system is open source, terribly cheap and comes in different variations (I got UNO but there is a bigger and a smaller alternative. It all depends on what kind of project you need Arduino for). Another big advantage is that Arduino uses the C programming language. I really don't like Visual Basic (which is used in a number of microcontrollers) and the Assembly is quite an over kill and C is my favorite.

So, how does Arduino compare to Lego Mindstorms NXT?

First, let's take the financial side. Lego Mindstorms NXT retails at around $250-$270. If you order it over the Internet you must add shipping (and very often customs) costs. So, the "toy" may cost you almost $300. Now, let's see what you get for this money.

The standard Lego Mindstorms NXT (there are other, more expensive versions also) package contains:

3 interactive servo motors
A sound sensor
A ultrasonic sensor
A touch sensor
A light sensor (which also functions as a color sensor)
Over 500 Lego Technick pieces (the good thing is that you can combine from other Legos that you or your kid may have. This is really nice).

The main brick features:

4 input ports
3 output ports
7 wire cords (6 wire each)
A matrix display
A sound speaker
USB 2.0 and Bluetooth support

You also get a pretty easy connection to the PC and an easy-to-program, icon-based IDE to program the robots.

Now, let's see what we can get for the same budget if we got the Arduino way. I am providing my actual experience. Prices and availability may vary depending on your location.

Arduino UNO board - $20.49
SainSmart 128x64 Graphic Blue LCD Display - $18.95
Ultrasonic Module - $7.68
Color sensor - $19.99
Misc electronic components (timer chips, IC sockets, etc) - $39.58
Arduino Sidekick Basic Kit (discussed in my previous post) - $22.50
3 Servo motors (one is included in the Sidekick kit) - $45
___________________________________________________________
Total: $174.19

As you can see we have around $100 to spend on various components (or if you are just starting on various tools). Please also keep in mind that when you use Arduino, any useless electric device becomes useful. Imagine how many electric components broken gadgets contain. While theoretically you could use components from those gadgets with Lego Mindstorms NXT, practically that is quite complicated. With Arduino, however, you can use any component. I rushed to the basement and salvaged quite an impressive number of various components already. This includes a couple of toners, a mic, a lot of transistors, all kinds of LEDs, IR detectors (unfortunately after I already had ordered one) and so on. Also, it must be noted that Arduino is considerably powerful with more IO pins, support for interrupts and support of both analog and digital singals.

So my conclusion is that for kids and less experienced robot builders Lego Mindstorms NXT is a better choice. For the real tinkerers, Arduino is the way to go.

Wednesday, August 8, 2012

Getting Started With Arduino

My Arduino board along with a Sideckick Basic Kit, has just arrived from Amazon.com and I quickly started a hands-on session. I was surprised how small and versatile the board actually is. Judging from the photos, I was expecting a bigger device but Arduino UNO is a small beast.

The Sideckick Basic Kit came from CanaKit.com. The kit comes in a white plastic box (pretty convenient) with a number of basic (but very important) components. This includes a number of red and green LEDs and one multi-color LED, around 30 resistors (330, 1K and 10K omega), capacitors (both ceramic and electrolytic), tiny switches and knobs, a buzzer, a potentiometer, a photo diod, a thermistor, a diod, a breadboard and a good number of colored jumper wires (of varying lengths).  The kit even includes a mini servo.The components are conveniently packed in little plastic bags. The kit also includes a sheet with resistor color coding. Speaking of resistors, they are really tiny and initially it was quite difficult to read the markings. So, keep a magnifying glass at hand :). Also, it would be good if there were any labels, but overall the kit is very good.

Having a programming background, my goal was to build a kind of "Hello World" thing with Arduino, so I started with a flashing LED project. In less then 10 minutes, I had the drivers installed, the board successfully connected to the PC and the LED happily flashing (actual photo on the right). Not very cool but quite exciting for start.

The next time I will be building something more interesting. A traffic lite or a light project incorporating the photo diod.

Sunday, August 5, 2012

First Quantum Router Created

Scientists at Tsinghau University in China created the first ever quantum router. The system makes a quantum photon from two separate photons in different polarized states to route data, well a qubit at a time. This is one step forward for quantum computing and while not practical immediately, gives hopes for the higher speed networking in the future.