AtlatestRepositorysigil-crypto
sigil-crypto / treepackage.sgl
1
;;; sigil-crypto - Cryptographic Functions2
;;;3
;;; Provides cryptographic primitives using mbedTLS:4
;;; - SHA-1 and SHA-256 hashing5
;;; - HMAC-SHA1 / HMAC-SHA256 / HMAC-SHA5126
;;; - PBKDF2-SHA1 / PBKDF2-SHA256 / PBKDF2-SHA512 key derivation7
;;; - HKDF-SHA256 (RFC 5869) key derivation8
;;; - ECDSA P-256 sign + verify + keygen (JOSE/ES256 format)9
;;; - ECDH P-256 shared-secret derivation10
;;; - AES-128-GCM authenticated encryption11
;;; - Base64 + base64url (RFC 4648 § 5) encoding/decoding12
;;; - Cryptographically secure random bytes13
;;;14
;;; This package vendors mbedTLS and can be used independently of TLS.16
(package17
name: "sigil-crypto"18
version: "0.16.4"19
sigil: "^0.17"20
description: "Cryptographic functions for Sigil (SHA, HMAC, ECDSA, ECDH, AES-GCM, HKDF, base64, random)"21
url: "https://codeberg.org/sigil/sigil-crypto"22
license: "BSD-3-Clause"23
authors: (list "David Wilson <[email protected]>")25
dependencies: (list26
;; Explicit sigil-lib pin: overrides the extraction-era implicit27
;; sigil-stdlib/sigil-lib (^0.15 from the retired sigil-lang repo)28
;; that the reintegrated monorepo test-runner chain would otherwise29
;; derive. sigil-crypto's native codegen needs the 0.17 runtime30
;; headers to build libsigil-crypto.a.31
(from-git url: "codeberg:sigil/sigil"32
package: "sigil-lib" version: "^0.17"))34
;; sigil-test + sigil-test-runner are required as dev-deps so35
;; `sigil test` can build a test-harness binary that statically36
;; links sigil-crypto's native init function. The harness imports37
;; (sigil test cli) from sigil-test-runner. Without these the host38
;; sigil binary's bundled (and potentially stale) `(sigil crypto).sgb`39
;; would be used instead of the local source, causing newer bindings40
;; to surface as `unbound variable`.41
dev-dependencies: (list42
(from-git url: "codeberg:sigil/sigil" package: "sigil-test" version: "^0.17")43
(from-git url: "codeberg:sigil/sigil" package: "sigil-test-runner" version: "^0.17"))45
;; Native library definition46
libraries: (list47
(library48
name: 'sigil-crypto49
c-sources: '("native/crypto.c"50
"vendor/mbedtls/library/*.c")51
c-include-dirs: '("vendor/mbedtls/include"52
"vendor/mbedtls")53
c-flags: '("-DMBEDTLS_CONFIG_FILE=\"sigil_mbedtls_config.h\"")54
native-init: "sigil__init_sigil_crypto_module"))56
tasks: (list57
(task58
name: 'build59
description: "Build the sigil-crypto native library"60
steps: (list61
;; Compile mbedTLS library with our minimal config62
;; The config disables TLS 1.3 (requires complex PSA crypto setup)63
;; and enables only what we need for TLS 1.2 client connections64
(compile-c-sources65
sources: "vendor/mbedtls/library/*.c"66
include-dirs: '("vendor/mbedtls/include"67
"vendor/mbedtls")68
flags: '("-std=c99"69
"-Wall" "-Wno-unused-function"70
"-DMBEDTLS_CONFIG_FILE=\"sigil_mbedtls_config.h\""))72
;; Compile crypto.c73
;; Flags go through with-sigil-c-flags so the build system injects74
;; -I<sigil-lib>/include + -I<sigil-lib>/src. crypto.c's75
;; #include <sigil/sigil.h> resolves via that auto-injection.76
(compile-c-sources77
sources: '("native/crypto.c")78
include-dirs: '("vendor/mbedtls/include"79
"vendor/mbedtls")80
flags: (with-sigil-c-flags '("-std=c99"81
"-Wall" "-Wextra"82
"-Wno-unused-parameter"83
"-D_GNU_SOURCE"84
"-DMBEDTLS_CONFIG_FILE=\"sigil_mbedtls_config.h\"")))86
;; Create static library87
(create-static-library88
name: "sigil-crypto")90
;; Compile Scheme module91
(compile-sigil-modules92
sources: "src/**/*.sgl")))))