13

libsodium is an awesome encryption library, and GnuPG is an awesome key management and signing software.

GnuPG recently released support for Ed25519 signing keys, and submitted a draft to the IETF.

I want to use Sodium-generated keys by my web application offline with GnuPG. This will make it so I don't have to trust the server with my private key each time I sign, and I don't have to use special software on my client (even if I have to write it) since I already have and trust GnuPG.

How can I do so? How do I convert libsodium private keys to OpenPGP compatible private key packets?

Fredrick Brennan
  • 7,079
  • 2
  • 30
  • 61
  • 6
    I cannot even find a specification of the key format for libsodium anywhere. It's good to know that modern crypto libraries can be *even worse* in that aspect than the older ones. – Maarten Bodewes Nov 06 '15 at 12:42
  • Here's a public key: `\xef'\x07Ga#\xfe\xbc7\x8a\x00\xb3o\xbe\x92}k_\xa8\x8aH\x99cEN\x84\xf7<\x05\xe2\xd8\x8a` and corresponding secret key: `\x88\xf2\xe6\`\xb2\xd9W@\xd7\x8e\`1'\xb9\x16XE\xe8_bq\xa7e\n\xb5\x13~o\xe7b\x9f\xd9\xef'\x07Ga#\xfe\xbc7\x8a\x00\xb3o\xbe\x92}k_\xa8\x8aH\x99cEN\x84\xf7<\x05\xe2\xd8\x8a` Public keys are 32 bytes long; secret keys 64 bytes (but last 32 bytes is the public key) Perhaps I should have mentioned this in my question, but the key I want to convert was generated with `crypto_sign_keypair()`. – Fredrick Brennan Nov 06 '15 at 13:19
  • @MaartenBodewes I think LibSodium uses the same [format as Supercop](https://blog.mozilla.org/warner/2011/11/29/ed25519-keys/). i.e. the seed concatenated with the public key. By hashing the seed with SHA-512 you get the 256 bit secret prefix for deterministic hashing and a 256 bit value, which after manipulating a few bits becomes private scalar. – CodesInChaos Nov 10 '15 at 08:54
  • 6
    I'm afraid that finding this out would involve reading the source code and performing the actual conversion myself. I'd call that *a project*. – Maarten Bodewes Nov 10 '15 at 09:33
  • Not sure what is it, but for 500 reputation I will learn something new today `lol` – Maduro Nov 14 '15 at 21:31
  • I'd also like use my sodium keys in gnupgp - or at least generate a consistent key in gnupgp based on existing sodium keys. If anyone has a lead, please let me know. – Tamas Kalman May 11 '18 at 00:08

1 Answers1

2

libsodium uses the xsalsa20 algorithm for encryption. This algorithm is not currently supported with PGP, and in turn, is not supported by GnuPG.

user229044
  • 232,980
  • 40
  • 330
  • 338
rettys
  • 21
  • 2