6

I've been learning some basics of information security and GPG encryption and it's super intriguing. I wanted to understand vulnerabilities behind an idea that I had.

After we create our public and private key pair with GPG, it's common and known to be okay to post your public key and fingerprint online.

My question revolves around me storing personally encrypted data online eg in my GitHub repo. I'm assuming it's going to be okay but wanted to check with the community since I'm fairly new to this topic.

Assume I have a data file that I encrypted with GPG using my own public key. I now upload the file to GitHub where it can be publicly viewed. I'm assuming this should be secure because no one but myself can decrypt this information with my personal private key. Is that a safe assumption or am I missing something critical here?

ggoober
  • 61
  • 3

2 Answers2

7

I generally subscribe to the idea that encryption has an expiry date. So assuming you follow best-practice for key length and cipher selection, the best practices generally assume a security horizon of about 30 years.

So if after 30 years, this data would still be sensitive information... then you would want to select either stronger-than-normal key lengths and ciphers (ie. look at post-quantum cryptography), or consider other ways to reduce your risk of exposure. For example, not posting the content publicly on GitHub. But keep in mind that the 30-year guidance provided by organizations like NIST to set industry practices is based on historical rates of churn in cryptography. If a new exploit renders a cipher insecure, your data could become readable by an attacker in a much shorter time.

But if the content is only sensitive for a short period of time - like an API key that is easy to revoke and change, or has an expiry date - then you're probably ok to post the encrypted data with some confidence that no one will be able to read the content.

nbering
  • 3,988
  • 1
  • 21
  • 22
  • Thank you so much! For some context I've been thinking about password managers and how we could simplify the process by just storing our own encrypted passwords using GPG. One inconvenience with this approach is we have to resort to command line interface or have a good knowledge of GPG itself. What I'm aiming for is to build a super simple lightweight UI around encrypted data. You would still own your private key on the client side and part of the encrypted data would live in a static site hosted on GitHub. So regarding your concerns, the encrypted content would be passwords :O – ggoober Sep 16 '18 at 21:48
  • I guess my fundamental question is how safe is it to store GPG encrypted content publicly as long as you can secure your private key and passphrase (these are never stored, communicated or sent over the network). If this is possible and the security is fundamentally sound, it's pretty awesome that the math of cryptography secures this data (no matter the nature of its contents). Thanks in advance! – ggoober Sep 16 '18 at 21:58
  • I'm sure there is some answer that explains this better, but good cryptography assumes that the attacker (and anyone else) could know everything about the encryption, and have access to the encrypted content, and not be able to derive the plaintext. So if you use best-practice key-lengths for RSA or ECC ciphers for the symmetric key exchange, and AES-256 for the message body with PGP, it should take about 30 years to either brute force or break the encryption algorithm. – nbering Sep 16 '18 at 22:18
  • Always my concern in where something is posted publicly is how many attackers am I exposing it to, and how many of them would be interested in cracking the key for my content. The fewer attackers I expose my content to the less likely that any of them could just "get lucky". – nbering Sep 16 '18 at 22:19
  • 1
    I am reminded of an anecdote about Friedrich Kasiski cracking the Vignere Cipher in 1861, and using it to crack personal messages people used to send to one another in the open using newspaper classified ads. The Public assumed the cipher was unbreakable. Once it was broken by academics, all they would have needed to pick up a load of juicy love letters to decrypt was grab a newspaper. While the same technique would break an encrypted telegram, they would have to intercept it first. This increases the difficulty for a casual attacker. – nbering Sep 16 '18 at 22:30
1

Assuming you do everything correctly, strong keys, no reuse of keys, protection of keys, strong crypto, then yes it's safe.

However, given your use scenario, you should consider symmetric key encryption instead.

The point of public key encryption is to provide the ability to encrypt and decrypt by different entities. In your stated scenario, there is no point in having public and private keys as you are the only user. A symmetric single key is all you need and you protect it the same as a private key.

The way Public Key Encryption works is that your file is actually encrypted with a randomly generated symmetric key. Only this symmetric key is encrypted by public key encryption because it's computationally expensive. Public key decryption only decrypts the symmetric key for subsequent symmetric decryption. If you are the only user, public key encryption only adds overhead and potential confusion with no added benefit.

user10216038
  • 7,552
  • 2
  • 16
  • 19
  • 1
    When using GPG... I would actually suggest that there is a great deal of convenience in using asymmetric keys with GPG since this is the most common way of using the software, and there’s lots of help graphical keychain tools, etc. You can also use GPG to encrypt for multiple recipients without transmitting the key key material in the clear, etc. Asymmetric keys can also be used for signatures which might be helpful to prove that no one has tampered with the data. – nbering Sep 21 '18 at 21:42
  • Yes your stated conveniences of GPG are true, but those conveniences don't apply to the original posters use scenario. GPG also supports a symmetric cipher. Or 7zip or PKzip can provide graphical integration into the file manager if ease of use is the driver. All of these can be done in a secure fashion, go with the most convenient. – user10216038 Sep 22 '18 at 03:23