abla/crypto/aes

Generated from source.

Import with import "abla/crypto/aes".

Source: abla/crypto/aes/entry.ab

Re-exports abla/crypto/result.

aesSwap (fun)

@inline fun aesSwap(a: secretU32, b: secretU32, low: u32, high: u32, shift: int,
    first: bool): secretU32

Returns one half of the bit exchange between two orthogonalized AES words.

aesMaskShift (fun)

@inline fun aesMaskShift(x: secretU32, mask: u32, count: int, left: bool): secretU32

Returns the masked word shifted in the selected direction.

AesKey (class)

resource class AesKey(val memory: int, val size: int, val rounds: int, val hardware: bool)

An AES key's expanded form, in memory this module owns. words is the schedule (little-endian words, 4 a round); sliced the bitsliced round keys, or 0 if hardware rounds take over.

AesKey.drop (method)

trusted fun drop(): void

Wipes and frees the owned expanded key and scratch memory.

AesKey.schedule (extension fun)

@inline fun AesKey.schedule(): int

Returns the address of the expanded round-key schedule owned by the key.

aesExpand (fun)

@noinline trusted fun aesExpand(key: string, hardware: bool): AesKey

Returns an owned expanded AES key from a valid 16-, 24-, or 32-byte key.

AesKey.decryption (extension fun)

@inline fun AesKey.decryption(): int

Returns the address of the hardware decryption round-key schedule.

aesSetHardware (fun)

trusted fun aesSetHardware(enabled: bool): void

Enables or disables selection of hardware acceleration for newly prepared AES operations.

aesHardwareEnabled (fun)

trusted fun aesHardwareEnabled(): bool

Returns true when AES hardware acceleration has not been disabled.

aesHardwareAvailable (fun)

fun aesHardwareAvailable(): bool

Returns true when AES hardware acceleration is enabled and available on this CPU.

aesKeySizeError (fun)

fun aesKeySizeError(key: string): string

Returns empty text for a 16-, 24-, or 32-byte key, or a key-size error otherwise.

aesPadded (fun)

trusted fun aesPadded(plaintext: string): NativeByteBuffer

Returns a native buffer containing the plaintext and enough padding to fill complete AES blocks.

aesEcbEncryptPkcs5 (fun)

trusted fun aesEcbEncryptPkcs5(key: string, plaintext: string): CryptoResult

Returns padded AES-ECB ciphertext or an error for an unsupported key length.

aesEcbDecryptPkcs5 (fun)

trusted fun aesEcbDecryptPkcs5(key: string, ciphertext: string): CryptoResult

Returns unpadded AES-ECB plaintext or an error for an invalid key, ciphertext length, or padding.

aesCbcEncryptPkcs7 (fun)

trusted fun aesCbcEncryptPkcs7(key: string, iv: string, plaintext: string): CryptoResult

Returns padded AES-CBC ciphertext or an error for an invalid key or IV.

aesCbcDecryptPkcs7 (fun)

trusted fun aesCbcDecryptPkcs7(key: string, iv: string, ciphertext: string): CryptoResult

Returns unpadded AES-CBC plaintext or an error for an invalid key, IV, ciphertext length, or padding.

aesCbcDecryptPkcs7BufferKey (fun)

trusted fun aesCbcDecryptPkcs7BufferKey(key: NativeByteBuffer, iv: string,
    ciphertext: string): CryptoResult

Buffer-key adapter: borrows a checked16/24/32-byte native buffer, never copies the key into a managed string. The caller owns and wipes that buffer.

ghashReverse (fun)

@inline fun ghashReverse(a: u8x16): u8x16

Returns the bytes of the GHASH vector in reverse order.

ghashBytesLeft8 (fun)

@inline fun ghashBytesLeft8(a: u64x2): u64x2

Returns the vector shifted left eight bytes with zeros filling the low half.

ghashBytesRight8 (fun)

@inline fun ghashBytesRight8(a: u64x2): u64x2

Returns the vector shifted right eight bytes with zeros filling the high half.

ghashWordsLeft1 (fun)

@inline fun ghashWordsLeft1(a: u32x4): u32x4

Returns the vector shifted left one 32-bit lane with a zero low lane.

ghashWordsLeft3 (fun)

@inline fun ghashWordsLeft3(a: u32x4): u32x4

Returns the vector shifted left three 32-bit lanes with zeros filling the low lanes.

ghashWordsRight1 (fun)

@inline fun ghashWordsRight1(a: u32x4): u32x4

Returns the vector shifted right one 32-bit lane with a zero high lane.

ghashWordsRight3 (fun)

@inline fun ghashWordsRight3(a: u32x4): u32x4

Returns the vector shifted right three 32-bit lanes with zeros filling the high lanes.

aesSwapWord (fun)

@inline fun aesSwapWord(value: int): u32

The counter bits of a block, big-endian, as the word a little-endian lane holds.

AesGcmState (class)

class AesGcmState(val memory: int)

Holds native working storage for a GCM counter, hash accumulator, and tag calculation.

AesGcmState.counter (method)

fun counter(): int

Returns the native address of the GCM counter block.

AesGcmState.batch (method)

fun batch(): int

Returns the native address of the GCM block scratch area.

AesGcmState.y (method)

fun y(): int

Returns the native address of the GHASH accumulator.

AesGcmState.h (method)

fun h(): int

Returns the native address of the GHASH subkey.

AesGcmState.tagMask (method)

fun tagMask(): int

Returns the native address of the encrypted initial counter used to mask the tag.

AesGcmState.lengths (method)

fun lengths(): int

Returns the native address of the final GHASH length block.

aesGcmStart (fun)

trusted fun aesGcmStart(key: AesKey, nonce: string, associatedData: string,
    hardware: bool): AesGcmState

Allocates and returns GCM state for a valid 12-byte nonce and incorporates the associated data.

aesGcmHardware (fun)

fun aesGcmHardware(): bool

Returns true when enabled hardware carries out the GHASH carry-less multiply.

aesGcmEncrypt (fun)

trusted fun aesGcmEncrypt(key: string, nonce: string, plaintext: string,
    associatedData: string = ""): CryptoResult

Returns ciphertext followed by its authentication tag, or an error for an invalid key or nonce size.

aesGcmDecrypt (fun)

trusted fun aesGcmDecrypt(key: string, nonce: string, ciphertext: string,
    associatedData: string = ""): CryptoResult

Returns authenticated plaintext or an error for invalid sizes or failed authentication.

AesGcmKey (class)

resource class AesGcmKey(val memory: int, val keySize: int)

The kept hardware key of aesGcmKeyNew as an owner: dropped, the memory is wiped and freed, so a connection that holds one needs no release call. A single owner (move it).

AesGcmKey.drop (method)

trusted fun drop(): void

Wipes and frees the retained GCM key material.

aesGcmKeyOwner (fun)

fun aesGcmKeyOwner(key: string): AesGcmKey?

The kept key for key, or null where aesGcmKeyNew gives none (no AES instructions, a wrong size).

AesGcmKey.seal (extension fun)

fun AesGcmKey.seal(nonce: string, plaintext: string, associatedData: string = ""): CryptoResult

Returns ciphertext and its tag using the retained key, or an error for invalid inputs.

AesGcmKey.open (extension fun)

fun AesGcmKey.open(nonce: string, ciphertext: string, associatedData: string = ""): CryptoResult

Returns plaintext using the retained key, or an error for invalid inputs or failed authentication.

AES_GCM_RANDOM_NONCE_SIZE (val)

val AES_GCM_RANDOM_NONCE_SIZE

The size of the nonce aesGcmSealRandom draws and puts first in its box.

aesGcmSealRandom (fun)

trusted fun aesGcmSealRandom(key: string, plaintext: string, associatedData: string = ""): CryptoResult

AES-GCM with a fresh random 12-byte nonce (from the system, or from cryptoSetRandom's source): the nonce, the ciphertext and the 16-byte tag, as one box for aesGcmOpenRandom. Fails without randomness. A random 96-bit nonce is safe for at most 2^32 messages under one key (NIST SP 800-38D 8.3: the chance of a repeated nonce stays below 2^-32); a sender with more must change the key before that, or count its nonces itself and use aesGcmEncrypt. Never reuse a nonce under a key: one repeat gives away the authentication key.

aesGcmOpenRandom (fun)

trusted fun aesGcmOpenRandom(key: string, box: string, associatedData: string = ""): CryptoResult

Opens what aesGcmSealRandom made (the nonce first), or fails with the message of aesGcmDecrypt.

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