pradeep1991singh / cordova-plugin-secure-key-store

Cordova plugin for securely saving keys, passwords or strings on devices.
MIT License
25 stars 29 forks source link

Max entry size #24

Open didkivskyy opened 3 years ago

didkivskyy commented 3 years ago

What is the maximum size for a single key to be successfully stored? I've been experimenting with longer strings (up to 1K characters) and was surprised that it stores the keys of such length without errors. But when getting back these keys strings come empty. I realize this really depends on hardware limitations but I could not find any documented max size. Any info?

It would also be nice to have some kind of error/warning if the key is too large and is not going to be saved well.

Many thanks!

fangornoftheforest commented 2 years ago

Maximum key size for RSA is 256 bytes

didkivskyy commented 2 years ago

Thanks for your answer. This is interesting. At least Android Keystore specification mentions different key sizes for different cryptosystems:

EC - 224, 256, 384, 521
RSA - 512, 768, 1024, 2048, 3072, 4096

Furthermore for more recent OS versions (Android 9 +) hardware security is supported with:

RSA 2048
AES 128 and 256
ECDSA P-256
HMAC-SHA256 (supports key sizes between 8 bytes and 64 bytes, inclusive)
Triple DES 168

This makes sense as since 2015 minimum recommended RSA and DSA key is 2048.

Maybe it is worth mentioning where this limitation comes from: the library inself or externally.

Thanks.