WOLFRAM NOTEBOOK

Authentication and Cryptography

Authentication: Reliably Identifying an Entity

Authentication: the process or action of verifying the identity of a user or process.
By extension, the process to associate a computer program with a person or a company (an entity).

Example: Usernames and Passwords

When authenticating a user, a machine or a website compares the password entered by the user with the one that it already knows.

Password Storage

  • Many early systems (and, unfortunately, some to this day) kept the passwords for all of their accounts in a “password file” that contained the passwords in clear text.
  • Normally, by design, the password storage would only be accessed by an administrator user (root, admin, superuser) and operating system utilities.
  • But under unusual circumstances, caused by software implementation errors or deliberate misuse, the contents of the password storage file almost inevitably can become available to adversaries.
  • Encryption

    Encryption is the process of encoding information.
    Encryption is part of the broader field of Cryptography, which is the practice and study of techniques for secure communication i.e. communication in the presence of an adversary.
    Today, cryptography is used as a tool for informatics, business, finance, politics, human rights—any sector that deals with personal information or requires communication.

    Encrypted Passwords

    Since storing passwords in the clear has clearly proven itself to be a bad idea, one option was to store passwords in an encrypted form instead--store them in a coded form.

    Encryption beyond Passwords

    There is always someone malicious to listen

    Modern communications, especially the Internet, operate under the assumption that the world is hostile and for anything you say there is always someone malicious to listen—the same reason why people would put handwritten letters in an envelope before sending, but scaled for billions of people and devices.
    Cryptography, in turn, is one of the major instruments in the arsenal of information security, a digital protective envelope for communications.

    Communication is not secure

    Today people are used to most of their connections to the web being secure, but that was not always the case. In fact, the HTTP (Hypertext Transfer Protocol), the foundation of data communication over the World Wide Web (WWW), is plaintext. That means all of the data in HTTP requests and responses is sent in the clear, under a risk of all sorts of intrusions and fraud.
    Providing security of communication over computer networks is the continuing challenge of the modern world. With the rise of the internet, cryptography is not only employed in securing communication, but also influences all sorts of daily business.

    How can Cryptography help?

    Cryptography has grown to be not only about encryption anymore, but includes a group of special-purpose algorithms to sustain the wider infrastructure of information security, such as:
  • user and message authentication,
  • protection from illegitimate changes to messages,
  • protection from eavesdropping, etc.
  • Cryptographic Objectives

    What is one trying to achieve by employing cryptographic algorithms in information security?

    Confidentiality

    Authentication

    Data Integrity

    Non-repudiation

    Beyond the Algorithms: Something to Note

    Measuring Security

    What do the words “secure” and “broken” actually mean?

    Practical Security or Computational Security

  • Based on the assumption that the adversary in reality does not have infinite computing resources at hand, but is bounded by the technology of the time and foreseeable future.
  • Computationally secure-- means the expected amount of computation required to break it using the best known methods exceeds the computational resources available.
  • Broken -- if an algorithm exists for an attacker to recover the message, without knowing the key, in a reasonable time frame.
  • Completely broken - If an attacker is able to do so systematically for any key.
  • Practically secure--if it is provably hard for an attacker to recover message or key or any other potentially useful information
  • Ways to break the system

  • Exhaustive key trial: search over all possible keys until the correct one is found is generally referred to as a brute-force attack.
  • Exploitation of system weaknesses, often to select a smaller set of possible keys
  • Brute-Force Difficulty

    The cipher recommended for US government information systems, AES256, provides 256 bits of security strength:
    In[]:=
    key=GenerateSymmetricKey[]
    Out[]=
    SymmetricKey
    Cipher: AES256
    Key size:
    256
    b
    In[]:=
    key["KeySize"]
    Out[]=
    256
    The number of all possible 256-bit long AES keys is:
    In[]:=
    keys=2^key["KeySize"]
    Out[]=
    115792089237316195423570985008687907853269984665640564039457584007913129639936
    The world’s fastest supercomputer has a speed of about:
    In[]:=
    442×10^15
    Out[]=
    442000000000000000
    (442 quadrillion) floating-point operations per second. Standard AES decryption requires around 2000 operations. Thus, the number of keys it could check per second would be:
    In[]:=
    checks=442
    15
    10
    /2000
    Out[]=
    221000000000000
    Which would take the adversary, who was lucky enough to lay hands on this computer, this amount of work:
    In[]:=
    N[UnitConvert[Quantity[keys/checks,"Seconds"],"Years"]]
    Out[]=
    1.66142×
    55
    10
    yr
    In[]:=
    age of the universe in years
    »
    Result
    1.38×
    10
    10
    yr
    Out[]=
    1.38×
    10
    10
    yr

    Exploiting potential weaknesses

  • Unrelated to the key, such as imperfections in software implementations of the algorithm or even careless users.
  • Sometimes such vulnerabilities drastically decrease the difficulty of an attack.
  • Fundamentally, cryptography aims to provide you with a safe that is easy to open with a correct combination, but extremely hard to unseal without.

    How Hard Is Hard?

    Need for Randomness

    Cryptographic applications requires the use of keys of sufficient length and that “look like a random sequence”
    You have seen how much time it would take to brute-force a 256-bit-long randomly generated key.
    The underlying source of randomness that produced the key should not give an adversary a chance to reduce the amount of work required to uncover the key based on the probabilities of some values of the keys being selected more often than others.

    Try Generating Randomness

    Coin Flips

  • Each flip of a fair coin produces 0 or 1 with a probability of exactly 1/2.
  • The flips are independent of each other: the result of any previous coin flip does not affect future coin flips.
  • The unbiased coin is thus the perfect random bit stream generator, and the value of the next element in the sequence cannot be predicted, regardless of how many times the coin has already been flipped:
  • In[]:=
    RandomChoice
    ,
    Out[]=
    A random bit generator is an algorithm or a physical device that produces a sequence of statistically independent and unbiased binary digits.
    Genuine randomness is extremely rare to come by.

    Random numbers

    Try the following:
    In[]:=
    RandomInteger[10]
    Out[]=
    8
    Now try the following:

    Pseudorandomness

    It is extremely hard to produce truly random bits as quickly and as large as needed. (Some banks or employers will provide “smart cards” that can be used for this)
    For practical cases, pseudorandom number generators are used.
  • A pseudorandom number generator (PRNG) is a deterministic algorithm that takes a truly random seed and expands it into a much longer bit sequence, statistically indistinguishable from a random sequence.
  • The length of the seed should be sufficient for an attempt to search over all possible seeds to be practically impossible.
  • In the generated sequence, the next output should not be predictable from any amount of the previous outputs available to the adversary.
  • Consider this function:
    The “mod” operation means take the remainder when dividing by m.
    On a large scale, the numbers produced do look as if they were uniformly distributed and random, even though you know they were computed using a deterministic algorithm.

    A “Good” Random Number Generator

    If I tell you F(x) = 123, can you tell me x?
    It should not be obvious how to invert the function.
    But F(x) has only 256 values, so one can use a computer to guess and check pretty quickly.

    Hash Functions

    Instead, we use a function that
    1
    .
    generates bits that seem random,
    2
    .
    is effectively impossible to invert, and
    3
    .
    generates enough bits that guessing them is also effectively impossible.
    Hash functions take an arbitrary long, but finite, input and produce a fixed-size output based on that input:
    SHA (Secure Hash Algorithms) are a family of secure hash functions.
    Several distinctive features about cryptographic hash functions:
  • efficient to compute for any finite input
  • same input to the same hash function will always produce same output
  • hard to "trick"; a slight change in the input results in a drastically different output
  • hard to guess or work back to an input that will produce a given output
  • Hash functions are commonly used for data integrity, to verify that the data received is indeed the data that was sent, with no alterations, or that “copies” of data stored in different locations are in fact the same.
    Alice has to send her fellow scientist Bob a novel formula their lab developed, so she attaches a file to an email and provides its digest:
    Dear Bob, please find attached the molecule plot . The hash checksum is 2654733945256440784
    Bob downloads the attachment he calculates the hash as well:
    It does not match with the number Alice provided and becomes alert. Maybe there is nothing to worry about and Alice just sent an older file by mistake, or maybe some malicious party intercepted the message.
    Software publishers often include the checksum along with the program files for the user to be sure they are about to install the right thing and not a corrupted file, or worse, a virus.

    Terms to remember

  • authentication
  • encryption
  • cruptography
  • random numbers
  • confidentiality
  • dat integrity
  • non-repudiation
  • computationally secure
  • brute-force attack
  • pseudorandom number generator
  • hash function
  • SHA
  • Wolfram Cloud

    You are using a browser not supported by the Wolfram Cloud

    Supported browsers include recent versions of Chrome, Edge, Firefox and Safari.


    I understand and wish to continue anyway »

    You are using a browser not supported by the Wolfram Cloud. Supported browsers include recent versions of Chrome, Edge, Firefox and Safari.