Score:1

Manually deriving asymmetric key pairs with Openssl

cw flag

In Openssl, is there a way to systematically generate a private key such that every time you perform this key derivation, you produce the same private key?

It seems like every openssl command that generates private keys does so randomly. So, if you lose your private key file for whatever reason, there's no practical method of recovering it. I know you can control some parameters of RSA key generation like the size and the exponent, but what if you wanted a specific modulus that you could remember?

Likewise, for ECDSA if you know a private key that is valid for a particular curve type,

  • How would you generate the public key from that chosen private key?
  • Maybe there is a way to edit a PKCS1/8 file so that you can change the private key?
  • Or, maybe there is an option for genrsa/gendsa/genpkey/etc that allows you to derive the private key from a passphrase?
knaccc avatar
es flag
I see the problem - the private key PEM file contains an uncompressed public key which bloats the length of the file, which means there is an unnecessary amount of information that would need to be written down. [These answers](https://stackoverflow.com/a/59329138/8656811) say you can't do it with OpenSSL, but you can specify a seed with GnuTLS
Score:1
cn flag

For RSA, because the key is highly structured, no.

For ECDSA/ECDH you can just use a costly hash like scrypt or argon2 of whatever, truncated if necessary, as privatekey and openssl can derive the publickey -- see https://stackoverflow.com/questions/48101258/ (commandline) or https://stackoverflow.com/questions/75474348/ (library). For EdDSA/XDH and DSA (in a known group, which doesn't need to be secret) you don't even need that; PKCS8 format only needs the privatekey number (which for XDH must be munged slightly to ensure it's not in a small subgroup and the multiplication can't be shortcutted creating a sidechannel).

But any key you can remember, or derived from something you can remember, is very likely breakable -- some Bitcoin users tried this and most lost their money; google brainwallet. (Although this happened back when Bitcoin was only a few hundred dollars, so they didn't feel quite as much agony as they would have last year, and maybe yet this year it will bounce back, who knows.)

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.