RSA - Weak Keys

Page content

Intro

Did you ever try to generate a small RSA Key ? Today, you should go with 3072 oder 4096 Bits, or use ECC.

With current Versions of OpenSSL, you can’t generate Key Smaller than 512 Bit.

128 Bit Key

import rsa

pubkey,privkey = rsa.newkeys(128)
print(pubkey.save_pkcs1('PEM').decode('UTF-8'))
print(privkey.save_pkcs1('PEM').decode('UTF-8'))

32 Bit Key

import rsa

pubkey,privkey = rsa.newkeys(32)
print(pubkey.save_pkcs1('PEM').decode('UTF-8'))
print(privkey.save_pkcs1('PEM').decode('UTF-8'))

16 Bit Key

import rsa

pubkey,privkey = rsa.newkeys(16)
print(pubkey.save_pkcs1('PEM').decode('UTF-8'))
print(privkey.save_pkcs1('PEM').decode('UTF-8'))

sample with 16Bit RSA Key

-----BEGIN RSA PUBLIC KEY-----
MAoCAwCVLwIDAQAB
-----END RSA PUBLIC KEY-----

-----BEGIN RSA PRIVATE KEY-----
MCQCAQACAwCVLwIDAQABAgMAjCECAgDTAgIAtQICAK0CATUCAQc=
-----END RSA PRIVATE KEY-----

Keep in mind that a key size of 128 bits is quite small and may not be considered secure for many applications. In practice, you might want to use larger key sizes, such as 2048 or 4096 bits, for better security.


Any Comments ?

sha256: c3aa5cbdb0d8801251ecb7cae260fbdaa75623a4dc32e2ec04840fbec28ef284