Enum class EncryptionAlgorithmClass

Package: keychain.constants

Description

Encryption algorithm class.

This enum defines the high-level classes of public-key encryption algorithms supported by the keychain library. Each class represents a family of related encryption schemes with different underlying mathematical foundations.

Since: v2.0

Enum Class Summary

Enum Constant Value Description

ECIES

1

Elliptic Curve Integrated Encryption Scheme

RSA

2

RSA Encryption Scheme

DLIES

3

Discrete Logarithm Integrated Encryption Scheme

ELGAMAL

4

ElGamal Integrated Encryption Scheme

Enum Class Detail

ECIES

Value: 1

Elliptic Curve Integrated Encryption Scheme. This class uses elliptic curve cryptography for public-key encryption, providing strong security with relatively small key sizes. ECIES combines the advantages of elliptic curve cryptography with hybrid encryption techniques.

RSA

Value: 2

RSA Encryption Scheme. This class uses the RSA algorithm for public-key encryption, one of the most widely used and well-established encryption schemes. RSA is based on the difficulty of factoring large composite numbers.

DLIES

Value: 3

Discrete Logarithm Integrated Encryption Scheme. This class uses discrete logarithm problems in finite fields for encryption, providing an alternative to both RSA and elliptic curve approaches.

ELGAMAL

Value: 4

ElGamal Integrated Encryption Scheme. This class uses the ElGamal encryption algorithm, which is based on the discrete logarithm problem and provides semantic security under chosen plaintext attacks.

Usage Example

from keychain.constants import EncryptionAlgorithmClass

# Select an encryption algorithm class
algorithm_class = EncryptionAlgorithmClass.ECIES
print(f"Selected algorithm class: {algorithm_class}")  # Outputs: 1

# Algorithm class selection based on requirements
def select_encryption_class(performance_priority=False):
    if performance_priority:
        # ECIES typically offers better performance with smaller keys
        return EncryptionAlgorithmClass.ECIES
    else:
        # RSA is widely supported and well-established
        return EncryptionAlgorithmClass.RSA

selected_class = select_encryption_class(performance_priority=True)
print(f"Recommended class: {selected_class}")

# Check algorithm family
def get_algorithm_family(alg_class):
    families = {
        EncryptionAlgorithmClass.ECIES: "Elliptic Curve",
        EncryptionAlgorithmClass.RSA: "Integer Factorization",
        EncryptionAlgorithmClass.DLIES: "Discrete Logarithm",
        EncryptionAlgorithmClass.ELGAMAL: "Discrete Logarithm"
    }
    return families.get(alg_class, "Unknown")

family = get_algorithm_family(algorithm_class)
print(f"Algorithm family: {family}")  # Outputs: "Elliptic Curve"