3

When calling openssl_get_cipher_methods we get several cipher methods.

I noticed that some of these method have same prefix like AES-256-(CBC|CFB|CFB1) or IDEA-(CBC|CFB).

My question is which one to choose: which is the most safe and secure for encrypting a string or large file? What process should I follow to encrypt data correctly?

Maarten Bodewes
  • 96,351
  • 14
  • 169
  • 323
Sidson AIdson
  • 43
  • 1
  • 3

1 Answers1

1

IDEA is a block cipher with a 128 bit key size and a 64 bit block size. AES-256 is a more modern block cipher with a key size of 256 bits and a block size of 128 bits. For large files AES certainly has the advantage.

As for the modes of operation: CBC, CFB and CFB1 are all non-authenticated modes of operation. CFB1 is an older format that is mainly useful for its error propagation properties. That's not often considered an important factor anymore. So lets focus on CBC and CFB. CFB is probably the more secure choice. It's a streaming mode of operation which doesn't require a randomized IV (just a unique IV). Because it is a streaming mode it also doesn't require a padding mode.

So AES-CFB is probably the best of the choices above. It certainly can be secure when correctly used within a protocol. But in the end the cipher and mode of operation cannot protect a broken security system. So how safe depends on the details of your protocol.

Maarten Bodewes
  • 96,351
  • 14
  • 169
  • 323