Cryptography · Topic 2 of 4
Symmetric and Asymmetric Algorithms
Compare symmetric ciphers DES, 3DES and AES with asymmetric algorithms RSA, Diffie Hellman and elliptic curves, plus hash functions and weak choices.
- 5 min
- AES is the standard symmetric cipher, with 128, 192 or 256 bit keys.
- DES has a 56 bit key and is broken. 3DES is slow and outdated.
- RSA is used for signatures and for encrypting small data. Keys of 2048 bits or more are used.
What it is
An algorithm is the specific procedure that does the encryption, and each one has strengths, limits and a typical job.
The previous page explained the two families. This page names the algorithms that you will meet in RouterOS and in the exam.
You do not need the mathematics. You need to know which algorithm belongs to which family, what it is used for, and which ones are no longer safe.
How it works
Symmetric algorithms protect the data, asymmetric algorithms handle keys and identity, and hashes check integrity.
Symmetric algorithms
| Algorithm | Block size and key | Status |
|---|---|---|
| DES | 64 bit blocks, 56 bit key | Broken, the key is too short |
| 3DES | Applies DES three times | Slow and no longer recommended |
| AES | 128 bit blocks, keys of 128, 192 or 256 bits | The standard choice today |
| Blowfish | 64 bit blocks, variable key | Older, mostly replaced by AES |
| RC4 | Stream cipher | Weak and should not be used |
AES is the one to remember. A larger key gives a larger safety margin, and a 256 bit key is the strongest of the three sizes.
A block cipher needs a mode of operation. CBC chains each block to the previous one. A newer mode called GCM also gives integrity checking in the same step.
Asymmetric algorithms
| Algorithm | Main use |
|---|---|
| RSA | Encryption of small data, and digital signatures |
| Diffie Hellman | Agreeing a shared secret over an open network |
| DSA and ECDSA | Digital signatures |
| Elliptic curve cryptography | The same jobs as RSA with much shorter keys |
RSA relies on the difficulty of factoring large numbers. Keys of 2048 bits or more are used today. Shorter keys are no longer considered safe.
Diffie Hellman does not encrypt anything. Two parties exchange public values and each calculates the same secret.
An eavesdropper who sees the public values cannot work out the secret. The group sets the size of the numbers, and a bigger group is stronger.
Elliptic curve methods reach the same strength as RSA with far smaller keys. This saves processing power, which helps on small devices.
Perfect forward secrecy
Without PFS, new data keys can be derived from secrets that were set up earlier. If an attacker steals that long term secret, recorded traffic can be opened.
Perfect forward secrecy, or PFS, makes a new Diffie Hellman exchange for each new set of keys. Stealing the long term key then does not reveal old sessions. In IPsec, PFS is controlled by the group chosen in the proposal.
Hash algorithms
| Algorithm | Output size | Status |
|---|---|---|
| MD5 | 128 bits | Broken for security use |
| SHA 1 | 160 bits | Weak, avoid in new designs |
| SHA 2 family, such as SHA 256 | 256 bits and more | Recommended |
A keyed hash, or HMAC, mixes a secret key into the hash. It proves that the sender knows the key as well as proving that the data is unchanged.
Choosing in RouterOS
IPsec shows all these choices in two places. The profile controls the first phase between the peers, and the proposal controls the protection of the data.
/ip ipsec profile add name=strong hash-algorithm=sha256 enc-algorithm=aes-256 dh-group=modp2048
/ip ipsec proposal add name=strong-data auth-algorithms=sha256 enc-algorithms=aes-256-cbc pfs-group=modp2048
Profiles replace the older phase 1 proposal settings in newer 6.x releases and in RouterOS 7. The dh-group setting sets the Diffie Hellman group, and pfs-group sets the group used for PFS on the data keys. The value none switches PFS off. Both peers must offer a matching choice, or the tunnel does not come up.
A secure default is AES for encryption, SHA 256 or better for hashing, and a Diffie Hellman group of 2048 bits or more.
What to remember for the exam
Eight facts cover the algorithms.
- AES is the standard symmetric cipher, with 128, 192 or 256 bit keys.
- DES has a 56 bit key and is broken. 3DES is slow and outdated.
- RSA is used for signatures and for encrypting small data. Keys of 2048 bits or more are used.
- Diffie Hellman agrees a shared secret and does not encrypt data itself.
- Elliptic curve methods give the same strength with shorter keys.
- MD5 and SHA 1 are weak. The SHA 2 family is recommended.
- An HMAC is a hash with a secret key mixed in.
- PFS makes a new key exchange so that a stolen long term key cannot open old sessions.
Common mistakes
Four mistakes appear on this topic.
Saying that Diffie Hellman encrypts data. It only agrees a secret. A symmetric cipher then protects the data.
Using MD5 or SHA 1 for new integrity checks. Both are weak, so choose SHA 2.
Thinking a longer RSA key is as fast as a short one. Bigger keys cost more processing power.
Mismatching algorithms between peers. If one side offers only AES and the other only 3DES, there is no agreement and no tunnel.
Do not choose DES, RC4 or MD5 just because an old device supports them. Upgrade the device or isolate it.
Check yourself
Work through these three questions.
Which symmetric cipher is the standard choice today, and which key sizes does it use?
AES is the standard choice. It uses keys of 128, 192 or 256 bits.
What does Diffie Hellman do?
It lets two parties agree a shared secret over an open network. It does not encrypt data itself.
Why do the two ends of an IPsec tunnel need matching algorithms?
They must agree on the same encryption, hash and group. If there is no match, the tunnel does not come up.
Topic 2 of 4 in Cryptography
Test yourself on Cryptography
The full MikroTik MTCSE question bank has 446 questions, with timed practice exams and an explanation for every answer.
This study guide is independent and is not affiliated with, endorsed by, or sponsored by MikroTik. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.