nim-bearssl/bearssl/abi/bearssl_prf.nim
Jacek Sieka c4aec8b664
split decls into separate modules in bearssl/abi (#27)
* split `decls.nim` into smaller modules - allows using parts of the ABI
without compiling all of `bearssl`
* deprecate functions with `Br` prefix - there are duplicate exports
both with and without `Br` for the same function and we use both in
consumers like `chronos` and `libp2p`
* fix several cases of incorrectly mapped types
* use `var` for certain arguments that can't be `nil`
* add script to regenerate ABI with `c2nim`
* consistently use `uint` for length (`int` was sometimes used)

The Split likely needs more cleanup work - this is a first cut to get
the idea in place.

In the new layout, `bearssl/abi/` contains "raw" nim mappings while
hand-written helpers are in `bearssl/`.
2022-06-14 19:33:00 +02:00

38 lines
1.4 KiB
Nim

import
"."/[csources]
{.pragma: importcFunc, cdecl, gcsafe, noSideEffect, raises: [].}
{.used.}
const
bearSslPath = bearSrcPath / "ssl"
{.compile: bearSslPath / "prf.c".}
{.compile: bearSslPath / "prf_md5sha1.c".}
{.compile: bearSslPath / "prf_sha256.c".}
{.compile: bearSslPath / "prf_sha384.c".}
type
TlsPrfSeedChunk* {.importc: "br_tls_prf_seed_chunk", header: "bearssl_prf.h",
bycopy.} = object
data* {.importc: "data".}: pointer
len* {.importc: "len".}: uint
proc tls10Prf*(dst: pointer; len: uint; secret: pointer; secretLen: uint;
label: cstring; seedNum: uint; seed: ptr TlsPrfSeedChunk) {.importcFunc,
importc: "br_tls10_prf", header: "bearssl_prf.h".}
proc tls12Sha256Prf*(dst: pointer; len: uint; secret: pointer; secretLen: uint;
label: cstring; seedNum: uint; seed: ptr TlsPrfSeedChunk) {.
importcFunc, importc: "br_tls12_sha256_prf", header: "bearssl_prf.h".}
proc tls12Sha384Prf*(dst: pointer; len: uint; secret: pointer; secretLen: uint;
label: cstring; seedNum: uint; seed: ptr TlsPrfSeedChunk) {.
importcFunc, importc: "br_tls12_sha384_prf", header: "bearssl_prf.h".}
type
TlsPrfImpl* {.importc: "br_tls_prf_impl".} = proc (dst: pointer; len: uint; secret: pointer; secretLen: uint;
label: cstring; seedNum: uint; seed: ptr TlsPrfSeedChunk) {.importcFunc.}