From e69b25bbf1702d48fccb54e5004908f640271010 Mon Sep 17 00:00:00 2001 From: Ludovic Chenut Date: Tue, 16 May 2023 16:12:15 +0200 Subject: [PATCH] mbedtls wrapper done --- webrtc/mbedtls/aes.nim | 22 +---- webrtc/mbedtls/aria.nim | 15 +-- webrtc/mbedtls/asn1.nim | 15 +-- webrtc/mbedtls/asn1write.nim | 16 +--- webrtc/mbedtls/base64.nim | 19 +--- webrtc/mbedtls/bignum.nim | 59 +----------- webrtc/mbedtls/build_info.nim | 15 +-- webrtc/mbedtls/camellia.nim | 15 +-- webrtc/mbedtls/ccm.nim | 21 +---- webrtc/mbedtls/chacha20.nim | 15 +-- webrtc/mbedtls/chachapoly.nim | 59 +----------- webrtc/mbedtls/check_config.nim | 22 ----- webrtc/mbedtls/cipher.nim | 62 ++----------- webrtc/mbedtls/cmac.nim | 16 +--- webrtc/mbedtls/compat_2_x.nim | 42 --------- webrtc/mbedtls/config_psa.nim | 15 +-- webrtc/mbedtls/constant_time.nim | 15 +-- webrtc/mbedtls/ctr_drbg.nim | 24 +---- webrtc/mbedtls/debug.nim | 89 +----------------- webrtc/mbedtls/des.nim | 21 +---- webrtc/mbedtls/dhm.nim | 60 +----------- webrtc/mbedtls/ecdh.nim | 64 +------------ webrtc/mbedtls/ecdsa.nim | 18 +--- webrtc/mbedtls/ecjpake.nim | 59 +----------- webrtc/mbedtls/ecp.nim | 64 +------------ webrtc/mbedtls/entropy.nim | 23 +---- webrtc/mbedtls/error.nim | 19 +--- webrtc/mbedtls/gcm.nim | 22 +---- webrtc/mbedtls/hash_info.nim | 1 + webrtc/mbedtls/hkdf.nim | 22 +---- webrtc/mbedtls/hmac_drbg.nim | 22 +---- webrtc/mbedtls/lms.nim | 59 +----------- webrtc/mbedtls/mbedtls_config.nim | 15 +-- webrtc/mbedtls/md.nim | 65 +------------ webrtc/mbedtls/md5.nim | 15 +-- webrtc/mbedtls/memory_buffer_alloc.nim | 18 +--- webrtc/mbedtls/net_sockets.nim | 48 +--------- webrtc/mbedtls/nist_kw.nim | 65 +------------ webrtc/mbedtls/oid.nim | 15 +-- webrtc/mbedtls/pem.nim | 17 +--- webrtc/mbedtls/pk.nim | 64 +------------ webrtc/mbedtls/pkcs12.nim | 15 +-- webrtc/mbedtls/pkcs5.nim | 17 +--- webrtc/mbedtls/pkcs7.nim | 65 +------------ webrtc/mbedtls/platform.nim | 21 +---- webrtc/mbedtls/platform_time.nim | 18 +--- webrtc/mbedtls/platform_util.nim | 23 +---- webrtc/mbedtls/poly1305.nim | 15 +-- webrtc/mbedtls/private_access.nim | 20 ---- webrtc/mbedtls/psa/crypto.nim | 72 +-------------- .../mbedtls/psa/crypto_builtin_composites.nim | 16 +--- .../mbedtls/psa/crypto_builtin_primitives.nim | 20 +--- webrtc/mbedtls/psa/crypto_compat.nim | 20 ---- webrtc/mbedtls/psa/crypto_config.nim | 15 +-- webrtc/mbedtls/psa/crypto_driver_common.nim | 62 +------------ .../psa/crypto_driver_contexts_composites.nim | 27 ------ .../crypto_driver_contexts_key_derivation.nim | 26 ------ .../psa/crypto_driver_contexts_primitives.nim | 27 ------ webrtc/mbedtls/psa/crypto_extra.nim | 23 ----- webrtc/mbedtls/psa/crypto_platform.nim | 22 ----- webrtc/mbedtls/psa/crypto_se_driver.nim | 62 +------------ webrtc/mbedtls/psa/crypto_sizes.nim | 16 +--- webrtc/mbedtls/psa/crypto_struct.nim | 24 +---- webrtc/mbedtls/psa/crypto_types.nim | 58 +----------- webrtc/mbedtls/psa/crypto_values.nim | 15 +-- webrtc/mbedtls/psa_util.nim | 16 +--- webrtc/mbedtls/ripemd160.nim | 15 +-- webrtc/mbedtls/rsa.nim | 16 +--- webrtc/mbedtls/sha1.nim | 15 +-- webrtc/mbedtls/sha256.nim | 15 +-- webrtc/mbedtls/sha512.nim | 15 +-- webrtc/mbedtls/ssl.nim | 92 ++----------------- webrtc/mbedtls/ssl_cache.nim | 47 +--------- webrtc/mbedtls/ssl_ciphersuites.nim | 73 +-------------- webrtc/mbedtls/ssl_cookie.nim | 47 +--------- webrtc/mbedtls/ssl_ticket.nim | 45 +-------- webrtc/mbedtls/threading.nim | 20 +--- webrtc/mbedtls/timing.nim | 19 +--- webrtc/mbedtls/version.nim | 18 +--- webrtc/mbedtls/x509.nim | 33 +------ webrtc/mbedtls/x509_crl.nim | 27 +----- webrtc/mbedtls/x509_crt.nim | 34 ++----- webrtc/mbedtls/x509_csr.nim | 26 +----- 83 files changed, 195 insertions(+), 2409 deletions(-) delete mode 100644 webrtc/mbedtls/check_config.nim delete mode 100644 webrtc/mbedtls/compat_2_x.nim delete mode 100644 webrtc/mbedtls/private_access.nim delete mode 100644 webrtc/mbedtls/psa/crypto_compat.nim delete mode 100644 webrtc/mbedtls/psa/crypto_driver_contexts_composites.nim delete mode 100644 webrtc/mbedtls/psa/crypto_driver_contexts_key_derivation.nim delete mode 100644 webrtc/mbedtls/psa/crypto_driver_contexts_primitives.nim delete mode 100644 webrtc/mbedtls/psa/crypto_extra.nim delete mode 100644 webrtc/mbedtls/psa/crypto_platform.nim diff --git a/webrtc/mbedtls/aes.nim b/webrtc/mbedtls/aes.nim index 73cfa32..71d8367 100644 --- a/webrtc/mbedtls/aes.nim +++ b/webrtc/mbedtls/aes.nim @@ -1,32 +1,14 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} - -# Included but not used -# import "private_access" -# import "build_info" -# import "mbedtls_config" -# import "config_psa" -# import "check_config" -# import "platform_time" import "platform_time" + {.compile: "./mbedtls/library/aes.c".} {.compile: "./mbedtls/library/aesni.c".} -# Generated @ 2023-05-11T11:19:07+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/aes.h {.push hint[ConvFromXtoItselfNotNeeded]: off.} - {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + const MBEDTLS_AES_ENCRYPT* = 1 MBEDTLS_AES_DECRYPT* = 0 diff --git a/webrtc/mbedtls/aria.nim b/webrtc/mbedtls/aria.nim index 8930d13..015420a 100644 --- a/webrtc/mbedtls/aria.nim +++ b/webrtc/mbedtls/aria.nim @@ -1,24 +1,13 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# import "platform_time" + {.compile: "./mbedtls/library/aria.c".} -# Generated @ 2023-05-11T11:19:07+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/aria.h {.push hint[ConvFromXtoItselfNotNeeded]: off.} - {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + const MBEDTLS_ARIA_ENCRYPT* = 1 MBEDTLS_ARIA_DECRYPT* = 0 diff --git a/webrtc/mbedtls/asn1.nim b/webrtc/mbedtls/asn1.nim index 6912d77..58bd3b5 100644 --- a/webrtc/mbedtls/asn1.nim +++ b/webrtc/mbedtls/asn1.nim @@ -1,24 +1,13 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# import "bignum" + {.compile: "./mbedtls/library/asn1parse.c".} -# Generated @ 2023-05-11T11:19:07+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/asn1.h {.push hint[ConvFromXtoItselfNotNeeded]: off.} - {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + const MBEDTLS_ERR_ASN1_OUT_OF_DATA* = -0x00000060 MBEDTLS_ERR_ASN1_UNEXPECTED_TAG* = -0x00000062 diff --git a/webrtc/mbedtls/asn1write.nim b/webrtc/mbedtls/asn1write.nim index 035c9e1..be962c6 100644 --- a/webrtc/mbedtls/asn1write.nim +++ b/webrtc/mbedtls/asn1write.nim @@ -1,26 +1,14 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# import "asn1" -import "platform_time" import "bignum" + {.compile: "./mbedtls/library/asn1write.c".} -# Generated @ 2023-05-11T11:19:07+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/asn1write.h {.push hint[ConvFromXtoItselfNotNeeded]: off.} - {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + proc mbedtls_asn1_write_len*(p: ptr ptr byte; start: ptr byte; len: uint): cint {. importc, cdecl.} proc mbedtls_asn1_write_tag*(p: ptr ptr byte; start: ptr byte; tag: byte): cint {. diff --git a/webrtc/mbedtls/base64.nim b/webrtc/mbedtls/base64.nim index f652a61..f77896e 100644 --- a/webrtc/mbedtls/base64.nim +++ b/webrtc/mbedtls/base64.nim @@ -1,28 +1,13 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# -# import "build_info" -# import "mbedtls_config" -# import "config_psa" -# import "check_config" import "constant_time" + {.compile: "./mbedtls/library/base64.c".} -# Generated @ 2023-05-11T11:19:07+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/base64.h {.push hint[ConvFromXtoItselfNotNeeded]: off.} - {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + const MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL* = -0x0000002A MBEDTLS_ERR_BASE64_INVALID_CHARACTER* = -0x0000002C diff --git a/webrtc/mbedtls/bignum.nim b/webrtc/mbedtls/bignum.nim index 72e7eae..2df9958 100644 --- a/webrtc/mbedtls/bignum.nim +++ b/webrtc/mbedtls/bignum.nim @@ -1,69 +1,18 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# import "md" +import "utils" + {.compile: "./mbedtls/library/bignum.c".} {.compile: "./mbedtls/library/bignum_core.c".} {.compile: "./mbedtls/library/constant_time.c".} -# Generated @ 2023-05-11T11:19:07+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/bignum.h {.push hint[ConvFromXtoItselfNotNeeded]: off.} -import macros - -macro defineEnum(typ: untyped): untyped = - result = newNimNode(nnkStmtList) - - # Enum mapped to distinct cint - result.add quote do: - type `typ`* = distinct cint - - for i in ["+", "-", "*", "div", "mod", "shl", "shr", "or", "and", "xor", "<", "<=", "==", ">", ">="]: - let - ni = newIdentNode(i) - typout = if i[0] in "<=>": newIdentNode("bool") else: typ # comparisons return bool - if i[0] == '>': # cannot borrow `>` and `>=` from templates - let - nopp = if i.len == 2: newIdentNode("<=") else: newIdentNode("<") - result.add quote do: - proc `ni`*(x: `typ`, y: cint): `typout` = `nopp`(y, x) - proc `ni`*(x: cint, y: `typ`): `typout` = `nopp`(y, x) - proc `ni`*(x, y: `typ`): `typout` = `nopp`(y, x) - else: - result.add quote do: - proc `ni`*(x: `typ`, y: cint): `typout` {.borrow.} - proc `ni`*(x: cint, y: `typ`): `typout` {.borrow.} - proc `ni`*(x, y: `typ`): `typout` {.borrow.} - result.add quote do: - proc `ni`*(x: `typ`, y: int): `typout` = `ni`(x, y.cint) - proc `ni`*(x: int, y: `typ`): `typout` = `ni`(x.cint, y) - - let - divop = newIdentNode("/") # `/`() - dlrop = newIdentNode("$") # `$`() - notop = newIdentNode("not") # `not`() - result.add quote do: - proc `divop`*(x, y: `typ`): `typ` = `typ`((x.float / y.float).cint) - proc `divop`*(x: `typ`, y: cint): `typ` = `divop`(x, `typ`(y)) - proc `divop`*(x: cint, y: `typ`): `typ` = `divop`(`typ`(x), y) - proc `divop`*(x: `typ`, y: int): `typ` = `divop`(x, y.cint) - proc `divop`*(x: int, y: `typ`): `typ` = `divop`(x.cint, y) - - proc `dlrop`*(x: `typ`): string {.borrow.} - proc `notop`*(x: `typ`): `typ` {.borrow.} - {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + defineEnum(mbedtls_mpi_gen_prime_flag_t) + const MBEDTLS_ERR_MPI_FILE_IO_ERROR* = -0x00000002 MBEDTLS_ERR_MPI_BAD_INPUT_DATA* = -0x00000004 diff --git a/webrtc/mbedtls/build_info.nim b/webrtc/mbedtls/build_info.nim index 1cf7e72..3e73b60 100644 --- a/webrtc/mbedtls/build_info.nim +++ b/webrtc/mbedtls/build_info.nim @@ -1,22 +1,9 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# -# Generated @ 2023-05-11T11:19:08+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/build_info.h - {.push hint[ConvFromXtoItselfNotNeeded]: off.} - {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + const MBEDTLS_VERSION_MAJOR* = 3 MBEDTLS_VERSION_MINOR* = 4 diff --git a/webrtc/mbedtls/camellia.nim b/webrtc/mbedtls/camellia.nim index d67bf18..6e13573 100644 --- a/webrtc/mbedtls/camellia.nim +++ b/webrtc/mbedtls/camellia.nim @@ -1,24 +1,13 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# import "platform_time" + {.compile: "./mbedtls/library/camellia.c".} -# Generated @ 2023-05-11T11:19:08+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/camellia.h {.push hint[ConvFromXtoItselfNotNeeded]: off.} - {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + const MBEDTLS_CAMELLIA_ENCRYPT* = 1 MBEDTLS_CAMELLIA_DECRYPT* = 0 diff --git a/webrtc/mbedtls/ccm.nim b/webrtc/mbedtls/ccm.nim index 8366a69..1695358 100644 --- a/webrtc/mbedtls/ccm.nim +++ b/webrtc/mbedtls/ccm.nim @@ -1,30 +1,11 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# -# import "private_access" -# import "build_info" -# import "mbedtls_config" -# import "config_psa" -# import "check_config" import "cipher" -# import "platform_util" -import "platform_time" -# Generated @ 2023-05-11T11:19:08+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/ccm.h {.push hint[ConvFromXtoItselfNotNeeded]: off.} - {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + const MBEDTLS_CCM_DECRYPT* = 0 MBEDTLS_CCM_ENCRYPT* = 1 diff --git a/webrtc/mbedtls/chacha20.nim b/webrtc/mbedtls/chacha20.nim index d9c5806..c6ee624 100644 --- a/webrtc/mbedtls/chacha20.nim +++ b/webrtc/mbedtls/chacha20.nim @@ -1,24 +1,13 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# import "platform_time" + {.compile: "./mbedtls/library/chacha20.c".} -# Generated @ 2023-05-11T11:19:08+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/chacha20.h {.push hint[ConvFromXtoItselfNotNeeded]: off.} - {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + const MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA* = -0x00000051 type diff --git a/webrtc/mbedtls/chachapoly.nim b/webrtc/mbedtls/chachapoly.nim index 9cb4046..9c8860e 100644 --- a/webrtc/mbedtls/chachapoly.nim +++ b/webrtc/mbedtls/chachapoly.nim @@ -1,68 +1,17 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# import "poly1305" import "chacha20" +import "utils" + {.compile: "./mbedtls/library/chachapoly.c".} -# Generated @ 2023-05-11T11:19:08+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/chachapoly.h {.push hint[ConvFromXtoItselfNotNeeded]: off.} -import macros - -macro defineEnum(typ: untyped): untyped = - result = newNimNode(nnkStmtList) - - # Enum mapped to distinct cint - result.add quote do: - type `typ`* = distinct cint - - for i in ["+", "-", "*", "div", "mod", "shl", "shr", "or", "and", "xor", "<", "<=", "==", ">", ">="]: - let - ni = newIdentNode(i) - typout = if i[0] in "<=>": newIdentNode("bool") else: typ # comparisons return bool - if i[0] == '>': # cannot borrow `>` and `>=` from templates - let - nopp = if i.len == 2: newIdentNode("<=") else: newIdentNode("<") - result.add quote do: - proc `ni`*(x: `typ`, y: cint): `typout` = `nopp`(y, x) - proc `ni`*(x: cint, y: `typ`): `typout` = `nopp`(y, x) - proc `ni`*(x, y: `typ`): `typout` = `nopp`(y, x) - else: - result.add quote do: - proc `ni`*(x: `typ`, y: cint): `typout` {.borrow.} - proc `ni`*(x: cint, y: `typ`): `typout` {.borrow.} - proc `ni`*(x, y: `typ`): `typout` {.borrow.} - result.add quote do: - proc `ni`*(x: `typ`, y: int): `typout` = `ni`(x, y.cint) - proc `ni`*(x: int, y: `typ`): `typout` = `ni`(x.cint, y) - - let - divop = newIdentNode("/") # `/`() - dlrop = newIdentNode("$") # `$`() - notop = newIdentNode("not") # `not`() - result.add quote do: - proc `divop`*(x, y: `typ`): `typ` = `typ`((x.float / y.float).cint) - proc `divop`*(x: `typ`, y: cint): `typ` = `divop`(x, `typ`(y)) - proc `divop`*(x: cint, y: `typ`): `typ` = `divop`(`typ`(x), y) - proc `divop`*(x: `typ`, y: int): `typ` = `divop`(x, y.cint) - proc `divop`*(x: int, y: `typ`): `typ` = `divop`(x.cint, y) - - proc `dlrop`*(x: `typ`): string {.borrow.} - proc `notop`*(x: `typ`): `typ` {.borrow.} - {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + defineEnum(mbedtls_chachapoly_mode_t) + const MBEDTLS_ERR_CHACHAPOLY_BAD_STATE* = -0x00000054 MBEDTLS_ERR_CHACHAPOLY_AUTH_FAILED* = -0x00000056 diff --git a/webrtc/mbedtls/check_config.nim b/webrtc/mbedtls/check_config.nim deleted file mode 100644 index 4e4b8f8..0000000 --- a/webrtc/mbedtls/check_config.nim +++ /dev/null @@ -1,22 +0,0 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# -# Generated @ 2023-05-11T11:19:08+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/check_config.h - -{.push hint[ConvFromXtoItselfNotNeeded]: off.} - - -{.experimental: "codeReordering".} -{.passc: "-I./mbedtls/include".} -{.passc: "-I./mbedtls/library".} -type - mbedtls_iso_c_forbids_empty_translation_units* = cint -{.pop.} diff --git a/webrtc/mbedtls/cipher.nim b/webrtc/mbedtls/cipher.nim index 4715188..9ba99f5 100644 --- a/webrtc/mbedtls/cipher.nim +++ b/webrtc/mbedtls/cipher.nim @@ -1,27 +1,16 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# import "aes" import "aria" import "camellia" import "chachapoly" import "des" import "constant_time" -import "platform_time" +import "utils" + {.compile: "./mbedtls/library/ccm.c".} {.compile: "./mbedtls/library/gcm.c".} {.compile: "./mbedtls/library/nist_kw.c".} {.compile: "./mbedtls/library/cipher_wrap.c".} {.compile: "./mbedtls/library/cipher.c".} -# Generated @ 2023-05-11T11:19:08+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/cipher.h # proc 'mbedtls_cipher_info_get_type' skipped - static inline procs cannot work with '--noHeader | -H' # proc 'mbedtls_cipher_info_get_mode' skipped - static inline procs cannot work with '--noHeader | -H' @@ -38,60 +27,21 @@ import "platform_time" # proc 'mbedtls_cipher_get_name' skipped - static inline procs cannot work with '--noHeader | -H' # proc 'mbedtls_cipher_get_key_bitlen' skipped - static inline procs cannot work with '--noHeader | -H' # proc 'mbedtls_cipher_get_operation' skipped - static inline procs cannot work with '--noHeader | -H' + + {.push hint[ConvFromXtoItselfNotNeeded]: off.} -import macros - -macro defineEnum(typ: untyped): untyped = - result = newNimNode(nnkStmtList) - - # Enum mapped to distinct cint - result.add quote do: - type `typ`* = distinct cint - - for i in ["+", "-", "*", "div", "mod", "shl", "shr", "or", "and", "xor", "<", "<=", "==", ">", ">="]: - let - ni = newIdentNode(i) - typout = if i[0] in "<=>": newIdentNode("bool") else: typ # comparisons return bool - if i[0] == '>': # cannot borrow `>` and `>=` from templates - let - nopp = if i.len == 2: newIdentNode("<=") else: newIdentNode("<") - result.add quote do: - proc `ni`*(x: `typ`, y: cint): `typout` = `nopp`(y, x) - proc `ni`*(x: cint, y: `typ`): `typout` = `nopp`(y, x) - proc `ni`*(x, y: `typ`): `typout` = `nopp`(y, x) - else: - result.add quote do: - proc `ni`*(x: `typ`, y: cint): `typout` {.borrow.} - proc `ni`*(x: cint, y: `typ`): `typout` {.borrow.} - proc `ni`*(x, y: `typ`): `typout` {.borrow.} - result.add quote do: - proc `ni`*(x: `typ`, y: int): `typout` = `ni`(x, y.cint) - proc `ni`*(x: int, y: `typ`): `typout` = `ni`(x.cint, y) - - let - divop = newIdentNode("/") # `/`() - dlrop = newIdentNode("$") # `$`() - notop = newIdentNode("not") # `not`() - result.add quote do: - proc `divop`*(x, y: `typ`): `typ` = `typ`((x.float / y.float).cint) - proc `divop`*(x: `typ`, y: cint): `typ` = `divop`(x, `typ`(y)) - proc `divop`*(x: cint, y: `typ`): `typ` = `divop`(`typ`(x), y) - proc `divop`*(x: `typ`, y: int): `typ` = `divop`(x, y.cint) - proc `divop`*(x: int, y: `typ`): `typ` = `divop`(x.cint, y) - - proc `dlrop`*(x: `typ`): string {.borrow.} - proc `notop`*(x: `typ`): `typ` {.borrow.} - {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + defineEnum(mbedtls_cipher_id_t) defineEnum(mbedtls_cipher_type_t) defineEnum(mbedtls_cipher_mode_t) defineEnum(mbedtls_cipher_padding_t) defineEnum(mbedtls_operation_t) defineEnum(Enum_cipherh1) + const MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE* = -0x00006080 MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA* = -0x00006100 diff --git a/webrtc/mbedtls/cmac.nim b/webrtc/mbedtls/cmac.nim index 3fa8e08..b186ecc 100644 --- a/webrtc/mbedtls/cmac.nim +++ b/webrtc/mbedtls/cmac.nim @@ -1,25 +1,13 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# import "cipher" -import "platform_time" + {.compile: "./mbedtls/library/cmac.c".} -# Generated @ 2023-05-11T11:19:09+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/cmac.h {.push hint[ConvFromXtoItselfNotNeeded]: off.} - {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + const MBEDTLS_AES_BLOCK_SIZE* = 16 MBEDTLS_DES3_BLOCK_SIZE* = 8 diff --git a/webrtc/mbedtls/compat_2_x.nim b/webrtc/mbedtls/compat_2_x.nim deleted file mode 100644 index 94a6779..0000000 --- a/webrtc/mbedtls/compat_2_x.nim +++ /dev/null @@ -1,42 +0,0 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# -# Generated @ 2023-05-11T11:19:09+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/compat-2.x.h - -# const 'mbedtls_ctr_drbg_update_ret' has unsupported value 'mbedtls_ctr_drbg_update' -# const 'mbedtls_hmac_drbg_update_ret' has unsupported value 'mbedtls_hmac_drbg_update' -# const 'mbedtls_md5_starts_ret' has unsupported value 'mbedtls_md5_starts' -# const 'mbedtls_md5_update_ret' has unsupported value 'mbedtls_md5_update' -# const 'mbedtls_md5_finish_ret' has unsupported value 'mbedtls_md5_finish' -# const 'mbedtls_md5_ret' has unsupported value 'mbedtls_md5' -# const 'mbedtls_ripemd160_starts_ret' has unsupported value 'mbedtls_ripemd160_starts' -# const 'mbedtls_ripemd160_update_ret' has unsupported value 'mbedtls_ripemd160_update' -# const 'mbedtls_ripemd160_finish_ret' has unsupported value 'mbedtls_ripemd160_finish' -# const 'mbedtls_ripemd160_ret' has unsupported value 'mbedtls_ripemd160' -# const 'mbedtls_sha1_starts_ret' has unsupported value 'mbedtls_sha1_starts' -# const 'mbedtls_sha1_update_ret' has unsupported value 'mbedtls_sha1_update' -# const 'mbedtls_sha1_finish_ret' has unsupported value 'mbedtls_sha1_finish' -# const 'mbedtls_sha1_ret' has unsupported value 'mbedtls_sha1' -# const 'mbedtls_sha256_starts_ret' has unsupported value 'mbedtls_sha256_starts' -# const 'mbedtls_sha256_update_ret' has unsupported value 'mbedtls_sha256_update' -# const 'mbedtls_sha256_finish_ret' has unsupported value 'mbedtls_sha256_finish' -# const 'mbedtls_sha256_ret' has unsupported value 'mbedtls_sha256' -# const 'mbedtls_sha512_starts_ret' has unsupported value 'mbedtls_sha512_starts' -# const 'mbedtls_sha512_update_ret' has unsupported value 'mbedtls_sha512_update' -# const 'mbedtls_sha512_finish_ret' has unsupported value 'mbedtls_sha512_finish' -# const 'mbedtls_sha512_ret' has unsupported value 'mbedtls_sha512' -{.push hint[ConvFromXtoItselfNotNeeded]: off.} - - -{.experimental: "codeReordering".} -{.passc: "-I./mbedtls/include".} -{.passc: "-I./mbedtls/library".} -{.pop.} diff --git a/webrtc/mbedtls/config_psa.nim b/webrtc/mbedtls/config_psa.nim index 3e22681..d4ba28a 100644 --- a/webrtc/mbedtls/config_psa.nim +++ b/webrtc/mbedtls/config_psa.nim @@ -1,22 +1,9 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# -# Generated @ 2023-05-11T11:19:09+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/config_psa.h - {.push hint[ConvFromXtoItselfNotNeeded]: off.} - {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + const MBEDTLS_PSA_BUILTIN_ALG_HMAC* = 1 PSA_WANT_ALG_HMAC* = 1 diff --git a/webrtc/mbedtls/constant_time.nim b/webrtc/mbedtls/constant_time.nim index a39047a..d03626d 100644 --- a/webrtc/mbedtls/constant_time.nim +++ b/webrtc/mbedtls/constant_time.nim @@ -1,21 +1,8 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# import "bignum" -# {.compile: "./mbedtls/library/constant_time.c".} -# Generated @ 2023-05-11T11:19:09+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/constant_time.h +# TODO: Remove bignum, it's not used in this file. {.push hint[ConvFromXtoItselfNotNeeded]: off.} - {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} diff --git a/webrtc/mbedtls/ctr_drbg.nim b/webrtc/mbedtls/ctr_drbg.nim index de4498b..3095af6 100644 --- a/webrtc/mbedtls/ctr_drbg.nim +++ b/webrtc/mbedtls/ctr_drbg.nim @@ -1,33 +1,15 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# -import "private_access" -import "build_info" -import "mbedtls_config" -import "config_psa" -import "check_config" import "aes" -import "platform_util" -import "platform_time" import "entropy" -import "md" +# TODO: Remove entropy, it's not used in this file. + {.compile: "./mbedtls/library/ctr_drbg.c".} -# Generated @ 2023-05-11T11:19:09+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/ctr_drbg.h {.push hint[ConvFromXtoItselfNotNeeded]: off.} - {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + const MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED* = -0x00000034 MBEDTLS_ERR_CTR_DRBG_REQUEST_TOO_BIG* = -0x00000036 diff --git a/webrtc/mbedtls/debug.nim b/webrtc/mbedtls/debug.nim index 2a25f66..0dd9a9e 100644 --- a/webrtc/mbedtls/debug.nim +++ b/webrtc/mbedtls/debug.nim @@ -1,101 +1,20 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# -import "build_info" -import "mbedtls_config" -import "config_psa" -import "check_config" import "ssl" -import "platform_util" -import "platform_time" -import "private_access" import "bignum" import "ecp" -import "ssl_ciphersuites" -import "pk" -import "md" -import "rsa" -import "ecdsa" -import "cipher" import "x509_crt" -import "x509" -import "asn1" -import "x509_crl" -import "dhm" import "ecdh" -import "md5" -import "ripemd160" -import "sha1" -import "sha256" -import "sha512" -import "cmac" -import "gcm" -import "ccm" -import "chachapoly" -import "poly1305" -import "chacha20" -import "ecjpake" -{.compile: "./mbedtls/library/debug.c".} -# Generated @ 2023-05-11T11:19:09+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/debug.h +import "utils" # const 'MBEDTLS_PRINTF_MS_TIME' has unsupported value 'PRId64' + {.push hint[ConvFromXtoItselfNotNeeded]: off.} -import macros - -macro defineEnum(typ: untyped): untyped = - result = newNimNode(nnkStmtList) - - # Enum mapped to distinct cint - result.add quote do: - type `typ`* = distinct cint - - for i in ["+", "-", "*", "div", "mod", "shl", "shr", "or", "and", "xor", "<", "<=", "==", ">", ">="]: - let - ni = newIdentNode(i) - typout = if i[0] in "<=>": newIdentNode("bool") else: typ # comparisons return bool - if i[0] == '>': # cannot borrow `>` and `>=` from templates - let - nopp = if i.len == 2: newIdentNode("<=") else: newIdentNode("<") - result.add quote do: - proc `ni`*(x: `typ`, y: cint): `typout` = `nopp`(y, x) - proc `ni`*(x: cint, y: `typ`): `typout` = `nopp`(y, x) - proc `ni`*(x, y: `typ`): `typout` = `nopp`(y, x) - else: - result.add quote do: - proc `ni`*(x: `typ`, y: cint): `typout` {.borrow.} - proc `ni`*(x: cint, y: `typ`): `typout` {.borrow.} - proc `ni`*(x, y: `typ`): `typout` {.borrow.} - result.add quote do: - proc `ni`*(x: `typ`, y: int): `typout` = `ni`(x, y.cint) - proc `ni`*(x: int, y: `typ`): `typout` = `ni`(x.cint, y) - - let - divop = newIdentNode("/") # `/`() - dlrop = newIdentNode("$") # `$`() - notop = newIdentNode("not") # `not`() - result.add quote do: - proc `divop`*(x, y: `typ`): `typ` = `typ`((x.float / y.float).cint) - proc `divop`*(x: `typ`, y: cint): `typ` = `divop`(x, `typ`(y)) - proc `divop`*(x: cint, y: `typ`): `typ` = `divop`(`typ`(x), y) - proc `divop`*(x: `typ`, y: int): `typ` = `divop`(x, y.cint) - proc `divop`*(x: int, y: `typ`): `typ` = `divop`(x.cint, y) - - proc `dlrop`*(x: `typ`): string {.borrow.} - proc `notop`*(x: `typ`): `typ` {.borrow.} - {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + defineEnum(mbedtls_debug_ecdh_attr) + const MBEDTLS_PRINTF_SIZET* = "zu" MBEDTLS_PRINTF_LONGLONG* = "lld" diff --git a/webrtc/mbedtls/des.nim b/webrtc/mbedtls/des.nim index d1e4196..7ec04b0 100644 --- a/webrtc/mbedtls/des.nim +++ b/webrtc/mbedtls/des.nim @@ -1,30 +1,13 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# -import "private_access" -import "build_info" -import "mbedtls_config" -import "config_psa" -import "check_config" -import "platform_util" import "platform_time" + {.compile: "./mbedtls/library/des.c".} -# Generated @ 2023-05-11T11:19:09+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/des.h {.push hint[ConvFromXtoItselfNotNeeded]: off.} - {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + const MBEDTLS_DES_ENCRYPT* = 1 MBEDTLS_DES_DECRYPT* = 0 diff --git a/webrtc/mbedtls/dhm.nim b/webrtc/mbedtls/dhm.nim index f839722..7aaab62 100644 --- a/webrtc/mbedtls/dhm.nim +++ b/webrtc/mbedtls/dhm.nim @@ -1,19 +1,9 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# import "asn1" import "pem" import "bignum" +import "utils" + {.compile: "./mbedtls/library/dhm.c".} -# Generated @ 2023-05-11T11:19:09+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/dhm.h # const 'MBEDTLS_DHM_RFC3526_MODP_2048_P_BIN' has unsupported value '{ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC9, 0x0F, 0xDA, 0xA2, 0x21, 0x68, 0xC2, 0x34, 0xC4, 0xC6, 0x62, 0x8B, 0x80, 0xDC, 0x1C, 0xD1, 0x29, 0x02, 0x4E, 0x08, 0x8A, 0x67, 0xCC, 0x74, 0x02, 0x0B, 0xBE, 0xA6, 0x3B, 0x13, 0x9B, 0x22, 0x51, 0x4A, 0x08, 0x79, 0x8E, 0x34, 0x04, 0xDD, 0xEF, 0x95, 0x19, 0xB3, 0xCD, 0x3A, 0x43, 0x1B, 0x30, 0x2B, 0x0A, 0x6D, 0xF2, 0x5F, 0x14, 0x37, 0x4F, 0xE1, 0x35, 0x6D, 0x6D, 0x51, 0xC2, 0x45, 0xE4, 0x85, 0xB5, 0x76, 0x62, 0x5E, 0x7E, 0xC6, 0xF4, 0x4C, 0x42, 0xE9, 0xA6, 0x37, 0xED, 0x6B, 0x0B, 0xFF, 0x5C, 0xB6, 0xF4, 0x06, 0xB7, 0xED, 0xEE, 0x38, 0x6B, 0xFB, 0x5A, 0x89, 0x9F, 0xA5, 0xAE, 0x9F, 0x24, 0x11, 0x7C, 0x4B, 0x1F, 0xE6, 0x49, 0x28, 0x66, 0x51, 0xEC, 0xE4, 0x5B, 0x3D, 0xC2, 0x00, 0x7C, 0xB8, 0xA1, 0x63, 0xBF, 0x05, 0x98, 0xDA, 0x48, 0x36, 0x1C, 0x55, 0xD3, 0x9A, 0x69, 0x16, 0x3F, 0xA8, 0xFD, 0x24, 0xCF, 0x5F, 0x83, 0x65, 0x5D, 0x23, 0xDC, 0xA3, 0xAD, 0x96, 0x1C, 0x62, 0xF3, 0x56, 0x20, 0x85, 0x52, 0xBB, 0x9E, 0xD5, 0x29, 0x07, 0x70, 0x96, 0x96, 0x6D, 0x67, 0x0C, 0x35, 0x4E, 0x4A, 0xBC, 0x98, 0x04, 0xF1, 0x74, 0x6C, 0x08, 0xCA, 0x18, 0x21, 0x7C, 0x32, 0x90, 0x5E, 0x46, 0x2E, 0x36, 0xCE, 0x3B, 0xE3, 0x9E, 0x77, 0x2C, 0x18, 0x0E, 0x86, 0x03, 0x9B, 0x27, 0x83, 0xA2, 0xEC, 0x07, 0xA2, 0x8F, 0xB5, 0xC5, 0x5D, 0xF0, 0x6F, 0x4C, 0x52, 0xC9, 0xDE, 0x2B, 0xCB, 0xF6, 0x95, 0x58, 0x17, 0x18, 0x39, 0x95, 0x49, 0x7C, 0xEA, 0x95, 0x6A, 0xE5, 0x15, 0xD2, 0x26, 0x18, 0x98, 0xFA, 0x05, 0x10, 0x15, 0x72, 0x8E, 0x5A, 0x8A, 0xAC, 0xAA, 0x68, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }' # const 'MBEDTLS_DHM_RFC3526_MODP_2048_G_BIN' has unsupported value '{ 0x02 }' @@ -31,55 +21,15 @@ import "bignum" # const 'MBEDTLS_DHM_RFC7919_FFDHE6144_G_BIN' has unsupported value '{ 0x02 }' # const 'MBEDTLS_DHM_RFC7919_FFDHE8192_P_BIN' has unsupported value '{ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xAD, 0xF8, 0x54, 0x58, 0xA2, 0xBB, 0x4A, 0x9A, 0xAF, 0xDC, 0x56, 0x20, 0x27, 0x3D, 0x3C, 0xF1, 0xD8, 0xB9, 0xC5, 0x83, 0xCE, 0x2D, 0x36, 0x95, 0xA9, 0xE1, 0x36, 0x41, 0x14, 0x64, 0x33, 0xFB, 0xCC, 0x93, 0x9D, 0xCE, 0x24, 0x9B, 0x3E, 0xF9, 0x7D, 0x2F, 0xE3, 0x63, 0x63, 0x0C, 0x75, 0xD8, 0xF6, 0x81, 0xB2, 0x02, 0xAE, 0xC4, 0x61, 0x7A, 0xD3, 0xDF, 0x1E, 0xD5, 0xD5, 0xFD, 0x65, 0x61, 0x24, 0x33, 0xF5, 0x1F, 0x5F, 0x06, 0x6E, 0xD0, 0x85, 0x63, 0x65, 0x55, 0x3D, 0xED, 0x1A, 0xF3, 0xB5, 0x57, 0x13, 0x5E, 0x7F, 0x57, 0xC9, 0x35, 0x98, 0x4F, 0x0C, 0x70, 0xE0, 0xE6, 0x8B, 0x77, 0xE2, 0xA6, 0x89, 0xDA, 0xF3, 0xEF, 0xE8, 0x72, 0x1D, 0xF1, 0x58, 0xA1, 0x36, 0xAD, 0xE7, 0x35, 0x30, 0xAC, 0xCA, 0x4F, 0x48, 0x3A, 0x79, 0x7A, 0xBC, 0x0A, 0xB1, 0x82, 0xB3, 0x24, 0xFB, 0x61, 0xD1, 0x08, 0xA9, 0x4B, 0xB2, 0xC8, 0xE3, 0xFB, 0xB9, 0x6A, 0xDA, 0xB7, 0x60, 0xD7, 0xF4, 0x68, 0x1D, 0x4F, 0x42, 0xA3, 0xDE, 0x39, 0x4D, 0xF4, 0xAE, 0x56, 0xED, 0xE7, 0x63, 0x72, 0xBB, 0x19, 0x0B, 0x07, 0xA7, 0xC8, 0xEE, 0x0A, 0x6D, 0x70, 0x9E, 0x02, 0xFC, 0xE1, 0xCD, 0xF7, 0xE2, 0xEC, 0xC0, 0x34, 0x04, 0xCD, 0x28, 0x34, 0x2F, 0x61, 0x91, 0x72, 0xFE, 0x9C, 0xE9, 0x85, 0x83, 0xFF, 0x8E, 0x4F, 0x12, 0x32, 0xEE, 0xF2, 0x81, 0x83, 0xC3, 0xFE, 0x3B, 0x1B, 0x4C, 0x6F, 0xAD, 0x73, 0x3B, 0xB5, 0xFC, 0xBC, 0x2E, 0xC2, 0x20, 0x05, 0xC5, 0x8E, 0xF1, 0x83, 0x7D, 0x16, 0x83, 0xB2, 0xC6, 0xF3, 0x4A, 0x26, 0xC1, 0xB2, 0xEF, 0xFA, 0x88, 0x6B, 0x42, 0x38, 0x61, 0x1F, 0xCF, 0xDC, 0xDE, 0x35, 0x5B, 0x3B, 0x65, 0x19, 0x03, 0x5B, 0xBC, 0x34, 0xF4, 0xDE, 0xF9, 0x9C, 0x02, 0x38, 0x61, 0xB4, 0x6F, 0xC9, 0xD6, 0xE6, 0xC9, 0x07, 0x7A, 0xD9, 0x1D, 0x26, 0x91, 0xF7, 0xF7, 0xEE, 0x59, 0x8C, 0xB0, 0xFA, 0xC1, 0x86, 0xD9, 0x1C, 0xAE, 0xFE, 0x13, 0x09, 0x85, 0x13, 0x92, 0x70, 0xB4, 0x13, 0x0C, 0x93, 0xBC, 0x43, 0x79, 0x44, 0xF4, 0xFD, 0x44, 0x52, 0xE2, 0xD7, 0x4D, 0xD3, 0x64, 0xF2, 0xE2, 0x1E, 0x71, 0xF5, 0x4B, 0xFF, 0x5C, 0xAE, 0x82, 0xAB, 0x9C, 0x9D, 0xF6, 0x9E, 0xE8, 0x6D, 0x2B, 0xC5, 0x22, 0x36, 0x3A, 0x0D, 0xAB, 0xC5, 0x21, 0x97, 0x9B, 0x0D, 0xEA, 0xDA, 0x1D, 0xBF, 0x9A, 0x42, 0xD5, 0xC4, 0x48, 0x4E, 0x0A, 0xBC, 0xD0, 0x6B, 0xFA, 0x53, 0xDD, 0xEF, 0x3C, 0x1B, 0x20, 0xEE, 0x3F, 0xD5, 0x9D, 0x7C, 0x25, 0xE4, 0x1D, 0x2B, 0x66, 0x9E, 0x1E, 0xF1, 0x6E, 0x6F, 0x52, 0xC3, 0x16, 0x4D, 0xF4, 0xFB, 0x79, 0x30, 0xE9, 0xE4, 0xE5, 0x88, 0x57, 0xB6, 0xAC, 0x7D, 0x5F, 0x42, 0xD6, 0x9F, 0x6D, 0x18, 0x77, 0x63, 0xCF, 0x1D, 0x55, 0x03, 0x40, 0x04, 0x87, 0xF5, 0x5B, 0xA5, 0x7E, 0x31, 0xCC, 0x7A, 0x71, 0x35, 0xC8, 0x86, 0xEF, 0xB4, 0x31, 0x8A, 0xED, 0x6A, 0x1E, 0x01, 0x2D, 0x9E, 0x68, 0x32, 0xA9, 0x07, 0x60, 0x0A, 0x91, 0x81, 0x30, 0xC4, 0x6D, 0xC7, 0x78, 0xF9, 0x71, 0xAD, 0x00, 0x38, 0x09, 0x29, 0x99, 0xA3, 0x33, 0xCB, 0x8B, 0x7A, 0x1A, 0x1D, 0xB9, 0x3D, 0x71, 0x40, 0x00, 0x3C, 0x2A, 0x4E, 0xCE, 0xA9, 0xF9, 0x8D, 0x0A, 0xCC, 0x0A, 0x82, 0x91, 0xCD, 0xCE, 0xC9, 0x7D, 0xCF, 0x8E, 0xC9, 0xB5, 0x5A, 0x7F, 0x88, 0xA4, 0x6B, 0x4D, 0xB5, 0xA8, 0x51, 0xF4, 0x41, 0x82, 0xE1, 0xC6, 0x8A, 0x00, 0x7E, 0x5E, 0x0D, 0xD9, 0x02, 0x0B, 0xFD, 0x64, 0xB6, 0x45, 0x03, 0x6C, 0x7A, 0x4E, 0x67, 0x7D, 0x2C, 0x38, 0x53, 0x2A, 0x3A, 0x23, 0xBA, 0x44, 0x42, 0xCA, 0xF5, 0x3E, 0xA6, 0x3B, 0xB4, 0x54, 0x32, 0x9B, 0x76, 0x24, 0xC8, 0x91, 0x7B, 0xDD, 0x64, 0xB1, 0xC0, 0xFD, 0x4C, 0xB3, 0x8E, 0x8C, 0x33, 0x4C, 0x70, 0x1C, 0x3A, 0xCD, 0xAD, 0x06, 0x57, 0xFC, 0xCF, 0xEC, 0x71, 0x9B, 0x1F, 0x5C, 0x3E, 0x4E, 0x46, 0x04, 0x1F, 0x38, 0x81, 0x47, 0xFB, 0x4C, 0xFD, 0xB4, 0x77, 0xA5, 0x24, 0x71, 0xF7, 0xA9, 0xA9, 0x69, 0x10, 0xB8, 0x55, 0x32, 0x2E, 0xDB, 0x63, 0x40, 0xD8, 0xA0, 0x0E, 0xF0, 0x92, 0x35, 0x05, 0x11, 0xE3, 0x0A, 0xBE, 0xC1, 0xFF, 0xF9, 0xE3, 0xA2, 0x6E, 0x7F, 0xB2, 0x9F, 0x8C, 0x18, 0x30, 0x23, 0xC3, 0x58, 0x7E, 0x38, 0xDA, 0x00, 0x77, 0xD9, 0xB4, 0x76, 0x3E, 0x4E, 0x4B, 0x94, 0xB2, 0xBB, 0xC1, 0x94, 0xC6, 0x65, 0x1E, 0x77, 0xCA, 0xF9, 0x92, 0xEE, 0xAA, 0xC0, 0x23, 0x2A, 0x28, 0x1B, 0xF6, 0xB3, 0xA7, 0x39, 0xC1, 0x22, 0x61, 0x16, 0x82, 0x0A, 0xE8, 0xDB, 0x58, 0x47, 0xA6, 0x7C, 0xBE, 0xF9, 0xC9, 0x09, 0x1B, 0x46, 0x2D, 0x53, 0x8C, 0xD7, 0x2B, 0x03, 0x74, 0x6A, 0xE7, 0x7F, 0x5E, 0x62, 0x29, 0x2C, 0x31, 0x15, 0x62, 0xA8, 0x46, 0x50, 0x5D, 0xC8, 0x2D, 0xB8, 0x54, 0x33, 0x8A, 0xE4, 0x9F, 0x52, 0x35, 0xC9, 0x5B, 0x91, 0x17, 0x8C, 0xCF, 0x2D, 0xD5, 0xCA, 0xCE, 0xF4, 0x03, 0xEC, 0x9D, 0x18, 0x10, 0xC6, 0x27, 0x2B, 0x04, 0x5B, 0x3B, 0x71, 0xF9, 0xDC, 0x6B, 0x80, 0xD6, 0x3F, 0xDD, 0x4A, 0x8E, 0x9A, 0xDB, 0x1E, 0x69, 0x62, 0xA6, 0x95, 0x26, 0xD4, 0x31, 0x61, 0xC1, 0xA4, 0x1D, 0x57, 0x0D, 0x79, 0x38, 0xDA, 0xD4, 0xA4, 0x0E, 0x32, 0x9C, 0xCF, 0xF4, 0x6A, 0xAA, 0x36, 0xAD, 0x00, 0x4C, 0xF6, 0x00, 0xC8, 0x38, 0x1E, 0x42, 0x5A, 0x31, 0xD9, 0x51, 0xAE, 0x64, 0xFD, 0xB2, 0x3F, 0xCE, 0xC9, 0x50, 0x9D, 0x43, 0x68, 0x7F, 0xEB, 0x69, 0xED, 0xD1, 0xCC, 0x5E, 0x0B, 0x8C, 0xC3, 0xBD, 0xF6, 0x4B, 0x10, 0xEF, 0x86, 0xB6, 0x31, 0x42, 0xA3, 0xAB, 0x88, 0x29, 0x55, 0x5B, 0x2F, 0x74, 0x7C, 0x93, 0x26, 0x65, 0xCB, 0x2C, 0x0F, 0x1C, 0xC0, 0x1B, 0xD7, 0x02, 0x29, 0x38, 0x88, 0x39, 0xD2, 0xAF, 0x05, 0xE4, 0x54, 0x50, 0x4A, 0xC7, 0x8B, 0x75, 0x82, 0x82, 0x28, 0x46, 0xC0, 0xBA, 0x35, 0xC3, 0x5F, 0x5C, 0x59, 0x16, 0x0C, 0xC0, 0x46, 0xFD, 0x82, 0x51, 0x54, 0x1F, 0xC6, 0x8C, 0x9C, 0x86, 0xB0, 0x22, 0xBB, 0x70, 0x99, 0x87, 0x6A, 0x46, 0x0E, 0x74, 0x51, 0xA8, 0xA9, 0x31, 0x09, 0x70, 0x3F, 0xEE, 0x1C, 0x21, 0x7E, 0x6C, 0x38, 0x26, 0xE5, 0x2C, 0x51, 0xAA, 0x69, 0x1E, 0x0E, 0x42, 0x3C, 0xFC, 0x99, 0xE9, 0xE3, 0x16, 0x50, 0xC1, 0x21, 0x7B, 0x62, 0x48, 0x16, 0xCD, 0xAD, 0x9A, 0x95, 0xF9, 0xD5, 0xB8, 0x01, 0x94, 0x88, 0xD9, 0xC0, 0xA0, 0xA1, 0xFE, 0x30, 0x75, 0xA5, 0x77, 0xE2, 0x31, 0x83, 0xF8, 0x1D, 0x4A, 0x3F, 0x2F, 0xA4, 0x57, 0x1E, 0xFC, 0x8C, 0xE0, 0xBA, 0x8A, 0x4F, 0xE8, 0xB6, 0x85, 0x5D, 0xFE, 0x72, 0xB0, 0xA6, 0x6E, 0xDE, 0xD2, 0xFB, 0xAB, 0xFB, 0xE5, 0x8A, 0x30, 0xFA, 0xFA, 0xBE, 0x1C, 0x5D, 0x71, 0xA8, 0x7E, 0x2F, 0x74, 0x1E, 0xF8, 0xC1, 0xFE, 0x86, 0xFE, 0xA6, 0xBB, 0xFD, 0xE5, 0x30, 0x67, 0x7F, 0x0D, 0x97, 0xD1, 0x1D, 0x49, 0xF7, 0xA8, 0x44, 0x3D, 0x08, 0x22, 0xE5, 0x06, 0xA9, 0xF4, 0x61, 0x4E, 0x01, 0x1E, 0x2A, 0x94, 0x83, 0x8F, 0xF8, 0x8C, 0xD6, 0x8C, 0x8B, 0xB7, 0xC5, 0xC6, 0x42, 0x4C, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }' # const 'MBEDTLS_DHM_RFC7919_FFDHE8192_G_BIN' has unsupported value '{ 0x02 }' + {.push hint[ConvFromXtoItselfNotNeeded]: off.} -import macros - -macro defineEnum(typ: untyped): untyped = - result = newNimNode(nnkStmtList) - - # Enum mapped to distinct cint - result.add quote do: - type `typ`* = distinct cint - - for i in ["+", "-", "*", "div", "mod", "shl", "shr", "or", "and", "xor", "<", "<=", "==", ">", ">="]: - let - ni = newIdentNode(i) - typout = if i[0] in "<=>": newIdentNode("bool") else: typ # comparisons return bool - if i[0] == '>': # cannot borrow `>` and `>=` from templates - let - nopp = if i.len == 2: newIdentNode("<=") else: newIdentNode("<") - result.add quote do: - proc `ni`*(x: `typ`, y: cint): `typout` = `nopp`(y, x) - proc `ni`*(x: cint, y: `typ`): `typout` = `nopp`(y, x) - proc `ni`*(x, y: `typ`): `typout` = `nopp`(y, x) - else: - result.add quote do: - proc `ni`*(x: `typ`, y: cint): `typout` {.borrow.} - proc `ni`*(x: cint, y: `typ`): `typout` {.borrow.} - proc `ni`*(x, y: `typ`): `typout` {.borrow.} - result.add quote do: - proc `ni`*(x: `typ`, y: int): `typout` = `ni`(x, y.cint) - proc `ni`*(x: int, y: `typ`): `typout` = `ni`(x.cint, y) - - let - divop = newIdentNode("/") # `/`() - dlrop = newIdentNode("$") # `$`() - notop = newIdentNode("not") # `not`() - result.add quote do: - proc `divop`*(x, y: `typ`): `typ` = `typ`((x.float / y.float).cint) - proc `divop`*(x: `typ`, y: cint): `typ` = `divop`(x, `typ`(y)) - proc `divop`*(x: cint, y: `typ`): `typ` = `divop`(`typ`(x), y) - proc `divop`*(x: `typ`, y: int): `typ` = `divop`(x, y.cint) - proc `divop`*(x: int, y: `typ`): `typ` = `divop`(x.cint, y) - - proc `dlrop`*(x: `typ`): string {.borrow.} - proc `notop`*(x: `typ`): `typ` {.borrow.} - {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + defineEnum(mbedtls_dhm_parameter) + const MBEDTLS_ERR_DHM_BAD_INPUT_DATA* = -0x00003080 MBEDTLS_ERR_DHM_READ_PARAMS_FAILED* = -0x00003100 diff --git a/webrtc/mbedtls/ecdh.nim b/webrtc/mbedtls/ecdh.nim index 18148b9..bea624e 100644 --- a/webrtc/mbedtls/ecdh.nim +++ b/webrtc/mbedtls/ecdh.nim @@ -1,74 +1,18 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# -import "private_access" -import "build_info" -import "mbedtls_config" -import "config_psa" -import "check_config" import "ecp" import "bignum" +import "utils" + {.compile: "./mbedtls/library/ecdh.c".} -# Generated @ 2023-05-11T11:19:09+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/ecdh.h {.push hint[ConvFromXtoItselfNotNeeded]: off.} -import macros - -macro defineEnum(typ: untyped): untyped = - result = newNimNode(nnkStmtList) - - # Enum mapped to distinct cint - result.add quote do: - type `typ`* = distinct cint - - for i in ["+", "-", "*", "div", "mod", "shl", "shr", "or", "and", "xor", "<", "<=", "==", ">", ">="]: - let - ni = newIdentNode(i) - typout = if i[0] in "<=>": newIdentNode("bool") else: typ # comparisons return bool - if i[0] == '>': # cannot borrow `>` and `>=` from templates - let - nopp = if i.len == 2: newIdentNode("<=") else: newIdentNode("<") - result.add quote do: - proc `ni`*(x: `typ`, y: cint): `typout` = `nopp`(y, x) - proc `ni`*(x: cint, y: `typ`): `typout` = `nopp`(y, x) - proc `ni`*(x, y: `typ`): `typout` = `nopp`(y, x) - else: - result.add quote do: - proc `ni`*(x: `typ`, y: cint): `typout` {.borrow.} - proc `ni`*(x: cint, y: `typ`): `typout` {.borrow.} - proc `ni`*(x, y: `typ`): `typout` {.borrow.} - result.add quote do: - proc `ni`*(x: `typ`, y: int): `typout` = `ni`(x, y.cint) - proc `ni`*(x: int, y: `typ`): `typout` = `ni`(x.cint, y) - - let - divop = newIdentNode("/") # `/`() - dlrop = newIdentNode("$") # `$`() - notop = newIdentNode("not") # `not`() - result.add quote do: - proc `divop`*(x, y: `typ`): `typ` = `typ`((x.float / y.float).cint) - proc `divop`*(x: `typ`, y: cint): `typ` = `divop`(x, `typ`(y)) - proc `divop`*(x: cint, y: `typ`): `typ` = `divop`(`typ`(x), y) - proc `divop`*(x: `typ`, y: int): `typ` = `divop`(x, y.cint) - proc `divop`*(x: int, y: `typ`): `typ` = `divop`(x.cint, y) - - proc `dlrop`*(x: `typ`): string {.borrow.} - proc `notop`*(x: `typ`): `typ` {.borrow.} - {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + defineEnum(mbedtls_ecdh_side) defineEnum(mbedtls_ecdh_variant) + const MBEDTLS_ECDH_OURS* = (0).mbedtls_ecdh_side MBEDTLS_ECDH_THEIRS* = (MBEDTLS_ECDH_OURS + 1).mbedtls_ecdh_side diff --git a/webrtc/mbedtls/ecdsa.nim b/webrtc/mbedtls/ecdsa.nim index 90edde1..93d2a27 100644 --- a/webrtc/mbedtls/ecdsa.nim +++ b/webrtc/mbedtls/ecdsa.nim @@ -1,31 +1,17 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# import "ecp" import "bignum" import "md" -import "platform_time" import "hmac_drbg" -import "asn1" import "asn1write" + {.compile: "./mbedtls/library/ecdsa.c".} -# Generated @ 2023-05-11T11:19:10+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/ecdsa.h -# const 'MBEDTLS_ECDSA_MAX_LEN' has unsupported value 'MBEDTLS_ECDSA_MAX_SIG_LEN(MBEDTLS_ECP_MAX_BITS)' {.push hint[ConvFromXtoItselfNotNeeded]: off.} - {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + type mbedtls_ecdsa_context* = mbedtls_ecp_keypair mbedtls_ecdsa_restart_ctx* = object diff --git a/webrtc/mbedtls/ecjpake.nim b/webrtc/mbedtls/ecjpake.nim index aff083e..a161a55 100644 --- a/webrtc/mbedtls/ecjpake.nim +++ b/webrtc/mbedtls/ecjpake.nim @@ -1,71 +1,20 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# import "ecp" import "bignum" import "md" import "hash_info" import "platform_time" +import "utils" + {.compile: "./mbedtls/library/ecjpake.c".} -# Generated @ 2023-05-11T11:19:10+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/ecjpake.h {.push hint[ConvFromXtoItselfNotNeeded]: off.} -import macros - -macro defineEnum(typ: untyped): untyped = - result = newNimNode(nnkStmtList) - - # Enum mapped to distinct cint - result.add quote do: - type `typ`* = distinct cint - - for i in ["+", "-", "*", "div", "mod", "shl", "shr", "or", "and", "xor", "<", "<=", "==", ">", ">="]: - let - ni = newIdentNode(i) - typout = if i[0] in "<=>": newIdentNode("bool") else: typ # comparisons return bool - if i[0] == '>': # cannot borrow `>` and `>=` from templates - let - nopp = if i.len == 2: newIdentNode("<=") else: newIdentNode("<") - result.add quote do: - proc `ni`*(x: `typ`, y: cint): `typout` = `nopp`(y, x) - proc `ni`*(x: cint, y: `typ`): `typout` = `nopp`(y, x) - proc `ni`*(x, y: `typ`): `typout` = `nopp`(y, x) - else: - result.add quote do: - proc `ni`*(x: `typ`, y: cint): `typout` {.borrow.} - proc `ni`*(x: cint, y: `typ`): `typout` {.borrow.} - proc `ni`*(x, y: `typ`): `typout` {.borrow.} - result.add quote do: - proc `ni`*(x: `typ`, y: int): `typout` = `ni`(x, y.cint) - proc `ni`*(x: int, y: `typ`): `typout` = `ni`(x.cint, y) - - let - divop = newIdentNode("/") # `/`() - dlrop = newIdentNode("$") # `$`() - notop = newIdentNode("not") # `not`() - result.add quote do: - proc `divop`*(x, y: `typ`): `typ` = `typ`((x.float / y.float).cint) - proc `divop`*(x: `typ`, y: cint): `typ` = `divop`(x, `typ`(y)) - proc `divop`*(x: cint, y: `typ`): `typ` = `divop`(`typ`(x), y) - proc `divop`*(x: `typ`, y: int): `typ` = `divop`(x, y.cint) - proc `divop`*(x: int, y: `typ`): `typ` = `divop`(x.cint, y) - - proc `dlrop`*(x: `typ`): string {.borrow.} - proc `notop`*(x: `typ`): `typ` {.borrow.} - {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + defineEnum(mbedtls_ecjpake_role) + const MBEDTLS_ECJPAKE_CLIENT* = (0).mbedtls_ecjpake_role MBEDTLS_ECJPAKE_SERVER* = (MBEDTLS_ECJPAKE_CLIENT + 1).mbedtls_ecjpake_role diff --git a/webrtc/mbedtls/ecp.nim b/webrtc/mbedtls/ecp.nim index beb0884..fe7a88f 100644 --- a/webrtc/mbedtls/ecp.nim +++ b/webrtc/mbedtls/ecp.nim @@ -1,75 +1,19 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# -import "private_access" -import "build_info" -import "mbedtls_config" -import "config_psa" -import "check_config" import "bignum" +import "utils" + {.compile: "./mbedtls/library/ecp.c".} {.compile: "./mbedtls/library/ecp_curves.c".} -# Generated @ 2023-05-11T11:19:10+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/ecp.h {.push hint[ConvFromXtoItselfNotNeeded]: off.} -import macros - -macro defineEnum(typ: untyped): untyped = - result = newNimNode(nnkStmtList) - - # Enum mapped to distinct cint - result.add quote do: - type `typ`* = distinct cint - - for i in ["+", "-", "*", "div", "mod", "shl", "shr", "or", "and", "xor", "<", "<=", "==", ">", ">="]: - let - ni = newIdentNode(i) - typout = if i[0] in "<=>": newIdentNode("bool") else: typ # comparisons return bool - if i[0] == '>': # cannot borrow `>` and `>=` from templates - let - nopp = if i.len == 2: newIdentNode("<=") else: newIdentNode("<") - result.add quote do: - proc `ni`*(x: `typ`, y: cint): `typout` = `nopp`(y, x) - proc `ni`*(x: cint, y: `typ`): `typout` = `nopp`(y, x) - proc `ni`*(x, y: `typ`): `typout` = `nopp`(y, x) - else: - result.add quote do: - proc `ni`*(x: `typ`, y: cint): `typout` {.borrow.} - proc `ni`*(x: cint, y: `typ`): `typout` {.borrow.} - proc `ni`*(x, y: `typ`): `typout` {.borrow.} - result.add quote do: - proc `ni`*(x: `typ`, y: int): `typout` = `ni`(x, y.cint) - proc `ni`*(x: int, y: `typ`): `typout` = `ni`(x.cint, y) - - let - divop = newIdentNode("/") # `/`() - dlrop = newIdentNode("$") # `$`() - notop = newIdentNode("not") # `not`() - result.add quote do: - proc `divop`*(x, y: `typ`): `typ` = `typ`((x.float / y.float).cint) - proc `divop`*(x: `typ`, y: cint): `typ` = `divop`(x, `typ`(y)) - proc `divop`*(x: cint, y: `typ`): `typ` = `divop`(`typ`(x), y) - proc `divop`*(x: `typ`, y: int): `typ` = `divop`(x, y.cint) - proc `divop`*(x: int, y: `typ`): `typ` = `divop`(x.cint, y) - - proc `dlrop`*(x: `typ`): string {.borrow.} - proc `notop`*(x: `typ`): `typ` {.borrow.} - {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + defineEnum(mbedtls_ecp_group_id) defineEnum(mbedtls_ecp_curve_type) defineEnum(mbedtls_ecp_modulus_type) + const MBEDTLS_ERR_ECP_BAD_INPUT_DATA* = -0x00004F80 MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL* = -0x00004F00 diff --git a/webrtc/mbedtls/entropy.nim b/webrtc/mbedtls/entropy.nim index db307a2..fd6281e 100644 --- a/webrtc/mbedtls/entropy.nim +++ b/webrtc/mbedtls/entropy.nim @@ -1,34 +1,17 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# -import "private_access" -import "build_info" -import "mbedtls_config" -import "config_psa" -import "check_config" import "md" -import "platform_util" -import "platform_time" + {.compile: "./mbedtls/library/entropy.c".} {.compile: "./mbedtls/library/entropy_poll.c".} -# Generated @ 2023-05-11T11:19:10+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/entropy.h # const 'MBEDTLS_ENTROPY_MD' has unsupported value 'MBEDTLS_MD_SHA512' # const 'MBEDTLS_ENTROPY_SOURCE_MANUAL' has unsupported value 'MBEDTLS_ENTROPY_MAX_SOURCES' -{.push hint[ConvFromXtoItselfNotNeeded]: off.} +{.push hint[ConvFromXtoItselfNotNeeded]: off.} {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + const MBEDTLS_ENTROPY_BLOCK_SIZE* = 64 MBEDTLS_ERR_ENTROPY_SOURCE_FAILED* = -0x0000003C diff --git a/webrtc/mbedtls/error.nim b/webrtc/mbedtls/error.nim index cf0242e..5b0f608 100644 --- a/webrtc/mbedtls/error.nim +++ b/webrtc/mbedtls/error.nim @@ -1,28 +1,13 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# -import "build_info" -import "mbedtls_config" -import "config_psa" -import "check_config" {.compile: "./mbedtls/library/error.c".} -# Generated @ 2023-05-11T11:19:10+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/error.h # proc 'mbedtls_error_add' skipped - static inline procs cannot work with '--noHeader | -H' -{.push hint[ConvFromXtoItselfNotNeeded]: off.} +{.push hint[ConvFromXtoItselfNotNeeded]: off.} {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + const MBEDTLS_ERR_ERROR_GENERIC_ERROR* = -0x00000001 MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED* = -0x0000006E diff --git a/webrtc/mbedtls/gcm.nim b/webrtc/mbedtls/gcm.nim index 0e3b790..21e29c4 100644 --- a/webrtc/mbedtls/gcm.nim +++ b/webrtc/mbedtls/gcm.nim @@ -1,31 +1,11 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# -import "private_access" -import "build_info" -import "mbedtls_config" -import "config_psa" -import "check_config" import "cipher" -import "platform_util" -import "platform_time" -#{.compile: "./mbedtls/library/gcm.c".} -# Generated @ 2023-05-11T11:19:10+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/gcm.h {.push hint[ConvFromXtoItselfNotNeeded]: off.} - {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + const MBEDTLS_GCM_ENCRYPT* = 1 MBEDTLS_GCM_DECRYPT* = 0 diff --git a/webrtc/mbedtls/hash_info.nim b/webrtc/mbedtls/hash_info.nim index 202cd21..536b204 100644 --- a/webrtc/mbedtls/hash_info.nim +++ b/webrtc/mbedtls/hash_info.nim @@ -1,3 +1,4 @@ +# TODO: Put the .compile. pragma in one of the file using it without breaking everything {.compile: "./mbedtls/library/hash_info.c".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} diff --git a/webrtc/mbedtls/hkdf.nim b/webrtc/mbedtls/hkdf.nim index c3c685b..2b2e3cf 100644 --- a/webrtc/mbedtls/hkdf.nim +++ b/webrtc/mbedtls/hkdf.nim @@ -1,31 +1,13 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# -import "build_info" -import "mbedtls_config" -import "config_psa" -import "check_config" import "md" -import "private_access" -import "platform_util" -import "platform_time" + {.compile: "./mbedtls/library/hkdf.c".} -# Generated @ 2023-05-11T11:19:10+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/hkdf.h {.push hint[ConvFromXtoItselfNotNeeded]: off.} - {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + const MBEDTLS_ERR_HKDF_BAD_INPUT_DATA* = -0x00005F80 proc mbedtls_hkdf*(md: ptr mbedtls_md_info_t; salt: ptr byte; salt_len: uint; diff --git a/webrtc/mbedtls/hmac_drbg.nim b/webrtc/mbedtls/hmac_drbg.nim index b456271..009d96f 100644 --- a/webrtc/mbedtls/hmac_drbg.nim +++ b/webrtc/mbedtls/hmac_drbg.nim @@ -1,31 +1,13 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# -import "private_access" -import "build_info" -import "mbedtls_config" -import "config_psa" -import "check_config" import "md" -import "platform_util" -import "platform_time" + {.compile: "./mbedtls/library/hmac_drbg.c".} -# Generated @ 2023-05-11T11:19:11+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/hmac_drbg.h {.push hint[ConvFromXtoItselfNotNeeded]: off.} - {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + const MBEDTLS_ERR_HMAC_DRBG_REQUEST_TOO_BIG* = -0x00000003 MBEDTLS_ERR_HMAC_DRBG_INPUT_TOO_BIG* = -0x00000005 diff --git a/webrtc/mbedtls/lms.nim b/webrtc/mbedtls/lms.nim index 8eacfda..8713064 100644 --- a/webrtc/mbedtls/lms.nim +++ b/webrtc/mbedtls/lms.nim @@ -1,69 +1,18 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# import "psa/crypto" +import "utils" + {.compile: "./mbedtls/library/lms.c".} {.compile: "./mbedtls/library/lmots.c".} -# Generated @ 2023-05-11T11:19:11+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/lms.h {.push hint[ConvFromXtoItselfNotNeeded]: off.} -import macros - -macro defineEnum(typ: untyped): untyped = - result = newNimNode(nnkStmtList) - - # Enum mapped to distinct cint - result.add quote do: - type `typ`* = distinct cint - - for i in ["+", "-", "*", "div", "mod", "shl", "shr", "or", "and", "xor", "<", "<=", "==", ">", ">="]: - let - ni = newIdentNode(i) - typout = if i[0] in "<=>": newIdentNode("bool") else: typ # comparisons return bool - if i[0] == '>': # cannot borrow `>` and `>=` from templates - let - nopp = if i.len == 2: newIdentNode("<=") else: newIdentNode("<") - result.add quote do: - proc `ni`*(x: `typ`, y: cint): `typout` = `nopp`(y, x) - proc `ni`*(x: cint, y: `typ`): `typout` = `nopp`(y, x) - proc `ni`*(x, y: `typ`): `typout` = `nopp`(y, x) - else: - result.add quote do: - proc `ni`*(x: `typ`, y: cint): `typout` {.borrow.} - proc `ni`*(x: cint, y: `typ`): `typout` {.borrow.} - proc `ni`*(x, y: `typ`): `typout` {.borrow.} - result.add quote do: - proc `ni`*(x: `typ`, y: int): `typout` = `ni`(x, y.cint) - proc `ni`*(x: int, y: `typ`): `typout` = `ni`(x.cint, y) - - let - divop = newIdentNode("/") # `/`() - dlrop = newIdentNode("$") # `$`() - notop = newIdentNode("not") # `not`() - result.add quote do: - proc `divop`*(x, y: `typ`): `typ` = `typ`((x.float / y.float).cint) - proc `divop`*(x: `typ`, y: cint): `typ` = `divop`(x, `typ`(y)) - proc `divop`*(x: cint, y: `typ`): `typ` = `divop`(`typ`(x), y) - proc `divop`*(x: `typ`, y: int): `typ` = `divop`(x, y.cint) - proc `divop`*(x: int, y: `typ`): `typ` = `divop`(x.cint, y) - - proc `dlrop`*(x: `typ`): string {.borrow.} - proc `notop`*(x: `typ`): `typ` {.borrow.} - {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + defineEnum(mbedtls_lms_algorithm_type_t) defineEnum(mbedtls_lmots_algorithm_type_t) + const MBEDTLS_ERR_LMS_BAD_INPUT_DATA* = -0x00000011 MBEDTLS_ERR_LMS_OUT_OF_PRIVATE_KEYS* = -0x00000013 diff --git a/webrtc/mbedtls/mbedtls_config.nim b/webrtc/mbedtls/mbedtls_config.nim index b5c38ca..808f7ff 100644 --- a/webrtc/mbedtls/mbedtls_config.nim +++ b/webrtc/mbedtls/mbedtls_config.nim @@ -1,22 +1,9 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# -# Generated @ 2023-05-11T11:19:11+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/mbedtls_config.h - {.push hint[ConvFromXtoItselfNotNeeded]: off.} - {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + const MBEDTLS_SSL_DTLS_CONNECTION_ID_COMPAT* = 0 MBEDTLS_SSL_MAX_EARLY_DATA_SIZE* = 1024 diff --git a/webrtc/mbedtls/md.nim b/webrtc/mbedtls/md.nim index f1fb65e..1b7e588 100644 --- a/webrtc/mbedtls/md.nim +++ b/webrtc/mbedtls/md.nim @@ -1,78 +1,21 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# -import "platform_time" import "ripemd160" import "sha1" import "sha256" import "sha512" import "md5" -# {.compile: "./mbedtls/library/ripemd160.c".} -# {.compile: "./mbedtls/library/sha1.c".} -# {.compile: "./mbedtls/library/sha256.c".} -# {.compile: "./mbedtls/library/sha512.c".} -# {.compile: "./mbedtls/library/md5.c".} +import "utils" + {.compile: "./mbedtls/library/md.c".} -# Generated @ 2023-05-11T11:19:11+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/md.h {.push hint[ConvFromXtoItselfNotNeeded]: off.} -import macros - -macro defineEnum(typ: untyped): untyped = - result = newNimNode(nnkStmtList) - - # Enum mapped to distinct cint - result.add quote do: - type `typ`* = distinct cint - - for i in ["+", "-", "*", "div", "mod", "shl", "shr", "or", "and", "xor", "<", "<=", "==", ">", ">="]: - let - ni = newIdentNode(i) - typout = if i[0] in "<=>": newIdentNode("bool") else: typ # comparisons return bool - if i[0] == '>': # cannot borrow `>` and `>=` from templates - let - nopp = if i.len == 2: newIdentNode("<=") else: newIdentNode("<") - result.add quote do: - proc `ni`*(x: `typ`, y: cint): `typout` = `nopp`(y, x) - proc `ni`*(x: cint, y: `typ`): `typout` = `nopp`(y, x) - proc `ni`*(x, y: `typ`): `typout` = `nopp`(y, x) - else: - result.add quote do: - proc `ni`*(x: `typ`, y: cint): `typout` {.borrow.} - proc `ni`*(x: cint, y: `typ`): `typout` {.borrow.} - proc `ni`*(x, y: `typ`): `typout` {.borrow.} - result.add quote do: - proc `ni`*(x: `typ`, y: int): `typout` = `ni`(x, y.cint) - proc `ni`*(x: int, y: `typ`): `typout` = `ni`(x.cint, y) - - let - divop = newIdentNode("/") # `/`() - dlrop = newIdentNode("$") # `$`() - notop = newIdentNode("not") # `not`() - result.add quote do: - proc `divop`*(x, y: `typ`): `typ` = `typ`((x.float / y.float).cint) - proc `divop`*(x: `typ`, y: cint): `typ` = `divop`(x, `typ`(y)) - proc `divop`*(x: cint, y: `typ`): `typ` = `divop`(`typ`(x), y) - proc `divop`*(x: `typ`, y: int): `typ` = `divop`(x, y.cint) - proc `divop`*(x: int, y: `typ`): `typ` = `divop`(x.cint, y) - - proc `dlrop`*(x: `typ`): string {.borrow.} - proc `notop`*(x: `typ`): `typ` {.borrow.} - {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + defineEnum(mbedtls_md_type_t) defineEnum(mbedtls_md_engine_t) + const MBEDTLS_ERR_MD_FEATURE_UNAVAILABLE* = -0x00005080 MBEDTLS_ERR_MD_BAD_INPUT_DATA* = -0x00005100 diff --git a/webrtc/mbedtls/md5.nim b/webrtc/mbedtls/md5.nim index 3e1c747..50974bd 100644 --- a/webrtc/mbedtls/md5.nim +++ b/webrtc/mbedtls/md5.nim @@ -1,24 +1,13 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# import "platform_time" + {.compile: "./mbedtls/library/md5.c".} -# Generated @ 2023-05-11T11:19:11+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/md5.h {.push hint[ConvFromXtoItselfNotNeeded]: off.} - {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + type mbedtls_md5_context* {.bycopy.} = object private_total*: array[2, uint32] diff --git a/webrtc/mbedtls/memory_buffer_alloc.nim b/webrtc/mbedtls/memory_buffer_alloc.nim index b1ca866..5ef0373 100644 --- a/webrtc/mbedtls/memory_buffer_alloc.nim +++ b/webrtc/mbedtls/memory_buffer_alloc.nim @@ -1,27 +1,11 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# -import "build_info" -import "mbedtls_config" -import "config_psa" -import "check_config" {.compile: "./mbedtls/library/memory_buffer_alloc.c".} -# Generated @ 2023-05-11T11:19:11+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/memory_buffer_alloc.h {.push hint[ConvFromXtoItselfNotNeeded]: off.} - {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + const MBEDTLS_MEMORY_ALIGN_MULTIPLE* = 4 MBEDTLS_MEMORY_VERIFY_NONE* = 0 diff --git a/webrtc/mbedtls/net_sockets.nim b/webrtc/mbedtls/net_sockets.nim index 588e55c..38dcc7d 100644 --- a/webrtc/mbedtls/net_sockets.nim +++ b/webrtc/mbedtls/net_sockets.nim @@ -1,57 +1,11 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# -import "private_access" -import "build_info" -import "mbedtls_config" -import "config_psa" -import "check_config" -import "ssl" -import "platform_util" -import "platform_time" -import "bignum" -import "ecp" -import "ssl_ciphersuites" -import "pk" -import "md" -import "rsa" -import "ecdsa" -import "cipher" -import "x509_crt" -import "x509" -import "asn1" -import "x509_crl" -import "dhm" -import "ecdh" -import "md5" -import "ripemd160" -import "sha1" -import "sha256" -import "sha512" -import "cmac" -import "gcm" -import "ccm" -import "chachapoly" -import "poly1305" -import "chacha20" -import "ecjpake" {.compile: "./mbedtls/library/net_sockets.c".} -# Generated @ 2023-05-11T11:19:11+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/net_sockets.h {.push hint[ConvFromXtoItselfNotNeeded]: off.} - {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + const MBEDTLS_ERR_NET_SOCKET_FAILED* = -0x00000042 MBEDTLS_ERR_NET_CONNECT_FAILED* = -0x00000044 diff --git a/webrtc/mbedtls/nist_kw.nim b/webrtc/mbedtls/nist_kw.nim index f610f92..b35c31a 100644 --- a/webrtc/mbedtls/nist_kw.nim +++ b/webrtc/mbedtls/nist_kw.nim @@ -1,73 +1,14 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# -import "private_access" -import "build_info" -import "mbedtls_config" -import "config_psa" -import "check_config" import "cipher" -import "platform_util" -import "platform_time" -# Generated @ 2023-05-11T11:19:11+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/nist_kw.h +import "utils" {.push hint[ConvFromXtoItselfNotNeeded]: off.} -import macros - -macro defineEnum(typ: untyped): untyped = - result = newNimNode(nnkStmtList) - - # Enum mapped to distinct cint - result.add quote do: - type `typ`* = distinct cint - - for i in ["+", "-", "*", "div", "mod", "shl", "shr", "or", "and", "xor", "<", "<=", "==", ">", ">="]: - let - ni = newIdentNode(i) - typout = if i[0] in "<=>": newIdentNode("bool") else: typ # comparisons return bool - if i[0] == '>': # cannot borrow `>` and `>=` from templates - let - nopp = if i.len == 2: newIdentNode("<=") else: newIdentNode("<") - result.add quote do: - proc `ni`*(x: `typ`, y: cint): `typout` = `nopp`(y, x) - proc `ni`*(x: cint, y: `typ`): `typout` = `nopp`(y, x) - proc `ni`*(x, y: `typ`): `typout` = `nopp`(y, x) - else: - result.add quote do: - proc `ni`*(x: `typ`, y: cint): `typout` {.borrow.} - proc `ni`*(x: cint, y: `typ`): `typout` {.borrow.} - proc `ni`*(x, y: `typ`): `typout` {.borrow.} - result.add quote do: - proc `ni`*(x: `typ`, y: int): `typout` = `ni`(x, y.cint) - proc `ni`*(x: int, y: `typ`): `typout` = `ni`(x.cint, y) - - let - divop = newIdentNode("/") # `/`() - dlrop = newIdentNode("$") # `$`() - notop = newIdentNode("not") # `not`() - result.add quote do: - proc `divop`*(x, y: `typ`): `typ` = `typ`((x.float / y.float).cint) - proc `divop`*(x: `typ`, y: cint): `typ` = `divop`(x, `typ`(y)) - proc `divop`*(x: cint, y: `typ`): `typ` = `divop`(`typ`(x), y) - proc `divop`*(x: `typ`, y: int): `typ` = `divop`(x, y.cint) - proc `divop`*(x: int, y: `typ`): `typ` = `divop`(x.cint, y) - - proc `dlrop`*(x: `typ`): string {.borrow.} - proc `notop`*(x: `typ`): `typ` {.borrow.} - {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + defineEnum(mbedtls_nist_kw_mode_t) + const MBEDTLS_KW_MODE_KW* = (0).mbedtls_nist_kw_mode_t MBEDTLS_KW_MODE_KWP* = (1).mbedtls_nist_kw_mode_t diff --git a/webrtc/mbedtls/oid.nim b/webrtc/mbedtls/oid.nim index de7cc44..39ae8e3 100644 --- a/webrtc/mbedtls/oid.nim +++ b/webrtc/mbedtls/oid.nim @@ -1,20 +1,8 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# import "asn1" import "pk" import "md" import "ecp" import "cipher" -# Generated @ 2023-05-11T11:19:12+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/oid.h # const 'MBEDTLS_OID_RSA_COMPANY' has unsupported value 'MBEDTLS_OID_ISO_MEMBER_BODIES MBEDTLS_OID_COUNTRY_US MBEDTLS_OID_ORG_RSA_DATA_SECURITY' # const 'MBEDTLS_OID_ANSI_X9_62' has unsupported value 'MBEDTLS_OID_ISO_MEMBER_BODIES MBEDTLS_OID_COUNTRY_US MBEDTLS_OID_ORG_ANSI_X9_62' @@ -167,12 +155,13 @@ import "cipher" # const 'MBEDTLS_OID_ECDSA_SHA256' has unsupported value 'MBEDTLS_OID_ANSI_X9_62_SIG_SHA2 "\x02"' # const 'MBEDTLS_OID_ECDSA_SHA384' has unsupported value 'MBEDTLS_OID_ANSI_X9_62_SIG_SHA2 "\x03"' # const 'MBEDTLS_OID_ECDSA_SHA512' has unsupported value 'MBEDTLS_OID_ANSI_X9_62_SIG_SHA2 "\x04"' -{.push hint[ConvFromXtoItselfNotNeeded]: off.} +{.push hint[ConvFromXtoItselfNotNeeded]: off.} {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + const MBEDTLS_ERR_OID_NOT_FOUND* = -0x0000002E MBEDTLS_ERR_OID_BUF_TOO_SMALL* = -0x0000000B diff --git a/webrtc/mbedtls/pem.nim b/webrtc/mbedtls/pem.nim index f927b76..8654fb0 100644 --- a/webrtc/mbedtls/pem.nim +++ b/webrtc/mbedtls/pem.nim @@ -1,28 +1,17 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# import "aes" import "base64" import "des" -import "constant_time" + {.compile: "./mbedtls/library/pem.c".} -# Generated @ 2023-05-11T11:19:12+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/pem.h # proc 'mbedtls_pem_get_buffer' skipped - static inline procs cannot work with '--noHeader | -H' -{.push hint[ConvFromXtoItselfNotNeeded]: off.} +{.push hint[ConvFromXtoItselfNotNeeded]: off.} {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + const MBEDTLS_ERR_PEM_NO_HEADER_FOOTER_PRESENT* = -0x00001080 MBEDTLS_ERR_PEM_INVALID_DATA* = -0x00001100 diff --git a/webrtc/mbedtls/pk.nim b/webrtc/mbedtls/pk.nim index fe8e9e4..2a33ec4 100644 --- a/webrtc/mbedtls/pk.nim +++ b/webrtc/mbedtls/pk.nim @@ -1,83 +1,29 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# import "pem" import "md" -import "platform_time" -import "rsa" -import "ecp" -import "ecdh" import "ecdsa" import "psa_util" import "psa/crypto" +import "utils" + {.compile: "./mbedtls/library/pk_wrap.c".} {.compile: "./mbedtls/library/pk.c".} {.compile: "./mbedtls/library/pkparse.c".} {.compile: "./mbedtls/library/pkwrite.c".} -# Generated @ 2023-05-11T11:19:12+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/pk.h # const 'MBEDTLS_PK_SIGNATURE_MAX_SIZE' has unsupported value 'MBEDTLS_MPI_MAX_SIZE' # proc 'mbedtls_pk_get_len' skipped - static inline procs cannot work with '--noHeader | -H' # proc 'mbedtls_pk_rsa' skipped - static inline procs cannot work with '--noHeader | -H' # proc 'mbedtls_pk_ec' skipped - static inline procs cannot work with '--noHeader | -H' + {.push hint[ConvFromXtoItselfNotNeeded]: off.} -import macros - -macro defineEnum(typ: untyped): untyped = - result = newNimNode(nnkStmtList) - - # Enum mapped to distinct cint - result.add quote do: - type `typ`* = distinct cint - - for i in ["+", "-", "*", "div", "mod", "shl", "shr", "or", "and", "xor", "<", "<=", "==", ">", ">="]: - let - ni = newIdentNode(i) - typout = if i[0] in "<=>": newIdentNode("bool") else: typ # comparisons return bool - if i[0] == '>': # cannot borrow `>` and `>=` from templates - let - nopp = if i.len == 2: newIdentNode("<=") else: newIdentNode("<") - result.add quote do: - proc `ni`*(x: `typ`, y: cint): `typout` = `nopp`(y, x) - proc `ni`*(x: cint, y: `typ`): `typout` = `nopp`(y, x) - proc `ni`*(x, y: `typ`): `typout` = `nopp`(y, x) - else: - result.add quote do: - proc `ni`*(x: `typ`, y: cint): `typout` {.borrow.} - proc `ni`*(x: cint, y: `typ`): `typout` {.borrow.} - proc `ni`*(x, y: `typ`): `typout` {.borrow.} - result.add quote do: - proc `ni`*(x: `typ`, y: int): `typout` = `ni`(x, y.cint) - proc `ni`*(x: int, y: `typ`): `typout` = `ni`(x.cint, y) - - let - divop = newIdentNode("/") # `/`() - dlrop = newIdentNode("$") # `$`() - notop = newIdentNode("not") # `not`() - result.add quote do: - proc `divop`*(x, y: `typ`): `typ` = `typ`((x.float / y.float).cint) - proc `divop`*(x: `typ`, y: cint): `typ` = `divop`(x, `typ`(y)) - proc `divop`*(x: cint, y: `typ`): `typ` = `divop`(`typ`(x), y) - proc `divop`*(x: `typ`, y: int): `typ` = `divop`(x, y.cint) - proc `divop`*(x: int, y: `typ`): `typ` = `divop`(x.cint, y) - - proc `dlrop`*(x: `typ`): string {.borrow.} - proc `notop`*(x: `typ`): `typ` {.borrow.} - {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + defineEnum(mbedtls_pk_type_t) defineEnum(mbedtls_pk_debug_type) + const MBEDTLS_ERR_PK_ALLOC_FAILED* = -0x00003F80 MBEDTLS_ERR_PK_TYPE_MISMATCH* = -0x00003F00 diff --git a/webrtc/mbedtls/pkcs12.nim b/webrtc/mbedtls/pkcs12.nim index b082ba0..e3c2d54 100644 --- a/webrtc/mbedtls/pkcs12.nim +++ b/webrtc/mbedtls/pkcs12.nim @@ -1,29 +1,18 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# import "md" import "platform_time" import "cipher" import "asn1" import "ctr_drbg" import "hash_info" + {.compile: "./mbedtls/library/pkcs12.c".} -# Generated @ 2023-05-11T11:19:12+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/pkcs12.h {.push hint[ConvFromXtoItselfNotNeeded]: off.} - {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + const MBEDTLS_ERR_PKCS12_BAD_INPUT_DATA* = -0x00001F80 MBEDTLS_ERR_PKCS12_FEATURE_UNAVAILABLE* = -0x00001F00 diff --git a/webrtc/mbedtls/pkcs5.nim b/webrtc/mbedtls/pkcs5.nim index 275f8e3..36986c4 100644 --- a/webrtc/mbedtls/pkcs5.nim +++ b/webrtc/mbedtls/pkcs5.nim @@ -1,30 +1,17 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# import "asn1" -import "platform_time" import "md" import "cipher" import "ctr_drbg" import "rsa" -import "hash_info" + {.compile: "./mbedtls/library/pkcs5.c".} -# Generated @ 2023-05-11T11:19:12+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/pkcs5.h {.push hint[ConvFromXtoItselfNotNeeded]: off.} - {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + const MBEDTLS_ERR_PKCS5_BAD_INPUT_DATA* = -0x00002F80 MBEDTLS_ERR_PKCS5_INVALID_FORMAT* = -0x00002F00 diff --git a/webrtc/mbedtls/pkcs7.nim b/webrtc/mbedtls/pkcs7.nim index 7bad6b6..217b1f2 100644 --- a/webrtc/mbedtls/pkcs7.nim +++ b/webrtc/mbedtls/pkcs7.nim @@ -1,76 +1,19 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# import "asn1" -import "platform_time" import "x509" -import "pk" -import "md" -import "rsa" -import "ecp" -import "ecdsa" import "x509_crt" import "x509_crl" +import "utils" + {.compile: "./mbedtls/library/pkcs7.c".} -# Generated @ 2023-05-11T11:19:12+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/pkcs7.h {.push hint[ConvFromXtoItselfNotNeeded]: off.} -import macros - -macro defineEnum(typ: untyped): untyped = - result = newNimNode(nnkStmtList) - - # Enum mapped to distinct cint - result.add quote do: - type `typ`* = distinct cint - - for i in ["+", "-", "*", "div", "mod", "shl", "shr", "or", "and", "xor", "<", "<=", "==", ">", ">="]: - let - ni = newIdentNode(i) - typout = if i[0] in "<=>": newIdentNode("bool") else: typ # comparisons return bool - if i[0] == '>': # cannot borrow `>` and `>=` from templates - let - nopp = if i.len == 2: newIdentNode("<=") else: newIdentNode("<") - result.add quote do: - proc `ni`*(x: `typ`, y: cint): `typout` = `nopp`(y, x) - proc `ni`*(x: cint, y: `typ`): `typout` = `nopp`(y, x) - proc `ni`*(x, y: `typ`): `typout` = `nopp`(y, x) - else: - result.add quote do: - proc `ni`*(x: `typ`, y: cint): `typout` {.borrow.} - proc `ni`*(x: cint, y: `typ`): `typout` {.borrow.} - proc `ni`*(x, y: `typ`): `typout` {.borrow.} - result.add quote do: - proc `ni`*(x: `typ`, y: int): `typout` = `ni`(x, y.cint) - proc `ni`*(x: int, y: `typ`): `typout` = `ni`(x.cint, y) - - let - divop = newIdentNode("/") # `/`() - dlrop = newIdentNode("$") # `$`() - notop = newIdentNode("not") # `not`() - result.add quote do: - proc `divop`*(x, y: `typ`): `typ` = `typ`((x.float / y.float).cint) - proc `divop`*(x: `typ`, y: cint): `typ` = `divop`(x, `typ`(y)) - proc `divop`*(x: cint, y: `typ`): `typ` = `divop`(`typ`(x), y) - proc `divop`*(x: `typ`, y: int): `typ` = `divop`(x, y.cint) - proc `divop`*(x: int, y: `typ`): `typ` = `divop`(x.cint, y) - - proc `dlrop`*(x: `typ`): string {.borrow.} - proc `notop`*(x: `typ`): `typ` {.borrow.} - {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + defineEnum(mbedtls_pkcs7_type) + const MBEDTLS_ERR_PKCS7_INVALID_FORMAT* = -0x00005300 MBEDTLS_ERR_PKCS7_FEATURE_UNAVAILABLE* = -0x00005380 diff --git a/webrtc/mbedtls/platform.nim b/webrtc/mbedtls/platform.nim index c28a78d..7bc2b60 100644 --- a/webrtc/mbedtls/platform.nim +++ b/webrtc/mbedtls/platform.nim @@ -1,22 +1,6 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# -import "private_access" -import "build_info" -import "mbedtls_config" -import "config_psa" -import "check_config" import "platform_time" + {.compile: "./mbedtls/library/platform.c".} -# Generated @ 2023-05-11T11:19:12+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/platform.h # const 'MBEDTLS_PLATFORM_STD_SNPRINTF' has unsupported value 'snprintf' # const 'MBEDTLS_PLATFORM_STD_VSNPRINTF' has unsupported value 'vsnprintf' @@ -41,12 +25,13 @@ import "platform_time" # const 'mbedtls_exit' has unsupported value 'exit' # const 'MBEDTLS_EXIT_SUCCESS' has unsupported value 'MBEDTLS_PLATFORM_STD_EXIT_SUCCESS' # const 'MBEDTLS_EXIT_FAILURE' has unsupported value 'MBEDTLS_PLATFORM_STD_EXIT_FAILURE' -{.push hint[ConvFromXtoItselfNotNeeded]: off.} +{.push hint[ConvFromXtoItselfNotNeeded]: off.} {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + const MBEDTLS_PLATFORM_STD_NV_SEED_FILE* = "seedfile" type diff --git a/webrtc/mbedtls/platform_time.nim b/webrtc/mbedtls/platform_time.nim index db439b7..dff2cec 100644 --- a/webrtc/mbedtls/platform_time.nim +++ b/webrtc/mbedtls/platform_time.nim @@ -1,21 +1,5 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# -# import "build_info" -# import "mbedtls_config" -# import "config_psa" -# import "check_config" {.used.} {.compile: "./mbedtls/library/platform_util.c".} -# Generated @ 2023-05-11T11:19:12+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/platform_time.h # const 'mbedtls_time' has unsupported value 'time' {.push hint[ConvFromXtoItselfNotNeeded]: off.} @@ -23,10 +7,10 @@ import std/time_t as std_time_t type time_t* = std_time_t.Time - {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + type mbedtls_time_t* = time_t mbedtls_ms_time_t* = int64 diff --git a/webrtc/mbedtls/platform_util.nim b/webrtc/mbedtls/platform_util.nim index b79f2a4..354694b 100644 --- a/webrtc/mbedtls/platform_util.nim +++ b/webrtc/mbedtls/platform_util.nim @@ -1,31 +1,16 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# -type tm {.importc: "struct tm", header: "".} = object -# import "build_info" -# import "mbedtls_config" -# import "config_psa" -# import "check_config" import "platform_time" -# {.compile: "./mbedtls/library/platform_util.c".} -# Generated @ 2023-05-11T11:19:12+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/platform_util.h # const 'MBEDTLS_CHECK_RETURN' has unsupported value '__attribute__((__warn_unused_result__))' # const 'MBEDTLS_CHECK_RETURN_CRITICAL' has unsupported value 'MBEDTLS_CHECK_RETURN' -{.push hint[ConvFromXtoItselfNotNeeded]: off.} +{.push hint[ConvFromXtoItselfNotNeeded]: off.} {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + +type tm {.importc: "struct tm", header: "".} = object + proc mbedtls_platform_zeroize*(buf: pointer; len: uint) {.importc, cdecl.} proc mbedtls_platform_gmtime_r*(tt: ptr mbedtls_time_t; tm_buf: ptr tm): ptr tm {. importc, cdecl.} diff --git a/webrtc/mbedtls/poly1305.nim b/webrtc/mbedtls/poly1305.nim index 98c5188..e3a35ec 100644 --- a/webrtc/mbedtls/poly1305.nim +++ b/webrtc/mbedtls/poly1305.nim @@ -1,24 +1,13 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# import "md" + {.compile: "./mbedtls/library/poly1305.c".} -# Generated @ 2023-05-11T11:19:12+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/poly1305.h {.push hint[ConvFromXtoItselfNotNeeded]: off.} - {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + const MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA* = -0x00000057 type diff --git a/webrtc/mbedtls/private_access.nim b/webrtc/mbedtls/private_access.nim deleted file mode 100644 index cfdc0e1..0000000 --- a/webrtc/mbedtls/private_access.nim +++ /dev/null @@ -1,20 +0,0 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# -# Generated @ 2023-05-11T11:19:13+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/private_access.h - -{.push hint[ConvFromXtoItselfNotNeeded]: off.} - - -{.experimental: "codeReordering".} -{.passc: "-I./mbedtls/include".} -{.passc: "-I./mbedtls/library".} -{.pop.} diff --git a/webrtc/mbedtls/psa/crypto.nim b/webrtc/mbedtls/psa/crypto.nim index 4ab1c00..39ba003 100644 --- a/webrtc/mbedtls/psa/crypto.nim +++ b/webrtc/mbedtls/psa/crypto.nim @@ -1,30 +1,11 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# import "crypto_types" -import "crypto_values" -import "crypto_sizes" import "crypto_struct" -import "crypto_driver_contexts_primitives" -import "crypto_driver_common" -import "crypto_sizes" -import "crypto_builtin_primitives" -import "crypto_driver_contexts_composites" -import "crypto_builtin_composites" -import "crypto_driver_contexts_key_derivation" import "../pk" import "../ecp" -import "../rsa" import "../ecdh" import "../cmac" -import "../cipher" -import "../ctr_drbg" +import "../utils" + {.compile: "./mbedtls/library/psa_crypto.c".} {.compile: "./mbedtls/library/psa_crypto_hash.c".} {.compile: "./mbedtls/library/psa_crypto_slot_management.c".} @@ -37,65 +18,22 @@ import "../ctr_drbg" {.compile: "./mbedtls/library/psa_crypto_ecp.c".} {.compile: "./mbedtls/library/psa_crypto_aead.c".} {.compile: "./mbedtls/library/psa_crypto_cipher.c".} -# Generated @ 2023-05-12T13:12:42+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/psa/crypto.h {.push hint[ConvFromXtoItselfNotNeeded]: off.} -import macros - -macro defineEnum(typ: untyped): untyped = - result = newNimNode(nnkStmtList) - - # Enum mapped to distinct cint - result.add quote do: - type `typ`* = distinct cint - - for i in ["+", "-", "*", "div", "mod", "shl", "shr", "or", "and", "xor", "<", "<=", "==", ">", ">="]: - let - ni = newIdentNode(i) - typout = if i[0] in "<=>": newIdentNode("bool") else: typ # comparisons return bool - if i[0] == '>': # cannot borrow `>` and `>=` from templates - let - nopp = if i.len == 2: newIdentNode("<=") else: newIdentNode("<") - result.add quote do: - proc `ni`*(x: `typ`, y: cint): `typout` = `nopp`(y, x) - proc `ni`*(x: cint, y: `typ`): `typout` = `nopp`(y, x) - proc `ni`*(x, y: `typ`): `typout` = `nopp`(y, x) - else: - result.add quote do: - proc `ni`*(x: `typ`, y: cint): `typout` {.borrow.} - proc `ni`*(x: cint, y: `typ`): `typout` {.borrow.} - proc `ni`*(x, y: `typ`): `typout` {.borrow.} - result.add quote do: - proc `ni`*(x: `typ`, y: int): `typout` = `ni`(x, y.cint) - proc `ni`*(x: int, y: `typ`): `typout` = `ni`(x.cint, y) - - let - divop = newIdentNode("/") # `/`() - dlrop = newIdentNode("$") # `$`() - notop = newIdentNode("not") # `not`() - result.add quote do: - proc `divop`*(x, y: `typ`): `typ` = `typ`((x.float / y.float).cint) - proc `divop`*(x: `typ`, y: cint): `typ` = `divop`(x, `typ`(y)) - proc `divop`*(x: cint, y: `typ`): `typ` = `divop`(`typ`(x), y) - proc `divop`*(x: `typ`, y: int): `typ` = `divop`(x, y.cint) - proc `divop`*(x: int, y: `typ`): `typ` = `divop`(x.cint, y) - - proc `dlrop`*(x: `typ`): string {.borrow.} - proc `notop`*(x: `typ`): `typ` {.borrow.} - {.pragma: impcryptoHdr, header: "/home/lchenut/minnim/webrtc/mbedtls/include/psa/crypto.h".} {.pragma: impcrypto_compatHdr, header: "/home/lchenut/minnim/webrtc/mbedtls/include/psa/crypto_compat.h".} {.pragma: impcrypto_extraHdr, header: "/home/lchenut/minnim/webrtc/mbedtls/include/psa/crypto_extra.h".} + {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + defineEnum(psa_jpake_step) defineEnum(psa_jpake_state) defineEnum(psa_jpake_sequence) defineEnum(psa_crypto_driver_pake_step) + const PSA_CRYPTO_API_VERSION_MAJOR* = 1 PSA_CRYPTO_API_VERSION_MINOR* = 0 diff --git a/webrtc/mbedtls/psa/crypto_builtin_composites.nim b/webrtc/mbedtls/psa/crypto_builtin_composites.nim index 47551bf..16147af 100644 --- a/webrtc/mbedtls/psa/crypto_builtin_composites.nim +++ b/webrtc/mbedtls/psa/crypto_builtin_composites.nim @@ -1,27 +1,17 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# -# Generated @ 2023-05-12T13:12:43+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/psa/crypto_builtin_composites.h - # const 'MBEDTLS_PSA_HMAC_OPERATION_INIT' has unsupported value '{ 0, PSA_HASH_OPERATION_INIT, { 0 } }' # const 'MBEDTLS_PSA_MAC_OPERATION_INIT' has unsupported value '{ 0, { 0 } }' # const 'MBEDTLS_PSA_AEAD_OPERATION_INIT' has unsupported value '{ 0, 0, 0, 0, { 0 } }' # const 'MBEDTLS_PSA_SIGN_HASH_INTERRUPTIBLE_OPERATION_INIT' has unsupported value '{ 0 }' # const 'MBEDTLS_VERIFY_SIGN_HASH_INTERRUPTIBLE_OPERATION_INIT' has unsupported value '{ 0 }' # const 'MBEDTLS_PSA_PAKE_OPERATION_INIT' has unsupported value '{ { 0 } }' + {.push hint[ConvFromXtoItselfNotNeeded]: off.} + {.pragma: impcrypto_builtin_compositesHdr, header: "/home/lchenut/minnim/webrtc/mbedtls/include/psa/crypto_builtin_composites.h".} {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + const MBEDTLS_PSA_BUILTIN_AEAD* = 1 MBEDTLS_PSA_BUILTIN_PAKE* = 1 diff --git a/webrtc/mbedtls/psa/crypto_builtin_primitives.nim b/webrtc/mbedtls/psa/crypto_builtin_primitives.nim index 415add7..155cf05 100644 --- a/webrtc/mbedtls/psa/crypto_builtin_primitives.nim +++ b/webrtc/mbedtls/psa/crypto_builtin_primitives.nim @@ -1,28 +1,12 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# -import "crypto_driver_common" -import "crypto_types" -import "crypto_platform" -import "crypto_values" -import "crypto_sizes" -# Generated @ 2023-05-12T13:12:43+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/psa/crypto_builtin_primitives.h - # const 'MBEDTLS_PSA_HASH_OPERATION_INIT' has unsupported value '{ 0, { 0 } }' # const 'MBEDTLS_PSA_CIPHER_OPERATION_INIT' has unsupported value '{ 0, 0, 0, { 0 } }' + {.push hint[ConvFromXtoItselfNotNeeded]: off.} {.pragma: impcrypto_builtin_primitivesHdr, header: "/home/lchenut/minnim/webrtc/mbedtls/include/psa/crypto_builtin_primitives.h".} {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + const MBEDTLS_PSA_BUILTIN_CIPHER* = 1 {.pop.} diff --git a/webrtc/mbedtls/psa/crypto_compat.nim b/webrtc/mbedtls/psa/crypto_compat.nim deleted file mode 100644 index 7bbb30c..0000000 --- a/webrtc/mbedtls/psa/crypto_compat.nim +++ /dev/null @@ -1,20 +0,0 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# -# Generated @ 2023-05-12T13:12:43+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/psa/crypto_compat.h - -# const 'PSA_KEY_HANDLE_INIT' has unsupported value 'MBEDTLS_SVC_KEY_ID_INIT' -{.push hint[ConvFromXtoItselfNotNeeded]: off.} -{.pragma: impcrypto_compatHdr, header: "/home/lchenut/minnim/webrtc/mbedtls/include/psa/crypto_compat.h".} -{.experimental: "codeReordering".} -{.passc: "-I./mbedtls/include".} -{.passc: "-I./mbedtls/library".} -{.pop.} diff --git a/webrtc/mbedtls/psa/crypto_config.nim b/webrtc/mbedtls/psa/crypto_config.nim index f17e15d..c6641ab 100644 --- a/webrtc/mbedtls/psa/crypto_config.nim +++ b/webrtc/mbedtls/psa/crypto_config.nim @@ -1,24 +1,11 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# -# Generated @ 2023-05-12T13:12:43+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/psa/crypto_config.h - {.push hint[ConvFromXtoItselfNotNeeded]: off.} - {.pragma: impcrypto_configHdr, header: "/home/lchenut/minnim/webrtc/mbedtls/include/psa/crypto_config.h".} {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + const PSA_WANT_ALG_CBC_NO_PADDING* = 1 PSA_WANT_ALG_CBC_PKCS7* = 1 diff --git a/webrtc/mbedtls/psa/crypto_driver_common.nim b/webrtc/mbedtls/psa/crypto_driver_common.nim index 67653f4..638f6cd 100644 --- a/webrtc/mbedtls/psa/crypto_driver_common.nim +++ b/webrtc/mbedtls/psa/crypto_driver_common.nim @@ -1,70 +1,14 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# -import "crypto_types" -import "crypto_platform" -import "crypto_values" -import "crypto_sizes" -# Generated @ 2023-05-12T13:12:43+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/psa/crypto_driver_common.h +import "../utils" {.push hint[ConvFromXtoItselfNotNeeded]: off.} -import macros - -macro defineEnum(typ: untyped): untyped = - result = newNimNode(nnkStmtList) - - # Enum mapped to distinct cint - result.add quote do: - type `typ`* = distinct cint - - for i in ["+", "-", "*", "div", "mod", "shl", "shr", "or", "and", "xor", "<", "<=", "==", ">", ">="]: - let - ni = newIdentNode(i) - typout = if i[0] in "<=>": newIdentNode("bool") else: typ # comparisons return bool - if i[0] == '>': # cannot borrow `>` and `>=` from templates - let - nopp = if i.len == 2: newIdentNode("<=") else: newIdentNode("<") - result.add quote do: - proc `ni`*(x: `typ`, y: cint): `typout` = `nopp`(y, x) - proc `ni`*(x: cint, y: `typ`): `typout` = `nopp`(y, x) - proc `ni`*(x, y: `typ`): `typout` = `nopp`(y, x) - else: - result.add quote do: - proc `ni`*(x: `typ`, y: cint): `typout` {.borrow.} - proc `ni`*(x: cint, y: `typ`): `typout` {.borrow.} - proc `ni`*(x, y: `typ`): `typout` {.borrow.} - result.add quote do: - proc `ni`*(x: `typ`, y: int): `typout` = `ni`(x, y.cint) - proc `ni`*(x: int, y: `typ`): `typout` = `ni`(x.cint, y) - - let - divop = newIdentNode("/") # `/`() - dlrop = newIdentNode("$") # `$`() - notop = newIdentNode("not") # `not`() - result.add quote do: - proc `divop`*(x, y: `typ`): `typ` = `typ`((x.float / y.float).cint) - proc `divop`*(x: `typ`, y: cint): `typ` = `divop`(x, `typ`(y)) - proc `divop`*(x: cint, y: `typ`): `typ` = `divop`(`typ`(x), y) - proc `divop`*(x: `typ`, y: int): `typ` = `divop`(x, y.cint) - proc `divop`*(x: int, y: `typ`): `typ` = `divop`(x.cint, y) - - proc `dlrop`*(x: `typ`): string {.borrow.} - proc `notop`*(x: `typ`): `typ` {.borrow.} - {.pragma: impcrypto_driver_commonHdr, header: "/home/lchenut/minnim/webrtc/mbedtls/include/psa/crypto_driver_common.h".} {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + defineEnum(psa_encrypt_or_decrypt_t) + const PSA_CRYPTO_DRIVER_DECRYPT* = (0).psa_encrypt_or_decrypt_t PSA_CRYPTO_DRIVER_ENCRYPT* = (PSA_CRYPTO_DRIVER_DECRYPT + 1).psa_encrypt_or_decrypt_t diff --git a/webrtc/mbedtls/psa/crypto_driver_contexts_composites.nim b/webrtc/mbedtls/psa/crypto_driver_contexts_composites.nim deleted file mode 100644 index c4d3a20..0000000 --- a/webrtc/mbedtls/psa/crypto_driver_contexts_composites.nim +++ /dev/null @@ -1,27 +0,0 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# -import "crypto_driver_common" -import "crypto_types" -import "crypto_platform" -import "crypto_values" -import "crypto_sizes" -import "crypto_builtin_composites" -# Generated @ 2023-05-12T13:12:43+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/psa/crypto_driver_contexts_composites.h - -{.push hint[ConvFromXtoItselfNotNeeded]: off.} - - -{.pragma: impcrypto_driver_contexts_compositesHdr, header: "/home/lchenut/minnim/webrtc/mbedtls/include/psa/crypto_driver_contexts_composites.h".} -{.experimental: "codeReordering".} -{.passc: "-I./mbedtls/include".} -{.passc: "-I./mbedtls/library".} -{.pop.} diff --git a/webrtc/mbedtls/psa/crypto_driver_contexts_key_derivation.nim b/webrtc/mbedtls/psa/crypto_driver_contexts_key_derivation.nim deleted file mode 100644 index 3e99495..0000000 --- a/webrtc/mbedtls/psa/crypto_driver_contexts_key_derivation.nim +++ /dev/null @@ -1,26 +0,0 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# -import "crypto_driver_common" -import "crypto_types" -import "crypto_platform" -import "crypto_values" -import "crypto_sizes" -# Generated @ 2023-05-12T13:12:43+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/psa/crypto_driver_contexts_key_derivation.h - -{.push hint[ConvFromXtoItselfNotNeeded]: off.} - - -{.pragma: impcrypto_driver_contexts_key_derivationHdr, header: "/home/lchenut/minnim/webrtc/mbedtls/include/psa/crypto_driver_contexts_key_derivation.h".} -{.experimental: "codeReordering".} -{.passc: "-I./mbedtls/include".} -{.passc: "-I./mbedtls/library".} -{.pop.} diff --git a/webrtc/mbedtls/psa/crypto_driver_contexts_primitives.nim b/webrtc/mbedtls/psa/crypto_driver_contexts_primitives.nim deleted file mode 100644 index c015dcd..0000000 --- a/webrtc/mbedtls/psa/crypto_driver_contexts_primitives.nim +++ /dev/null @@ -1,27 +0,0 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# -import "crypto_driver_common" -import "crypto_types" -import "crypto_platform" -import "crypto_values" -import "crypto_sizes" -import "crypto_builtin_primitives" -# Generated @ 2023-05-12T13:12:43+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/psa/crypto_driver_contexts_primitives.h - -{.push hint[ConvFromXtoItselfNotNeeded]: off.} - - -{.pragma: impcrypto_driver_contexts_primitivesHdr, header: "/home/lchenut/minnim/webrtc/mbedtls/include/psa/crypto_driver_contexts_primitives.h".} -{.experimental: "codeReordering".} -{.passc: "-I./mbedtls/include".} -{.passc: "-I./mbedtls/library".} -{.pop.} diff --git a/webrtc/mbedtls/psa/crypto_extra.nim b/webrtc/mbedtls/psa/crypto_extra.nim deleted file mode 100644 index 9168adb..0000000 --- a/webrtc/mbedtls/psa/crypto_extra.nim +++ /dev/null @@ -1,23 +0,0 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# -# Generated @ 2023-05-12T13:12:43+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/psa/crypto_extra.h - -# const 'PSA_ALG_DSA_DETERMINISTIC_FLAG' has unsupported value 'PSA_ALG_ECDSA_DETERMINISTIC_FLAG' -# const 'PSA_PAKE_CIPHER_SUITE_INIT' has unsupported value '{ PSA_ALG_NONE, 0, 0, 0, PSA_ALG_NONE }' -# const 'PSA_PAKE_OPERATION_INIT' has unsupported value '{ 0, PSA_ALG_NONE, 0, PSA_PAKE_OPERATION_STAGE_SETUP, { 0 }, { { 0 } } }' -{.push hint[ConvFromXtoItselfNotNeeded]: off.} -{.pragma: impcrypto_extraHdr, - header: "/home/lchenut/minnim/webrtc/mbedtls/include/psa/crypto_extra.h".} -{.experimental: "codeReordering".} -{.passc: "-I./mbedtls/include".} -{.passc: "-I./mbedtls/library".} -{.pop.} diff --git a/webrtc/mbedtls/psa/crypto_platform.nim b/webrtc/mbedtls/psa/crypto_platform.nim deleted file mode 100644 index b73f92d..0000000 --- a/webrtc/mbedtls/psa/crypto_platform.nim +++ /dev/null @@ -1,22 +0,0 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# -# Generated @ 2023-05-12T13:12:43+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/psa/crypto_platform.h - -{.push hint[ConvFromXtoItselfNotNeeded]: off.} - - -{.pragma: impcrypto_platformHdr, - header: "/home/lchenut/minnim/webrtc/mbedtls/include/psa/crypto_platform.h".} -{.experimental: "codeReordering".} -{.passc: "-I./mbedtls/include".} -{.passc: "-I./mbedtls/library".} -{.pop.} diff --git a/webrtc/mbedtls/psa/crypto_se_driver.nim b/webrtc/mbedtls/psa/crypto_se_driver.nim index d480aaa..995fc6f 100644 --- a/webrtc/mbedtls/psa/crypto_se_driver.nim +++ b/webrtc/mbedtls/psa/crypto_se_driver.nim @@ -1,73 +1,19 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# import "crypto_driver_common" import "crypto_types" -import "crypto_platform" -import "crypto_values" -import "crypto_sizes" +import "../utils" + {.compile: "./mbedtls/library/psa_crypto_se.c".} -# Generated @ 2023-05-12T13:12:44+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/psa/crypto_se_driver.h {.push hint[ConvFromXtoItselfNotNeeded]: off.} -import macros - -macro defineEnum(typ: untyped): untyped = - result = newNimNode(nnkStmtList) - - # Enum mapped to distinct cint - result.add quote do: - type `typ`* = distinct cint - - for i in ["+", "-", "*", "div", "mod", "shl", "shr", "or", "and", "xor", "<", "<=", "==", ">", ">="]: - let - ni = newIdentNode(i) - typout = if i[0] in "<=>": newIdentNode("bool") else: typ # comparisons return bool - if i[0] == '>': # cannot borrow `>` and `>=` from templates - let - nopp = if i.len == 2: newIdentNode("<=") else: newIdentNode("<") - result.add quote do: - proc `ni`*(x: `typ`, y: cint): `typout` = `nopp`(y, x) - proc `ni`*(x: cint, y: `typ`): `typout` = `nopp`(y, x) - proc `ni`*(x, y: `typ`): `typout` = `nopp`(y, x) - else: - result.add quote do: - proc `ni`*(x: `typ`, y: cint): `typout` {.borrow.} - proc `ni`*(x: cint, y: `typ`): `typout` {.borrow.} - proc `ni`*(x, y: `typ`): `typout` {.borrow.} - result.add quote do: - proc `ni`*(x: `typ`, y: int): `typout` = `ni`(x, y.cint) - proc `ni`*(x: int, y: `typ`): `typout` = `ni`(x.cint, y) - - let - divop = newIdentNode("/") # `/`() - dlrop = newIdentNode("$") # `$`() - notop = newIdentNode("not") # `not`() - result.add quote do: - proc `divop`*(x, y: `typ`): `typ` = `typ`((x.float / y.float).cint) - proc `divop`*(x: `typ`, y: cint): `typ` = `divop`(x, `typ`(y)) - proc `divop`*(x: cint, y: `typ`): `typ` = `divop`(`typ`(x), y) - proc `divop`*(x: `typ`, y: int): `typ` = `divop`(x, y.cint) - proc `divop`*(x: int, y: `typ`): `typ` = `divop`(x.cint, y) - - proc `dlrop`*(x: `typ`): string {.borrow.} - proc `notop`*(x: `typ`): `typ` {.borrow.} - {.pragma: impcrypto_se_driverHdr, header: "/home/lchenut/minnim/webrtc/mbedtls/include/psa/crypto_se_driver.h".} {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + defineEnum(psa_key_creation_method_t) + const PSA_KEY_CREATION_IMPORT* = (0).psa_key_creation_method_t PSA_KEY_CREATION_GENERATE* = (PSA_KEY_CREATION_IMPORT + 1).psa_key_creation_method_t diff --git a/webrtc/mbedtls/psa/crypto_sizes.nim b/webrtc/mbedtls/psa/crypto_sizes.nim index f039f20..63fdd09 100644 --- a/webrtc/mbedtls/psa/crypto_sizes.nim +++ b/webrtc/mbedtls/psa/crypto_sizes.nim @@ -1,16 +1,3 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# -# Generated @ 2023-05-12T13:12:44+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/psa/crypto_sizes.h - # const 'PSA_MAC_MAX_SIZE' has unsupported value 'PSA_HASH_MAX_SIZE' # const 'PSA_VENDOR_ECDSA_SIGNATURE_MAX_SIZE' has unsupported value 'PSA_ECDSA_SIGNATURE_SIZE(PSA_VENDOR_ECC_MAX_CURVE_BITS)' # const 'PSA_SIGNATURE_MAX_SIZE' has unsupported value '(PSA_BITS_TO_BYTES(PSA_VENDOR_RSA_MAX_KEY_BITS) > PSA_VENDOR_ECDSA_SIGNATURE_MAX_SIZE ? PSA_BITS_TO_BYTES(PSA_VENDOR_RSA_MAX_KEY_BITS) : PSA_VENDOR_ECDSA_SIGNATURE_MAX_SIZE)' @@ -19,14 +6,15 @@ # const 'PSA_EXPORT_KEY_PAIR_MAX_SIZE' has unsupported value '(PSA_KEY_EXPORT_RSA_KEY_PAIR_MAX_SIZE(PSA_VENDOR_RSA_MAX_KEY_BITS) > PSA_KEY_EXPORT_ECC_KEY_PAIR_MAX_SIZE(PSA_VENDOR_ECC_MAX_CURVE_BITS) ? PSA_KEY_EXPORT_RSA_KEY_PAIR_MAX_SIZE(PSA_VENDOR_RSA_MAX_KEY_BITS) : PSA_KEY_EXPORT_ECC_KEY_PAIR_MAX_SIZE(PSA_VENDOR_ECC_MAX_CURVE_BITS))' # const 'PSA_EXPORT_PUBLIC_KEY_MAX_SIZE' has unsupported value '(PSA_KEY_EXPORT_RSA_PUBLIC_KEY_MAX_SIZE(PSA_VENDOR_RSA_MAX_KEY_BITS) > PSA_KEY_EXPORT_ECC_PUBLIC_KEY_MAX_SIZE(PSA_VENDOR_ECC_MAX_CURVE_BITS) ? PSA_KEY_EXPORT_RSA_PUBLIC_KEY_MAX_SIZE(PSA_VENDOR_RSA_MAX_KEY_BITS) : PSA_KEY_EXPORT_ECC_PUBLIC_KEY_MAX_SIZE(PSA_VENDOR_ECC_MAX_CURVE_BITS))' # const 'PSA_RAW_KEY_AGREEMENT_OUTPUT_MAX_SIZE' has unsupported value '(PSA_BITS_TO_BYTES(PSA_VENDOR_ECC_MAX_CURVE_BITS))' -{.push hint[ConvFromXtoItselfNotNeeded]: off.} +{.push hint[ConvFromXtoItselfNotNeeded]: off.} {.pragma: impcrypto_sizesHdr, header: "/home/lchenut/minnim/webrtc/mbedtls/include/psa/crypto_sizes.h".} {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + const PSA_HASH_MAX_SIZE* = 64 PSA_HMAC_MAX_HASH_BLOCK_SIZE* = 128 diff --git a/webrtc/mbedtls/psa/crypto_struct.nim b/webrtc/mbedtls/psa/crypto_struct.nim index f46b1e9..70ebb39 100644 --- a/webrtc/mbedtls/psa/crypto_struct.nim +++ b/webrtc/mbedtls/psa/crypto_struct.nim @@ -1,26 +1,5 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# -import "crypto_driver_contexts_primitives" -import "crypto_driver_common" import "crypto_types" -import "crypto_platform" -import "crypto_values" -import "crypto_sizes" -import "crypto_builtin_primitives" -import "crypto_driver_contexts_composites" -import "crypto_builtin_composites" -import "crypto_driver_contexts_key_derivation" {.compile: "./mbedtls/library/psa_crypto_client.c".} -# Generated @ 2023-05-12T13:12:44+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/psa/crypto_struct.h # const 'PSA_HASH_OPERATION_INIT' has unsupported value '{ 0, { 0 } }' # const 'PSA_CIPHER_OPERATION_INIT' has unsupported value '{ 0, 0, 0, 0, { 0 } }' @@ -33,14 +12,15 @@ import "crypto_driver_contexts_key_derivation" # const 'PSA_KEY_ATTRIBUTES_INIT' has unsupported value '{ PSA_CORE_KEY_ATTRIBUTES_INIT, NULL, 0 }' # const 'PSA_SIGN_HASH_INTERRUPTIBLE_OPERATION_INIT' has unsupported value '{ 0, { 0 }, 0, 0 }' # const 'PSA_VERIFY_HASH_INTERRUPTIBLE_OPERATION_INIT' has unsupported value '{ 0, { 0 }, 0, 0 }' -{.push hint[ConvFromXtoItselfNotNeeded]: off.} +{.push hint[ConvFromXtoItselfNotNeeded]: off.} {.pragma: impcrypto_structHdr, header: "/home/lchenut/minnim/webrtc/mbedtls/include/psa/crypto_struct.h".} {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + const PSA_MAX_KEY_BITS* = 0x0000FFF8 MBEDTLS_PSA_KA_FLAG_HAS_SLOT_NUMBER* = ( diff --git a/webrtc/mbedtls/psa/crypto_types.nim b/webrtc/mbedtls/psa/crypto_types.nim index 7fdc6ab..a0a2428 100644 --- a/webrtc/mbedtls/psa/crypto_types.nim +++ b/webrtc/mbedtls/psa/crypto_types.nim @@ -1,13 +1,3 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# -import "crypto_platform" import "../md5" import "../ripemd160" import "../sha1" @@ -18,59 +8,17 @@ import "../ccm" import "../gcm" import "../chachapoly" import "../ecjpake" -# Generated @ 2023-05-12T13:12:44+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/psa/crypto_types.h +import "../utils" {.push hint[ConvFromXtoItselfNotNeeded]: off.} -import macros -macro defineEnum(typ: untyped): untyped = - result = newNimNode(nnkStmtList) - - # Enum mapped to distinct cint - result.add quote do: - type `typ`* = distinct cint - - for i in ["+", "-", "*", "div", "mod", "shl", "shr", "or", "and", "xor", "<", "<=", "==", ">", ">="]: - let - ni = newIdentNode(i) - typout = if i[0] in "<=>": newIdentNode("bool") else: typ # comparisons return bool - if i[0] == '>': # cannot borrow `>` and `>=` from templates - let - nopp = if i.len == 2: newIdentNode("<=") else: newIdentNode("<") - result.add quote do: - proc `ni`*(x: `typ`, y: cint): `typout` = `nopp`(y, x) - proc `ni`*(x: cint, y: `typ`): `typout` = `nopp`(y, x) - proc `ni`*(x, y: `typ`): `typout` = `nopp`(y, x) - else: - result.add quote do: - proc `ni`*(x: `typ`, y: cint): `typout` {.borrow.} - proc `ni`*(x: cint, y: `typ`): `typout` {.borrow.} - proc `ni`*(x, y: `typ`): `typout` {.borrow.} - result.add quote do: - proc `ni`*(x: `typ`, y: int): `typout` = `ni`(x, y.cint) - proc `ni`*(x: int, y: `typ`): `typout` = `ni`(x.cint, y) - - let - divop = newIdentNode("/") # `/`() - dlrop = newIdentNode("$") # `$`() - notop = newIdentNode("not") # `not`() - result.add quote do: - proc `divop`*(x, y: `typ`): `typ` = `typ`((x.float / y.float).cint) - proc `divop`*(x: `typ`, y: cint): `typ` = `divop`(x, `typ`(y)) - proc `divop`*(x: cint, y: `typ`): `typ` = `divop`(`typ`(x), y) - proc `divop`*(x: `typ`, y: int): `typ` = `divop`(x, y.cint) - proc `divop`*(x: int, y: `typ`): `typ` = `divop`(x.cint, y) - - proc `dlrop`*(x: `typ`): string {.borrow.} - proc `notop`*(x: `typ`): `typ` {.borrow.} - {.pragma: impcrypto_builtin_key_derivationHdr, header: "/home/lchenut/minnim/webrtc/mbedtls/include/psa/crypto_builtin_key_derivation.h".} {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + defineEnum(psa_tls12_prf_key_derivation_state_t) + const PSA_TLS12_PRF_STATE_INIT* = (0).psa_tls12_prf_key_derivation_state_t PSA_TLS12_PRF_STATE_SEED_SET* = (PSA_TLS12_PRF_STATE_INIT + 1).psa_tls12_prf_key_derivation_state_t diff --git a/webrtc/mbedtls/psa/crypto_values.nim b/webrtc/mbedtls/psa/crypto_values.nim index 171a837..1718ee5 100644 --- a/webrtc/mbedtls/psa/crypto_values.nim +++ b/webrtc/mbedtls/psa/crypto_values.nim @@ -1,16 +1,4 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} import "crypto_types" -# -# Generated @ 2023-05-12T13:12:44+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/psa/crypto_values.h # const 'PSA_ERROR_GENERIC_ERROR' has unsupported value '((psa_status_t)-132)' # const 'PSA_ERROR_NOT_SUPPORTED' has unsupported value '((psa_status_t)-134)' @@ -37,14 +25,15 @@ import "crypto_types" # const 'PSA_ALG_RSA_PKCS1V15_SIGN_RAW' has unsupported value 'PSA_ALG_RSA_PKCS1V15_SIGN_BASE' # const 'PSA_ALG_ECDSA_ANY' has unsupported value 'PSA_ALG_ECDSA_BASE' # const 'PSA_INTERRUPTIBLE_MAX_OPS_UNLIMITED' has unsupported value 'UINT32_MAX' -{.push hint[ConvFromXtoItselfNotNeeded]: off.} +{.push hint[ConvFromXtoItselfNotNeeded]: off.} {.pragma: impcrypto_valuesHdr, header: "/home/lchenut/minnim/webrtc/mbedtls/include/psa/crypto_values.h".} {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + const PSA_SUCCESS* = (cast[psa_status_t](0)) PSA_KEY_TYPE_NONE* = (cast[psa_key_type_t](0x00000000)) diff --git a/webrtc/mbedtls/psa_util.nim b/webrtc/mbedtls/psa_util.nim index fc8d8de..a0340ae 100644 --- a/webrtc/mbedtls/psa_util.nim +++ b/webrtc/mbedtls/psa_util.nim @@ -1,20 +1,9 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# import "ctr_drbg" import "pkcs5" import "pkcs12" +# TODO: Remove pkcs5 and pkcs12, they're not used in this file. import "psa/crypto_types" {.compile: "./mbedtls/library/psa_util.c".} -# Generated @ 2023-05-11T11:19:13+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/psa_util.h # proc 'mbedtls_psa_translate_cipher_type' skipped - static inline procs cannot work with '--noHeader | -H' # proc 'mbedtls_psa_translate_cipher_mode' skipped - static inline procs cannot work with '--noHeader | -H' @@ -24,12 +13,13 @@ import "psa/crypto_types" # const 'MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH' has unsupported value 'PSA_KEY_EXPORT_ECC_PUBLIC_KEY_MAX_SIZE(PSA_VENDOR_ECC_MAX_CURVE_BITS)' # const 'MBEDTLS_PSA_MAX_EC_KEY_PAIR_LENGTH' has unsupported value 'PSA_KEY_EXPORT_ECC_KEY_PAIR_MAX_SIZE(PSA_VENDOR_ECC_MAX_CURVE_BITS)' # const 'MBEDTLS_PSA_RANDOM_STATE' has unsupported value 'mbedtls_psa_random_state' -{.push hint[ConvFromXtoItselfNotNeeded]: off.} +{.push hint[ConvFromXtoItselfNotNeeded]: off.} {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + type mbedtls_f_rng_t* = proc (p_rng: pointer; output: ptr byte; output_size: uint): cint {. cdecl.} diff --git a/webrtc/mbedtls/ripemd160.nim b/webrtc/mbedtls/ripemd160.nim index 78f3885..85a0db8 100644 --- a/webrtc/mbedtls/ripemd160.nim +++ b/webrtc/mbedtls/ripemd160.nim @@ -1,24 +1,13 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# import "platform_time" + {.compile: "./mbedtls/library/ripemd160.c".} -# Generated @ 2023-05-11T11:19:13+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/ripemd160.h {.push hint[ConvFromXtoItselfNotNeeded]: off.} - {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + type mbedtls_ripemd160_context* {.bycopy.} = object private_total*: array[2, uint32] diff --git a/webrtc/mbedtls/rsa.nim b/webrtc/mbedtls/rsa.nim index b6f77bd..43c2c1a 100644 --- a/webrtc/mbedtls/rsa.nim +++ b/webrtc/mbedtls/rsa.nim @@ -1,29 +1,17 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# import "hash_info" import "bignum" import "md" -import "platform_time" + {.compile: "./mbedtls/library/oid.c"} {.compile: "./mbedtls/library/rsa.c"} {.compile: "./mbedtls/library/rsa_alt_helpers.c"} -# Generated @ 2023-05-11T11:19:13+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/rsa.h {.push hint[ConvFromXtoItselfNotNeeded]: off.} - {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + const MBEDTLS_ERR_RSA_BAD_INPUT_DATA* = -0x00004080 MBEDTLS_ERR_RSA_INVALID_PADDING* = -0x00004100 diff --git a/webrtc/mbedtls/sha1.nim b/webrtc/mbedtls/sha1.nim index a1b1e2e..087d7fc 100644 --- a/webrtc/mbedtls/sha1.nim +++ b/webrtc/mbedtls/sha1.nim @@ -1,24 +1,13 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# import "platform_time" + {.compile: "./mbedtls/library/sha1.c".} -# Generated @ 2023-05-11T11:19:13+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/sha1.h {.push hint[ConvFromXtoItselfNotNeeded]: off.} - {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + const MBEDTLS_ERR_SHA1_BAD_INPUT_DATA* = -0x00000073 type diff --git a/webrtc/mbedtls/sha256.nim b/webrtc/mbedtls/sha256.nim index edfe16c..9f845c0 100644 --- a/webrtc/mbedtls/sha256.nim +++ b/webrtc/mbedtls/sha256.nim @@ -1,24 +1,13 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# import "platform_time" + {.compile: "./mbedtls/library/sha256.c".} -# Generated @ 2023-05-11T11:19:13+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/sha256.h {.push hint[ConvFromXtoItselfNotNeeded]: off.} - {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + const MBEDTLS_ERR_SHA256_BAD_INPUT_DATA* = -0x00000074 type diff --git a/webrtc/mbedtls/sha512.nim b/webrtc/mbedtls/sha512.nim index 90a3939..b675262 100644 --- a/webrtc/mbedtls/sha512.nim +++ b/webrtc/mbedtls/sha512.nim @@ -1,24 +1,13 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# import "platform_time" + {.compile: "./mbedtls/library/sha512.c".} -# Generated @ 2023-05-11T11:19:13+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/sha512.h {.push hint[ConvFromXtoItselfNotNeeded]: off.} - {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + const MBEDTLS_ERR_SHA512_BAD_INPUT_DATA* = -0x00000075 type diff --git a/webrtc/mbedtls/ssl.nim b/webrtc/mbedtls/ssl.nim index 5591ee6..4f7049e 100644 --- a/webrtc/mbedtls/ssl.nim +++ b/webrtc/mbedtls/ssl.nim @@ -1,52 +1,20 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# -import "platform_util" -import "build_info" -import "mbedtls_config" -import "config_psa" -import "check_config" +import "ssl_ciphersuites" import "platform_time" -import "private_access" import "bignum" import "ecp" -import "ssl_ciphersuites" import "pk" -import "md" -import "rsa" -import "ecdsa" -import "cipher" import "x509_crt" -import "x509" -import "asn1" import "x509_crl" import "dhm" -import "ecdh" -import "md5" -import "ripemd160" -import "sha1" -import "sha256" -import "sha512" -import "cmac" -import "gcm" -import "ccm" -import "chachapoly" -import "poly1305" -import "chacha20" -import "ecjpake" -{.compile: "./mbedtls/library/ssl_ciphersuites.c".} +import "utils" + +{.compile: "./mbedtls/library/debug.c".} +{.compile: "./mbedtls/library/ssl_debug_helpers_generated.c".} {.compile: "./mbedtls/library/ssl_msg.c".} {.compile: "./mbedtls/library/ssl_tls12_server.c".} {.compile: "./mbedtls/library/ssl_tls.c".} -# Generated @ 2023-05-11T11:19:14+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/ssl.h +{.compile: "./mbedtls/library/ssl_client.c".} +{.compile: "./mbedtls/library/ssl_tls12_client.c".} # const 'MBEDTLS_PREMASTER_SIZE' has unsupported value 'sizeof(union mbedtls_ssl_premaster_secret)' # const 'MBEDTLS_TLS1_3_MD_MAX_SIZE' has unsupported value 'PSA_HASH_MAX_SIZE' @@ -65,58 +33,18 @@ import "ecjpake" # proc 'mbedtls_ssl_conf_min_tls_version' skipped - static inline procs cannot work with '--noHeader | -H' # proc 'mbedtls_ssl_get_version_number' skipped - static inline procs cannot work with '--noHeader | -H' # proc 'mbedtls_ssl_is_handshake_over' skipped - static inline procs cannot work with '--noHeader | -H' + {.push hint[ConvFromXtoItselfNotNeeded]: off.} -import macros - -macro defineEnum(typ: untyped): untyped = - result = newNimNode(nnkStmtList) - - # Enum mapped to distinct cint - result.add quote do: - type `typ`* = distinct cint - - for i in ["+", "-", "*", "div", "mod", "shl", "shr", "or", "and", "xor", "<", "<=", "==", ">", ">="]: - let - ni = newIdentNode(i) - typout = if i[0] in "<=>": newIdentNode("bool") else: typ # comparisons return bool - if i[0] == '>': # cannot borrow `>` and `>=` from templates - let - nopp = if i.len == 2: newIdentNode("<=") else: newIdentNode("<") - result.add quote do: - proc `ni`*(x: `typ`, y: cint): `typout` = `nopp`(y, x) - proc `ni`*(x: cint, y: `typ`): `typout` = `nopp`(y, x) - proc `ni`*(x, y: `typ`): `typout` = `nopp`(y, x) - else: - result.add quote do: - proc `ni`*(x: `typ`, y: cint): `typout` {.borrow.} - proc `ni`*(x: cint, y: `typ`): `typout` {.borrow.} - proc `ni`*(x, y: `typ`): `typout` {.borrow.} - result.add quote do: - proc `ni`*(x: `typ`, y: int): `typout` = `ni`(x, y.cint) - proc `ni`*(x: int, y: `typ`): `typout` = `ni`(x.cint, y) - - let - divop = newIdentNode("/") # `/`() - dlrop = newIdentNode("$") # `$`() - notop = newIdentNode("not") # `not`() - result.add quote do: - proc `divop`*(x, y: `typ`): `typ` = `typ`((x.float / y.float).cint) - proc `divop`*(x: `typ`, y: cint): `typ` = `divop`(x, `typ`(y)) - proc `divop`*(x: cint, y: `typ`): `typ` = `divop`(`typ`(x), y) - proc `divop`*(x: `typ`, y: int): `typ` = `divop`(x, y.cint) - proc `divop`*(x: int, y: `typ`): `typ` = `divop`(x.cint, y) - - proc `dlrop`*(x: `typ`): string {.borrow.} - proc `notop`*(x: `typ`): `typ` {.borrow.} - {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + defineEnum(mbedtls_ssl_states) defineEnum(mbedtls_ssl_protocol_version) defineEnum(mbedtls_tls_prf_types) defineEnum(mbedtls_ssl_key_export_type) + const MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS* = -0x00007000 MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE* = -0x00007080 diff --git a/webrtc/mbedtls/ssl_cache.nim b/webrtc/mbedtls/ssl_cache.nim index 32d1dfe..b073669 100644 --- a/webrtc/mbedtls/ssl_cache.nim +++ b/webrtc/mbedtls/ssl_cache.nim @@ -1,57 +1,14 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# -import "private_access" -import "build_info" -import "mbedtls_config" -import "config_psa" -import "check_config" import "ssl" -import "platform_util" import "platform_time" -import "bignum" -import "ecp" -import "ssl_ciphersuites" -import "pk" -import "md" -import "rsa" -import "ecdsa" -import "cipher" -import "x509_crt" -import "x509" -import "asn1" -import "x509_crl" -import "dhm" -import "ecdh" -import "md5" -import "ripemd160" -import "sha1" -import "sha256" -import "sha512" -import "cmac" -import "gcm" -import "ccm" -import "chachapoly" -import "poly1305" -import "chacha20" -import "ecjpake" + {.compile: "./mbedtls/library/ssl_cache.c".} -# Generated @ 2023-05-11T11:19:14+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/ssl_cache.h {.push hint[ConvFromXtoItselfNotNeeded]: off.} - {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + const MBEDTLS_SSL_CACHE_DEFAULT_TIMEOUT* = 86400 MBEDTLS_SSL_CACHE_DEFAULT_MAX_ENTRIES* = 50 diff --git a/webrtc/mbedtls/ssl_ciphersuites.nim b/webrtc/mbedtls/ssl_ciphersuites.nim index 8c7da00..5517a46 100644 --- a/webrtc/mbedtls/ssl_ciphersuites.nim +++ b/webrtc/mbedtls/ssl_ciphersuites.nim @@ -1,30 +1,7 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# -import "private_access" -import "build_info" -import "mbedtls_config" -import "config_psa" -import "check_config" import "pk" -import "md" -import "platform_util" -import "platform_time" -import "rsa" -import "bignum" -import "ecp" -import "ecdsa" -import "cipher" +import "utils" + {.compile: "./mbedtls/library/ssl_ciphersuites.c".} -# Generated @ 2023-05-11T11:19:14+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/ssl_ciphersuites.h # proc 'mbedtls_ssl_ciphersuite_get_name' skipped - static inline procs cannot work with '--noHeader | -H' # proc 'mbedtls_ssl_ciphersuite_has_pfs' skipped - static inline procs cannot work with '--noHeader | -H' @@ -35,55 +12,15 @@ import "cipher" # proc 'mbedtls_ssl_ciphersuite_uses_dhe' skipped - static inline procs cannot work with '--noHeader | -H' # proc 'mbedtls_ssl_ciphersuite_uses_ecdhe' skipped - static inline procs cannot work with '--noHeader | -H' # proc 'mbedtls_ssl_ciphersuite_uses_server_signature' skipped - static inline procs cannot work with '--noHeader | -H' + {.push hint[ConvFromXtoItselfNotNeeded]: off.} -import macros - -macro defineEnum(typ: untyped): untyped = - result = newNimNode(nnkStmtList) - - # Enum mapped to distinct cint - result.add quote do: - type `typ`* = distinct cint - - for i in ["+", "-", "*", "div", "mod", "shl", "shr", "or", "and", "xor", "<", "<=", "==", ">", ">="]: - let - ni = newIdentNode(i) - typout = if i[0] in "<=>": newIdentNode("bool") else: typ # comparisons return bool - if i[0] == '>': # cannot borrow `>` and `>=` from templates - let - nopp = if i.len == 2: newIdentNode("<=") else: newIdentNode("<") - result.add quote do: - proc `ni`*(x: `typ`, y: cint): `typout` = `nopp`(y, x) - proc `ni`*(x: cint, y: `typ`): `typout` = `nopp`(y, x) - proc `ni`*(x, y: `typ`): `typout` = `nopp`(y, x) - else: - result.add quote do: - proc `ni`*(x: `typ`, y: cint): `typout` {.borrow.} - proc `ni`*(x: cint, y: `typ`): `typout` {.borrow.} - proc `ni`*(x, y: `typ`): `typout` {.borrow.} - result.add quote do: - proc `ni`*(x: `typ`, y: int): `typout` = `ni`(x, y.cint) - proc `ni`*(x: int, y: `typ`): `typout` = `ni`(x.cint, y) - - let - divop = newIdentNode("/") # `/`() - dlrop = newIdentNode("$") # `$`() - notop = newIdentNode("not") # `not`() - result.add quote do: - proc `divop`*(x, y: `typ`): `typ` = `typ`((x.float / y.float).cint) - proc `divop`*(x: `typ`, y: cint): `typ` = `divop`(x, `typ`(y)) - proc `divop`*(x: cint, y: `typ`): `typ` = `divop`(`typ`(x), y) - proc `divop`*(x: `typ`, y: int): `typ` = `divop`(x, y.cint) - proc `divop`*(x: int, y: `typ`): `typ` = `divop`(x.cint, y) - - proc `dlrop`*(x: `typ`): string {.borrow.} - proc `notop`*(x: `typ`): `typ` {.borrow.} - {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + defineEnum(mbedtls_key_exchange_type_t) + const MBEDTLS_TLS_RSA_WITH_NULL_MD5* = 0x00000001 MBEDTLS_TLS_RSA_WITH_NULL_SHA* = 0x00000002 diff --git a/webrtc/mbedtls/ssl_cookie.nim b/webrtc/mbedtls/ssl_cookie.nim index 449cdb8..214b466 100644 --- a/webrtc/mbedtls/ssl_cookie.nim +++ b/webrtc/mbedtls/ssl_cookie.nim @@ -1,57 +1,14 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# -import "private_access" -import "build_info" -import "mbedtls_config" -import "config_psa" -import "check_config" import "ssl" -import "platform_util" -import "platform_time" -import "bignum" -import "ecp" -import "ssl_ciphersuites" -import "pk" import "md" -import "rsa" -import "ecdsa" -import "cipher" -import "x509_crt" -import "x509" -import "asn1" -import "x509_crl" -import "dhm" -import "ecdh" -import "md5" -import "ripemd160" -import "sha1" -import "sha256" -import "sha512" -import "cmac" -import "gcm" -import "ccm" -import "chachapoly" -import "poly1305" -import "chacha20" -import "ecjpake" + {.compile: "./mbedtls/library/ssl_cookie.c".} -# Generated @ 2023-05-11T11:19:14+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/ssl_cookie.h {.push hint[ConvFromXtoItselfNotNeeded]: off.} - {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + const MBEDTLS_SSL_COOKIE_TIMEOUT* = 60 type diff --git a/webrtc/mbedtls/ssl_ticket.nim b/webrtc/mbedtls/ssl_ticket.nim index 9446a2b..2dce02e 100644 --- a/webrtc/mbedtls/ssl_ticket.nim +++ b/webrtc/mbedtls/ssl_ticket.nim @@ -1,57 +1,16 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# -import "private_access" -import "build_info" -import "mbedtls_config" -import "config_psa" -import "check_config" import "ssl" -import "platform_util" import "platform_time" -import "bignum" -import "ecp" import "ssl_ciphersuites" -import "pk" -import "md" -import "rsa" -import "ecdsa" import "cipher" -import "x509_crt" -import "x509" -import "asn1" -import "x509_crl" -import "dhm" -import "ecdh" -import "md5" -import "ripemd160" -import "sha1" -import "sha256" -import "sha512" -import "cmac" -import "gcm" -import "ccm" -import "chachapoly" -import "poly1305" -import "chacha20" -import "ecjpake" + {.compile: "./mbedtls/library/ssl_ticket.c".} -# Generated @ 2023-05-11T11:19:15+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/ssl_ticket.h {.push hint[ConvFromXtoItselfNotNeeded]: off.} - {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + const MBEDTLS_SSL_TICKET_MAX_KEY_BYTES* = 32 MBEDTLS_SSL_TICKET_KEY_NAME_BYTES* = 4 diff --git a/webrtc/mbedtls/threading.nim b/webrtc/mbedtls/threading.nim index 4ce3ffe..e4a193d 100644 --- a/webrtc/mbedtls/threading.nim +++ b/webrtc/mbedtls/threading.nim @@ -1,27 +1,9 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# -import "private_access" -import "build_info" -import "mbedtls_config" -import "config_psa" -import "check_config" -# Generated @ 2023-05-11T11:19:15+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/threading.h - {.push hint[ConvFromXtoItselfNotNeeded]: off.} - {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + const MBEDTLS_ERR_THREADING_BAD_INPUT_DATA* = -0x0000001C MBEDTLS_ERR_THREADING_MUTEX_ERROR* = -0x0000001E diff --git a/webrtc/mbedtls/timing.nim b/webrtc/mbedtls/timing.nim index f05a1dd..557a188 100644 --- a/webrtc/mbedtls/timing.nim +++ b/webrtc/mbedtls/timing.nim @@ -1,28 +1,11 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# -import "private_access" -import "build_info" -import "mbedtls_config" -import "config_psa" -import "check_config" {.compile: "./mbedtls/library/timing.c".} -# Generated @ 2023-05-11T11:19:15+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/timing.h {.push hint[ConvFromXtoItselfNotNeeded]: off.} - {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + type mbedtls_timing_hr_time* {.bycopy.} = object private_opaque*: array[4, uint64] diff --git a/webrtc/mbedtls/version.nim b/webrtc/mbedtls/version.nim index 9770bfb..1851677 100644 --- a/webrtc/mbedtls/version.nim +++ b/webrtc/mbedtls/version.nim @@ -1,28 +1,12 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# -import "build_info" -import "mbedtls_config" -import "config_psa" -import "check_config" {.compile: "./mbedtls/library/version.c".} {.compile: "./mbedtls/library/version_features.c".} -# Generated @ 2023-05-11T11:19:15+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/version.h {.push hint[ConvFromXtoItselfNotNeeded]: off.} - {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + proc mbedtls_version_get_number*(): cuint {.importc, cdecl.} proc mbedtls_version_get_string*(string: cstring) {.importc, cdecl.} proc mbedtls_version_get_string_full*(string: cstring) {.importc, cdecl.} diff --git a/webrtc/mbedtls/x509.nim b/webrtc/mbedtls/x509.nim index 5de4e6b..4ea1f6b 100644 --- a/webrtc/mbedtls/x509.nim +++ b/webrtc/mbedtls/x509.nim @@ -1,37 +1,9 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# -import "private_access" -import "build_info" -import "mbedtls_config" -import "config_psa" -import "check_config" import "asn1" -import "platform_util" -import "platform_time" -import "bignum" import "pk" import "md" -import "rsa" -import "ecp" -import "ecdsa" -import "oid" -import "hmac_drbg" -import "asn1write" -import "nist_kw" -import "hash_info" -{.compile: "./mbedtls/library/rsa_alt_helpers.c".} + {.compile: "./mbedtls/library/x509.c".} {.compile: "./mbedtls/library/x509_create.c".} -# Generated @ 2023-05-11T11:19:15+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/x509.h # const 'MBEDTLS_X509_EXT_AUTHORITY_KEY_IDENTIFIER' has unsupported value 'MBEDTLS_OID_X509_EXT_AUTHORITY_KEY_IDENTIFIER' # const 'MBEDTLS_X509_EXT_SUBJECT_KEY_IDENTIFIER' has unsupported value 'MBEDTLS_OID_X509_EXT_SUBJECT_KEY_IDENTIFIER' @@ -51,12 +23,13 @@ import "hash_info" # const 'MBEDTLS_X509_EXT_NS_CERT_TYPE' has unsupported value 'MBEDTLS_OID_X509_EXT_NS_CERT_TYPE' # proc 'mbedtls_x509_dn_get_next' skipped - static inline procs cannot work with '--noHeader | -H' # const 'MBEDTLS_X509_SAFE_SNPRINTF' has unsupported value 'do { if (ret < 0 || (size_t) ret >= n) return MBEDTLS_ERR_X509_BUFFER_TOO_SMALL; n -= (size_t) ret; p += (size_t) ret; } while (0)' -{.push hint[ConvFromXtoItselfNotNeeded]: off.} +{.push hint[ConvFromXtoItselfNotNeeded]: off.} {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + const MBEDTLS_X509_MAX_INTERMEDIATE_CA* = 8 MBEDTLS_ERR_X509_FEATURE_UNAVAILABLE* = -0x00002080 diff --git a/webrtc/mbedtls/x509_crl.nim b/webrtc/mbedtls/x509_crl.nim index 4e309b9..f9b7a1d 100644 --- a/webrtc/mbedtls/x509_crl.nim +++ b/webrtc/mbedtls/x509_crl.nim @@ -1,38 +1,15 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# -import "private_access" -import "build_info" -import "mbedtls_config" -import "config_psa" -import "check_config" import "x509" -import "asn1" -import "platform_util" -import "platform_time" -import "bignum" import "pk" import "md" -import "rsa" -import "ecp" -import "ecdsa" + {.compile: "./mbedtls/library/x509_crl.c".} -# Generated @ 2023-05-11T11:19:15+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/x509_crl.h {.push hint[ConvFromXtoItselfNotNeeded]: off.} - {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + type mbedtls_x509_crl_entry* {.bycopy.} = object raw*: mbedtls_x509_buf diff --git a/webrtc/mbedtls/x509_crt.nim b/webrtc/mbedtls/x509_crt.nim index 89336b6..bdd055c 100644 --- a/webrtc/mbedtls/x509_crt.nim +++ b/webrtc/mbedtls/x509_crt.nim @@ -1,43 +1,23 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# -import "private_access" -import "build_info" -import "mbedtls_config" -import "config_psa" -import "check_config" import "x509" -import "asn1" -import "platform_util" -import "platform_time" -import "bignum" -import "pk" -import "md" -import "rsa" -import "ecp" -import "ecdsa" import "x509_crl" +import "asn1" +import "bignum" +import "md" +import "pk" + {.compile: "./mbedtls/library/x509_crt.c".} {.compile: "./mbedtls/library/x509write_crt.c".} -# Generated @ 2023-05-11T11:19:15+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/x509_crt.h # const 'MBEDTLS_X509_CRT_ERROR_INFO_LIST' has unsupported value 'X509_CRT_ERROR_INFO(MBEDTLS_X509_BADCERT_EXPIRED, "MBEDTLS_X509_BADCERT_EXPIRED", "The certificate validity has expired") X509_CRT_ERROR_INFO(MBEDTLS_X509_BADCERT_REVOKED, "MBEDTLS_X509_BADCERT_REVOKED", "The certificate has been revoked (is on a CRL)") X509_CRT_ERROR_INFO(MBEDTLS_X509_BADCERT_CN_MISMATCH, "MBEDTLS_X509_BADCERT_CN_MISMATCH", "The certificate Common Name (CN) does not match with the expected CN") X509_CRT_ERROR_INFO(MBEDTLS_X509_BADCERT_NOT_TRUSTED, "MBEDTLS_X509_BADCERT_NOT_TRUSTED", "The certificate is not correctly signed by the trusted CA") X509_CRT_ERROR_INFO(MBEDTLS_X509_BADCRL_NOT_TRUSTED, "MBEDTLS_X509_BADCRL_NOT_TRUSTED", "The CRL is not correctly signed by the trusted CA") X509_CRT_ERROR_INFO(MBEDTLS_X509_BADCRL_EXPIRED, "MBEDTLS_X509_BADCRL_EXPIRED", "The CRL is expired") X509_CRT_ERROR_INFO(MBEDTLS_X509_BADCERT_MISSING, "MBEDTLS_X509_BADCERT_MISSING", "Certificate was missing") X509_CRT_ERROR_INFO(MBEDTLS_X509_BADCERT_SKIP_VERIFY, "MBEDTLS_X509_BADCERT_SKIP_VERIFY", "Certificate verification was skipped") X509_CRT_ERROR_INFO(MBEDTLS_X509_BADCERT_OTHER, "MBEDTLS_X509_BADCERT_OTHER", "Other reason (can be used by verify callback)") X509_CRT_ERROR_INFO(MBEDTLS_X509_BADCERT_FUTURE, "MBEDTLS_X509_BADCERT_FUTURE", "The certificate validity starts in the future") X509_CRT_ERROR_INFO(MBEDTLS_X509_BADCRL_FUTURE, "MBEDTLS_X509_BADCRL_FUTURE", "The CRL is from the future") X509_CRT_ERROR_INFO(MBEDTLS_X509_BADCERT_KEY_USAGE, "MBEDTLS_X509_BADCERT_KEY_USAGE", "Usage does not match the keyUsage extension") X509_CRT_ERROR_INFO(MBEDTLS_X509_BADCERT_EXT_KEY_USAGE, "MBEDTLS_X509_BADCERT_EXT_KEY_USAGE", "Usage does not match the extendedKeyUsage extension") X509_CRT_ERROR_INFO(MBEDTLS_X509_BADCERT_NS_CERT_TYPE, "MBEDTLS_X509_BADCERT_NS_CERT_TYPE", "Usage does not match the nsCertType extension") X509_CRT_ERROR_INFO(MBEDTLS_X509_BADCERT_BAD_MD, "MBEDTLS_X509_BADCERT_BAD_MD", "The certificate is signed with an unacceptable hash.") X509_CRT_ERROR_INFO(MBEDTLS_X509_BADCERT_BAD_PK, "MBEDTLS_X509_BADCERT_BAD_PK", "The certificate is signed with an unacceptable PK alg (eg RSA vs ECDSA).") X509_CRT_ERROR_INFO(MBEDTLS_X509_BADCERT_BAD_KEY, "MBEDTLS_X509_BADCERT_BAD_KEY", "The certificate is signed with an unacceptable key (eg bad curve, RSA too short).") X509_CRT_ERROR_INFO(MBEDTLS_X509_BADCRL_BAD_MD, "MBEDTLS_X509_BADCRL_BAD_MD", "The CRL is signed with an unacceptable hash.") X509_CRT_ERROR_INFO(MBEDTLS_X509_BADCRL_BAD_PK, "MBEDTLS_X509_BADCRL_BAD_PK", "The CRL is signed with an unacceptable PK alg (eg RSA vs ECDSA).") X509_CRT_ERROR_INFO(MBEDTLS_X509_BADCRL_BAD_KEY, "MBEDTLS_X509_BADCRL_BAD_KEY", "The CRL is signed with an unacceptable key (eg bad curve, RSA too short).")' # const 'MBEDTLS_X509_MAX_VERIFY_CHAIN_SIZE' has unsupported value '(MBEDTLS_X509_MAX_INTERMEDIATE_CA + 2)' # proc 'mbedtls_x509_crt_has_ext_type' skipped - static inline procs cannot work with '--noHeader | -H' -{.push hint[ConvFromXtoItselfNotNeeded]: off.} +{.push hint[ConvFromXtoItselfNotNeeded]: off.} {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + const MBEDTLS_X509_CRT_VERSION_1* = 0 MBEDTLS_X509_CRT_VERSION_2* = 1 diff --git a/webrtc/mbedtls/x509_csr.nim b/webrtc/mbedtls/x509_csr.nim index dac044f..99be885 100644 --- a/webrtc/mbedtls/x509_csr.nim +++ b/webrtc/mbedtls/x509_csr.nim @@ -1,39 +1,17 @@ -#import strformat, os -# -## C include directory -#const root = currentSourcePath.parentDir -#const mbedtlsInclude = root/"mbedtls"/"include" -#const mbedtlsLibrary = root/"mbedtls"/"library" -# -#{.passc: fmt"-I{mbedtlsInclude} -I{mbedtlsLibrary}".} -# -import "private_access" -import "build_info" -import "mbedtls_config" -import "config_psa" -import "check_config" import "x509" import "asn1" -import "platform_util" -import "platform_time" -import "bignum" import "pk" import "md" -import "rsa" -import "ecp" -import "ecdsa" + {.compile: "./mbedtls/library/x509_csr.c".} {.compile: "./mbedtls/library/x509write_csr.c".} -# Generated @ 2023-05-11T11:19:15+02:00 -# Command line: -# /home/lchenut/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --pnim --preprocess --nocomment --noHeader --replace=_pms_rsa=u_pms_rsa --replace=_pms_dhm=u_pms_dhm --replace=_pms_ecdh=u_pms_ecdh --replace=_pms_psk=u_pms_psk --replace=_pms_dhe_psk=u_pms_dhe_psk --replace=_pms_rsa_psk=u_pms_rsa_psk --replace=_pms_ecdhe_psk=u_pms_ecdhe_psk --replace=_pms_ecjpake=u_pms_ecjpake --replace=private_xm1=private_xm1_1 --replace=private_xm2=private_xm2_1 --includeDirs=./mbedtls/include --includeDirs=./mbedtls/library ./mbedtls/include/mbedtls/x509_csr.h {.push hint[ConvFromXtoItselfNotNeeded]: off.} - {.experimental: "codeReordering".} {.passc: "-I./mbedtls/include".} {.passc: "-I./mbedtls/library".} + type mbedtls_x509_csr* {.bycopy.} = object raw*: mbedtls_x509_buf