libp2p/crypto/chacha20poly1305

    Dark Mode
Search:
Group by:
  Source   Edit

Nim-Libp2p Copyright (c) 2020-2022 Status Research & Development GmbH

Licensed under either of

at your option. This file may not be copied, modified, or distributed except according to those terms.

This module integrates BearSSL ChaCha20+Poly1305

This module uses unmodified parts of code from BearSSL library <https://bearssl.org/> Copyright(C) 2018 Thomas Pornin <pornin@bolet.org>.

Types

ChaChaPoly = object
  Source   Edit
ChaChaPolyKey = array[ChaChaPolyKeySize, byte]
  Source   Edit
ChaChaPolyNonce = array[ChaChaPolyNonceSize, byte]
  Source   Edit
ChaChaPolyTag = array[ChaChaPolyTagSize, byte]
  Source   Edit

Procs

proc decrypt(_: type[ChaChaPoly]; key: ChaChaPolyKey; nonce: ChaChaPolyNonce;
             tag: var ChaChaPolyTag; data: var openArray[byte];
             aad: openArray[byte]) {....raises: [Defect].}
  Source   Edit
proc encrypt(_: type[ChaChaPoly]; key: ChaChaPolyKey; nonce: ChaChaPolyNonce;
             tag: var ChaChaPolyTag; data: var openArray[byte];
             aad: openArray[byte]) {....raises: [Defect].}
  Source   Edit
proc intoChaChaPolyKey(s: openArray[byte]): ChaChaPolyKey {....raises: [Defect],
    tags: [].}
  Source   Edit
proc intoChaChaPolyNonce(s: openArray[byte]): ChaChaPolyNonce {.
    ...raises: [Defect], tags: [].}
  Source   Edit
proc intoChaChaPolyTag(s: openArray[byte]): ChaChaPolyTag {....raises: [Defect],
    tags: [].}
  Source   Edit
proc ourPoly1305CtmulRun(key: pointer; iv: pointer; data: pointer; len: int;
                         aad: pointer; aadLen: int; tag: pointer;
                         ichacha: pointer; encrypt: cint) {.cdecl,
    importc: "br_poly1305_ctmul_run", header: "bearssl_block.h",
    ...raises: [Defect], tags: [].}
  Source   Edit