Why does my SSH private key still work after changing some bytes? (2016)
crypto.stackexchange.com
crypto.stackexchange.com
Inserting or removing a control character in a binary file would break stuff too. Maybe even more so.
You may think of the ability to add CRCs (or at least checksums/parity bits) in a binary file? That's extra work, and can be provided by other mechanisms, like par files or at the filesystem level.
The advantage of text formats is that binary decoders for text are ubiquitous. That said, it's usually simple to filter input data through a decoder like gzip.
If a format is human-readable and text based it's both far more likely that a) the spec isn't actually complete (because there's an implicit "sensible" option), and b) people don't read the spec anyway and guess the "sensible" option.
There are countless examples of bugs and security flaws in HTTP that wouldn't have been a problem with e.g. Protobuf.
https://learn.microsoft.com/en-us/cpp/c-runtime-library/refe...
> In text mode, carriage return-line feed (CRLF) combinations are translated into single line feed (LF) characters on input, and LF characters are translated to CRLF combinations on output.
Rather, what's happening here is that the interpretation of the parsed format is malleable in an arguably incorrect way. There aren't any great solutions that I'm aware of to that, since the "fix" is to validate the correctness of fields that ultimately don't matter to the operation at hand.
It uses the Fermat's little theorem of prime numbers, which was defined in 1640 then proved by Euler almost 100 years after that.
Plus uses the Chinese reminder theorem that was discovered in the 300 CE
What is more crazy is that RSA (or something comparable to that) was discovered in parallel also by another mathematician working for a government agency 4 years prior to the RSA algo
Cocks, Ellis and Williamson at GCHQ: https://www.nsa.gov/History/Cryptologic-History/Historical-F...
An interview with Cocks and Ralph Benjamin: https://www.zdnet.com/article/gchq-pioneers-on-birth-of-publ...
I would say it's more interesting that one-time pad encryption was not invented and used much earlier than 19th century. It has obvious military and intelligence uses and is simple enough to be executed by hand.
People can get shockingly good at that kind of thing with enough practice.
RSA doesn't largely depends on the existence of computer, it could've been used "by hand" using the math behind it. The reason why was not is because, prior to computer, there was not a problem of "sharing" the key (and btw Nazi knew that a single key was weak, that's why they'd change it everyday to encrypt the communication with enigma)
> I would say it's more interesting that one-time pad encryption was not invented and used much earlier than 19th century
That's not true, as I mentioned Cesar's cipher is an example of that, though of course uses a simple key. Radio communications (and of course internet later) is the reason why encryption started to boom on the early 19th century onwards.
Lol. There is a new dude sitting in a castle one sea over. You want to communicate with them. Let’s say you want to agree to attack a third neighbour at the same time. If your message gets intercepted you will be in trouble.
How do you share your secret keys with them? Mind you, you don’t really trust any of your man, and the sea route is treacherous so you don’t fancy risking going in person.
Sharing keys is a problem old as time.
Why didn't people came up with a manual "RSA" before. Since the math is 400 years old.
We actually did that in university; the public key we used was something like 91 (not hard to factor). Wikipedia has an example with 3233, and that's already very cumbersome: https://en.wikipedia.org/wiki/RSA_(cryptosystem)#Example
I wish there was some way to simplify the math to allow doing it by hand. It would be a nice way to check for correctness while computing it offline, and while ensuring dependencies hadn't been compromised to produce a fake public address.
It can be done manually easily
RSA is OTP?
In other words, the "inconvenience" of doing a Caesar cipher by hand is nowhere near comparable as doing an RSA cipher by hand.
If people were able to do that in 15th century by hand I don't see how who really needs it couldn't.
Is just the needs were different, but is not complicated
That story is great - he was a new grad and given it as an exercise by his mentor. He wasn't allowed to write anything down at home so he worked it out entirely in his head that evening.
So not exactly thousands of years back.
That's actively used in some libraries to validate the key (as stated in the link)
Euler just proved what Fermat theorized.
To be fair mathematics was really close for a really long time, but before that generalisation not all of the ingredients were there at the same place at the same time. It might well have been possible for the Chinese or Hindu-Arabic mathematicians to discover Fermat's theorem or perhaps even Lagrange's theorem (which is how I'd prove it from scratch if necessary), but as far as I can tell they did not.
as if that was an argument. We use the wheel for a gazillion o "important and f daily life" applications.
While the wheel has been used from the next day of its invention till today, the Fermat's little theorem had no application outside of pure math for roughly 400 years.
Ubuntu 22.04 for example won't let you SSH into another server using an RSA key unless you configure your OpenSSH client to continue supporting RSA. I noticed this even with an RSA SHA-256 key[0]. GitHub and other git hosting providers are also pushing Ed25519 over RSA for generating new keys.
I would say it's had a good run, and will likely still be in use for decades because there's always going to be systems that can't updated for whatever reasons.
[0]: https://nickjanetakis.com/blog/switching-from-an-rsa-ssh-key...
https://levelup.gitconnected.com/demystifying-ssh-rsa-in-ope...
It's unfortunate that there's a signature algorithm and a key format with the same name, because that definitely leads to confusion in cases like this. But RSA keypairs are fine for now.
Thanks for the clarification, but from the end user's perspective it's all the same in the end?
It translates to "I have an SSH keypair that was generated using RSA as the algorithm and I was able to SSH into my servers when using OpenSSH vX.X.X and now after updating OpenSSH to a newer version I can no longer SSH into the same servers.". In the end it used to work and now it doesn't and the solution is to pick a different algorithm such as Ed25519 or re-configure your OpenSSH client to continue allowing RSA even though the creators of OpenSSH have deprecated it by default.
The vast majority of users will not experience this unless their client is old. I literally dealt with this issue yesterday with one of our lead Developers.
He was using JSch in an older version of dbeaver, couldn't SSH into the new test environments we're validating on Ubuntu 22.04. Turns out to be this exact issue. The solution was to update dbeaver and switch to the new default SSHJ client within it.
Same private key, new client. Problem solved.
I will be using this as leverage to force a company standard change from RSA4096 keys to ed25519. So I am not going to clarify the difference to the Security teams.
Another thing that may get deprecated in the coming years is RSA 1.5 padding, requiring to use PSS padding instead. Again, that doesn’t impact RSA keys, but only the algorithm parameters used with RSA.
In the context of TLS/SSH, it just means that client and server have to negotiate the RSA-based algorithm variant they both support and both deem to be safe, using the existing RSA keys.
> or re-configure your OpenSSH client to continue allowing RSA even though the creators of OpenSSH have deprecated it by default
^ this is not correct. RSA is not deprecated by default. A specific signature algorithm used with RSA keys is deprecated. But yes, if your server is running a very old version of OpenSSH, that may be the only signature algorithm it supports.
I'm not sure there are any distro releases running versions of OpenSSH this old that aren't EOL though, so really you should probably update your servers, which would also take care of this. (I suppose if you're running CentOS 7 or RHEL 7 you still get security updates for the next 1.5 years at least, but it's no longer actively supported.)
Is not a "bad design", is a feature that allows to include or exclude derived values, if you do so then the original values are used and the encoded private key would be smaller.
The reason why they'd keep the original values when the derived are available might have to do with backwards compatibility and/or legacy constraint
Where does it say or imply that? When I read the answer it sounds like using them is optional but generating them is mandatory.
> *at least for OpenSSH, they do not have to be present: setting p=q=1 and dp=dq=qinv=0 makes the implementation use n and d.
https://crypto.stackexchange.com/questions/31807/why-does-my...
Could this be abused in any way?
What implementations use the legacy approach of using $d$?
Do TLS keys/x509 express the same phenomenon?
See this brand-new paper which briefly discusses the desired property of "non-malleability": https://www.fstar-lang.org/papers/asn1star.pdf
"DER are designed to ensure that every value of a given ASN.1 type has a distinct, canonical wire format representation. That is, DER formats are intended to be unambiguous and non-malleable, in the sense that given a bit string b that encodes a value v, every parser will yield back o, whereas changing any bit in b either produces an invalid representation or yields a distinct value o' + v. These properties are particularly important in security applications, inasmuch as they depend on values u but apply cryptographic protection only on binary formats b."
It is possible to have an RSAPrivateKey structure where the privateExponent field is inconsistent with the exponent1/exponent2 fields, effectively representing two different private keys, and where one library uses the one and another uses the other. However, that just means that only one of the two would work with the given public key.
That can be exploited only insofar as it will break interoperability depending on which library is used. In addition, an attacker would need access to the private key in order to create the inconsistent values, or would need to install a key creation software producing such inconsistent values, in which case the attacker probably can already do much worse.
> With this optimization, the values of n, e and d are not required
https://cvsweb.openbsd.org/src/usr.bin/ssh/PROTOCOL.key?anno...
Posted here because SSH algorithms are a moving target.
https://github.com/jtesta/ssh-audit/tree/e50ac5c84d46e902e02...