Package zeroecho.core.policy


package zeroecho.core.policy
Policy enforcement for algorithms, keys, and specifications.

This package centralizes checks that validate algorithm identifiers, intended roles, keys, and optional specifications before a context is created. Policies allow an application to enforce organizational rules without hard-wiring constraints into individual algorithms.

Key elements

  • CryptoPolicy - strategy interface consulted during context creation to validate the combination of algorithm id, KeyUsage role, key, and optional spec.
  • SecurityStrengthAdvisor - utility that estimates a conservative security strength in bits from an algorithm family id and a key, used by policies such as minimum-strength guards.

Typical usage

zeroecho.sdk.ZeroEchoSession session = new zeroecho.sdk.ZeroEchoSession()
    .withPolicy(zeroecho.core.policy.CryptoPolicy.minStrength(128));

// The session applies the policy without changing other consumers.
zeroecho.core.context.EncryptionContext ctx =
    session.createContext("AES", zeroecho.core.KeyUsage.ENCRYPT, secretKey);

Design notes

  • Policies can be permissive or strict, ranging from "accept all" to enforcing whitelists and minimum key strengths.
  • Strength estimation favors safe lower bounds and relies on visible key characteristics (for example, modulus bits for RSA, key length for AES, or NIST-level hints for KEMs).
  • Validation failures are signaled using unchecked exceptions suitable for configuration-time errors.
Since:
1.0
  • Class
    Description
    CryptoPolicy<S extends ContextSpec, K extends Key>
    A strategy interface for validating cryptographic keys, usages, and specifications before contexts are created.
    Estimates conservative security strength in bits for a given algorithm identifier and key.