abla/crypto/pbe

Generated from source.

Import with import "abla/crypto/pbe".

Source: abla/crypto/pbe/entry.ab

Re-exports abla/crypto/result.

RsaKeyReadLimits (class)

class RsaKeyReadLimits(val maximumIterations: int = 1000000,
    val maximumKdfWork: int = 8000000, val maximumDerBytes: int = 1048576,
    val maximumPemBytes: int = 2097152, val maximumSaltBytes: int = 1024,
    val maximumDepth: int = 8, val maximumBags: int = 64)

No module-initializer allocations: unencrypted RSA imports keep this dead.

rsaKeyReadLimits (fun)

fun rsaKeyReadLimits(): RsaKeyReadLimits

Creates the default parsing and key derivation limits for RSA key imports.

rsaKeyReadLimitsValid (fun)

trusted fun rsaKeyReadLimitsValid(l: RsaKeyReadLimits): bool

Reports whether all RSA key import limits fall within supported bounds.

CryptoPassword (class)

resource class CryptoPassword()

Owns password bytes and a PKCS#12 representation when the input can be encoded.

CryptoPassword.drop (method)

trusted fun drop(): void

Wipes and frees the owned password buffers.

CryptoPassword.ok (method)

fun ok(): bool

Reports whether the owner holds a password buffer.

CryptoPassword.error (method)

fun error(): string

Returns the password owner's error text, or an empty string for a successful import.

cryptoPassword (fun)

trusted fun cryptoPassword(bytes: string): CryptoPassword

Copies at most1024 password octets. Only this owned copy can be wiped.

PbeKey (class)

resource class PbeKey()

An opened private key: the decrypted PKCS#8 PrivateKeyInfo DER (the key's p, q, d and the rest) in a buffer of its own, which drop overwrites with zeros, so no copy of it is left in freed memory. der() lends it: read it while the owner lives; to keep it longer, copy it (cryptoOwnedCopy), and the copy is then yours to wipe (cryptoWipeString). Check ok() and error().

PbeKey.drop (method)

trusted fun drop(): void

Wipes the owned DER and marks the key owner closed.

PbeKey.ok (method)

fun ok(): bool

Reports whether the owner holds a decrypted key.

PbeKey.error (method)

fun error(): string

Returns the key owner's error text, or an empty string for a successful import.

PbeKey.der (method)

fun der(): string

Returns the owned decrypted key as DER, or an empty string if no key is held.

pbeOpenPkcs8 (fun)

trusted fun pbeOpenPkcs8(data: string, password: CryptoPassword,
    limits: RsaKeyReadLimits = rsaKeyReadLimits()): PbeKey

Checked PBES2 envelope. The decrypted key comes back in an owner that wipes it when dropped (PbeKey), and the plaintext buffer it was decrypted into is wiped before this returns. This is not authenticated encryption or an entire-loader CT claim.

pbeOpenPkcs12 (fun)

trusted fun pbeOpenPkcs12(data: string, password: CryptoPassword,
    limits: RsaKeyReadLimits = rsaKeyReadLimits()): PbeKey

DER PFXv3 with a required SHA1/SHA256 MAC. Only authenticated content is traversed or decrypted; returns exactly one PKCS#8 key, in an owner that wipes it when dropped (PbeKey), not a TLS identity. Every buffer decrypted on the way is wiped before this returns.

Pkcs12Contents (class)

class Pkcs12Contents(val ok: bool, val error: string, val key: string, val certificates: array<string>)

What a PKCS#12 holds: its one private key (PKCS#8 DER) and its certificates (DER) in bag order. key is an exact copy of its own (every buffer decrypted on the way is wiped): it is the caller's, to wipe with cryptoWipeString when done.

pbeOpenPkcs12Contents (fun)

trusted fun pbeOpenPkcs12Contents(data: string, password: CryptoPassword,
    limits: RsaKeyReadLimits = rsaKeyReadLimits()): Pkcs12Contents

As pbeOpenPkcs12, with the certificates too: the same MAC check before anything is read or decrypted, the same limits, exactly one private key; the certificates come back as found (a TLS identity picks the one that matches the key and orders the chain: abla/tls/pure/identity). Its stack residue is not part of the ct residue checks.

Built from Abla v0.2.79 source ba5d6b7d. Examples and generated signatures follow that source revision.