15

Is there a way that I can use a RSA keypair with PGP? What I mean is that I have 2048 length keypair and i want to use that to encrypt and decrypt data. But all I have found is that the PGP uses some keyrings and some pgp keys. And I haven't found anywhere why they are different? Why I am asking is that I need to store keys in HSM but i cant do that with PGP keys. Looked around and didn't find anything about that on google also.

Can anyone explain it to me or share some link.

Thomas Pornin
  • 320,799
  • 57
  • 780
  • 949
t678
  • 173
  • 1
  • 2
  • 6
  • This may be a little off the wall as a question - but why PGP? Is that a mandated architecture? I'm just surprised, since I don't often hear of requirements for PGP and key storage in an HSM. Usually I see PGP as a low end security mechanism - not that it's so bad, just that it isn't used in the bigger enterprise-ish stuff – bethlakshmi Jun 28 '11 at 18:21
  • There might be some miscommunication, but thats what i was told that they need to hold pgp keys in HSM. When i asked what keys they sayd RSA 2048, so maybe they just holding private key in HSM. – t678 Jun 28 '11 at 18:29
  • Why did you ask the same question twice within 30 minutes? This should be merged with [Store PGP keys in HSM - IT Security - Stack Exchange](http://security.stackexchange.com/questions/4884/store-pgp-keys-in-hsm). – nealmcb Jun 29 '11 at 01:33
  • 1
    @bethlakshmi: Why would PGP be low-end? It's PKI does not quite match the hierarchy of an enterprise, but nobody prevents you from building a hierarchical infrastructure of PGP keys. In contrast, everyone can get SMIME certificates and clients have about a hundret CAs, including foreign governments and rather low-cost CAs. And most clients don't really warn the user if the cert signer is different/unexpected. X509 is a mess. Security needs simple, scalable infrastructures. – pepe Jun 29 '11 at 08:40
  • @pepe - I'm not saying there's anything wrong with it... it's just that not once in 10 years of building enterprise level security has PGP ever come up as something desired. Usually the desire is for a straight up PKI. And I really don't see a lot of enterprise level products out there touting their PGP compatibility... – bethlakshmi Jun 29 '11 at 13:43

5 Answers5

10

What PGP does is described in the OpenPGP standard. In OpenPGP, "key rings" are some terminology for "public and/or private keys encoded in the format described by OpenPGP".

Among the types of keys for which OpenPGP describes a key ring format are RSA keys. There is no fundamental issue which would prevent an OpenPGP implementation from using a RSA private key which is stored in a HSM. Practically speaking, though, the free OpenPGP implementation, called GnuPG, does not inherently supports that -- but the gnupg-pkcs11 project may help: it allows integration of a cryptographic device which offers a PKCS#11 driver (virtually all HSM do that) into the GnuPG world.

Importing an existing "PGP key" (i.e. a RSA private key currently stored as a file in the OpenPGP format) into a HSM is not necessarily a good idea: a HSM is an expensive device which aims at never allowing a private key to ever exist outside of the tamper-resistant hardware of the HSM. If the key is imported, then it does/did exist somewhere in the outer world, which makes the use of the HSM much less justified.

Thomas Pornin
  • 320,799
  • 57
  • 780
  • 949
5

I don't know about PGP, but GPG can use Smartcards (and sometimes more interesting, PKCS#11 USB-Tokens) to protect the private key:

http://www.gnupg.org/howtos/card-howto/en/smartcard-howto-single.html

If you take the hassle to use a HSM, you should consider using one with a dedicated key pad. Otherwise the protection is of very little use.

You might also want to bring this to the attention of your IT security department: http://secgroup.ext.dsi.unive.it/projects/security-apis/pkcs11-security/tookan/

They have a paper at ACM CCS 2010 explaining the issue.

pepe
  • 3,536
  • 14
  • 14
  • Actually GPG support for smart cards (other than their own "OpenPGP" card) has poor support for "other" smart cards. Meaning it is not that simple to deploy PGP on top of existing X509 oriented cards, with open source software. – martin Jul 07 '11 at 18:19
  • For PKCS#11 tokens have a look at http://gnupg-pkcs11.sourceforge.net/, it is only about as broken as all the other (free) PKCS#11 middleware. – pepe Jul 08 '11 at 22:17
4

You can't use anything in PGP other that PGP keys. Some features will also work with certificates and S/MIME keys but not all (e.g. Additional Decryption Key will not work). I'm hoping you have not bought it without knowing this.

You can though set the RSA algorithm in PGP on key generation and in PGP Universal as a policy setting:

PGP Key

Some lessons learned implementing PGP email encryption in an organization

Rakkhi
  • 5,783
  • 1
  • 23
  • 47
  • +1 interesting blog post. And definite similarity in lessons learned from implementations I have been involved with :-) – Rory Alsop Jun 29 '11 at 07:46
  • @rory-alsop yeah was very stressful at the time but good learning experience. Always good to be doing rather than advising. Would never implement PGP by choice again though. – Rakkhi Jun 29 '11 at 08:13
4

If you are using RSA certificates, then you should use cms (evolved from PCCS#7 and s/mime) this is supported by openssl. http://www.openssl.org/docs/apps/cms.html

To sign and encrypt a file:

openssl cms –encrypt –text –in compressed-file.txt –out encrypted-file.txt public-key.pem

Next we sign the file contents:

openssl cms –sign –text –in encrypted-file.zip –signer certificate.pem –inkey certtificate.key –out signed-file.txt

To verify and decrypt:

openssl cms –verify –in file –signer certificate.pem 

If the verification is successful then the file contents can be decrypted.

openssl cms –decrypt –in file –inkey private-key.pem –out decrypted-file
Stuart
  • 300
  • 1
  • 3
2

You can't import keys to HSM AFAIK. They are devices designed to perform cryptographic onboard generation/storage/use of cryptographic critical data. Being able to import a private key to the HSM will negate the purpose of the HSM itself.

I think there is a backup procedure although. But I never had an HSM card in my hands (I wish I had :P) You can't export unencrypted information out of the HSM as well.

But you are right, they embeds 2048-length RSA keys (NIST recommendation since 2010).

Most of information available on Wikipedia

M'vy
  • 13,033
  • 3
  • 47
  • 69
  • You can import keys, both plaintext as well as wrapped (from one HSM to another HSM). It all depends on established policies and configurations. And it depends on the "HSM" as well. If you have HSMs in the first place, you usually want to make sure that cleartext key material never leaves the HSM, be it a "big one" or a smart card/USB token. – martin Jul 07 '11 at 18:22