Is one more secure than the other?
id_rsa.pub and id_dsa.pub are the public keys for id_rsa and id_dsa.
If you are asking in relation to SSH, id_rsa is an RSA key and can be used with the SSH protocol 1 or 2, whereas id_dsa is a DSA key and can only be used with SSH protocol 2. Both are very secure, but DSA does seem to be the standard these days (assuming all your clients/servers support SSH 2).
Update: Since this was written DSA has been shown to be insecure. More information available in the answer below.
SSH uses public/private key pairs, so
id_rsa is your RSA private key (based on prime numbers), which is more secure than your id_dsa DSA private key (based on exponents). Keep your private keys safe and share your id_rsa.pub and id_dsa.pub public keys broadly.
DSA is insecure
DSA has a guessable parameter if your computer's random number generator is sub par, which will reveal your secret key. ECDSA (DSA's elliptical curve upgrade) is similarly vulnerable. Even with good random numbers, DSA has other strength concerns/🎬 (these are also found in Diffie-Hellman).
OpenSSH creates insecure 1024 bit keys(workaround) and now disables DSA by default.
Prefer Ed25519
Elliptic curve cryptography offers increased complexity with smaller key sizes. Ed25519 (based on the complexity of plane-modeled elliptical curves) is the preferred implementation due to its assumed lack of meddling (leaked documents show that the US NSA weakens crypto standards).
Ed25519 was introduced in OpenSSH 6.5 (2014-01-30) and GnuPG 2.1 (2014-11-06) and became the default ("first-preference") in OpenSSH 8.5 (2021-03-03). Older systems may not yet accept Ed25519, but the list of supported implementations has been growing steadily.
Use RSA with 4096 bits when Ed25519 is unavailable
RSA key sizes of 4096 bits should have comparable complexity to Ed25519.
Ed25519 is still preferred to RSA due to a worry that RSA may be vulnerable to the same strength concerns as DSA, though applying that exploit to RSA is expected to be considerably harder.
rsa is considered more secure.
Not anymore (May 2020, ten years later), with OpenSSH 8.2, as reported by Julio
Future deprecation notice
It is now possible1 to perform chosen-prefix attacks against the SHA-1 hash algorithm for less than USD$50K.
For this reason, we will be disabling the "ssh-rsa" public key signature algorithm that depends on SHA-1 by default in a near-future release.
(See "SHA-1 is a Shambles: First Chosen-Prefix Collision on SHA-1 and Application to the PGP Web of Trust" Leurent, G and Peyrin, T (2020) )
This algorithm is unfortunately still used widely despite the existence of better alternatives, being the only remaining public key signature algorithm specified by the original SSH RFCs.
The better alternatives include:
The RFC8332 RSA SHA-2 signature algorithms rsa-sha2-256/512.
These algorithms have the advantage of using the same key type as "ssh-rsa", but use the safe SHA-2 hash algorithms.
These have been supported since OpenSSH 7.2 and are already used by default if the client and server support them.
The ssh-ed25519 signature algorithm.
It has been supported in OpenSSH since release 6.5.
The RFC5656 ECDSA algorithms: ecdsa-sha2-nistp256/384/521.
These have been supported by OpenSSH since release 5.7.
To check whether a server is using the weak ssh-rsa public key algorithm for host authentication, try to connect to it after removing the ssh-rsa algorithm from ssh(1)'s allowed list:
ssh -oHostKeyAlgorithms=-ssh-rsa user#host
If the host key verification fails and no other supported host key types are available, the server software on that host should be upgraded.
A future release of OpenSSH will enable UpdateHostKeys by default to allow the client to automatically migrate to better algorithms.
Users may consider enabling this option manually.
Yes, rsa is considered more secure.
In October 2014, OpenSSH 7 (the default with Ubuntu 16.04LTS) has disabled default support for DSA. Take this as a strong sign that DSA is not a recommended method anymore.
https://www.gentoo.org/support/news-items/2015-08-13-openssh-weak-keys.html
One uses DSA and one uses RSA.
Related
I am planning to create an application that has to be able to securely (that is, encrypted) send messages between clients. These messages may include images and videos (up to 50MB in size). Due to how public-key cryptography works, the encryption process has to be run once for each public key.
For these reasons, I am looking for an algorithm that can encrypt the media fairly quickly on modern devices (eg. mid-level smartphones).
I am asking the question because all algorithms I came across (Blowfish and RSA for example) have a relatively small payload limit, which means that even an image will not fit into it.
Don't roll your own protocol. You're thinking about this at a far too low level. People who know exactly what they're doing have a hard time writing secure code. You don't even know where to start, so you don't stand a chance of getting it right.
If you can establish a direct connection between the two endpoints, use TLS. If you can't establish a direct connection, consider using TLS and relaying the encrypted packets; if that's impractical, use Signal. TLS is ubiquitous; your operating system(s) probably come with an implementation in their default installation. Signal is less ubiquitous, so you'll probably have to embed a library. Make sure to keep up with updates to this library. And once again, don't implement your own library.
Under the hood, all systems that use public-key cryptography to store or transmit more than a few bytes of data use hybrid cryptography. Public-key cryptography is used to establish a symmetric key and authenticate the data, and symmetric cryptography does the heavy lifting.
For example, RSA can be used to encrypt a symmetric key. It's pretty difficult to get it right in practice, however. It's also slower than more modern methods that use elliptic-curve cryptography. TLS can use RSA encryption, but this is deprecated. TLS preferably uses an (elliptic curve) Diffie-Hellman key exchange and an RSA or (EC)DSA signature to set up the secure connection. If you'd like more explanations about how TLS works, read an overview of the protocol, a history of problems and how they were resolved, and an explanation of why RSA encryption is problematic.
Note that Blowfish has been obsolete for a while. If you ever need to choose a specific symmetric cryptosystem — which usually means you're doing it wrong — pick AES-GCM, AES-CCM or ChaCha20-Poly1305.
You are correct about the input size for RSA. In general, for any public key cryptography, the input size of limited and as opposed to your needs, it's quite a bit slower than what you need. Public key cryptography is usually used to share small pieces of data.
For example, in the TLS implementation using RSA (TLS_RSA_WITH_AES_128_GCM_SHA256), the RSA step is used to share a symmetric key, generally, AES, between 2 parties and then all the heavy lifting is done by AES.
What you need is a symmetric encryption algorithm. You can use AES (key sizes of 128, 192 or even 256) to encrypt your images which can be of any size. AES is a block cipher and, using a suitable block cipher mode, theoretically does not have an input limit to it. AES-128 is a fairly standard NIST approved (FIPS 197) symmetric encryption scheme, so it should be safe, but you can always go for a higher key size, say 256.
Since, you have the security of the algorithm defined, we can now talk about the speed.
RSA:
$ openssl speed rsa2048
Doing 2048 bit private rsa's for 10s: 296 2048 bit private RSA's in 10.00s
Doing 2048 bit public rsa's for 10s: 6171 2048 bit public RSA's in 9.99s
LibreSSL 2.6.5
built on: date not available
options:bn(64,64) rc4(ptr,int) des(idx,cisc,16,int) aes(partial) blowfish(idx)
compiler: information not available
sign verify sign/s verify/s
rsa 2048 bits 0.033784s 0.001619s 29.6 617.7
AES-128 in GCM mode
$ openssl speed aes-128-gcm
Doing aes-128 gcm for 3s on 16 size blocks: 3778792 aes-128 gcm's in 2.99s
Doing aes-128 gcm for 3s on 64 size blocks: 1611239 aes-128 gcm's in 3.00s
Doing aes-128 gcm for 3s on 256 size blocks: 485243 aes-128 gcm's in 2.99s
Doing aes-128 gcm for 3s on 1024 size blocks: 125054 aes-128 gcm's in 2.99s
Doing aes-128 gcm for 3s on 8192 size blocks: 15366 aes-128 gcm's in 2.96s
LibreSSL 2.6.5
built on: date not available
options:bn(64,64) rc4(ptr,int) des(idx,cisc,16,int) aes(partial) blowfish(idx)
compiler: information not available
The 'numbers' are in 1000s of bytes per second processed.
type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes
aes-128 gcm 20220.96k 34373.10k 41545.89k 42827.86k 42526.44k
You can see the difference, how AES can blow away RSA in the dust with respect to speed. Symmetric Encryption algorithms are inherently faster due to its design. Asymmetric algorithms use math operations on huge numbers and primes which are slower.
Since AES is so popular, CPU manufacturers started implementing special instructions to make AES computations more and more native (AES-NI). So AES will be faster on almost all popular CPUs.
A small note on security between RSA and AES, although it's like comparing apples to oranges.
RSA2048 offers only 112 bits of security whereas AES128 offers 128 bits of security (ref: aes-vs-rsa)
Another challenge in the above problem would be key management. How would you safely manage the keys? If the keys are to be ephemeral, i.e. session based or one key per use, then you can use RSA to exchange symmetric keys and then perform the encryption. This would guarantee perfect forward secrecy. If you want persistent keys, then obviously there are much more elaborate methods to do that which is out of scope of this question.
I am trying to use asymmetric encryption to encrypt firmware. The bootloader will decrypt and update the flash. This is on a embedded device with 32 bit CPU executing at 60MHz.
I want to use ECC due to its varies advantages. I am new to encryption and my understanding os ECC as implemented in ECIES is to use ECC for the key generation and use AES for actual data encryption. Due to code and ram size, I cannot support multiple encryption algorithms.
Is there a implementation of ECC that can be used just like AES. All I am looking for is to use a "Private key" to encrypt firmware and the bootloader uses "Public Key" to decrypt it.
Thanks.
I'm not sure that you completely understand what ECIES consists of:
http://en.wikipedia.org/wiki/Integrated_Encryption_Scheme
That's quite a bit of work, and it requires a whole lot of primitives, including at least one symmetric primitive, it seems to me. That might as well be AES.
Let's start from the last sentence of the question:
All I am looking for is to use a "Private key" to encrypt firmware and the bootloader uses "Public Key" to decrypt it.
There's some confusion in terminology here. Private keys are used to decrypt (or sign) and public keys are used to encrypt (or verify). If I understand correctly, what you want is for the bootloader to verify a signature on the firmware so that only a firmware that was properly signed by yourself will be accepted by the bootloader.
There are various asymmetric signature schemes which can be used for this purpose, including some which are based on eliptic curve cryptography. For example you could use the OpenSSL implementation of ECDSA (see http://www.openssl.org/docs/crypto/ecdsa.html).
I'm afraid there's not enough information in the question to properly choose the best signature scheme (and possibly an encryption scheme as well if there is a need to keep the firmware secret). In any case, good cryptography is not enough to make a system secure and other considerations such as secure implementation are no less important.
If this is is something that is important for you to protect and that you are worried that hackers may try to break, I would strongly advise procuring the services of a security professional. Using cryptography correctly is a very tricky business that requires a full understanding of the system - otherwise you may find yourself in a situation like this
If you look for "authentication" you have to use asymmetric algorithm like EC, this usually done because if the user or process want to update the "firmware" he should identify him self to the bootloader by his "signature" to check who request this update.
After that is done, the bootloader will load the symmetric key from a secure memory to decrypt what you want to do.
So, you have a symmetric key for encryption (AES), and asymmetric two keys for authentication (=Who are you?).
Note: there is no advantages of EC on 32 bit CPU executing at 60MHz for Encryption, unless your application need asymmetric for Encryption NOT authentication, this happen due to line between the user and bootloader is not secure.
Therefore, you could use bootloader's "public key" to encrypt firmware and the bootloader uses its "private Key" to decrypt it, however, the implementation cost a lot due to the high computing for asymmetric algorithm.
Look for "lightweight cryptography", it is typical for your application.
Introduction:
For my personal webserver I have setup apache with a self signed certificate to enable TLS security to learn and test.
I have this line in virtualhost:
SSLProtocol -all -SSLv3 +TLSv1
SSLCipherSuite TLSv1:+HIGH:!MEDIUM
With firefox, I get Camellia-256 encrypted connection, and with opera I get TLS v1.0 256 bit AES (1024 bit DHE_RSA/SHA) with the same config in same server.
That leads me to question, which is stronger, AES, or Camellia?
I noticed that if I disable camellia with SSLCipherSuite TLSv1:+HIGH:!MEDIUM:!CAMELLIA then, firefox takes the same suite than opera.
In my config, I also try to disable all SSL versions to enable only TLS (advise needed if I didn't do so correctly), but the original question still stands: Which one should be stronger?
I would be more worried about the fact that your SSL encryption is not secure because you are only using 1024 bit asymmetric encryption to protect your keys.
Adi Shamir (the 'S' in RSA) recommended moving to 2048 bit keys back in 2006, even the american standards institute (NIST) have made 2048 bit a required minimum strength since January 2011 (see NIST SP800-57 for recommended minumum key strengths -- this states 2048 bit for both RSA and DH/el-gamal).
In short, make sure your RSA encryption is strong enough first, as it is used to protect the symmetric keys (AES/Camellia). Never rely on a key which is protected by a weaker key (this is like using a secure 256 bit random WPA 2 key on a wireless access point and then trusting it to WPS which will reveal in in a few hours!)
Even if this is a test system, learn to use crypto the way you intend to go forward; do not compromise on certificate key strength (all CAs these days should reject 1024 bit requests or CSRs using MD5 on sight, if not don't use them; create your own test certs as you would a real request, and don't use default key sizes).
Difficult to compare strengths, both have received cryptographic analysis (AES more publicly) and are adequate for securing data.
At the risk of repeating myself, I’d be more worried about the 1024 bits used to secure the key negotiation.
It's hard to judge the strength of these algorithms. Camellia is considered roughly equivalent to AES in security (source). In any case, the difference probably won't matter. Either algorithm is secure enough to make your data channel no longer be the weakest link in your system, so you don't need to bother modifying any configuration.
The OpenSSL cipherlist TLSv1:+HIGH is a really bad choice. The "+something" notation means move all the ciphers that match "something" to the end of the list.
Therefore, you're using HIGH only as a last resort, with anything that's not HIGH preferred.
A much better choice is "DEFAULT:!MEDIUM:!LOW:!EXPORT:+3DES", which starts with sensible defaults, removes MEDIUM, LOW and EXPORT, and uses 3DES last (which it probably is anyway, but on some systems it comes before AES128 because it may be considered to be 168-bit strong).
We are putting an HTTP RESTful interface into an embedded platform of ours. The hardware is too limited to support SSL, but we do use AES encryption for other things.
I'm thinking of using AES with a shared key to encrypt the data. Is there anything else that is at least a somewhat standard way of encrypting via HTTP?
The standard way of encrypting HTTP is SSL (or its successor TLS, nowadays) (this is then known as HTTPS).
As GregS asked in a comment, in what way is your platform too limited for SSL, but still allows AES? Does it have not enough computing power/memory to do modular exponentiation (which is used in RSA, DSA, Diffie-Hellman)?
Then you might be able to use a pre-shared key version of TLS. RFC 4279 defines cipher suites with pre-shared key authentication, where the TLS_PSK_WITH_AES_128_CBC_SHA looks like if needs only AES and SHA-1, no modular exponentiation.
Of course, you shouldn't use this if there is the danger that an attacker can get the secret (e.g. by cracking your device), since this allows also to read all previously registered connections (in contrast to Diffie-Hellman, which provides a new session key for each session).
Found this gem: Diffie-Hellman Key Exchange in 10 lines of C
http://www.cypherspace.org/rsa/dh-in-C.html
How does public key encryption work, using a private and public/public key to decrypt/encrypt? What does it mean for the key to be 256 bits? How is it decrypted? Is there a language for writing encryption programs or is any language fine?
In brief:
the data is encrypted using symmetric algorithm and a random symmetric key. Then the random key is encrypted using public asymmetric key. The encrypted random key is stored together with the encrypted data. To decrypt the data one uses private asymmetric key to decrypt the stored random key, then the decrypted random key is used to decrypt the data.
256-bit is the length of the key. However, it has dramatically different meaning for symmetric and asymmetric keys. For symmetric keys 256 bits are a very strong key (you can have even longer keys with AES 384 or AES 512 where the numbers specify the key length the algorithm operates with). For asymmetric algorithms 256 bits is nothing, and comparable strength is 2048 bits.
Public key encryption can be implemented using any language, that supports math operations and arrays. However, doing this is reinventing the wheels. There exists a number of cross-platform libraries for PKI: open-source OpenSSL for C++, BouncyCastle for Java and some more. Our company offers a supported and maintained SecureBlackbox product for .NET, Windows and Linux (MacOS X version to come soon).
Also there's a couple of books about PKI that we recommend to all our users. RSA's guide is an easy reading (but very useful) and the second book goes into deeper details.
For the first question see http://en.wikipedia.org/wiki/Public-key_cryptography
you can google for more details.
256 bit key means we are using key of length 256. you will understand that after more reading about answer of first question.
Many language have inbuilt or third party api to implement these calls.