about summary refs log tree commit diff
path: root/third_party
diff options
context:
space:
mode:
authorGriffin Smith <grfn@gws.fyi>2020-07-21T18·29-0400
committerglittershark <grfn@gws.fyi>2020-07-26T21·21+0000
commite231493ff4207e1fe3191ba13ece8c7477c3f242 (patch)
treea283de314590f542ec21086a7643c587e8bd2cf4 /third_party
parentb0e80d9465ca23cc59a35937675ee1f9bc6cc2cf (diff)
feat(3p/lisp): Add ironclad r/1483
Add ironclad, a common lisp library for cryptography. This is a huge
library with a lot of moving parts - probably most notable here is that
I've had to turn off compiling with `:ironclad-assembly`, as it was
causing an infinite loop in the compiler due to
https://github.com/sharplispers/ironclad/blob/master/src/opt/sbcl/cpu-features.lisp#L9-L10,
a mutually self-recursive function that looks like:

    (defun aes-ni-support-p ()
      (aes-ni-support-p))

Without knowing much about how sbcl handles native-compiled assembly, it
seems like this definition should actually be skipped entirely, due to
it being defined as a `defknown` in `fndb.lisp`:

    (defknown ironclad::aes-ni-support-p
      ()
      (boolean)
      (any)
      :overwrite-fndb-silently t)

But something about how we're compiling things was causing that not to
happen, and the infinite recursion caused the compiler to hang. This
should be fixed at some point, but given I only need this library as a
transitive dependency down a level I'm not going to attempt to do so now.

Change-Id: Id768717991404f959b003c7e2f28f1f4d532b94b
Reviewed-on: https://cl.tvl.fyi/c/depot/+/1333
Tested-by: BuildkiteCI
Reviewed-by: kanepyork <rikingcoding@gmail.com>
Diffstat (limited to 'third_party')
-rw-r--r--third_party/lisp/ironclad.nix145
-rw-r--r--third_party/lisp/nibbles.nix27
2 files changed, 172 insertions, 0 deletions
diff --git a/third_party/lisp/ironclad.nix b/third_party/lisp/ironclad.nix
new file mode 100644
index 0000000000..9bdf87114a
--- /dev/null
+++ b/third_party/lisp/ironclad.nix
@@ -0,0 +1,145 @@
+{ depot, pkgs, ...}:
+
+let
+  inherit (pkgs) runCommand;
+  inherit (depot.nix.buildLisp) bundled;
+  src = pkgs.fetchFromGitHub {
+    owner = "sharplispers";
+    repo = "ironclad";
+    rev = "c3aa33080621abc10fdb0f34acc4655cc4e982a6";
+    sha256 = "0k4bib9mbrzalbl9ivkw4a7g4c7bbad1l5jw4pzkifqszy2swkr5";
+  };
+
+in depot.nix.buildLisp.library {
+  name = "ironclad";
+
+  deps = with depot.third_party.lisp; [
+    (bundled "asdf")
+    (bundled "sb-rotate-byte")
+    alexandria
+    bordeaux-threads
+    nibbles
+  ];
+
+  srcs = [
+    "${src}/ironclad.asd"
+    # TODO(grfn): Figure out how to get this compiling with the assembly
+    # optimization eventually - see https://cl.tvl.fyi/c/depot/+/1333
+    (runCommand "package.lisp" {} ''
+      substitute ${src}/src/package.lisp $out \
+        --replace \#-ecl-bytecmp "" \
+        --replace '(pushnew :ironclad-assembly *features*)' ""
+    '')
+  ] ++ (map (f: src + ("/src/" + f)) [
+    "macro-utils.lisp"
+
+    "opt/sbcl/fndb.lisp"
+    "opt/sbcl/cpu-features.lisp"
+    "opt/sbcl/x86oid-vm.lisp"
+
+    "common.lisp"
+    "conditions.lisp"
+    "generic.lisp"
+    "util.lisp"
+
+    "ciphers/padding.lisp"
+    "ciphers/cipher.lisp"
+    "ciphers/chacha.lisp"
+    "ciphers/modes.lisp"
+    "ciphers/salsa20.lisp"
+    "ciphers/xchacha.lisp"
+    "ciphers/xsalsa20.lisp"
+    "ciphers/aes.lisp"
+    "ciphers/arcfour.lisp"
+    "ciphers/arcfour.lisp"
+    "ciphers/aria.lisp"
+    "ciphers/blowfish.lisp"
+    "ciphers/camellia.lisp"
+    "ciphers/cast5.lisp"
+    "ciphers/des.lisp"
+    "ciphers/idea.lisp"
+    "ciphers/keystream.lisp"
+    "ciphers/kalyna.lisp"
+    "ciphers/kuznyechik.lisp"
+    "ciphers/make-cipher.lisp"
+    "ciphers/misty1.lisp"
+    "ciphers/rc2.lisp"
+    "ciphers/rc5.lisp"
+    "ciphers/rc6.lisp"
+    "ciphers/seed.lisp"
+    "ciphers/serpent.lisp"
+    "ciphers/sm4.lisp"
+    "ciphers/sosemanuk.lisp"
+    "ciphers/square.lisp"
+    "ciphers/tea.lisp"
+    "ciphers/threefish.lisp"
+    "ciphers/twofish.lisp"
+    "ciphers/xor.lisp"
+    "ciphers/xtea.lisp"
+
+    "digests/digest.lisp"
+    "digests/adler32.lisp"
+    "digests/blake2.lisp"
+    "digests/blake2s.lisp"
+    "digests/crc24.lisp"
+    "digests/crc32.lisp"
+    "digests/groestl.lisp"
+    "digests/jh.lisp"
+    "digests/kupyna.lisp"
+    "digests/md2.lisp"
+    "digests/md4.lisp"
+    "digests/md5.lisp"
+    "digests/md5-lispworks-int32.lisp"
+    "digests/ripemd-128.lisp"
+    "digests/ripemd-160.lisp"
+    "digests/sha1.lisp"
+    "digests/sha256.lisp"
+    "digests/sha3.lisp"
+    "digests/sha512.lisp"
+    "digests/skein.lisp"
+    "digests/sm3.lisp"
+    "digests/streebog.lisp"
+    "digests/tiger.lisp"
+    "digests/tree-hash.lisp"
+    "digests/whirlpool.lisp"
+
+    "prng/prng.lisp"
+    "prng/generator.lisp"
+    "prng/fortuna.lisp"
+    "prng/os-prng.lisp"
+
+    "math.lisp"
+
+    "macs/mac.lisp"
+    "macs/blake2-mac.lisp"
+    "macs/blake2s-mac.lisp"
+    "macs/cmac.lisp"
+    "macs/hmac.lisp"
+    "macs/gmac.lisp"
+    "macs/poly1305.lisp"
+    "macs/siphash.lisp"
+    "macs/skein-mac.lisp"
+
+    "kdf/kdf-common.lisp"
+    "kdf/argon2.lisp"
+    "kdf/password-hash.lisp"
+    "kdf/pkcs5.lisp"
+    "kdf/scrypt.lisp"
+    "kdf/hmac.lisp"
+
+    "aead/aead.lisp"
+    "aead/eax.lisp"
+    "aead/etm.lisp"
+    "aead/gcm.lisp"
+
+    "public-key/public-key.lisp"
+    "public-key/curve25519.lisp"
+    "public-key/curve448.lisp"
+    "public-key/dsa.lisp"
+    "public-key/ed25519.lisp"
+    "public-key/ed448.lisp"
+    "public-key/elgamal.lisp"
+    "public-key/pkcs1.lisp"
+    "public-key/rsa.lisp"
+  ]);
+}
diff --git a/third_party/lisp/nibbles.nix b/third_party/lisp/nibbles.nix
new file mode 100644
index 0000000000..593bc4b385
--- /dev/null
+++ b/third_party/lisp/nibbles.nix
@@ -0,0 +1,27 @@
+{ depot, pkgs, ... }:
+
+let
+  inherit (depot.nix.buildLisp) bundled;
+  src = pkgs.fetchFromGitHub {
+    owner = "froydnj";
+    repo = "nibbles";
+    rev = "9de8c755c2ff24117748a3271e8582bb8d4a6b6c";
+    sha256 = "11rznn33m950mp4zgnpyjaliy3z3rvibfdr8y4vnk2aq42kqi7dj";
+  };
+
+in depot.nix.buildLisp.library {
+  name = "nibbles";
+
+  deps = with depot.third_party.lisp; [
+    (bundled "asdf")
+  ];
+
+  srcs = map (f: src + ("/" + f)) [
+    "package.lisp"
+    "types.lisp"
+    "macro-utils.lisp"
+    "types.lisp"
+    "vectors.lisp"
+    "streams.lisp"
+  ];
+}