Home /Modules/crypto/SLNationalSuite.sleela

SLNationalSuite.sleela

lib/crypto/SLNationalSuite.sleela · 114 line(s) · sleela

<< lib/crypto/SLNationalSuite.sleela
   SLeeLa Standard Library Definition.
   Definition: Defines the SLeeLa standard-library type SLNationalSuite used within the crypto library family. >>
#sleela 2.5
material;
< Unified SLeeLa SDK front-end object. >
< Family: crypto. National-grade (NSA CNSA 1.0/2.0, NIST FIPS) algorithm roster. >
< Names the suite member set; native computation crosses the explicit VM/OS >
< bridge into /crypto (libslcrypto). See crypto/README.md. >
<  >
< SECURITY NOTE: the native /crypto backend is a correct, specification-faithful >
< REFERENCE implementation. It is NOT guaranteed constant-time and is NOT >
< side-channel resistant. For data that must be protected use an audited library >
< (BoringSSL, OpenSSL, libsodium, liboqs). See crypto/README.md. >
class SLNationalSuite {
  < ---- Descriptive metadata (version 1.11 nested-friendly accessors) ---- >
  << Eleven catalogued attributes with getter/setter pairs, so a GUI, loader,
     or catalog can read and (where appropriate) override this record.
     Values are faithful to the subject's real origin where publicly known. >>
  String metaVersion = "1.0.0";
  int metaId = 10267;
  String metaAuthor = "Kiro Agent";
  String metaDate = "2026-10-16";
  String metaCopyright = "SLeeLa project";
  String metaTrademark = "none";
  String metaCorporation = "none";
  < metaOrigin: National | <nation> | International | Galactic >
  String metaOrigin = "International";
  String metaBirthDate = "2026-10-06";
  < metaScienceRating: maturity/robustness on a 1..10 scale >
  int metaScienceRating = 9;
  < metaNationalSchedule: a real, citable instrument or "none" >
  String metaNationalSchedule = "none";

  String getMetaVersion() { return metaVersion; }
  void setMetaVersion(String v) { metaVersion = v; }
  int getMetaId() { return metaId; }
  void setMetaId(int v) { metaId = v; }
  String getAuthor() { return metaAuthor; }
  void setAuthor(String v) { metaAuthor = v; }
  String getDate() { return metaDate; }
  void setDate(String v) { metaDate = v; }
  String getCopyright() { return metaCopyright; }
  void setCopyright(String v) { metaCopyright = v; }
  String getTrademark() { return metaTrademark; }
  void setTrademark(String v) { metaTrademark = v; }
  String getCorporation() { return metaCorporation; }
  void setCorporation(String v) { metaCorporation = v; }
  String getOrigin() { return metaOrigin; }
  void setOrigin(String v) { metaOrigin = v; }
  String getBirthDate() { return metaBirthDate; }
  void setBirthDate(String v) { metaBirthDate = v; }
  int getScienceRating() { return metaScienceRating; }
  void setScienceRating(int v) { metaScienceRating = v; }
  String getNationalSchedule() { return metaNationalSchedule; }
  void setNationalSchedule(String v) { metaNationalSchedule = v; }
  < Status codes mirror slcrypto_status in crypto/include/slcrypto.h. >
  static final int OK = 0;
  static final int ERR_PARAM = -1;
  static final int ERR_AUTH = -2;
  static final int ERR_UNIMPL = -3;

  < "CNSA-1.0" | "CNSA-2.0" >
  String suite;
  < 1 = enabled, 0 = disabled >
  int state;
  < 1 once a supported suite has been accepted >
  int configured;
  < 1 when the native /crypto backend is linked and ready >
  int backend;

  < Accept only the two named suites. >
  int configure(String s) {
    if (s == null) { configured = 0; return ERR_PARAM; }
    if (s == "CNSA-1.0" || s == "CNSA-2.0") { suite = s; configured = 1; return OK; }
    configured = 0;
    return ERR_PARAM;
  }

  void bindBackend(int ready) { if (ready == 1) { backend = 1; } else { backend = 0; } }
  boolean backendReady() { return backend == 1; }

  void enable() { state = 1; }
  void disable() { state = 0; }
  boolean active() { return state == 1 && configured == 1 && backend == 1; }

  < Classical members are implemented and KAT-verified in /crypto today. >
  String members() {
    return "SHA-256,SHA-384,SHA-512,SHA3-256,SHA3-512,AES-128,AES-192,AES-256,AES-GCM,HMAC,HKDF,ML-KEM,ML-DSA";
  }

  < The two CNSA 2.0 post-quantum members whose native backend is still pending >
  < (slc_mlkem_* / slc_mldsa_* return ERR_UNIMPL). Surfaced so callers can tell >
  < which roster entries are not yet usable. >
  String pendingMembers() {
    return "ML-KEM,ML-DSA";
  }

  < 1 if the named member is implemented and callable today, 0 if pending, ERR_PARAM if unknown. >
  int memberReady(String name) {
    if (name == null) { return ERR_PARAM; }
    if (name == "ML-KEM" || name == "ML-DSA") { return 0; }
    if (name == "SHA-256" || name == "SHA-384" || name == "SHA-512" ||
        name == "SHA3-256" || name == "SHA3-512" ||
        name == "AES-128" || name == "AES-192" || name == "AES-256" ||
        name == "AES-GCM" || name == "HMAC" || name == "HKDF") { return 1; }
    return ERR_PARAM;
  }

  String securityNote() {
    return "Reference-grade: not constant-time, not side-channel resistant; ML-KEM/ML-DSA backend pending. Use an audited library in production.";
  }
}