hardware tokens or Hardware Security Modules are devices on which you can store a private key in a safe manner: it is not possible to extract the private key from it. There are many solutions out there, an open source package is OpenSC:
http://www.opensc-project.org