×
1 Choose EITC/EITCA Certificates
2 Learn and take online exams
3 Get your IT skills certified

Confirm your IT skills and competencies under the European IT Certification framework from anywhere in the world fully online.

EITCA Academy

Digital skills attestation standard by the European IT Certification Institute aiming to support Digital Society development

SIGN IN YOUR ACCOUNT TO HAVE ACCESS TO DIFFERENT FEATURES

CREATE AN ACCOUNT FORGOT YOUR PASSWORD?

FORGOT YOUR DETAILS?

AAH, WAIT, I REMEMBER NOW!

CREATE ACCOUNT

ALREADY HAVE AN ACCOUNT?
EUROPEAN INFORMATION TECHNOLOGIES CERTIFICATION ACADEMY - ATTESTING YOUR PROFESSIONAL DIGITAL SKILLS
  • SIGN UP
  • LOGIN
  • SUPPORT

EITCA Academy

EITCA Academy

The European Information Technologies Certification Institute - EITCI ASBL

Certification Provider

EITCI Institute ASBL

Brussels, European Union

Governing European IT Certification (EITC) framework in support of the IT professionalism and Digital Society

  • CERTIFICATES
    • EITCA ACADEMIES
      • EITCA ACADEMIES CATALOGUE<
      • EITCA/CG COMPUTER GRAPHICS
      • EITCA/IS INFORMATION SECURITY
      • EITCA/BI BUSINESS INFORMATION
      • EITCA/KC KEY COMPETENCIES
      • EITCA/EG E-GOVERNMENT
      • EITCA/WD WEB DEVELOPMENT
      • EITCA/AI ARTIFICIAL INTELLIGENCE
    • EITC CERTIFICATES
      • EITC CERTIFICATES CATALOGUE<
      • COMPUTER GRAPHICS CERTIFICATES
      • WEB DESIGN CERTIFICATES
      • 3D DESIGN CERTIFICATES
      • OFFICE IT CERTIFICATES
      • BITCOIN BLOCKCHAIN CERTIFICATE
      • WORDPRESS CERTIFICATE
      • CLOUD PLATFORM CERTIFICATENEW
    • EITC CERTIFICATES
      • INTERNET CERTIFICATES
      • CRYPTOGRAPHY CERTIFICATES
      • BUSINESS IT CERTIFICATES
      • TELEWORK CERTIFICATES
      • PROGRAMMING CERTIFICATES
      • DIGITAL PORTRAIT CERTIFICATE
      • WEB DEVELOPMENT CERTIFICATES
      • DEEP LEARNING CERTIFICATESNEW
    • CERTIFICATES FOR
      • EU PUBLIC ADMINISTRATION
      • TEACHERS AND EDUCATORS
      • IT SECURITY PROFESSIONALS
      • GRAPHICS DESIGNERS & ARTISTS
      • BUSINESSMEN AND MANAGERS
      • BLOCKCHAIN DEVELOPERS
      • WEB DEVELOPERS
      • CLOUD AI EXPERTSNEW
  • FEATURED
  • SUBSIDY
  • HOW IT WORKS
  •   IT ID
  • ABOUT
  • CONTACT
  • MY ORDER
    Your current order is empty.
EITCIINSTITUTE
CERTIFIED

What is the key space of an affine cipher?

by Emmanuel Udofia / Friday, 09 August 2024 / Published in Cybersecurity, EITC/IS/CCF Classical Cryptography Fundamentals, History of cryptography, Modular arithmetic and historical ciphers

The key space of an affine cipher is a fundamental concept in classical cryptography, particularly within the domain of modular arithmetic and historical ciphers. The affine cipher is a type of substitution cipher, which means it replaces each letter in the plaintext with a corresponding letter in the ciphertext according to a mathematical function. Understanding the key space of an affine cipher involves delving into the mathematical structure of the cipher and exploring the parameters that define it.

The affine cipher operates on the principle of affine transformations in modular arithmetic. Specifically, it uses the function:

    \[ E(x) = (ax + b) \mod m \]

where:
– E(x) is the encryption function.
– x represents the numerical value of the plaintext letter.
– a and b are the keys of the cipher.
– m is the size of the alphabet (typically 26 for the English alphabet).
– \mod denotes the modulus operation, ensuring the result wraps around within the range of the alphabet.

To decrypt the ciphertext, the inverse function is used:

    \[ D(y) = a^{-1}(y - b) \mod m \]

where:
– D(y) is the decryption function.
– y represents the numerical value of the ciphertext letter.
– a^{-1} is the modular multiplicative inverse of a modulo m.

The key space of the affine cipher is defined by the set of all possible pairs (a, b) that can be used as keys. However, not all pairs of (a, b) are valid. For a pair (a, b) to be a valid key, a must be coprime with m, meaning that the greatest common divisor (gcd) of a and m must be 1. This requirement ensures that a has a modular multiplicative inverse, which is necessary for the decryption process to work correctly.

To explore the key space in detail, consider the following steps:

1. Determine Valid Values for a:
– The value of a must be coprime with m. For the English alphabet, m = 26. The values of a that are coprime with 26 are those integers less than 26 that do not share any common factors with 26 other than 1.
– The integers that are coprime with 26 are: 1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23, and 25. There are 12 such integers.

2. Determine Valid Values for b:
– The value of b can be any integer from 0 to m-1. For the English alphabet, this means b can range from 0 to 25. There are 26 possible values for b.

3. Calculate the Total Key Space:
– The total number of possible keys is the product of the number of valid values for a and the number of possible values for b.
– Therefore, the total key space is 12 \times 26 = 312.

This means there are 312 unique pairs (a, b) that can be used as keys in an affine cipher when m = 26.

Examples

To illustrate the affine cipher, consider the following example:

Encryption Example:

Suppose we choose a = 5 and b = 8. The encryption function becomes:

    \[ E(x) = (5x + 8) \mod 26 \]

Let's encrypt the plaintext "HELLO". First, we convert each letter to its corresponding numerical value (A = 0, B = 1, …, Z = 25):

– H = 7
– E = 4
– L = 11
– L = 11
– O = 14

Applying the encryption function to each letter:

– E(7) = (5 \times 7 + 8) \mod 26 = (35 + 8) \mod 26 = 43 \mod 26 = 17 (R)
– E(4) = (5 \times 4 + 8) \mod 26 = (20 + 8) \mod 26 = 28 \mod 26 = 2 (C)
– E(11) = (5 \times 11 + 8) \mod 26 = (55 + 8) \mod 26 = 63 \mod 26 = 11 (L)
– E(11) = (5 \times 11 + 8) \mod 26 = 11 (L)
– E(14) = (5 \times 14 + 8) \mod 26 = (70 + 8) \mod 26 = 78 \mod 26 = 0 (A)

The ciphertext is "RCLLA".

Decryption Example:

To decrypt the ciphertext "RCLLA" using the same keys a = 5 and b = 8, we need the decryption function:

    \[ D(y) = a^{-1}(y - b) \mod 26 \]

First, we find the modular multiplicative inverse of a = 5 modulo 26. The inverse a^{-1} is the integer such that:

    \[ 5a^{-1} \equiv 1 \mod 26 \]

Using the extended Euclidean algorithm, we find that a^{-1} = 21.

Now, the decryption function becomes:

    \[ D(y) = 21(y - 8) \mod 26 \]

Applying the decryption function to each letter in the ciphertext:

– R = 17
– C = 2
– L = 11
– L = 11
– A = 0

– D(17) = 21(17 - 8) \mod 26 = 21 \times 9 \mod 26 = 189 \mod 26 = 7 (H)
– D(2) = 21(2 - 8) \mod 26 = 21 \times (-6) \mod 26 = -126 \mod 26 = 4 (E)
– D(11) = 21(11 - 8) \mod 26 = 21 \times 3 \mod 26 = 63 \mod 26 = 11 (L)
– D(11) = 11 (L)
– D(0) = 21(0 - 8) \mod 26 = 21 \times (-8) \mod 26 = -168 \mod 26 = 14 (O)

The decrypted plaintext is "HELLO".

Key Space Analysis

The key space of an affine cipher is relatively small compared to modern cryptographic standards. With only 312 possible keys for the English alphabet, an exhaustive search (brute force attack) is feasible. This limited key space is one of the reasons why the affine cipher is not secure by contemporary standards. However, it serves as an excellent educational tool for understanding the principles of modular arithmetic and the structure of classical ciphers.

Practical Implications

In modern cryptography, the security of a cipher is heavily dependent on the size of its key space. A larger key space makes it more difficult for an attacker to perform a brute force attack. For example, the Advanced Encryption Standard (AES) uses key sizes of 128, 192, or 256 bits, resulting in key spaces of 2^{128}, 2^{192}, and 2^{256} possible keys, respectively. These key spaces are astronomically larger than that of the affine cipher, providing a much higher level of security.

The affine cipher, with its key space of 312 possible keys for the English alphabet, is a simple yet instructive example of classical cryptography. It demonstrates the application of modular arithmetic and the importance of key selection in ensuring the security of a cipher. While it is not suitable for modern cryptographic needs, the affine cipher remains a valuable educational tool for those studying the history and fundamentals of cryptography.

Other recent questions and answers regarding EITC/IS/CCF Classical Cryptography Fundamentals:

  • Is cryptography considered a part of cryptology and cryptanalysis?
  • Will a shift cipher with a key equal to 4 replace the letter d with the letter h in ciphertext?
  • Does the ECB mode breaks large input plaintext into subsequent blocks
  • Do identical plaintext map to identical cipher text of a letter frequency analysis attact against a substitution cipher
  • What is EEA ?
  • Are brute force attack always an exhausive key search?
  • In RSA cipher, does Alice need Bob’s public key to encrypt a message to Bob?
  • Can we use a block cipher to build a hash function or MAC?
  • What are initialization vectors?
  • How many part does a public and private key has in RSA cipher

View more questions and answers in EITC/IS/CCF Classical Cryptography Fundamentals

More questions and answers:

  • Field: Cybersecurity
  • Programme: EITC/IS/CCF Classical Cryptography Fundamentals (go to the certification programme)
  • Lesson: History of cryptography (go to related lesson)
  • Topic: Modular arithmetic and historical ciphers (go to related topic)
Tagged under: Affine Cipher, Classical Cryptography, Cybersecurity, Encryption And Decryption, Key Space, Modular Arithmetic
Home » Cybersecurity / EITC/IS/CCF Classical Cryptography Fundamentals / History of cryptography / Modular arithmetic and historical ciphers » What is the key space of an affine cipher?

Certification Center

USER MENU

  • My Account

CERTIFICATE CATEGORY

  • EITC Certification (106)
  • EITCA Certification (9)

What are you looking for?

  • Introduction
  • How it works?
  • EITCA Academies
  • EITCI DSJC Subsidy
  • Full EITC catalogue
  • Your order
  • Featured
  •   IT ID
  • EITCA reviews (Reddit publ.)
  • About
  • Contact
  • Cookie Policy (EU)

EITCA Academy is a part of the European IT Certification framework

The European IT Certification framework has been established in 2008 as a Europe based and vendor independent standard in widely accessible online certification of digital skills and competencies in many areas of professional digital specializations. The EITC framework is governed by the European IT Certification Institute (EITCI), a non-profit certification authority supporting information society growth and bridging the digital skills gap in the EU.

    EITCA Academy Secretary Office

    European IT Certification Institute ASBL
    Brussels, Belgium, European Union

    EITC / EITCA Certification Framework Operator
    Governing European IT Certification Standard
    Access contact form or call +32 25887351

    Follow EITCI on Twitter
    Visit EITCA Academy on Facebook
    Engage with EITCA Academy on LinkedIn
    Check out EITCI and EITCA videos on YouTube

    Funded by the European Union

    Funded by the European Regional Development Fund (ERDF) and the European Social Fund (ESF), governed by the EITCI Institute since 2008

    Information Security Policy | DSRRM and GDPR Policy | Data Protection Policy | Record of Processing Activities | HSE Policy | Anti-Corruption Policy | Modern Slavery Policy

    Automatically translate to your language

    Terms and Conditions | Privacy Policy
    Follow @EITCI
    EITCA Academy

    Your browser doesn't support the HTML5 CANVAS tag.

    • Artificial Intelligence
    • Cybersecurity
    • Cloud Computing
    • Web Development
    • Quantum Information
    • GET SOCIAL
    EITCA Academy


    © 2008-2026  European IT Certification Institute
    Brussels, Belgium, European Union

    TOP
    CHAT WITH SUPPORT
    Do you have any questions?
    We will reply here and by email. Your conversation is tracked with a support token.