1
$\begingroup$

I am working on a cryptography application which is to be used in my country. I tried looking up to see if there are any algorithms that support the Cyrillic alphabet, but I found none. Do you know of any? Can mainstream algorithms (Like AES) work with Cyrillic letters?

$\endgroup$

3 Answers 3

5
$\begingroup$

Can AES work with Cyrillic letters?

No, AES is a block cipher that can only operate on blocks of 16 bytes. AES may be securily used within a mode of operation to operate on plaintext of any bit/byte size.

So you only have to encode your Cyrillic letters to any bit or byte encoding. Unicode - which designates code points to a huge range of characters - specifies the most likely candicate: UTF-8 encoding.

UTF-8 is identical to ASCII for any code points up to 127. After that it uses more bytes depending on the value of the code point; higher code points require more bytes.


So you follow these steps for encryption:

  • character encode your Cyrillic text in UTF-8, results in the plaintext
  • encrypt the plaintext, results in the ciphertext
  • possibly encode the ciphertext using base 64, resulting in encoded ciphertext

and for decryption:

  • possibly decode the encoded ciphertext using base 64, resulting in the (binary) ciphertext
  • decrypt the ciphertext, results in the plaintext
  • character decode the plaintext, results in your Cyrillic text

Notes:

  • for modern ciphers, plaintext and ciphertext are binary despite their name;
  • character encoding (e.g. UTF-8) converts strings of characters to bytes;
  • encoding (e.g. base 64) converts bytes to printable characters;
  • for larger text you may want to look into streaming, all of the above can be accomplished using streams as well;
  • if you want to send something you also need an authentication tag (MAC or HMAC) over the ciphertext.
$\endgroup$
0
11
$\begingroup$

Modern cryptographic algorithms are specified in terms of bytes or even bits, not characters. Whether the data you encrypt happens to represent latin or cyrillic letters or pictures or audio data or anything else does not matter at all to an encryption algorithm; all it ever sees is a bunch of bytes.

What this means in practice is: You have to fix some encoding (UTF-8 is very common nowadays) to translate your characters to a string of bytes which can then be processed by any cryptographic implementation as usual.

$\endgroup$
2
  • $\begingroup$ So does that mean that I can convert the bytes to UTF-8 and work with them just as I would with ASCII? Would I end up with the same result (as my code already works with ASCII bytes)? For example, let's take AES, wouldn't UTF-8 characters be too big to have representations in the S-box matrix? $\endgroup$
    – Elhitch
    Feb 3, 2016 at 9:51
  • 5
    $\begingroup$ @Elhitch Your terminology seems a bit off: UTF-8 encodes Unicode characters to bytes. AES encrypts bytes to bytes. If you encode your Unicode string to a string of bytes using UTF-8 before applying AES, that should work, unless you do strange things to the bytes besides encrypting. Indeed, the set of Unicode characters is too large to be encoded into a single byte per character: That is why UTF-8 encodes most non-ASCII characters to more than one single byte. For instance, UTF-8 encodes the cyrillic character ф to the bytes d1 84. $\endgroup$
    – yyyyyyy
    Feb 3, 2016 at 10:12
1
$\begingroup$

Modern cryptographic algorithms work on strings of bits, independently of how such strings are interpreted in any specific application.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.