SLMlKem.sleela
lib/crypto/SLMlKem.sleela · 120 line(s) · sleela
<< lib/crypto/SLMlKem.sleela
SLeeLa Standard Library Definition.
Definition: Defines the SLeeLa standard-library type SLMlKem used within the crypto library family. >>
#sleela 2.5
material;
< Unified SLeeLa SDK front-end object. >
< Family: crypto. ML-KEM post-quantum key encapsulation (FIPS 203, CNSA 2.0). >
< Native impl crosses the VM/OS bridge to /crypto; see crypto/PQ-INTEGRATION.md. >
< >
< IMPLEMENTATION STATUS: the native entry points (slc_mlkem_*) are DECLARED but >
< currently return SLCRYPTO_ERR_UNIMPL. Until an audited reference (liboqs / >
< pq-crystals) is vendored, backendReady() is false and operations return >
< ERR_UNIMPL. Callers must not treat this primitive as available. >
< >
< 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 SLMlKem {
< ---- 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 = 10266;
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;
< "ML-KEM-512" | "ML-KEM-768" | "ML-KEM-1024" >
String parameterSet;
< 1 = enabled, 0 = disabled >
int state;
< 1 once a supported parameter set has been accepted >
int configured;
< 1 only once a real native implementation is linked >
int backend;
< Validate against the three FIPS 203 parameter sets named by CNSA 2.0. >
int configure(String p) {
if (p == null) { configured = 0; return ERR_PARAM; }
if (p == "ML-KEM-512" || p == "ML-KEM-768" || p == "ML-KEM-1024") {
parameterSet = p; configured = 1; return OK;
}
configured = 0;
return ERR_PARAM;
}
< The VM/OS bridge binding calls this with 1 only when a real ML-KEM >
< implementation is present. It stays 0 while src/pq.c returns ERR_UNIMPL. >
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; }
< active() reflects real usability: it is false while the PQ backend is pending, >
< so it cannot report ready for an unimplemented primitive. >
boolean active() { return state == 1 && configured == 1 && backend == 1; }
< KEM operations. Model slc_mlkem_keygen/encaps/decaps; they surface >
< ERR_UNIMPL until the backend is vendored. >
int keygen() {
if (configured == 0) { return ERR_PARAM; }
if (backend == 0) { return ERR_UNIMPL; }
return OK;
}
int encapsulate(String publicKey) {
if (backend == 0) { return ERR_UNIMPL; }
if (publicKey == null) { return ERR_PARAM; }
return OK;
}
int decapsulate(String secretKey, String ciphertext) {
if (backend == 0) { return ERR_UNIMPL; }
if (secretKey == null || ciphertext == null) { return ERR_PARAM; }
return OK;
}
String securityNote() {
return "Reference-grade and PQ backend pending; not constant-time or side-channel resistant. Use an audited library (liboqs) in production.";
}
}