0
$\begingroup$

Let us say that we take a sequence of the integers from a to a+n-1: (a, a+1, a+2, a+n-1), where a and n are picked arbitrarily and have no lower or upper bounds on either, except that a < n, and we apply AES encryption to that sequence, one element at a time, utilizing the same key for each element in the sequence.

Assumption is that we encode the resulting ciphered values as Base64 or some other encoding to produce strings.

Would the resulting set of encrypted strings have any, irrespective of how infinitesimally small, chance for collisions?

$\endgroup$
3
$\begingroup$

Since any cipher must be able to decrypt every message that it encrypts, it follows that, given a fixed key, any cipher must be an injective function:

In mathematics, an injective function or injection or one-to-one function is a function that preserves distinctness: it never maps distinct elements of its domain to the same element of its codomain. In other words, every element of the function's codomain is the image of at most one element of its domain.

Or graphically, think of X as plaintexts and Y as ciphertexts:

Injective function (but not surjective or bijective)

Although often ciphers are more than just injective—they're also bijective:

Bijection

And permutations as well: X and Y are normally the same set. E.g., for AES, X and Y are the sets of 128-bit strings.

$\endgroup$
4
  • 1
    $\begingroup$ Encryption schemes are generally not bijective (there are generally invalid ciphertexts). In the case of AES, this would depend on which mode of operation and padding schemes are used. $\endgroup$ – fkraiem Jul 15 '16 at 2:18
  • $\begingroup$ @fkraiem Right. Fixed. $\endgroup$ – Luis Casillas Jul 15 '16 at 2:54
  • 1
    $\begingroup$ to be fair, the description in the question implied that ECB mode was used, in which case bijectivity would hold. $\endgroup$ – kodlu Jul 15 '16 at 4:02
  • $\begingroup$ Yes indeed it would be bijective. The purpose of this wouldn't be to encrypt the integers, but rather to generate absolutely unique identifiers for a single entity. ECB mode is bad for encryption, but doesn't much matter and is quite perfect for the job. :) $\endgroup$ – zealoushacker Jul 15 '16 at 4:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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