august.crypto
Install this source library with aug add https://github.com/GreenPandaStudios/augscript/src/stdlib/crypto --as crypto, then import its public names from crypto.
Signatures show result types and checked errors. See packages to pin a release and language constructs for built-in types.
Crypto
capability CryptoExplicit permission for native cryptographic operations. Keys and bytes are immutable.
Crypto.random
random(int size) returns Bytes unless CryptoErrorGenerate unpredictable bytes with the operating-system-backed GnuTLS RNG.
Uses Crypto.random.
Crypto.sha256
sha256(Bytes input) returns Bytes unless CryptoErrorHash the complete input using SHA-256.
Uses Crypto.sha256.
Crypto.generateRsa
generateRsa() returns RsaPrivateKey unless CryptoErrorCreate a fresh 3072-bit RSA private key. Private material is opaque and scrubbed on reclamation.
Uses Crypto.generateRsa.
Crypto.publicRsa
publicRsa(RsaPrivateKey key) returns RsaPublicKey unless CryptoErrorExport the corresponding public key as an opaque immutable value.
Uses Crypto.publicRsa.
Crypto.signRsa
signRsa(RsaPrivateKey key, Bytes input) returns Bytes unless CryptoErrorSign bytes using RSASSA-PKCS1-v1_5 with SHA-256 (JOSE RS256).
Uses Crypto.signRsa.
Crypto.verifyRsa
verifyRsa(RsaPublicKey publicKey, Bytes input, Bytes signature) returns bool unless CryptoErrorVerify only RS256. Invalid signatures return false; invalid keys raise CryptoError.
Uses Crypto.verifyRsa.
Crypto.verifyEd25519
verifyEd25519(string publicKey, Bytes input, Bytes signature) returns bool unless CryptoErrorVerify Ed25519 using a PEM SubjectPublicKeyInfo public key. Invalid signatures return false; invalid or wrong-algorithm keys raise CryptoError.
Uses Crypto.verifyEd25519.
Crypto.decodeBase64url
decodeBase64url(string input) returns Bytes unless CryptoErrorDecode canonical unpadded URL-safe base64, rejecting invalid characters and unused bits.
Uses Crypto.decodeBase64url.
Crypto.equal
equal(Bytes left, Bytes right) returns boolCompare bytes without early exit on their contents. Length remains observable.
Uses Crypto.equal.
Crypto.exportRsa
exportRsa(RsaPublicKey publicKey) returns Tuple<Bytes, Bytes> unless CryptoErrorExport unsigned big-endian modulus and exponent for an RSA JWK.
Uses Crypto.exportRsa.
Crypto.importRsa
importRsa(Bytes modulus, Bytes exponent) returns RsaPublicKey unless CryptoErrorImport canonical public RSA parameters. Keys must have 2048 to 8192 bits.
Uses Crypto.importRsa.
Crypto.passwordHash
passwordHash(Bytes password, Bytes salt, int iterations) returns Bytes unless CryptoErrorPBKDF2-HMAC-SHA256, producing 32 bytes. Use a unique 16–64 byte salt; supported work factors are 100,000–2,000,000.
Uses Crypto.passwordHash.
GnuTlsCrypto
GnuTlsCrypto() implements CryptoGnuTLS-backed capability adapter. Its constructor performs no I/O or key generation.
GnuTlsCrypto.random
random(int size) returns Bytes unless CryptoErrorGenerate unpredictable bytes with the operating-system-backed GnuTLS RNG.
Uses Crypto.random.
GnuTlsCrypto.sha256
sha256(Bytes input) returns Bytes unless CryptoErrorHash the complete input using SHA-256.
Uses Crypto.sha256.
GnuTlsCrypto.generateRsa
generateRsa() returns RsaPrivateKey unless CryptoErrorCreate a fresh 3072-bit RSA private key. Private material is opaque and scrubbed on reclamation.
Uses Crypto.generateRsa.
GnuTlsCrypto.publicRsa
publicRsa(RsaPrivateKey key) returns RsaPublicKey unless CryptoErrorExport the corresponding public key as an opaque immutable value.
Uses Crypto.publicRsa.
GnuTlsCrypto.signRsa
signRsa(RsaPrivateKey key, Bytes input) returns Bytes unless CryptoErrorSign bytes using RSASSA-PKCS1-v1_5 with SHA-256 (JOSE RS256).
Uses Crypto.signRsa.
GnuTlsCrypto.verifyEd25519
verifyEd25519(string publicKey, Bytes input, Bytes signature) returns bool unless CryptoErrorVerify Ed25519 using a PEM SubjectPublicKeyInfo public key. Invalid signatures return false; invalid or wrong-algorithm keys raise CryptoError.
Uses Crypto.verifyEd25519.
GnuTlsCrypto.verifyRsa
verifyRsa(RsaPublicKey publicKey, Bytes input, Bytes signature) returns bool unless CryptoErrorVerify only RS256. Invalid signatures return false; invalid keys raise CryptoError.
Uses Crypto.verifyRsa.
GnuTlsCrypto.decodeBase64url
decodeBase64url(string input) returns Bytes unless CryptoErrorDecode canonical unpadded URL-safe base64, rejecting invalid characters and unused bits.
Uses Crypto.decodeBase64url.
GnuTlsCrypto.equal
equal(Bytes left, Bytes right) returns boolCompare bytes without early exit on their contents. Length remains observable.
Uses Crypto.equal.
GnuTlsCrypto.exportRsa
exportRsa(RsaPublicKey publicKey) returns Tuple<Bytes, Bytes> unless CryptoErrorExport unsigned big-endian modulus and exponent for an RSA JWK.
Uses Crypto.exportRsa.
GnuTlsCrypto.importRsa
importRsa(Bytes modulus, Bytes exponent) returns RsaPublicKey unless CryptoErrorImport canonical public RSA parameters. Keys must have 2048 to 8192 bits.
Uses Crypto.importRsa.
GnuTlsCrypto.passwordHash
passwordHash(Bytes password, Bytes salt, int iterations) returns Bytes unless CryptoErrorPBKDF2-HMAC-SHA256, producing 32 bytes. Use a unique 16–64 byte salt; supported work factors are 100,000–2,000,000.
Uses Crypto.passwordHash.
JwtError
JwtError() implements ErrorA failed JOSE validation reveals no unverified claims.
RsaJwk
record RsaJwk(string kty, string kid, string alg, string use, string n, string e)Public signing-key metadata in RFC 7517 / RFC 7518 form.
RsaJwks
record RsaJwks(List<RsaJwk> keys)rsaJwk
rsaJwk(RsaPublicKey publicKey, string kid, resolve Crypto crypto) returns RsaJwk unless CryptoErrorExport public parameters. Private key material never enters the JSON document.
Uses Crypto.exportRsa.
importJwk
importJwk(RsaJwk jwk, resolve Crypto crypto) returns RsaPublicKey unless JwtErrorImport only an RSA signing key for RS256. The transport caller selects the trusted JWKS URL.
Uses Crypto.decodeBase64url and Crypto.importRsa.
signJwt
signJwt(
RsaPrivateKey key,
Json claims,
string kid,
string tokenType,
resolve Crypto crypto
) returns string unless JwtErrorSign immutable JSON with an explicit key id and token type. Claims are validated by the protocol that consumes the token.
Uses Crypto.signRsa.
verifyJwt
verifyJwt(
string token,
RsaPublicKey publicKey,
string kid,
string tokenType,
resolve Crypto crypto
) returns Json unless JwtErrorVerify the signature and configured algorithm, key id, and type before exposing the JSON payload. Never follows token-supplied URLs.
Uses Crypto.decodeBase64url and Crypto.verifyRsa.
verifyIdentityToken
verifyIdentityToken(
string token,
string publicKey,
string issuer,
string audience,
string tokenType,
int now,
int maximumAge,
resolve Crypto crypto
) returns Json unless JwtErrorVerify an Ed25519 JWT before exposing its claims. The caller supplies trusted issuer, audience, token type, current epoch seconds, and the maximum lifetime. sub, iat and exp are required. No token-supplied key location is followed.
Uses Crypto.decodeBase64url and Crypto.verifyEd25519.
IdentityVerifier
interface IdentityVerifierValidate one configured identity-token profile. A failed check exposes no claims.
IdentityVerifier.verify
verify(string token, int now) returns Json unless JwtErrorUses Crypto.decodeBase64url and Crypto.verifyEd25519.
Ed25519IdentityVerifier
Ed25519IdentityVerifier(
resolve Crypto crypto,
string publicKey,
string issuer,
string audience,
string tokenType,
int maximumAge
) implements IdentityVerifierBind trusted key and identity settings once. The caller supplies the current epoch seconds for each verification.
Ed25519IdentityVerifier.verify
verify(string token, int now) returns Json unless JwtErrorUses Crypto.decodeBase64url and Crypto.verifyEd25519.