What is a cipher?

1

Several times I find some questions related to numbers here in SO en . However I did not find any definition of it. So,

  • What would be a cipher and what is its function?
  • I saw that there are several types. Are they related to encryption as a hash or as encoding, usually?
  • Can these be used in any language?
asked by anonymous 12.07.2017 / 15:48

1 answer

0

I believe that "Cipher" is a very generic term, but refers to the algorithm used for encryption and decryption of the text, that is, how the text-plane will become a ciphertext and how it will be deciphered.

A cipher can be classified by two types:

  • Cipher Style:
    • Block Cipher (CBC EX)
    • Stream Cipher (EX CTR, ChaCha)

Historically they can cite other types of cipher, such as replacement cipher and etc ...

  • Key Style:
    • Symmetric Cipher (Private Key Encryption) (EX: DES, AES)
    • Asymmetric Cipher (Public Key Encryption) (EX: RSA)

There may be more sorts of sorts, so some figures such as GCM and CCM can also guarantee confidentiality, integrity and authenticity. While others such as CBC only confidentiality, requiring you to use some other type of authentication externally, such as EtM via HMAC.

  

What would be a cipher and what is its function?

The cipher is the algorithm that will be used to generate the ciphertext and so that it can decrypt the ciphertext so that we can read it. The CBC and CTR cipher are different, both are used for AES and both generate ciphertext and decrypt the text.

The cipher is how the text will be encrypted.

  

I saw that there are several types. Are they related to encryption as a hash or as encoding, usually?

Neither. The figure is related to encryption, the generation of encrypted texts.

Encoding does not involve a key, Base64 is just an "alternate representation", just as you can use Hexadecimal or Decimal.

You can encode a ciphertext, for example in OpenPGP there is the "ascii-armored" that converts a binary signature to ASCII, allowing better visualization and distribution, for example.

Since the hash does not have much here, it is not reversible and therefore does not use any ciphers. It is also known as a "cryptographic summary", so you may find some books. It is made so that N input bytes always result in a fixed-size output, in summary it is used to ensure integrity. Just to complement the case, there are also Keyed-Hash , which are hashes that have keys, such as HMAC.

#

  

Can these be used in any language?

Used can be used, but most likely you will end up using a library written in C. For example OpenSSL and Libsodium (and many others) are written in C, C is almost a rule for encryption.

However several languages implement cryptographic libraries, in PHP for example, it is possible to use asymmetric cryptography using OpenSSL via openssl_public_encrypt() or using Libsodium via crypto_box() . Now, neither of the two libraries are written in PHP, you're using something written in C.

    
21.07.2017 / 22:36