encryption_scheme Enum

namespace keychainenum class encryption_scheme

Overview

The encryption_scheme enumeration specifies complete encryption algorithms with specific parameters, curves, and key sizes for public key encryption operations.

Syntax

namespace keychain {
    enum class encryption_scheme {
        // ECIES schemes
        ECIES_P256_AES_128_GCM,     // ECIES with P-256 curve, AES-128-GCM
        ECIES_P256_AES_256_GCM,     // ECIES with P-256 curve, AES-256-GCM
        ECIES_P384_AES_256_GCM,     // ECIES with P-384 curve, AES-256-GCM
        ECIES_P521_AES_256_GCM,     // ECIES with P-521 curve, AES-256-GCM

        // RSA schemes
        RSA_2048_OAEP_SHA256,       // RSA-2048 with OAEP padding, SHA-256
        RSA_3072_OAEP_SHA256,       // RSA-3072 with OAEP padding, SHA-256
        RSA_4096_OAEP_SHA256,       // RSA-4096 with OAEP padding, SHA-256
        RSA_2048_OAEP_SHA512,       // RSA-2048 with OAEP padding, SHA-512
        RSA_3072_OAEP_SHA512,       // RSA-3072 with OAEP padding, SHA-512
        RSA_4096_OAEP_SHA512,       // RSA-4096 with OAEP padding, SHA-512

        // ElGamal schemes
        ELGAMAL_2048_SHA256,        // ElGamal 2048-bit with SHA-256
        ELGAMAL_3072_SHA256,        // ElGamal 3072-bit with SHA-256
        ELGAMAL_2048_SHA512,        // ElGamal 2048-bit with SHA-512
        ELGAMAL_3072_SHA512         // ElGamal 3072-bit with SHA-512
    };
}

Members

ECIES Schemes

ECIES_P256_AES_128_GCM

Value: encryption_scheme::ECIES_P256_AES_128_GCM

ECIES with NIST P-256 curve and AES-128-GCM symmetric encryption.

Security Level: 128-bit
Key Size: 256-bit ECC
Symmetric Cipher: AES-128-GCM
Performance: Excellent

ECIES_P256_AES_256_GCM

Value: encryption_scheme::ECIES_P256_AES_256_GCM

ECIES with NIST P-256 curve and AES-256-GCM symmetric encryption.

Security Level: 128-bit ECC, 256-bit symmetric
Key Size: 256-bit ECC
Symmetric Cipher: AES-256-GCM
Performance: Excellent

ECIES_P384_AES_256_GCM

Value: encryption_scheme::ECIES_P384_AES_256_GCM

ECIES with NIST P-384 curve and AES-256-GCM symmetric encryption.

Security Level: 192-bit
Key Size: 384-bit ECC
Symmetric Cipher: AES-256-GCM
Performance: Very Good

ECIES_P521_AES_256_GCM

Value: encryption_scheme::ECIES_P521_AES_256_GCM

ECIES with NIST P-521 curve and AES-256-GCM symmetric encryption.

Security Level: 256-bit
Key Size: 521-bit ECC
Symmetric Cipher: AES-256-GCM
Performance: Good

RSA Schemes

RSA_2048_OAEP_SHA256

Value: encryption_scheme::RSA_2048_OAEP_SHA256

RSA-2048 with OAEP padding and SHA-256 hash function.

Security Level: 112-bit
Key Size: 2048-bit
Padding: OAEP with SHA-256
Status: Minimum recommended size

RSA_3072_OAEP_SHA256

Value: encryption_scheme::RSA_3072_OAEP_SHA256

RSA-3072 with OAEP padding and SHA-256 hash function.

Security Level: 128-bit
Key Size: 3072-bit
Padding: OAEP with SHA-256
Status: Recommended for new applications

RSA_4096_OAEP_SHA256

Value: encryption_scheme::RSA_4096_OAEP_SHA256

RSA-4096 with OAEP padding and SHA-256 hash function.

Security Level: ~140-bit
Key Size: 4096-bit
Padding: OAEP with SHA-256
Status: High security applications

ElGamal Schemes

ELGAMAL_2048_SHA256

Value: encryption_scheme::ELGAMAL_2048_SHA256

ElGamal encryption with 2048-bit key and SHA-256 hash.

Security Level: 112-bit
Key Size: 2048-bit
Hash Function: SHA-256
Ciphertext Size: 2x plaintext (expansion)

Usage

#include <keychain/keychain.h>

// Select encryption scheme for persona
keychain::encryption_scheme scheme = keychain::encryption_scheme::ECIES_P256_AES_256_GCM;

// Create persona with specific scheme
keychain::persona alice = gateway.create_persona(
    "alice", "personal",
    keychain::security_level::HIGH,
    scheme  // encryption scheme
);

// Check scheme properties
auto algorithm_class = scheme.get_algorithm_class();
if (algorithm_class == keychain::encryption_algorithm_class::ECIES) {
    std::cout << "Using elliptic curve encryption" << std::endl;
}

// Get scheme details
std::string scheme_name = to_string(scheme);
std::cout << "Encryption scheme: " << scheme_name << std::endl;

Security Levels and Recommendations

Scheme Security Level Key Size Performance Recommendation

ECIES_P256_AES_128_GCM

128-bit

256-bit ECC

★★★★★

Recommended for most applications

ECIES_P256_AES_256_GCM

128-bit ECC, 256-bit AES

256-bit ECC

★★★★★

Recommended for high security

ECIES_P384_AES_256_GCM

192-bit

384-bit ECC

★★★★☆

Future-proof applications

ECIES_P521_AES_256_GCM

256-bit

521-bit ECC

★★★☆☆

Maximum security requirements

RSA_2048_OAEP_SHA256

112-bit

2048-bit

★★☆☆☆

Legacy compatibility only

RSA_3072_OAEP_SHA256

128-bit

3072-bit

★★☆☆☆

New RSA applications

RSA_4096_OAEP_SHA256

~140-bit

4096-bit

★☆☆☆☆

High security RSA

ELGAMAL_2048_SHA256

112-bit

2048-bit

★★☆☆☆

Specialized use cases

Algorithm Selection Guidelines

For New Applications

  1. ECIES_P256_AES_256_GCM - Best balance of security and performance

  2. ECIES_P384_AES_256_GCM - Future-proof with moderate performance impact

  3. RSA_3072_OAEP_SHA256 - When RSA is required by standards

For High Security Applications

  1. ECIES_P521_AES_256_GCM - Maximum elliptic curve security

  2. ECIES_P384_AES_256_GCM - Good balance for sensitive data

  3. RSA_4096_OAEP_SHA256 - When RSA is mandated

Performance Considerations

// Performance comparison example
void benchmark_encryption_schemes() {
    std::vector<keychain::encryption_scheme> schemes = {
        keychain::encryption_scheme::ECIES_P256_AES_256_GCM,
        keychain::encryption_scheme::ECIES_P384_AES_256_GCM,
        keychain::encryption_scheme::RSA_3072_OAEP_SHA256
    };

    for (auto scheme : schemes) {
        auto start = std::chrono::high_resolution_clock::now();

        // Perform encryption benchmark
        for (int i = 0; i < 1000; ++i) {
            // Encrypt test data with scheme
        }

        auto end = std::chrono::high_resolution_clock::now();
        auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(end - start);

        std::cout << "Scheme " << to_string(scheme)
                 << ": " << duration.count() << "ms" << std::endl;
    }
}

Ciphertext Size Comparison

Scheme Plaintext Size Ciphertext Size Overhead

ECIES_P256_AES_128_GCM

1KB

~1.1KB

~65 bytes

ECIES_P384_AES_256_GCM

1KB

~1.1KB

~97 bytes

RSA_2048_OAEP_SHA256

214 bytes max

256 bytes

Fixed size

RSA_3072_OAEP_SHA256

318 bytes max

384 bytes

Fixed size

ELGAMAL_2048_SHA256

1KB

~2KB

100% expansion

See Also

  • gateway - Encryption operations

  • encrypted_data - Encrypted data containers

  • {nist-sp-800-57}[NIST SP 800-57] - Key management recommendations

  • {rfc-3447}[RFC 3447] - RSA PKCS#1 specification