forked from cyph/rsasign.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
executable file
·66 lines (56 loc) · 3.34 KB
/
Copy pathMakefile
File metadata and controls
executable file
·66 lines (56 loc) · 3.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
all:
rm -rf dist libsodium node_modules openssl package-lock.json 2> /dev/null
mkdir dist node_modules
npm install
git clone --depth 1 -b stable https://github.com/jedisct1/libsodium
cd libsodium ; emconfigure ./configure --enable-minimal --disable-shared
git clone --depth 1 -b OpenSSL_1_1_0-stable https://github.com/openssl/openssl
cd openssl ; emconfigure perl Configure -static no-afalgeng no-asan no-asm no-async no-autoalginit no-autoerrinit no-bf no-blake2 no-camellia no-capieng no-cast no-chacha no-cmac no-cms no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-ct no-deprecated no-des no-dgram no-dh no-dsa no-dso no-dtls no-dynamic-engine no-ec no-ec2m no-ecdh no-ecdsa no-ec_nistp_64_gcc_128 no-egd no-engine no-err no-filenames no-fuzz-libfuzzer no-fuzz-afl no-gost no-heartbeats no-hw no-idea no-makedepend no-md2 no-md4 no-mdc2 no-msan no-multiblock no-nextprotoneg no-ocb no-ocsp no-pic no-poly1305 no-posix-io no-psk no-rc2 no-rc4 no-rc5 no-rdrand no-rfc3779 no-rmd160 no-scrypt no-sctp no-seed no-shared no-sock no-srp no-srtp no-sse2 no-ssl no-ssl-trace no-static-engine no-stdio no-threads no-tls no-ts no-ubsan no-ui no-unit-test no-whirlpool no-weak-ssl-ciphers no-zlib no-zlib-dynamic linux-generic32 ; sed -i 's|$$(CROSS_COMPILE)/home/|/home/|g' Makefile ; sed -i 's|$$(CROSS_COMPILE)python|python|g' Makefile ; make build_libs
bash -c ' \
args="$$(echo " \
-s SINGLE_FILE=1 \
-DRSASIGNJS_BITS=2048 -DRSASIGNJS_PUBLEN=450 -DRSASIGNJS_PRIVLEN=1700 -DRSASIGNJS_SIGLEN=256 \
-s TOTAL_MEMORY=16777216 -s TOTAL_STACK=8388608 \
-s RUNNING_JS_OPTS=1 \
-s ASSERTIONS=0 \
-s AGGRESSIVE_VARIABLE_ELIMINATION=1 \
-s ALIASING_FUNCTION_POINTERS=1 \
-s DISABLE_EXCEPTION_CATCHING=1 \
-s NO_FILESYSTEM=1 \
-Ilibsodium/src/libsodium/include/sodium \
-Iopenssl -Iopenssl/include -Iopenssl/crypto \
libsodium/src/libsodium/randombytes/randombytes.c \
openssl/crypto/rand/rand_err.o \
$$(find openssl/crypto -type f -name "*.o" -not -path "openssl/crypto/rand/*" | tr "\n" " ") \
rsasign.c \
-s EXTRA_EXPORTED_RUNTIME_METHODS=\"[ \
'"'"'writeArrayToMemory'"'"' \
]\" \
-s EXPORTED_FUNCTIONS=\"[ \
'"'"'_free'"'"', \
'"'"'_malloc'"'"', \
'"'"'_rsasignjs_init'"'"', \
'"'"'_rsasignjs_keypair'"'"', \
'"'"'_rsasignjs_sign'"'"', \
'"'"'_rsasignjs_verify'"'"', \
'"'"'_rsasignjs_public_key_bytes'"'"', \
'"'"'_rsasignjs_secret_key_bytes'"'"', \
'"'"'_rsasignjs_signature_bytes'"'"' \
]\" \
" | perl -pe "s/\s+/ /g" | perl -pe "s/\[ /\[/g" | perl -pe "s/ \]/\]/g")"; \
\
bash -c "emcc -Oz $$args -o dist/rsasign.tmp.js"; \
'
cp pre.js dist/rsasign.module.js
cat dist/rsasign.tmp.js >> dist/rsasign.module.js
cat post.js >> dist/rsasign.module.js
sed -i 's|use asm||g' dist/rsasign.module.js
sed -i 's|require(|eval("require")(|g' dist/rsasign.module.js
sed -i 's|eval("require")(.pem-jwk-norecompute.)|require("pem-jwk-norecompute")|g' dist/rsasign.module.js
sed -i 's|eval("require")(.sodiumutil.)|require("sodiumutil")|g' dist/rsasign.module.js
webpack --output-library-target var --output-library rsaSign dist/rsasign.module.js dist/rsasign.js
uglifyjs dist/rsasign.module.js -cmo dist/rsasign.module.js
uglifyjs dist/rsasign.js -cmo dist/rsasign.js
rm -rf dist/rsasign.tmp.js libsodium node_modules openssl package-lock.json
clean:
rm -rf dist libsodium node_modules openssl