API reference: nimcrypto

bcmode

Types

ECB

ECB (Electronic Code Book) context object

ECB[T] = object
  cipher: T
  tmp: array[MaxBlockBytesSize, byte]
1
2
3

CBC

CBC (Cipher Block Chaining) context object

CBC[T] = object
  cipher: T
  iv: array[MaxBlockBytesSize, byte]
  tmp: array[MaxBlockBytesSize, byte]
1
2
3
4

OFB

OFB (Output FeedBack) context object

OFB[T] = object
  cipher: T
  iv: array[MaxBlockBytesSize, byte]
1
2
3

CFB

CFB (Cipher FeedBack) context object

CFB[T] = object
  cipher: T
  iv: array[MaxBlockBytesSize, byte]
1
2
3

CTR

CTR (Counter) context object

CTR[T] = object
  cipher: T
  iv: array[MaxBlockBytesSize, byte]
  ecount: array[MaxBlockBytesSize, byte]
  num: uint
1
2
3
4
5

GCM

GCM (Galois/Counter Mode) context object

GCM[T] = object
  cipher: T
  h: array[16, byte]
  y: array[16, byte]
  basectr: array[16, byte]
  buf: array[16, byte]
  aadlen: uint64
  datalen: uint64
1
2
3
4
5
6
7
8

Procs


init

Initialize ECB[T] with encryption key key.

Note! Size of data pointed by key must be at least ctx.sizeKey octets (bytes).

proc init[T](ctx: var ECB[T]; key: ptr byte)
1

init

Initialize ECB[T] with encryption key key.

This procedure will not perform any additional padding for encryption key key.

Length of key must be at least ECB[T].sizeKey() octets (bytes).

You can see examples of usage ECB mode here examples/ecb.nim.

proc init[T](ctx: var ECB[T]; key: openArray[byte]) {.inline.}
1

init

Initialize ECB[T] with encryption key key.

This procedure will not perform any additional padding for encryption key key.

Length of key must be at least ECB[T].sizeKey() octets (bytes).

You can see examples of usage ECB mode here examples/ecb.nim.

proc init[T](ctx: var ECB[T]; key: openArray[char]) {.inline.}
1

clear

Clear ECB[T] context ctx.

proc clear[T](ctx: var ECB[T]) {.inline.}
1

encrypt

Perform ECB[T] encryption of plain data pointed by inp of length length and store encrypted data to oup. oup must be able to hold at least length octets (bytes) of data.

Note, that this procedure do not perform any additional padding, so you need to do it on your own. length must be aligned to the ctx.sizeBlock value, e.g. length mod ctx.sizeBlock == 0.

Procedure returns number of processed octets (bytes).

proc encrypt[T](ctx: var ECB[T]; inp: ptr byte; oup: ptr byte; length: uint): uint {.
    discardable.}
1
2

decrypt

Perform ECB[T] decryption of encrypted data pointed by inp of length length and store plain data to oup. oup must be able to hold at least length octets (bytes) of data.

Note, that this procedure do not perform any additional padding, so you need to do it on your own. length must be aligned to the ctx.sizeBlock value, e.g. length mod ctx.sizeBlock == 0.

Procedure returns number of processed octets (bytes).

proc decrypt[T](ctx: var ECB[T]; inp: ptr byte; oup: ptr byte; length: uint): uint {.
    discardable.}
1
2

encrypt

Encrypt array of data input and store encrypted data to array output using ECB[T] context ctx.

Note that length of input array must be less or equal to length of output array. Length of input array must not be zero.

Note, that this procedure do not perform any additional padding, so you need to do it on your own. Length of input must be aligned to the ctx.sizeBlock value, e.g. len(input) mod ctx.sizeBlock == 0.

proc encrypt[T](ctx: var ECB[T]; input: openArray[byte]; output: var openArray[byte]) {.
    inline.}
1
2

encrypt

Encrypt array of data input and store encrypted data to array output using ECB[T] context ctx.

Note that length of input array must be less or equal to length of output array. Length of input array must not be zero.

Note, that this procedure do not perform any additional padding, so you need to do it on your own. Length of input must be aligned to the ctx.sizeBlock value, e.g. len(input) mod ctx.sizeBlock == 0.

proc encrypt[T](ctx: var ECB[T]; input: openArray[char]; output: var openArray[char]) {.
    inline.}
1
2

decrypt

Decrypt array of data input and store decrypted data to array output using ECB[T] context ctx.

Note that length of input array must be less or equal to length of output array. Length of input array must not be zero.

Note, that this procedure do not perform any additional padding, so you need to do it on your own. Length of input must be aligned to the ctx.sizeBlock value, e.g. len(input) mod ctx.sizeBlock == 0.

proc decrypt[T](ctx: var ECB[T]; input: openArray[byte]; output: var openArray[byte]) {.
    inline.}
1
2

decrypt

Decrypt array of data input and store decrypted data to array output using ECB[T] context ctx.

Note that length of input array must be less or equal to length of output array. Length of input array must not be zero.

Note, that this procedure do not perform any additional padding, so you need to do it on your own. Length of input must be aligned to the ctx.sizeBlock value, e.g. len(input) mod ctx.sizeBlock == 0.

proc decrypt[T](ctx: var ECB[T]; input: openArray[char]; output: var openArray[char]) {.
    inline.}
1
2

init

Initialize CBC[T] with encryption key key and initial vector (IV) iv.

Note! Size of encryption key pointed by key must be at least ctx.sizeKey octets (bytes) and size of initial vector iv must be at least ctx.sizeBlock octets (bytes).

You can see examples of usage CBC mode here examples/cbc.nim.

proc init[T](ctx: var CBC[T]; key: ptr byte; iv: ptr byte)
1

init

Initialize CBC[T] with encryption key key and initial vector (IV) iv.

This procedure will not perform any additional padding for encryption key key and initial vector iv.

Length of key must be at least ctx.sizeKey() octets (bytes). Length of iv must be at least ctx.sizeBlock() octets (bytes)

You can see examples of usage CBC mode here examples/cbc.nim.

proc init[T](ctx: var CBC[T]; key: openArray[byte]; iv: openArray[byte])
1

init

Initialize CBC[T] with encryption key key and initial vector (IV) iv.

This procedure will not perform any additional padding for encryption key key and initial vector iv.

Length of key must be at least ctx.sizeKey() octets (bytes). Length of iv must be at least ctx.sizeBlock() octets (bytes)

You can see examples of usage CBC mode here examples/cbc.nim.

proc init[T](ctx: var CBC[T]; key: openArray[char]; iv: openArray[char])
1

clear

Clear CBC[T] context ctx.

proc clear[T](ctx: var CBC[T]) {.inline.}
1

encrypt

Perform CBC[T] encryption of plain data pointed by inp of length length and store encrypted data to oup. oup must be able to hold at least length octets (bytes) of data.

Note, that this procedure do not perform any additional padding, so you need to do it on your own. length must be aligned to the ctx.sizeBlock value, e.g. length mod ctx.sizeBlock == 0.

Procedure returns number of processed octets (bytes).

proc encrypt[T](ctx: var CBC[T]; inp: ptr byte; oup: ptr byte; length: uint): uint {.
    discardable.}
1
2

decrypt

Perform CBC[T] decryption of encrypted data pointed by inp of length length and store plain data to oup. oup must be able to hold at least length octets (bytes) of data.

Note, that this procedure do not perform any additional padding, so you need to do it on your own. length must be aligned to the ctx.sizeBlock value, e.g. length mod ctx.sizeBlock == 0.

Procedure returns number of processed octets (bytes).

proc decrypt[T](ctx: var CBC[T]; inp: ptr byte; oup: ptr byte; length: uint): uint {.
    discardable.}
1
2

encrypt

Encrypt array of data input and store encrypted data to array output using CBC[T] context ctx.

Note that length of input array must be less or equal to length of output array. Length of input array must not be zero.

Note, that this procedure do not perform any additional padding, so you need to do it on your own. Length of input must be aligned to the ctx.sizeBlock value, e.g. len(input) mod ctx.sizeBlock == 0.

proc encrypt[T](ctx: var CBC[T]; input: openArray[byte]; output: var openArray[byte]) {.
    inline.}
1
2

encrypt

Encrypt array of data input and store encrypted data to array output using CBC[T] context ctx.

Note that length of input array must be less or equal to length of output array. Length of input array must not be zero.

Note, that this procedure do not perform any additional padding, so you need to do it on your own. Length of input must be aligned to the ctx.sizeBlock value, e.g. len(input) mod ctx.sizeBlock == 0.

proc encrypt[T](ctx: var CBC[T]; input: openArray[char]; output: var openArray[char]) {.
    inline.}
1
2

decrypt

Decrypt array of data input and store decrypted data to array output using CBC[T] context ctx.

Note that length of input array must be less or equal to length of output array. Length of input array must not be zero.

Note, that this procedure do not perform any additional padding, so you need to do it on your own. Length of input must be aligned to the ctx.sizeBlock value, e.g. len(input) mod ctx.sizeBlock == 0.

proc decrypt[T](ctx: var CBC[T]; input: openArray[byte]; output: var openArray[byte]) {.
    inline.}
1
2

decrypt

Decrypt array of data input and store decrypted data to array output using CBC[T] context ctx.

Note that length of input array must be less or equal to length of output array. Length of input array must not be zero.

Note, that this procedure do not perform any additional padding, so you need to do it on your own. Length of input must be aligned to the ctx.sizeBlock value, e.g. len(input) mod ctx.sizeBlock == 0.

proc decrypt[T](ctx: var CBC[T]; input: openArray[char]; output: var openArray[char]) {.
    inline.}
1
2

init

Initialize CTR[T] with encryption key key and initial vector (IV) iv.

Note! Size of encryption key pointed by key must be at least ctx.sizeKey octets (bytes) and size of initial vector iv must be at least ctx.sizeBlock octets (bytes).

You can see examples of usage CTR mode here examples/ctr.nim.

proc init[T](ctx: var CTR[T]; key: ptr byte; iv: ptr byte)
1

init

Initialize CTR[T] with encryption key key and initial vector (IV) iv.

This procedure will not perform any additional padding for encryption key key and initial vector iv.

Length of key array must be at least ctx.sizeKey() octets (bytes). Length of iv array must be at least ctx.sizeBlock() octets (bytes).

You can see examples of usage CTR mode here examples/ctr.nim.

proc init[T](ctx: var CTR[T]; key: openArray[byte]; iv: openArray[byte])
1

init

Initialize CTR[T] with encryption key key and initial vector (IV) iv.

This procedure will not perform any additional padding for encryption key key and initial vector iv.

Length of key array must be at least ctx.sizeKey() octets (bytes). Length of iv array must be at least ctx.sizeBlock() octets (bytes).

You can see examples of usage CTR mode here examples/ctr.nim.

proc init[T](ctx: var CTR[T]; key: openArray[char]; iv: openArray[char]) {.inline.}
1

clear

Clear CTR[T] context ctx.

proc clear[T](ctx: var CTR[T]) {.inline.}
1

encrypt

Perform CTR[T] encryption of plain data pointed by inp of length length and store encrypted data to oup. oup must be able to hold at least length octets (bytes) of data.

Procedure returns number of processed octets (bytes).

proc encrypt[T](ctx: var CTR[T]; inp: ptr byte; oup: ptr byte; length: uint): uint {.
    discardable.}
1
2

decrypt

Perform CTR[T] decryption of encrypted data pointed by inp of length length and store decrypted data to oup. oup must be able to hold at least length octets (bytes) of data.

Procedures returns number of processed octets (bytes).

proc decrypt[T](ctx: var CTR[T]; inp: ptr byte; oup: ptr byte; length: uint): uint {.
    discardable, inline.}
1
2

encrypt

Encrypt array of data input and store encrypted data to array output using CTR[T] context ctx.

Note that length of input array must be less or equal to length of output array. Length of input array must not be zero.

proc encrypt[T](ctx: var CTR[T]; input: openArray[byte]; output: var openArray[byte]) {.
    inline.}
1
2

encrypt

Encrypt array of data input and store encrypted data to array output using CTR[T] context ctx.

Note that length of input array must be less or equal to length of output array. Length of input array must not be zero.

proc encrypt[T](ctx: var CTR[T]; input: openArray[char]; output: var openArray[char]) {.
    inline.}
1
2

decrypt

Decrypt array of data input and store decrypted data to array output using CTR[T] context ctx.

Note that length of input array must be less or equal to length of output array. Length of input array must not be zero.

proc decrypt[T](ctx: var CTR[T]; input: openArray[byte]; output: var openArray[byte]) {.
    inline.}
1
2

decrypt

Decrypt array of data input and store decrypted data to array output using CTR[T] context ctx.

Note that length of input array must be less or equal to length of output array. Length of input array must not be zero.

proc decrypt[T](ctx: var CTR[T]; input: openArray[char]; output: var openArray[char]) {.
    inline.}
1
2

init

Initialize OFB[T] with encryption key key and initial vector (IV) iv.

Note! Size of encryption key pointed by key must be at least ctx.sizeKey octets (bytes) and size of initial vector iv must be at least ctx.sizeBlock octets (bytes).

You can see examples of usage OFB mode here examples/ofb.nim.

proc init[T](ctx: var OFB[T]; key: ptr byte; iv: ptr byte)
1

init

Initialize OFB[T] with encryption key key and initial vector (IV) iv.

This procedure will not perform any additional padding for encryption key key and initial vector iv.

Length of key array must be at least ctx.sizeKey() octets (bytes). Length of iv array must be at least ctx.sizeBlock() octets (bytes).

You can see examples of usage OFB mode here examples/ofb.nim.

proc init[T](ctx: var OFB[T]; key: openArray[byte]; iv: openArray[byte])
1

init

Initialize OFB[T] with encryption key key and initial vector (IV) iv.

This procedure will not perform any additional padding for encryption key key and initial vector iv.

Length of key array must be at least ctx.sizeKey() octets (bytes). Length of iv array must be at least ctx.sizeBlock() octets (bytes).

You can see examples of usage OFB mode here examples/ofb.nim.

proc init[T](ctx: var OFB[T]; key: openArray[char]; iv: openArray[char])
1

clear

Clear OFB[T] context ctx.

proc clear[T](ctx: var OFB[T]) {.inline.}
1

encrypt

Perform OFB[T] encryption of plain data pointed by inp of length length and store encrypted data to oup. oup must be able to hold at least length octets (bytes) of data.

Note, that this procedure do not perform any additional padding, so you need to do it on your own. length must be aligned to the ctx.sizeBlock value, e.g. length mod ctx.sizeBlock == 0.

Procedure returns number of processed octets (bytes).

proc encrypt[T](ctx: var OFB[T]; inp: ptr byte; oup: ptr byte; length: uint): uint {.
    discardable.}
1
2

decrypt

Perform OFB[T] decryption of encrypted data pointed by inp of length length and store plain data to oup. oup must be able to hold at least length octets (bytes) of data.

Note, that this procedure do not perform any additional padding, so you need to do it on your own. length must be aligned to the ctx.sizeBlock value, e.g. length mod ctx.sizeBlock == 0.

Procedure returns number of processed octets (bytes).

proc decrypt[T](ctx: var OFB[T]; inp: ptr byte; oup: ptr byte; length: uint): uint {.
    discardable, inline.}
1
2

encrypt

Encrypt array of data input and store encrypted data to array output using OFB[T] context ctx.

Note that length of input array must be less or equal to length of output array. Length of input array must not be zero.

Note, that this procedure do not perform any additional padding, so you need to do it on your own. Length of input must be aligned to the ctx.sizeBlock value, e.g. len(input) mod ctx.sizeBlock == 0.

proc encrypt[T](ctx: var OFB[T]; input: openArray[byte]; output: var openArray[byte]) {.
    inline.}
1
2

encrypt

Encrypt array of data input and store encrypted data to array output using OFB[T] context ctx.

Note that length of input array must be less or equal to length of output array. Length of input array must not be zero.

Note, that this procedure do not perform any additional padding, so you need to do it on your own. Length of input must be aligned to the ctx.sizeBlock value, e.g. len(input) mod ctx.sizeBlock == 0.

proc encrypt[T](ctx: var OFB[T]; input: openArray[char]; output: var openArray[char]) {.
    inline.}
1
2

decrypt

Decrypt array of data input and store decrypted data to array output using OFB[T] context ctx.

Note that length of input array must be less or equal to length of output array. Length of input array must not be zero.

Note, that this procedure do not perform any additional padding, so you need to do it on your own. Length of input must be aligned to the ctx.sizeBlock value, e.g. len(input) mod ctx.sizeBlock == 0.

proc decrypt[T](ctx: var OFB[T]; input: openArray[byte]; output: var openArray[byte]) {.
    inline.}
1
2

decrypt

Decrypt array of data input and store decrypted data to array output using OFB[T] context ctx.

Note that length of input array must be less or equal to length of output array. Length of input array must not be zero.

Note, that this procedure do not perform any additional padding, so you need to do it on your own. Length of input must be aligned to the ctx.sizeBlock value, e.g. len(input) mod ctx.sizeBlock == 0.

proc decrypt[T](ctx: var OFB[T]; input: openArray[char]; output: var openArray[char]) {.
    inline.}
1
2

init

Initialize CFB[T] with encryption key key and initial vector (IV) iv.

Note! Size of encryption key pointed by key must be at least ctx.sizeKey octets (bytes) and size of initial vector iv must be at least ctx.sizeBlock octets (bytes).

You can see examples of usage CFB mode here examples/cfb.nim.

proc init[T](ctx: var CFB[T]; key: ptr byte; iv: ptr byte)
1

init

Initialize CFB[T] with encryption key key and initial vector (IV) iv.

This procedure will not perform any additional padding for encryption key key and initial vector iv.

Length of key array must be at least ctx.sizeKey() octets (bytes). Length of iv array must be at least ctx.sizeBlock() octets (bytes).

You can see examples of usage CFB mode here examples/cfb.nim.

proc init[T](ctx: var CFB[T]; key: openArray[byte]; iv: openArray[byte])
1

init

Initialize CFB[T] with encryption key key and initial vector (IV) iv.

This procedure will not perform any additional padding for encryption key key and initial vector iv.

Length of key array must be at least ctx.sizeKey() octets (bytes). Length of iv array must be at least ctx.sizeBlock() octets (bytes).

You can see examples of usage CFB mode here examples/cfb.nim.

proc init[T](ctx: var CFB[T]; key: openArray[char]; iv: openArray[char])
1

clear

Clear CFB[T] context ctx.

proc clear[T](ctx: var CFB[T]) {.inline.}
1

encrypt

Perform CFB[T] encryption of plain data pointed by inp of length length and store encrypted data to oup. oup must be able to hold at least length octets (bytes) of data.

Note, that this procedure do not perform any additional padding, so you need to do it on your own. length must be aligned to the ctx.sizeBlock value, e.g. length mod ctx.sizeBlock == 0.

Procedure returns number of processed octets (bytes).

proc encrypt[T](ctx: var CFB[T]; inp: ptr byte; oup: ptr byte; length: uint): uint {.
    discardable.}
1
2

decrypt

Perform CFB[T] decryption of encrypted data pointed by inp of length length and store plain data to oup. oup must be able to hold at least length octets (bytes) of data.

Note, that this procedure do not perform any additional padding, so you need to do it on your own. length must be aligned to the ctx.sizeBlock value, e.g. length mod ctx.sizeBlock == 0.

Procedure returns number of processed octets (bytes).

proc decrypt[T](ctx: var CFB[T]; inp: ptr byte; oup: ptr byte; length: uint): uint {.
    discardable.}
1
2

encrypt

Encrypt array of data input and store encrypted data to array output using CFB[T] context ctx.

Note that length of input array must be less or equal to length of output array. Length of input array must not be zero.

Note, that this procedure do not perform any additional padding, so you need to do it on your own. Length of input must be aligned to the ctx.sizeBlock value, e.g. len(input) mod ctx.sizeBlock == 0.

proc encrypt[T](ctx: var CFB[T]; input: openArray[byte]; output: var openArray[byte]) {.
    inline.}
1
2

encrypt

Encrypt array of data input and store encrypted data to array output using CFB[T] context ctx.

Note that length of input array must be less or equal to length of output array. Length of input array must not be zero.

Note, that this procedure do not perform any additional padding, so you need to do it on your own. Length of input must be aligned to the ctx.sizeBlock value, e.g. len(input) mod ctx.sizeBlock == 0.

proc encrypt[T](ctx: var CFB[T]; input: openArray[char]; output: var openArray[char]) {.
    inline.}
1
2

decrypt

Decrypt array of data input and store decrypted data to array output using CFB[T] context ctx.

Note that length of input array must be less or equal to length of output array. Length of input array must not be zero.

Note, that this procedure do not perform any additional padding, so you need to do it on your own. Length of input must be aligned to the ctx.sizeBlock value, e.g. len(input) mod ctx.sizeBlock == 0.

proc decrypt[T](ctx: var CFB[T]; input: openArray[byte]; output: var openArray[byte])
1

decrypt

Decrypt array of data input and store decrypted data to array output using CFB[T] context ctx.

Note that length of input array must be less or equal to length of output array. Length of input array must not be zero.

Note, that this procedure do not perform any additional padding, so you need to do it on your own. Length of input must be aligned to the ctx.sizeBlock value, e.g. len(input) mod ctx.sizeBlock == 0.

proc decrypt[T](ctx: var CFB[T]; input: openArray[char]; output: var openArray[char])
1

init

Initialize GCM[T] with encryption key key, initial vector (IV) iv and additional authentication data (AAD) aad.

Size of key must be at least ctx.sizeKey() octets (bytes). Size of cipher T block must be 128 bits (16 bytes).

You can see examples of usage GCM mode here examples/gcm.nim.

proc init[T](ctx: var GCM[T]; key: openArray[byte]; iv: openArray[byte];
            aad: openArray[byte])
1
2

encrypt

Encrypt array of data input and store encrypted data to array output using GCM[T] context ctx.

Note that length of input must be less or equal to length of output. Length of input must not be zero.

proc encrypt[T](ctx: var GCM[T]; input: openArray[byte]; output: var openArray[byte])
1

decrypt

Decrypt array of data input and store decrypted data to array output using GCM[T] context ctx.

Note that length of input must be less or equal to length of output. Length of input must not be zero.

proc decrypt[T](ctx: var GCM[T]; input: openArray[byte]; output: var openArray[byte])
1

getTag

Obtain authentication tag from GCM[T] context ctx and store it to tag.

Note that maximum size of tag is 128 bits (16 bytes).

proc getTag[T](ctx: var GCM[T]; tag: var openArray[byte])
1

getTag

Obtain authentication tag from GCM[T] context ctx and return it as result array.

proc getTag[T](ctx: var GCM[T]): array[16, byte] {.noinit.}
1

clear

Clear GCM[T] context ctx.

proc clear[T](ctx: var GCM[T]) {.inline.}
1

Templates


sizeBlock

Size of ECB[T] block in octets (bytes). This value is equal to cipher T block size.

template sizeBlock[T](ctx: ECB[T]): int
1

sizeKey

Size of ECB[T] key in octets (bytes). This value is equal to cipher T key size.

template sizeKey[T](ctx: ECB[T]): int
1

sizeBlock

Size of CBC[T] block in octets (bytes). This value is equal to cipher T block size.

template sizeBlock[T](ctx: CBC[T]): int
1

sizeKey

Size of CBC[T] key in octets (bytes). This value is equal to cipher T key size.

template sizeKey[T](ctx: CBC[T]): int
1

sizeBlock

Size of CTR[T] block in octets (bytes). This value is equal to cipher T block size.

template sizeBlock[T](ctx: CTR[T]): int
1

sizeKey

Size of CTR[T] key in octets (bytes). This value is equal to cipher T key size.

template sizeKey[T](ctx: CTR[T]): int
1

sizeBlock

Size of OFB[T] block in octets (bytes). This value is equal to cipher T block size.

template sizeBlock[T](ctx: OFB[T]): int
1

sizeKey

Size of OFB[T] key in octets (bytes). This value is equal to cipher T key size.

template sizeKey[T](ctx: OFB[T]): int
1

sizeBlock

Size of CFB[T] block in octets (bytes). This value is equal to cipher T block size.

template sizeBlock[T](ctx: CFB[T]): int
1

sizeKey

Size of CFB[T] key in octets (bytes). This value is equal to cipher T key size.

template sizeKey[T](ctx: CFB[T]): int
1

sizeBlock

Size of GCM[T] block in octets (bytes). This value is equal to cipher T block size.

template sizeBlock[T](ctx: GCM[T]): int
1

sizeKey

Size of GCM[T] key in octets (bytes). This value is equal to cipher T key size.

template sizeKey[T](ctx: GCM[T]): int
1

blake2

Types

Blake2Context

undefined

Blake2Context = Blake2sContext | Blake2bContext
1

blake2_224

undefined

blake2_224 = Blake2sContext[224]
1

blake2_256

undefined

blake2_256 = Blake2sContext[256]
1

blake2_384

undefined

blake2_384 = Blake2bContext[384]
1

blake2_512

undefined

blake2_512 = Blake2bContext[512]
1

blake2

undefined

blake2 = blake2_224 | blake2_256 | blake2_384 | blake2_512
1

Procs


update

undefined

proc update(ctx: var Blake2Context; data: ptr byte; ulen: uint)
1

update

undefined

proc update[T: bchar](ctx: var Blake2Context; data: openArray[T]) {.inline.}
1

finish

undefined

proc finish(ctx: var Blake2sContext; data: ptr byte; ulen: uint): uint
1

finish

undefined

proc finish(ctx: var Blake2bContext; data: ptr byte; ulen: uint): uint
1

finish

undefined

proc finish(ctx: var Blake2sContext): MDigest[ctx.bits]
1

finish

undefined

proc finish(ctx: var Blake2bContext): MDigest[ctx.bits]
1

finish

undefined

proc finish[T: bchar](ctx: var Blake2Context; data: var openArray[T])
1

init

undefined

proc init(ctx: var Blake2Context; key: ptr byte = nil; keylen: uint = 0'u)
1

init

undefined

proc init[T: bchar](ctx: var Blake2Context; key: openArray[T]) {.inline.}
1

clear

undefined

proc clear(ctx: var Blake2Context) {.inline.}
1

Templates


BLGETU64

undefined

template BLGETU64(p, o): uint64
1

BLGETU32

undefined

template BLGETU32(p, o): uint32
1

sizeDigest

undefined

template sizeDigest(ctx: Blake2Context): uint
1

sizeBlock

undefined

template sizeBlock(ctx: Blake2Context): uint
1

sizeDigest

undefined

template sizeDigest(r: typedesc[blake2]): int
1

sizeBlock

undefined

template sizeBlock(r: typedesc[blake2]): int
1

blowfish

Types

blowfish

undefined

blowfish = BlowfishContext[64]
1

Procs


blowfishEncrypt

undefined

proc blowfishEncrypt(ctx: var BlowfishContext; inp: ptr byte; oup: ptr byte)
1

blowfishDecrypt

undefined

proc blowfishDecrypt(ctx: var BlowfishContext; inp: ptr byte; oup: ptr byte)
1

initBlowfishContext

undefined

proc initBlowfishContext(ctx: var BlowfishContext; key: ptr byte; nkey: int)
1

init

undefined

proc init(ctx: var BlowfishContext; key: ptr byte; nkey: int) {.inline.}
1

init

undefined

proc init(ctx: var BlowfishContext; key: openArray[byte]) {.inline.}
1

clear

undefined

proc clear(ctx: var BlowfishContext) {.inline.}
1

encrypt

undefined

proc encrypt(ctx: var BlowfishContext; inbytes: ptr byte; outbytes: ptr byte) {.inline.}
1

decrypt

undefined

proc decrypt(ctx: var BlowfishContext; inbytes: ptr byte; outbytes: ptr byte) {.inline.}
1

encrypt

undefined

proc encrypt(ctx: var BlowfishContext; input: openArray[byte];
            output: var openArray[byte]) {.inline.}
1
2

decrypt

undefined

proc decrypt(ctx: var BlowfishContext; input: openArray[byte];
            output: var openArray[byte]) {.inline.}
1
2

Templates


sizeKey

undefined

template sizeKey(ctx: BlowfishContext): int
1

sizeBlock

undefined

template sizeBlock(ctx: BlowfishContext): int
1

sizeKey

undefined

template sizeKey(r: typedesc[blowfish]): int
1

sizeBlock

undefined

template sizeBlock(r: typedesc[blowfish]): int
1

hash

Types

MDigest

Message digest type

MDigest[bits] = object
  data*: array[bits div 8, byte]
1
2

bchar

undefined

bchar = byte | char
1

Procs


`####

Return hexadecimal string representation of digest.

import nimcrypto

var digestHexString = $sha256.digest("Hello World!") echo digestHexString

proc `#### `####  

 Return hexadecimal string representation of <tt class="docutils literal"><span class="pre">digest</span></tt>.<blockquote><p><pre class="listing"><span class="Keyword">import</span> <span class="Identifier">nimcrypto</span>

<span class="Keyword">var</span> <span class="Identifier">digestHexString</span> <span class="Operator">=</span> <span class="Operator">$</span><span class="Identifier">sha256</span><span class="Operator">.</span><span class="Identifier">digest</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World!&quot;</span><span class="Punctuation">)</span>
<span class="Identifier">echo</span> <span class="Identifier">digestHexString</span></pre></p></blockquote>
 

```nim(digest: MDigest): string
1
2
3
4
5
6
7
8
9

digest

Calculate and return digest using algorithm HashType of data data with length ulen.

import nimcrypto

var stringToHash = "Hello World!" let data = cast[ptr byte](addr stringToHash[0]) let datalen = uint(len(stringToHash)) echo sha256.digest(data, datalen)

proc digest(HashType: typedesc; data: ptr byte; ulen: uint): MDigest[HashType.bits]
1

digest

Calculate and return digest using algorithm HashType of data data in slice [ostart, ofinish], both ostart and ofinish are inclusive.

import nimcrypto

var stringToHash = "Hello World!" ## Calculate digest of whole string Hello World!. echo sha256.digest(stringToHash) ## Calcualte digest of Hello. echo sha256.digest(stringToHash, ofinish = 4) ## Calculate digest of World!. echo sha256.digest(stringToHash, ostart = 6) ## Calculate digest of constant Hello. echo sha256.digest("Hello") ## Calculate digest of constant World!. echo sha256.digest("World!")

proc digest[T](HashType: typedesc; data: openArray[T]; ostart: int = 0;
              ofinish: int = -1): MDigest[HashType.bits]
1
2

fromHex

Create MDigest object from hexadecimal string representation.

import nimcrypto

var a = MDigest[256].fromHex("7F83B1657FF1FC53B92DC18148A1D65DFC2D4B1FA3D677284ADDD200126D9069") echo $a ## Get number of bits used by a. echo a.bits

proc fromHex(T: typedesc[MDigest]; s: string): T:type
1

==

Check for equality between two MDigest objects d1 and d2. If size in bits of d1 is not equal to size in bits of d2 then digests considered as not equal.

proc `==`[A, B](d1: MDigest[A]; d2: MDigest[B]): bool
1

Templates


toDigest

Convert hexadecimal string representation to MDigest object. This template can be used to create MDigest constants.

import nimcrypto

const SomeDigest = "7F83B1657FF1FC53B92DC18148A1D65DFC2D4B1FA3D677284ADDD200126D9069".toDigest echo $SomeDigest ## Get number of bits used by SomeDigest. echo SomeDigest.bits

template toDigest(s: static string): auto
1

hmac

Types

HMAC

HMAC context object.

HMAC[HashType] = object
  mdctx: HashType
  opadctx: HashType
1
2
3

Procs


init

Initialize HMAC context hmctx with key using key and size ulen.

key can be nil.

proc init[T](hmctx: var HMAC[T]; key: ptr byte; ulen: uint)
1

init

Initialize HMAC context hmctx with key using key array.

key can be zero-length array.

proc init[T](hmctx: var HMAC[T]; key: openArray[byte]) {.inline.}
1

init

Initialize HMAC context hmctx with key using key string/array.

key can be zero-length array.

proc init[T](hmctx: var HMAC[T]; key: openArray[char]) {.inline.}
1

clear

Clear HMAC context hmctx.

proc clear(hmctx: var HMAC)
1

update

Update HMAC context hmctx with data pointed by data and length ulen. Repeated calls are equivalent to a single call with the concatenation of all data arguments.

data can be nil, but ulen must be 0 in such case.

proc update(hmctx: var HMAC; data: ptr byte; ulen: uint)
1

update

Update HMAC context hmctx with data array data. Repeated calls are equivalent to a single call with the concatenation of all data arguments.

data can be zero-length array.

proc update[T: bchar](hmctx: var HMAC; data: openArray[T]) {.inline.}
1

finish

Finalize HMAC context hmctx and store calculated digest in data pointed by data and length ulen. data must be able to hold result.

proc finish(hmctx: var HMAC; data: ptr byte; ulen: uint): uint
1

finish

Finalize HMAC context hmctx and store calculated digest in array data. data length must be at least hmctx.sizeDigest octets (bytes).

proc finish[T: bchar](hmctx: var HMAC; data: var openArray[T]): uint {.inline.}
1

finish

Finalize HMAC context hmctx and return calculated digest as MDigest object.

proc finish(hmctx: var HMAC): MDigest[HashType.bits]
1

hmac

Perform HMAC computation with hash algorithm HashType using key key of length klen on data buffer pointed by data of length ulen.

import nimcrypto

var stringToHmac = "Hello World!" var stringHmacKey = "AliceKey" let data = cast[ptr byte](addr stringToHmac[0]) let datalen = uint(len(stringToHmac)) let key = cast[ptr byte](addr stringHmacKey[0]) let keylen = uint(len(stringHmacKey)) # Print HMAC[SHA256](key = "AliceKey", data = "Hello World!") echo sha256.hmac(key, keylen, data, datalen) # Print HMAC[SHA512](key = "AliceKey", data = "Hello World!") echo sha512.hmac(key, keylen, data, datalen) # Print HMAC[KECCAK256](key = "AliceKey", data = "Hello World!") echo keccak256.hmac(key, keylen, data, datalen) # Print HMAC[RIPEMD160](key = "AliceKey", data = "Hello World!") echo ripemd160.hmac(key, keylen, data, datalen)

proc hmac(HashType: typedesc; key: ptr byte; klen: uint; data: ptr byte; ulen: uint): MDigest[
    HashType.bits]
1
2

hmac

Perform HMAC computation with hash algorithm HashType using key key of data data, in slice [ostart, ofinish], both ostart and ofinish are inclusive.

import nimcrypto

var stringToHmac = "Hello World!" var stringHmacKey = "AliceKey" # Print HMAC[SHA256] digest of whole string Hello World! using # key AliceKey. echo sha256.hmac(stringHmacKey, stringToHmac) # Print HMAC[SHA256] digest of Hello using key AliceKey. echo sha256.hmac(stringHmacKey, stringToHmac, ofinish = 4) # Print HMAC[SHA256] digest of World! using key AliceKey. echo sha256.hmac(stringHmacKey, stringToHmac, ostart = 6) # Print HMAC[SHA256] digest of constant Hello using constant key # AliceKey. echo sha256.hmac("AliceKey", "Hello") # Print HMAC[SHA256] digest of constant World! using constant key # AliceKey echo sha256.hmac("AliceKey", "World!")

proc hmac[A, B](HashType: typedesc; key: openArray[A]; data: openArray[B];
              ostart: int = 0; ofinish: int = -1): MDigest[HashType.bits]
1
2

Templates


sizeBlock

Size of processing block in octets (bytes), while perform HMAC operation using SHA2 algorithms.

template sizeBlock(h: HMAC[Sha2Context]): uint
1

sizeBlock

Size of processing block in octets (bytes), while perform HMAC operation using RIPEMD algorithms.

template sizeBlock(h: HMAC[RipemdContext]): uint
1

sizeBlock

Size of processing block in octets (bytes), while perform HMAC operation using KECCAK/SHA3/SHAKE algorithms.

template sizeBlock(h: HMAC[KeccakContext]): uint
1

sizeBlock

Size of processing block in octets (bytes), while perform HMAC operation using BLAKE2b/BLAKE2s algorithms.

template sizeBlock(h: HMAC[Blake2Context]): uint
1

sizeBlock

Size of processing block in octets (bytes), while perform HMAC operation using SHA1 algorithm.

template sizeBlock(h: HMAC[Sha1Context]): uint
1

sizeDigest

Size of HMAC digest in octets (bytes) using SHA2 algorithms.

template sizeDigest(h: HMAC[Sha2Context]): uint
1

sizeDigest

Size of HMAC digest in octets (bytes) using RIPEMD algorithms.

template sizeDigest(h: HMAC[RipemdContext]): uint
1

sizeDigest

Size of HMAC digest in octets (bytes) using KECCAK/SHA3/SHAKE algorithms.

template sizeDigest(h: HMAC[KeccakContext]): uint
1

sizeDigest

Size of HMAC digest in octets (bytes) using BLAKE2b/BLAKE2s algorithms.

template sizeDigest(h: HMAC[Blake2Context]): uint
1

sizeDigest

Size of HMAC digest in octets (bytes) using SHA1 algorithm.

template sizeDigest(h: HMAC[Sha1Context]): uint
1

keccak

Types

KeccakKind

undefined

KeccakKind = enum
  Sha3, Keccak, Shake
1
2

KeccakContext

undefined

KeccakContext[bits; kind] = object
  q: array[25, uint64]
  pt: int
1
2
3

keccak224

undefined

keccak224 = KeccakContext[224, Keccak]
1

keccak256

undefined

keccak256 = KeccakContext[256, Keccak]
1

keccak384

undefined

keccak384 = KeccakContext[384, Keccak]
1

keccak512

undefined

keccak512 = KeccakContext[512, Keccak]
1

sha3_224

undefined

sha3_224 = KeccakContext[224, Sha3]
1

sha3_256

undefined

sha3_256 = KeccakContext[256, Sha3]
1

sha3_384

undefined

sha3_384 = KeccakContext[384, Sha3]
1

sha3_512

undefined

sha3_512 = KeccakContext[512, Sha3]
1

shake128

undefined

shake128 = KeccakContext[128, Shake]
1

shake256

undefined

shake256 = KeccakContext[256, Shake]
1

keccak

undefined

keccak = keccak224 | keccak256 | keccak384 | keccak512 | sha3_224 | sha3_256 | sha3_384 |
    sha3_512
1
2

Procs


init

undefined

proc init(ctx: var KeccakContext)
1

clear

undefined

proc clear(ctx: var KeccakContext) {.inline.}
1

update

undefined

proc update(ctx: var KeccakContext; data: ptr byte; ulen: uint)
1

update

undefined

proc update[T: bchar](ctx: var KeccakContext; data: openArray[T])
1

xof

undefined

proc xof(ctx: var KeccakContext)
1

output

undefined

proc output(ctx: var KeccakContext; data: ptr byte; ulen: uint): uint
1

finish

undefined

proc finish(ctx: var KeccakContext; data: ptr byte; ulen: uint): uint
1

finish

undefined

proc finish(ctx: var KeccakContext): MDigest[ctx.bits]
1

finish

undefined

proc finish[T: bchar](ctx: var KeccakContext; data: var openArray[T])
1

Templates


sizeDigest

undefined

template sizeDigest(ctx: KeccakContext): uint
1

sizeBlock

undefined

template sizeBlock(ctx: KeccakContext): uint
1

sizeDigest

undefined

template sizeDigest(r: typedesc[keccak | shake128 | shake256]): int
1

sizeBlock

undefined

template sizeBlock(r: typedesc[keccak | shake128 | shake256]): int
1

rijndael

Types

rijndael128

undefined

rijndael128 = RijndaelContext[128]
1

rijndael192

undefined

rijndael192 = RijndaelContext[192]
1

rijndael256

undefined

rijndael256 = RijndaelContext[256]
1

aes128

undefined

aes128 = rijndael128
1

aes192

undefined

aes192 = rijndael192
1

aes256

undefined

aes256 = rijndael256
1

rijndael

undefined

rijndael = rijndael128 | rijndael192 | rijndael256 | aes128 | aes192 | aes256
1

Procs


rijndaelEncrypt

undefined

proc rijndaelEncrypt(ctx: var RijndaelContext; inp: ptr byte; oup: ptr byte)
1

rijndaelDecrypt

undefined

proc rijndaelDecrypt(ctx: var RijndaelContext; inp: ptr byte; oup: ptr byte)
1

initRijndaelContext

undefined

proc initRijndaelContext(ctx: var RijndaelContext; N: int; key: ptr byte)
1

init

undefined

proc init(ctx: var RijndaelContext; key: ptr byte; nkey: int = 0) {.inline.}
1

init

undefined

proc init(ctx: var RijndaelContext; key: openArray[byte]) {.inline.}
1

clear

undefined

proc clear(ctx: var RijndaelContext) {.inline.}
1

encrypt

undefined

proc encrypt(ctx: var RijndaelContext; inbytes: ptr byte; outbytes: ptr byte) {.inline.}
1

decrypt

undefined

proc decrypt(ctx: var RijndaelContext; inbytes: ptr byte; outbytes: ptr byte) {.inline.}
1

encrypt

undefined

proc encrypt(ctx: var RijndaelContext; input: openArray[byte];
            output: var openArray[byte]) {.inline.}
1
2

decrypt

undefined

proc decrypt(ctx: var RijndaelContext; input: openArray[byte];
            output: var openArray[byte]) {.inline.}
1
2

Templates


sizeKey

undefined

template sizeKey(ctx: RijndaelContext): int
1

sizeBlock

undefined

template sizeBlock(ctx: RijndaelContext): int
1

sizeKey

undefined

template sizeKey(r: typedesc[rijndael]): int
1

sizeBlock

undefined

template sizeBlock(r: typedesc[rijndael]): int
1

ripemd

Types

RipemdContext

undefined

RipemdContext[bits] = object
  count: array[2, uint32]
  state: array[bits div 32, uint32]
  buffer: array[64, byte]
1
2
3
4

ripemd128

undefined

ripemd128 = RipemdContext[128]
1

ripemd160

undefined

ripemd160 = RipemdContext[160]
1

ripemd256

undefined

ripemd256 = RipemdContext[256]
1

ripemd320

undefined

ripemd320 = RipemdContext[320]
1

ripemd

undefined

ripemd = ripemd128 | ripemd160 | ripemd256 | ripemd320
1

Procs


init

undefined

proc init(ctx: var RipemdContext)
1

clear

undefined

proc clear(ctx: var RipemdContext) {.inline.}
1

update

undefined

proc update(ctx: var RipemdContext; data: ptr byte; ulen: uint)
1

update

undefined

proc update[T: bchar](ctx: var RipemdContext; data: openArray[T])
1

finish

undefined

proc finish(ctx: var RipemdContext; data: ptr byte; ulen: uint): uint
1

finish

undefined

proc finish(ctx: var RipemdContext): MDigest[ctx.bits]
1

finish

undefined

proc finish[T: bchar](ctx: var RipemdContext; data: var openArray[T])
1

Templates


sizeDigest

undefined

template sizeDigest(ctx: RipemdContext): uint
1

sizeBlock

undefined

template sizeBlock(ctx: RipemdContext): uint
1

sizeDigest

undefined

template sizeDigest(r: typedesc[ripemd]): int
1

sizeBlock

undefined

template sizeBlock(r: typedesc[ripemd]): int
1

sha

Types

Sha1Context

undefined

Sha1Context[bits] = object
  size: uint64
  h: array[5, uint32]
  w: array[16, uint32]
1
2
3
4

sha1

undefined

sha1 = Sha1Context[160]
1

Procs


init

undefined

proc init(ctx: var Sha1Context)
1

clear

undefined

proc clear(ctx: var Sha1Context) {.inline.}
1

update

undefined

proc update(ctx: var Sha1Context; pBytes: ptr byte; nBytes: uint)
1

update

undefined

proc update[T: bchar](ctx: var Sha1Context; data: openArray[T])
1

finish

undefined

proc finish(ctx: var Sha1Context; pBytes: ptr byte; nBytes: uint): uint
1

finish

undefined

proc finish(ctx: var Sha1Context): MDigest[160]
1

finish

undefined

proc finish[T: bchar](ctx: var Sha1Context; data: var openArray[T])
1

Templates


sizeDigest

undefined

template sizeDigest(ctx: Sha1Context): uint
1

sizeBlock

undefined

template sizeBlock(ctx: Sha1Context): uint
1

sizeDigest

undefined

template sizeDigest(r: typedesc[sha1]): int
1

sizeBlock

undefined

template sizeBlock(r: typedesc[sha1]): int
1

sha2

Types

Sha2Context

undefined

Sha2Context[bits; bsize; T] = object
  count: array[2, T]
  state: array[8, T]
  buffer: array[bsize, byte]
1
2
3
4

sha224

undefined

sha224 = Sha2Context[224, 64, uint32]
1

sha256

undefined

sha256 = Sha2Context[256, 64, uint32]
1

sha384

undefined

sha384 = Sha2Context[384, 128, uint64]
1

sha512

undefined

sha512 = Sha2Context[512, 128, uint64]
1

sha512_224

undefined

sha512_224 = Sha2Context[224, 128, uint64]
1

sha512_256

undefined

sha512_256 = Sha2Context[256, 128, uint64]
1

sha2

undefined

sha2 = sha224 | sha256 | sha384 | sha512 | sha512_224 | sha512_256
1

Procs


init

undefined

proc init(ctx: var Sha2Context)
1

clear

undefined

proc clear(ctx: var Sha2Context) {.inline.}
1

update

undefined

proc update(ctx: var Sha2Context; data: ptr byte; inlen: uint)
1

update

undefined

proc update[T: bchar](ctx: var Sha2Context; data: openArray[T])
1

finish

undefined

proc finish(ctx: var Sha2Context; pBytes: ptr byte; nBytes: uint): uint
1

finish

undefined

proc finish(ctx: var Sha2Context): MDigest[ctx.bits]
1

finish

undefined

proc finish[T: bchar](ctx: var Sha2Context; data: var openArray[T])
1

Templates


sizeDigest

undefined

template sizeDigest(ctx: Sha2Context): uint
1

sizeBlock

undefined

template sizeBlock(ctx: Sha2Context): uint
1

sizeDigest

undefined

template sizeDigest(r: typedesc[sha2]): int
1

sizeBlock

undefined

template sizeBlock(r: typedesc[sha2]): int
1

sysrand

Types


Procs


randomBytes

undefined

proc randomBytes(pbytes: pointer; nbytes: int): int {.raises: [Exception],
    tags: [RootEffect].}
1
2

randomClose

undefined

proc randomClose() {.raises: [Exception, OSError], tags: [RootEffect].}
1

randomBytes

undefined

proc randomBytes[T](bytes: var openArray[T]): int
1

Templates


twofish

Types

twofish128

undefined

twofish128 = TwofishContext[128]
1

twofish192

undefined

twofish192 = TwofishContext[192]
1

twofish256

undefined

twofish256 = TwofishContext[256]
1

twofish

undefined

twofish = twofish128 | twofish192 | twofish256
1

Procs


init

undefined

proc init(ctx: var TwofishContext; key: ptr byte; nkey: int = 0) {.inline.}
1

init

undefined

proc init(ctx: var TwofishContext; key: openArray[byte]) {.inline.}
1

clear

undefined

proc clear(ctx: var TwofishContext) {.inline.}
1

encrypt

undefined

proc encrypt(ctx: var TwofishContext; inbytes: ptr byte; outbytes: ptr byte) {.inline.}
1

decrypt

undefined

proc decrypt(ctx: var TwofishContext; inbytes: ptr byte; outbytes: ptr byte) {.inline.}
1

encrypt

undefined

proc encrypt(ctx: var TwofishContext; input: openArray[byte];
            output: var openArray[byte]) {.inline.}
1
2

decrypt

undefined

proc decrypt(ctx: var TwofishContext; input: openArray[byte];
            output: var openArray[byte]) {.inline.}
1
2

Templates


sizeKey

undefined

template sizeKey(ctx: TwofishContext): int
1

sizeBlock

undefined

template sizeBlock(ctx: TwofishContext): int
1

sizeKey

undefined

template sizeKey(r: typedesc[twofish]): int
1

sizeBlock

undefined

template sizeBlock(r: typedesc[twofish]): int
1

utils

Types


Procs


ROL

undefined

proc ROL[T: uint32 | uint64](x: T; n: int): T {.inline.}
1

ROR

undefined

proc ROR[T: uint32 | uint64](x: T; n: int): T {.inline.}
1

hexToBytes

undefined

proc hexToBytes(a: string; result: var openArray[byte]) {.raises: [], tags: [].}
1

fromHex

undefined

proc fromHex(a: string): seq[byte] {.raises: [], tags: [].}
1

hexChar

undefined

proc hexChar(c: byte; lowercase: bool = false): string {.raises: [], tags: [].}
1

toHex

undefined

proc toHex(a: openArray[byte]; lowercase: bool = false): string {.raises: [], tags: [].}
1

stripSpaces

undefined

proc stripSpaces(s: string): string {.raises: [], tags: [].}
1

burnMem

undefined

proc burnMem(p: pointer; size: Natural) {.raises: [], tags: [].}
1

burnArray

undefined

proc burnArray[T](a: var openArray[T]) {.inline.}
1

burnMem

undefined

proc burnMem[T](a: var T) {.inline.}
1

isFullZero

undefined

proc isFullZero(p: pointer; size: Natural): bool {.raises: [], tags: [].}
1

isFullZero

undefined

proc isFullZero[T](a: openArray[T]): bool {.inline.}
1

isFullZero

undefined

proc isFullZero[T](a: T): bool {.inline.}
1

lit64ToCpu

Get uint64 integer from pointer p and offset o which must be stored in little-endian order.

proc lit64ToCpu(p: ptr byte; offset: int): uint64 {.inline, raises: [], tags: [].}
1

big64ToCpu

Get uint64 integer from pointer p and offset o which must be stored in big-endian order.

proc big64ToCpu(p: ptr byte; offset: int): uint64 {.inline, raises: [], tags: [].}
1

cpuToLit64

Store uint64 integer v to pointer p and offset o in little-endian order.

proc cpuToLit64(p: ptr byte; offset: int; v: uint64) {.inline, raises: [], tags: [].}
1

cpuToBig64

Store uint64 integer v to pointer p and offset o in big-endian order.

proc cpuToBig64(p: ptr byte; offset: int; v: uint64) {.inline, raises: [], tags: [].}
1

Templates


GETU32

undefined

template GETU32(p, o): uint32
1

GETU64

undefined

template GETU64(p, o): uint64
1

PUTU32

undefined

template PUTU32(p, o, v)
1

PUTU64

undefined

template PUTU64(p, o, v)
1

BSWAP

undefined

template BSWAP[T](x: T): T
1

LSWAP

undefined

template LSWAP[T](x: T): T
1

EGETU32

undefined

template EGETU32(p, o): uint32
1

EPUTU32

undefined

template EPUTU32(p, o, v)
1

EGETU64

undefined

template EGETU64(p, o): uint64
1

EPUTU64

undefined

template EPUTU64(p, o, v)
1

GET_DWORD

undefined

template GET_DWORD(p: ptr byte; i: int): uint32
1

SET_DWORD

undefined

template SET_DWORD(p: ptr byte; i: int; v: uint32)
1

GET_QWORD

undefined

template GET_QWORD(p: ptr byte; i: int): uint64
1

SET_QWORD

undefined

template SET_QWORD(p: ptr byte; i: int; v: uint64)
1

GETU8

undefined

template GETU8(p, o): byte
1

PUTU8

undefined

template PUTU8(p, o, v)
1

burnMem

undefined

template burnMem[T](a: var seq[T])
1

burnMem

undefined

template burnMem[A; B](a: var array[A, B])
1