From: Thomas Pornin Date: Sun, 22 Jan 2017 19:00:29 +0000 (+0100) Subject: New Makefile structure; added compatibility with Windows + Visual C + nmake. X-Git-Tag: v0.4~14 X-Git-Url: https://bearssl.org/gitweb//home/git/?a=commitdiff_plain;h=3f00688b9d9f483a6ca97e659eea104995ea15b7;p=BearSSL New Makefile structure; added compatibility with Windows + Visual C + nmake. --- diff --git a/Makefile b/Makefile index f739d9a..044f5bc 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Thomas Pornin +# Copyright (c) 2017 Thomas Pornin # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -20,732 +20,22 @@ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. +# ====================================================================== + +# The lines below are a horrible hack that nonetheless works. On a +# "make" utility compatible with Single Unix v4 (this includes GNU and +# BSD make), the '\' at the end of a command line counts as an escape +# for the newline character, so the next line is still a comment. +# However, Microsoft's nmake.exe (that comes with Visual Studio) does +# not interpret the final '\' that way in a comment. The end result is +# that when using nmake.exe, this will include "mk/Win.mk", whereas +# GNU/BSD make will include "mk/Unix.mk". + +# \ +!ifndef 0 # \ +!include mk/NMake.mk # \ +!else .POSIX: - -# ======================================================================== -# Configurable elements: C compiler and flags, linker flags, static -# library archival command. - -CC = gcc -CFLAGS = -W -Wall -Os -fPIC -I src -I inc -#CFLAGS = -W -Wall -g -fPIC -I src -I inc -LDFLAGS = -AR = ar -rcs - -# Nothing is meant to be changed below this line. - -# ======================================================================== - -HEADERS = inc/bearssl.h inc/bearssl_block.h inc/bearssl_ec.h inc/bearssl_hash.h inc/bearssl_hmac.h inc/bearssl_pem.h inc/bearssl_prf.h inc/bearssl_rand.h inc/bearssl_rsa.h inc/bearssl_ssl.h inc/bearssl_x509.h src/inner.h src/config.h -BUILD = build - -BEARSSLLIB = libbearssl.a -BRSSL = brssl -TESTCRYPTO = testcrypto -TESTSPEED = testspeed -TESTX509 = testx509 -TESTMATH = testmath - -OBJCODEC = $(BUILD)/ccopy.o $(BUILD)/dec16be.o $(BUILD)/dec16le.o $(BUILD)/dec32be.o $(BUILD)/dec32le.o $(BUILD)/dec64be.o $(BUILD)/dec64le.o $(BUILD)/enc16be.o $(BUILD)/enc16le.o $(BUILD)/enc32be.o $(BUILD)/enc32le.o $(BUILD)/enc64be.o $(BUILD)/enc64le.o $(BUILD)/pemdec.o -OBJEC = $(BUILD)/ec_all_m15.o $(BUILD)/ec_all_m31.o $(BUILD)/ec_c25519_i15.o $(BUILD)/ec_c25519_i31.o $(BUILD)/ec_c25519_m15.o $(BUILD)/ec_c25519_m31.o $(BUILD)/ec_curve25519.o $(BUILD)/ec_p256_m15.o $(BUILD)/ec_p256_m31.o $(BUILD)/ec_prime_i15.o $(BUILD)/ec_prime_i31.o $(BUILD)/ec_secp256r1.o $(BUILD)/ec_secp384r1.o $(BUILD)/ec_secp521r1.o $(BUILD)/ecdsa_atr.o $(BUILD)/ecdsa_i15_bits.o $(BUILD)/ecdsa_i15_sign_asn1.o $(BUILD)/ecdsa_i15_sign_raw.o $(BUILD)/ecdsa_i15_vrfy_asn1.o $(BUILD)/ecdsa_i15_vrfy_raw.o $(BUILD)/ecdsa_i31_bits.o $(BUILD)/ecdsa_i31_sign_asn1.o $(BUILD)/ecdsa_i31_sign_raw.o $(BUILD)/ecdsa_i31_vrfy_asn1.o $(BUILD)/ecdsa_i31_vrfy_raw.o $(BUILD)/ecdsa_rta.o -# $(BUILD)/ec_prime_i31_secp256r1.o $(BUILD)/ec_prime_i31_secp384r1.o $(BUILD)/ec_prime_i31_secp521r1.o -OBJHASH = $(BUILD)/dig_oid.o $(BUILD)/dig_size.o $(BUILD)/ghash_ctmul.o $(BUILD)/ghash_ctmul32.o $(BUILD)/ghash_ctmul64.o $(BUILD)/md5.o $(BUILD)/md5sha1.o $(BUILD)/multihash.o $(BUILD)/sha1.o $(BUILD)/sha2big.o $(BUILD)/sha2small.o -OBJINT15 = $(BUILD)/i15_add.o $(BUILD)/i15_bitlen.o $(BUILD)/i15_decmod.o $(BUILD)/i15_decode.o $(BUILD)/i15_decred.o $(BUILD)/i15_encode.o $(BUILD)/i15_fmont.o $(BUILD)/i15_iszero.o $(BUILD)/i15_modpow.o $(BUILD)/i15_montmul.o $(BUILD)/i15_mulacc.o $(BUILD)/i15_muladd.o $(BUILD)/i15_ninv15.o $(BUILD)/i15_reduce.o $(BUILD)/i15_rshift.o $(BUILD)/i15_sub.o $(BUILD)/i15_tmont.o -OBJINT31 = $(BUILD)/i31_add.o $(BUILD)/i31_bitlen.o $(BUILD)/i31_decmod.o $(BUILD)/i31_decode.o $(BUILD)/i31_decred.o $(BUILD)/i31_encode.o $(BUILD)/i31_fmont.o $(BUILD)/i31_iszero.o $(BUILD)/i31_modpow.o $(BUILD)/i31_montmul.o $(BUILD)/i31_mulacc.o $(BUILD)/i31_muladd.o $(BUILD)/i31_ninv31.o $(BUILD)/i31_reduce.o $(BUILD)/i31_rshift.o $(BUILD)/i31_sub.o $(BUILD)/i31_tmont.o -OBJINT32 = $(BUILD)/i32_add.o $(BUILD)/i32_bitlen.o $(BUILD)/i32_decmod.o $(BUILD)/i32_decode.o $(BUILD)/i32_decred.o $(BUILD)/i32_div32.o $(BUILD)/i32_encode.o $(BUILD)/i32_fmont.o $(BUILD)/i32_iszero.o $(BUILD)/i32_modpow.o $(BUILD)/i32_montmul.o $(BUILD)/i32_mulacc.o $(BUILD)/i32_muladd.o $(BUILD)/i32_ninv32.o $(BUILD)/i32_reduce.o $(BUILD)/i32_sub.o $(BUILD)/i32_tmont.o -OBJMAC = $(BUILD)/hmac.o $(BUILD)/hmac_ct.o -OBJRAND = $(BUILD)/hmac_drbg.o -OBJRSA = $(BUILD)/rsa_i15_pkcs1_sign.o $(BUILD)/rsa_i15_pkcs1_vrfy.o $(BUILD)/rsa_i15_priv.o $(BUILD)/rsa_i15_pub.o $(BUILD)/rsa_i31_pkcs1_sign.o $(BUILD)/rsa_i31_pkcs1_vrfy.o $(BUILD)/rsa_i31_priv.o $(BUILD)/rsa_i31_pub.o $(BUILD)/rsa_i32_pkcs1_sign.o $(BUILD)/rsa_i32_pkcs1_vrfy.o $(BUILD)/rsa_i32_priv.o $(BUILD)/rsa_i32_pub.o $(BUILD)/rsa_pkcs1_sig_pad.o $(BUILD)/rsa_pkcs1_sig_unpad.o $(BUILD)/rsa_ssl_decrypt.o -OBJSSL = $(BUILD)/prf.o $(BUILD)/prf_md5sha1.o $(BUILD)/prf_sha256.o $(BUILD)/prf_sha384.o $(BUILD)/ssl_ccert_single_ec.o $(BUILD)/ssl_ccert_single_rsa.o $(BUILD)/ssl_client.o $(BUILD)/ssl_client_full.o $(BUILD)/ssl_engine.o $(BUILD)/ssl_hashes.o $(BUILD)/ssl_hs_client.o $(BUILD)/ssl_hs_server.o $(BUILD)/ssl_io.o $(BUILD)/ssl_lru.o $(BUILD)/ssl_rec_cbc.o $(BUILD)/ssl_rec_chapol.o $(BUILD)/ssl_rec_gcm.o $(BUILD)/ssl_server.o $(BUILD)/ssl_server_mine2c.o $(BUILD)/ssl_server_mine2g.o $(BUILD)/ssl_server_minf2c.o $(BUILD)/ssl_server_minf2g.o $(BUILD)/ssl_server_minr2g.o $(BUILD)/ssl_server_minu2g.o $(BUILD)/ssl_server_minv2g.o $(BUILD)/ssl_server_full_ec.o $(BUILD)/ssl_server_full_rsa.o $(BUILD)/ssl_scert_single_ec.o $(BUILD)/ssl_scert_single_rsa.o -OBJSYMCIPHER = $(BUILD)/aes_big_cbcdec.o $(BUILD)/aes_big_cbcenc.o $(BUILD)/aes_big_ctr.o $(BUILD)/aes_big_dec.o $(BUILD)/aes_big_enc.o $(BUILD)/aes_common.o $(BUILD)/aes_ct.o $(BUILD)/aes_ct64.o $(BUILD)/aes_ct64_cbcdec.o $(BUILD)/aes_ct64_cbcenc.o $(BUILD)/aes_ct64_ctr.o $(BUILD)/aes_ct64_dec.o $(BUILD)/aes_ct64_enc.o $(BUILD)/aes_ct_cbcdec.o $(BUILD)/aes_ct_cbcenc.o $(BUILD)/aes_ct_ctr.o $(BUILD)/aes_ct_dec.o $(BUILD)/aes_ct_enc.o $(BUILD)/aes_small_cbcdec.o $(BUILD)/aes_small_cbcenc.o $(BUILD)/aes_small_ctr.o $(BUILD)/aes_small_dec.o $(BUILD)/aes_small_enc.o $(BUILD)/chacha20_ct.o $(BUILD)/des_ct.o $(BUILD)/des_ct_cbcdec.o $(BUILD)/des_ct_cbcenc.o $(BUILD)/des_support.o $(BUILD)/des_tab.o $(BUILD)/des_tab_cbcdec.o $(BUILD)/des_tab_cbcenc.o $(BUILD)/poly1305_ctmul.o $(BUILD)/poly1305_ctmul32.o $(BUILD)/poly1305_i15.o -OBJX509 = $(BUILD)/skey_decoder.o $(BUILD)/x509_decoder.o $(BUILD)/x509_knownkey.o $(BUILD)/x509_minimal.o $(BUILD)/x509_minimal_full.o -OBJ = $(OBJCODEC) $(OBJEC) $(OBJHASH) $(OBJINT15) $(OBJINT31) $(OBJINT32) $(OBJMAC) $(OBJRAND) $(OBJRSA) $(OBJSSL) $(OBJSYMCIPHER) $(OBJX509) -OBJBRSSL = $(BUILD)/brssl.o $(BUILD)/certs.o $(BUILD)/chain.o $(BUILD)/client.o $(BUILD)/errors.o $(BUILD)/files.o $(BUILD)/keys.o $(BUILD)/names.o $(BUILD)/server.o $(BUILD)/skey.o $(BUILD)/sslio.o $(BUILD)/ta.o $(BUILD)/vector.o $(BUILD)/verify.o $(BUILD)/xmem.o -OBJTESTCRYPTO = $(BUILD)/test_crypto.o -OBJTESTSPEED = $(BUILD)/test_speed.o -OBJTESTX509 = $(BUILD)/test_x509.o -OBJTESTMATH = $(BUILD)/test_math.o - -T0COMP = T0Comp.exe -T0SRC = T0/BlobWriter.cs T0/CPU.cs T0/CodeElement.cs T0/CodeElementJump.cs T0/CodeElementUInt.cs T0/CodeElementUIntExpr.cs T0/CodeElementUIntInt.cs T0/CodeElementUIntUInt.cs T0/ConstData.cs T0/Opcode.cs T0/OpcodeCall.cs T0/OpcodeConst.cs T0/OpcodeGetLocal.cs T0/OpcodeJump.cs T0/OpcodeJumpIf.cs T0/OpcodeJumpIfNot.cs T0/OpcodeJumpUncond.cs T0/OpcodePutLocal.cs T0/OpcodeRet.cs T0/SType.cs T0/T0Comp.cs T0/TPointerBase.cs T0/TPointerBlob.cs T0/TPointerExpr.cs T0/TPointerNull.cs T0/TPointerXT.cs T0/TValue.cs T0/Word.cs T0/WordBuilder.cs T0/WordData.cs T0/WordInterpreted.cs T0/WordNative.cs -T0KERN = T0/kern.t0 - -all: compile - -compile: $(BEARSSLLIB) $(BRSSL) $(TESTCRYPTO) $(TESTSPEED) $(TESTX509) - -$(BEARSSLLIB): $(BUILD) $(OBJ) - $(AR) $(BEARSSLLIB) $(OBJ) - -$(BRSSL): $(BEARSSLLIB) $(OBJBRSSL) - $(CC) $(LDFLAGS) -o $(BRSSL) $(OBJBRSSL) $(BEARSSLLIB) - -$(TESTCRYPTO): $(BEARSSLLIB) $(OBJTESTCRYPTO) - $(CC) $(LDFLAGS) -o $(TESTCRYPTO) $(OBJTESTCRYPTO) $(BEARSSLLIB) - -$(TESTSPEED): $(BEARSSLLIB) $(OBJTESTSPEED) - $(CC) $(LDFLAGS) -o $(TESTSPEED) $(OBJTESTSPEED) $(BEARSSLLIB) - -$(TESTX509): $(BEARSSLLIB) $(OBJTESTX509) - $(CC) $(LDFLAGS) -o $(TESTX509) $(OBJTESTX509) $(BEARSSLLIB) - -$(TESTMATH): $(BEARSSLLIB) $(OBJTESTMATH) - $(CC) $(LDFLAGS) -o $(TESTMATH) $(OBJTESTMATH) $(BEARSSLLIB) -lgmp - -$(BUILD): - -mkdir -p $(BUILD) - -T0: $(T0COMP) T0Gen - -T0Gen: - mono T0Comp.exe -o src/codec/pemdec -r br_pem_decoder src/codec/pemdec.t0 - mono T0Comp.exe -o src/ssl/ssl_hs_client -r br_ssl_hs_client src/ssl/ssl_hs_common.t0 src/ssl/ssl_hs_client.t0 - mono T0Comp.exe -o src/ssl/ssl_hs_server -r br_ssl_hs_server src/ssl/ssl_hs_common.t0 src/ssl/ssl_hs_server.t0 - mono T0Comp.exe -o src/x509/skey_decoder -r br_skey_decoder src/x509/asn1.t0 src/x509/skey_decoder.t0 - mono T0Comp.exe -o src/x509/x509_decoder -r br_x509_decoder src/x509/asn1.t0 src/x509/x509_decoder.t0 - mono T0Comp.exe -o src/x509/x509_minimal -r br_x509_minimal src/x509/asn1.t0 src/x509/x509_minimal.t0 - -$(T0COMP): $(T0SRC) $(T0KERN) - ./mkT0.sh - -clean: - -rm -f $(OBJ) $(BEARSSLLIB) $(OBJSSL) $(BRSSL) $(OBJBRSSL) $(TESTCRYPTO) $(OBJTESTCRYPTO) $(TESTSPEED) $(OBJTESTSPEED) $(TESTX509) $(OBJTESTX509) $(TESTMATH) $(OBJTESTMATH) - -$(BUILD)/ccopy.o: src/codec/ccopy.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/ccopy.o src/codec/ccopy.c - -$(BUILD)/dec16be.o: src/codec/dec16be.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/dec16be.o src/codec/dec16be.c - -$(BUILD)/dec16le.o: src/codec/dec16le.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/dec16le.o src/codec/dec16le.c - -$(BUILD)/dec32be.o: src/codec/dec32be.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/dec32be.o src/codec/dec32be.c - -$(BUILD)/dec32le.o: src/codec/dec32le.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/dec32le.o src/codec/dec32le.c - -$(BUILD)/dec64be.o: src/codec/dec64be.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/dec64be.o src/codec/dec64be.c - -$(BUILD)/dec64le.o: src/codec/dec64le.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/dec64le.o src/codec/dec64le.c - -$(BUILD)/enc16be.o: src/codec/enc16be.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/enc16be.o src/codec/enc16be.c - -$(BUILD)/enc16le.o: src/codec/enc16le.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/enc16le.o src/codec/enc16le.c - -$(BUILD)/enc32be.o: src/codec/enc32be.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/enc32be.o src/codec/enc32be.c - -$(BUILD)/enc32le.o: src/codec/enc32le.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/enc32le.o src/codec/enc32le.c - -$(BUILD)/enc64be.o: src/codec/enc64be.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/enc64be.o src/codec/enc64be.c - -$(BUILD)/enc64le.o: src/codec/enc64le.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/enc64le.o src/codec/enc64le.c - -$(BUILD)/pemdec.o: src/codec/pemdec.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/pemdec.o src/codec/pemdec.c - -$(BUILD)/ec_g_secp256r1.o: src/ec/ec_g_secp256r1.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/ec_g_secp256r1.o src/ec/ec_g_secp256r1.c - -$(BUILD)/ec_g_secp384r1.o: src/ec/ec_g_secp384r1.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/ec_g_secp384r1.o src/ec/ec_g_secp384r1.c - -$(BUILD)/ec_g_secp521r1.o: src/ec/ec_g_secp521r1.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/ec_g_secp521r1.o src/ec/ec_g_secp521r1.c - -$(BUILD)/ec_all_m15.o: src/ec/ec_all_m15.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/ec_all_m15.o src/ec/ec_all_m15.c - -$(BUILD)/ec_all_m31.o: src/ec/ec_all_m31.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/ec_all_m31.o src/ec/ec_all_m31.c - -$(BUILD)/ec_c25519_i15.o: src/ec/ec_c25519_i15.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/ec_c25519_i15.o src/ec/ec_c25519_i15.c - -$(BUILD)/ec_c25519_i31.o: src/ec/ec_c25519_i31.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/ec_c25519_i31.o src/ec/ec_c25519_i31.c - -$(BUILD)/ec_c25519_m15.o: src/ec/ec_c25519_m15.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/ec_c25519_m15.o src/ec/ec_c25519_m15.c - -$(BUILD)/ec_c25519_m31.o: src/ec/ec_c25519_m31.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/ec_c25519_m31.o src/ec/ec_c25519_m31.c - -$(BUILD)/ec_curve25519.o: src/ec/ec_curve25519.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/ec_curve25519.o src/ec/ec_curve25519.c - -$(BUILD)/ec_p256_m15.o: src/ec/ec_p256_m15.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/ec_p256_m15.o src/ec/ec_p256_m15.c - -$(BUILD)/ec_p256_m31.o: src/ec/ec_p256_m31.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/ec_p256_m31.o src/ec/ec_p256_m31.c - -$(BUILD)/ec_prime_i15.o: src/ec/ec_prime_i15.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/ec_prime_i15.o src/ec/ec_prime_i15.c - -$(BUILD)/ec_prime_i31.o: src/ec/ec_prime_i31.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/ec_prime_i31.o src/ec/ec_prime_i31.c - -$(BUILD)/ec_prime_i31_secp256r1.o: src/ec/ec_prime_i31_secp256r1.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/ec_prime_i31_secp256r1.o src/ec/ec_prime_i31_secp256r1.c - -$(BUILD)/ec_prime_i31_secp384r1.o: src/ec/ec_prime_i31_secp384r1.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/ec_prime_i31_secp384r1.o src/ec/ec_prime_i31_secp384r1.c - -$(BUILD)/ec_prime_i31_secp521r1.o: src/ec/ec_prime_i31_secp521r1.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/ec_prime_i31_secp521r1.o src/ec/ec_prime_i31_secp521r1.c - -$(BUILD)/ec_secp256r1.o: src/ec/ec_secp256r1.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/ec_secp256r1.o src/ec/ec_secp256r1.c - -$(BUILD)/ec_secp384r1.o: src/ec/ec_secp384r1.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/ec_secp384r1.o src/ec/ec_secp384r1.c - -$(BUILD)/ec_secp521r1.o: src/ec/ec_secp521r1.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/ec_secp521r1.o src/ec/ec_secp521r1.c - -$(BUILD)/ecdsa_atr.o: src/ec/ecdsa_atr.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/ecdsa_atr.o src/ec/ecdsa_atr.c - -$(BUILD)/ecdsa_i15_bits.o: src/ec/ecdsa_i15_bits.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/ecdsa_i15_bits.o src/ec/ecdsa_i15_bits.c - -$(BUILD)/ecdsa_i15_sign_asn1.o: src/ec/ecdsa_i15_sign_asn1.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/ecdsa_i15_sign_asn1.o src/ec/ecdsa_i15_sign_asn1.c - -$(BUILD)/ecdsa_i15_sign_raw.o: src/ec/ecdsa_i15_sign_raw.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/ecdsa_i15_sign_raw.o src/ec/ecdsa_i15_sign_raw.c - -$(BUILD)/ecdsa_i15_vrfy_asn1.o: src/ec/ecdsa_i15_vrfy_asn1.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/ecdsa_i15_vrfy_asn1.o src/ec/ecdsa_i15_vrfy_asn1.c - -$(BUILD)/ecdsa_i15_vrfy_raw.o: src/ec/ecdsa_i15_vrfy_raw.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/ecdsa_i15_vrfy_raw.o src/ec/ecdsa_i15_vrfy_raw.c - -$(BUILD)/ecdsa_i31_bits.o: src/ec/ecdsa_i31_bits.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/ecdsa_i31_bits.o src/ec/ecdsa_i31_bits.c - -$(BUILD)/ecdsa_i31_sign_asn1.o: src/ec/ecdsa_i31_sign_asn1.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/ecdsa_i31_sign_asn1.o src/ec/ecdsa_i31_sign_asn1.c - -$(BUILD)/ecdsa_i31_sign_raw.o: src/ec/ecdsa_i31_sign_raw.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/ecdsa_i31_sign_raw.o src/ec/ecdsa_i31_sign_raw.c - -$(BUILD)/ecdsa_i31_vrfy_asn1.o: src/ec/ecdsa_i31_vrfy_asn1.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/ecdsa_i31_vrfy_asn1.o src/ec/ecdsa_i31_vrfy_asn1.c - -$(BUILD)/ecdsa_i31_vrfy_raw.o: src/ec/ecdsa_i31_vrfy_raw.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/ecdsa_i31_vrfy_raw.o src/ec/ecdsa_i31_vrfy_raw.c - -$(BUILD)/ecdsa_rta.o: src/ec/ecdsa_rta.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/ecdsa_rta.o src/ec/ecdsa_rta.c - -$(BUILD)/dig_oid.o: src/hash/dig_oid.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/dig_oid.o src/hash/dig_oid.c - -$(BUILD)/dig_size.o: src/hash/dig_size.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/dig_size.o src/hash/dig_size.c - -$(BUILD)/ghash_ctmul.o: src/hash/ghash_ctmul.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/ghash_ctmul.o src/hash/ghash_ctmul.c - -$(BUILD)/ghash_ctmul32.o: src/hash/ghash_ctmul32.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/ghash_ctmul32.o src/hash/ghash_ctmul32.c - -$(BUILD)/ghash_ctmul64.o: src/hash/ghash_ctmul64.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/ghash_ctmul64.o src/hash/ghash_ctmul64.c - -$(BUILD)/md5.o: src/hash/md5.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/md5.o src/hash/md5.c - -$(BUILD)/md5sha1.o: src/hash/md5sha1.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/md5sha1.o src/hash/md5sha1.c - -$(BUILD)/multihash.o: src/hash/multihash.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/multihash.o src/hash/multihash.c - -$(BUILD)/sha1.o: src/hash/sha1.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/sha1.o src/hash/sha1.c - -$(BUILD)/sha2big.o: src/hash/sha2big.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/sha2big.o src/hash/sha2big.c - -$(BUILD)/sha2small.o: src/hash/sha2small.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/sha2small.o src/hash/sha2small.c - -$(BUILD)/i15_add.o: src/int/i15_add.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/i15_add.o src/int/i15_add.c - -$(BUILD)/i15_bitlen.o: src/int/i15_bitlen.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/i15_bitlen.o src/int/i15_bitlen.c - -$(BUILD)/i15_decmod.o: src/int/i15_decmod.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/i15_decmod.o src/int/i15_decmod.c - -$(BUILD)/i15_decode.o: src/int/i15_decode.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/i15_decode.o src/int/i15_decode.c - -$(BUILD)/i15_decred.o: src/int/i15_decred.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/i15_decred.o src/int/i15_decred.c - -$(BUILD)/i15_encode.o: src/int/i15_encode.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/i15_encode.o src/int/i15_encode.c - -$(BUILD)/i15_fmont.o: src/int/i15_fmont.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/i15_fmont.o src/int/i15_fmont.c - -$(BUILD)/i15_iszero.o: src/int/i15_iszero.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/i15_iszero.o src/int/i15_iszero.c - -$(BUILD)/i15_modpow.o: src/int/i15_modpow.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/i15_modpow.o src/int/i15_modpow.c - -$(BUILD)/i15_montmul.o: src/int/i15_montmul.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/i15_montmul.o src/int/i15_montmul.c - -$(BUILD)/i15_mulacc.o: src/int/i15_mulacc.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/i15_mulacc.o src/int/i15_mulacc.c - -$(BUILD)/i15_muladd.o: src/int/i15_muladd.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/i15_muladd.o src/int/i15_muladd.c - -$(BUILD)/i15_ninv15.o: src/int/i15_ninv15.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/i15_ninv15.o src/int/i15_ninv15.c - -$(BUILD)/i15_reduce.o: src/int/i15_reduce.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/i15_reduce.o src/int/i15_reduce.c - -$(BUILD)/i15_rshift.o: src/int/i15_rshift.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/i15_rshift.o src/int/i15_rshift.c - -$(BUILD)/i15_sub.o: src/int/i15_sub.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/i15_sub.o src/int/i15_sub.c - -$(BUILD)/i15_tmont.o: src/int/i15_tmont.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/i15_tmont.o src/int/i15_tmont.c - -$(BUILD)/i31_add.o: src/int/i31_add.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/i31_add.o src/int/i31_add.c - -$(BUILD)/i31_bitlen.o: src/int/i31_bitlen.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/i31_bitlen.o src/int/i31_bitlen.c - -$(BUILD)/i31_decmod.o: src/int/i31_decmod.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/i31_decmod.o src/int/i31_decmod.c - -$(BUILD)/i31_decode.o: src/int/i31_decode.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/i31_decode.o src/int/i31_decode.c - -$(BUILD)/i31_decred.o: src/int/i31_decred.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/i31_decred.o src/int/i31_decred.c - -$(BUILD)/i31_encode.o: src/int/i31_encode.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/i31_encode.o src/int/i31_encode.c - -$(BUILD)/i31_fmont.o: src/int/i31_fmont.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/i31_fmont.o src/int/i31_fmont.c - -$(BUILD)/i31_iszero.o: src/int/i31_iszero.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/i31_iszero.o src/int/i31_iszero.c - -$(BUILD)/i31_modpow.o: src/int/i31_modpow.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/i31_modpow.o src/int/i31_modpow.c - -$(BUILD)/i31_montmul.o: src/int/i31_montmul.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/i31_montmul.o src/int/i31_montmul.c - -$(BUILD)/i31_mulacc.o: src/int/i31_mulacc.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/i31_mulacc.o src/int/i31_mulacc.c - -$(BUILD)/i31_muladd.o: src/int/i31_muladd.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/i31_muladd.o src/int/i31_muladd.c - -$(BUILD)/i31_ninv31.o: src/int/i31_ninv31.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/i31_ninv31.o src/int/i31_ninv31.c - -$(BUILD)/i31_reduce.o: src/int/i31_reduce.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/i31_reduce.o src/int/i31_reduce.c - -$(BUILD)/i31_rshift.o: src/int/i31_rshift.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/i31_rshift.o src/int/i31_rshift.c - -$(BUILD)/i31_sub.o: src/int/i31_sub.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/i31_sub.o src/int/i31_sub.c - -$(BUILD)/i31_tmont.o: src/int/i31_tmont.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/i31_tmont.o src/int/i31_tmont.c - -$(BUILD)/i32_add.o: src/int/i32_add.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/i32_add.o src/int/i32_add.c - -$(BUILD)/i32_bitlen.o: src/int/i32_bitlen.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/i32_bitlen.o src/int/i32_bitlen.c - -$(BUILD)/i32_decmod.o: src/int/i32_decmod.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/i32_decmod.o src/int/i32_decmod.c - -$(BUILD)/i32_decode.o: src/int/i32_decode.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/i32_decode.o src/int/i32_decode.c - -$(BUILD)/i32_decred.o: src/int/i32_decred.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/i32_decred.o src/int/i32_decred.c - -$(BUILD)/i32_div32.o: src/int/i32_div32.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/i32_div32.o src/int/i32_div32.c - -$(BUILD)/i32_encode.o: src/int/i32_encode.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/i32_encode.o src/int/i32_encode.c - -$(BUILD)/i32_fmont.o: src/int/i32_fmont.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/i32_fmont.o src/int/i32_fmont.c - -$(BUILD)/i32_iszero.o: src/int/i32_iszero.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/i32_iszero.o src/int/i32_iszero.c - -$(BUILD)/i32_modpow.o: src/int/i32_modpow.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/i32_modpow.o src/int/i32_modpow.c - -$(BUILD)/i32_montmul.o: src/int/i32_montmul.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/i32_montmul.o src/int/i32_montmul.c - -$(BUILD)/i32_mulacc.o: src/int/i32_mulacc.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/i32_mulacc.o src/int/i32_mulacc.c - -$(BUILD)/i32_muladd.o: src/int/i32_muladd.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/i32_muladd.o src/int/i32_muladd.c - -$(BUILD)/i32_ninv32.o: src/int/i32_ninv32.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/i32_ninv32.o src/int/i32_ninv32.c - -$(BUILD)/i32_reduce.o: src/int/i32_reduce.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/i32_reduce.o src/int/i32_reduce.c - -$(BUILD)/i32_sub.o: src/int/i32_sub.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/i32_sub.o src/int/i32_sub.c - -$(BUILD)/i32_tmont.o: src/int/i32_tmont.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/i32_tmont.o src/int/i32_tmont.c - -$(BUILD)/hmac.o: src/mac/hmac.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/hmac.o src/mac/hmac.c - -$(BUILD)/hmac_ct.o: src/mac/hmac_ct.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/hmac_ct.o src/mac/hmac_ct.c - -$(BUILD)/hmac_drbg.o: src/rand/hmac_drbg.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/hmac_drbg.o src/rand/hmac_drbg.c - -$(BUILD)/rsa_i15_pkcs1_sign.o: src/rsa/rsa_i15_pkcs1_sign.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/rsa_i15_pkcs1_sign.o src/rsa/rsa_i15_pkcs1_sign.c - -$(BUILD)/rsa_i15_pkcs1_vrfy.o: src/rsa/rsa_i15_pkcs1_vrfy.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/rsa_i15_pkcs1_vrfy.o src/rsa/rsa_i15_pkcs1_vrfy.c - -$(BUILD)/rsa_i15_priv.o: src/rsa/rsa_i15_priv.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/rsa_i15_priv.o src/rsa/rsa_i15_priv.c - -$(BUILD)/rsa_i15_pub.o: src/rsa/rsa_i15_pub.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/rsa_i15_pub.o src/rsa/rsa_i15_pub.c - -$(BUILD)/rsa_i31_pkcs1_sign.o: src/rsa/rsa_i31_pkcs1_sign.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/rsa_i31_pkcs1_sign.o src/rsa/rsa_i31_pkcs1_sign.c - -$(BUILD)/rsa_i31_pkcs1_vrfy.o: src/rsa/rsa_i31_pkcs1_vrfy.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/rsa_i31_pkcs1_vrfy.o src/rsa/rsa_i31_pkcs1_vrfy.c - -$(BUILD)/rsa_i31_priv.o: src/rsa/rsa_i31_priv.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/rsa_i31_priv.o src/rsa/rsa_i31_priv.c - -$(BUILD)/rsa_i31_pub.o: src/rsa/rsa_i31_pub.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/rsa_i31_pub.o src/rsa/rsa_i31_pub.c - -$(BUILD)/rsa_i32_pkcs1_sign.o: src/rsa/rsa_i32_pkcs1_sign.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/rsa_i32_pkcs1_sign.o src/rsa/rsa_i32_pkcs1_sign.c - -$(BUILD)/rsa_i32_pkcs1_vrfy.o: src/rsa/rsa_i32_pkcs1_vrfy.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/rsa_i32_pkcs1_vrfy.o src/rsa/rsa_i32_pkcs1_vrfy.c - -$(BUILD)/rsa_i32_priv.o: src/rsa/rsa_i32_priv.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/rsa_i32_priv.o src/rsa/rsa_i32_priv.c - -$(BUILD)/rsa_i32_pub.o: src/rsa/rsa_i32_pub.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/rsa_i32_pub.o src/rsa/rsa_i32_pub.c - -$(BUILD)/rsa_pkcs1_sig_pad.o: src/rsa/rsa_pkcs1_sig_pad.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/rsa_pkcs1_sig_pad.o src/rsa/rsa_pkcs1_sig_pad.c - -$(BUILD)/rsa_pkcs1_sig_unpad.o: src/rsa/rsa_pkcs1_sig_unpad.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/rsa_pkcs1_sig_unpad.o src/rsa/rsa_pkcs1_sig_unpad.c - -$(BUILD)/rsa_ssl_decrypt.o: src/rsa/rsa_ssl_decrypt.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/rsa_ssl_decrypt.o src/rsa/rsa_ssl_decrypt.c - -$(BUILD)/prf.o: src/ssl/prf.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/prf.o src/ssl/prf.c - -$(BUILD)/prf_md5sha1.o: src/ssl/prf_md5sha1.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/prf_md5sha1.o src/ssl/prf_md5sha1.c - -$(BUILD)/prf_sha256.o: src/ssl/prf_sha256.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/prf_sha256.o src/ssl/prf_sha256.c - -$(BUILD)/prf_sha384.o: src/ssl/prf_sha384.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/prf_sha384.o src/ssl/prf_sha384.c - -$(BUILD)/ssl_ccert_single_ec.o: src/ssl/ssl_ccert_single_ec.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/ssl_ccert_single_ec.o src/ssl/ssl_ccert_single_ec.c - -$(BUILD)/ssl_ccert_single_rsa.o: src/ssl/ssl_ccert_single_rsa.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/ssl_ccert_single_rsa.o src/ssl/ssl_ccert_single_rsa.c - -$(BUILD)/ssl_client.o: src/ssl/ssl_client.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/ssl_client.o src/ssl/ssl_client.c - -$(BUILD)/ssl_client_full.o: src/ssl/ssl_client_full.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/ssl_client_full.o src/ssl/ssl_client_full.c - -$(BUILD)/ssl_engine.o: src/ssl/ssl_engine.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/ssl_engine.o src/ssl/ssl_engine.c - -$(BUILD)/ssl_hashes.o: src/ssl/ssl_hashes.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/ssl_hashes.o src/ssl/ssl_hashes.c - -$(BUILD)/ssl_hs_client.o: src/ssl/ssl_hs_client.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/ssl_hs_client.o src/ssl/ssl_hs_client.c - -$(BUILD)/ssl_hs_server.o: src/ssl/ssl_hs_server.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/ssl_hs_server.o src/ssl/ssl_hs_server.c - -$(BUILD)/ssl_io.o: src/ssl/ssl_io.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/ssl_io.o src/ssl/ssl_io.c - -$(BUILD)/ssl_lru.o: src/ssl/ssl_lru.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/ssl_lru.o src/ssl/ssl_lru.c - -$(BUILD)/ssl_rec_cbc.o: src/ssl/ssl_rec_cbc.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/ssl_rec_cbc.o src/ssl/ssl_rec_cbc.c - -$(BUILD)/ssl_rec_chapol.o: src/ssl/ssl_rec_chapol.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/ssl_rec_chapol.o src/ssl/ssl_rec_chapol.c - -$(BUILD)/ssl_rec_gcm.o: src/ssl/ssl_rec_gcm.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/ssl_rec_gcm.o src/ssl/ssl_rec_gcm.c - -$(BUILD)/ssl_server.o: src/ssl/ssl_server.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/ssl_server.o src/ssl/ssl_server.c - -$(BUILD)/ssl_server_mine2c.o: src/ssl/ssl_server_mine2c.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/ssl_server_mine2c.o src/ssl/ssl_server_mine2c.c - -$(BUILD)/ssl_server_mine2g.o: src/ssl/ssl_server_mine2g.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/ssl_server_mine2g.o src/ssl/ssl_server_mine2g.c - -$(BUILD)/ssl_server_minf2c.o: src/ssl/ssl_server_minf2c.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/ssl_server_minf2c.o src/ssl/ssl_server_minf2c.c - -$(BUILD)/ssl_server_minf2g.o: src/ssl/ssl_server_minf2g.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/ssl_server_minf2g.o src/ssl/ssl_server_minf2g.c - -$(BUILD)/ssl_server_minr2g.o: src/ssl/ssl_server_minr2g.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/ssl_server_minr2g.o src/ssl/ssl_server_minr2g.c - -$(BUILD)/ssl_server_minu2g.o: src/ssl/ssl_server_minu2g.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/ssl_server_minu2g.o src/ssl/ssl_server_minu2g.c - -$(BUILD)/ssl_server_minv2g.o: src/ssl/ssl_server_minv2g.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/ssl_server_minv2g.o src/ssl/ssl_server_minv2g.c - -$(BUILD)/ssl_server_full_ec.o: src/ssl/ssl_server_full_ec.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/ssl_server_full_ec.o src/ssl/ssl_server_full_ec.c - -$(BUILD)/ssl_server_full_rsa.o: src/ssl/ssl_server_full_rsa.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/ssl_server_full_rsa.o src/ssl/ssl_server_full_rsa.c - -$(BUILD)/ssl_scert_single_ec.o: src/ssl/ssl_scert_single_ec.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/ssl_scert_single_ec.o src/ssl/ssl_scert_single_ec.c - -$(BUILD)/ssl_scert_single_rsa.o: src/ssl/ssl_scert_single_rsa.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/ssl_scert_single_rsa.o src/ssl/ssl_scert_single_rsa.c - -$(BUILD)/aes_big_cbcdec.o: src/symcipher/aes_big_cbcdec.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/aes_big_cbcdec.o src/symcipher/aes_big_cbcdec.c - -$(BUILD)/aes_big_cbcenc.o: src/symcipher/aes_big_cbcenc.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/aes_big_cbcenc.o src/symcipher/aes_big_cbcenc.c - -$(BUILD)/aes_big_ctr.o: src/symcipher/aes_big_ctr.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/aes_big_ctr.o src/symcipher/aes_big_ctr.c - -$(BUILD)/aes_big_dec.o: src/symcipher/aes_big_dec.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/aes_big_dec.o src/symcipher/aes_big_dec.c - -$(BUILD)/aes_big_enc.o: src/symcipher/aes_big_enc.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/aes_big_enc.o src/symcipher/aes_big_enc.c - -$(BUILD)/aes_common.o: src/symcipher/aes_common.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/aes_common.o src/symcipher/aes_common.c - -$(BUILD)/aes_ct.o: src/symcipher/aes_ct.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/aes_ct.o src/symcipher/aes_ct.c - -$(BUILD)/aes_ct64.o: src/symcipher/aes_ct64.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/aes_ct64.o src/symcipher/aes_ct64.c - -$(BUILD)/aes_ct64_cbcdec.o: src/symcipher/aes_ct64_cbcdec.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/aes_ct64_cbcdec.o src/symcipher/aes_ct64_cbcdec.c - -$(BUILD)/aes_ct64_cbcenc.o: src/symcipher/aes_ct64_cbcenc.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/aes_ct64_cbcenc.o src/symcipher/aes_ct64_cbcenc.c - -$(BUILD)/aes_ct64_ctr.o: src/symcipher/aes_ct64_ctr.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/aes_ct64_ctr.o src/symcipher/aes_ct64_ctr.c - -$(BUILD)/aes_ct64_dec.o: src/symcipher/aes_ct64_dec.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/aes_ct64_dec.o src/symcipher/aes_ct64_dec.c - -$(BUILD)/aes_ct64_enc.o: src/symcipher/aes_ct64_enc.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/aes_ct64_enc.o src/symcipher/aes_ct64_enc.c - -$(BUILD)/aes_ct_cbcdec.o: src/symcipher/aes_ct_cbcdec.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/aes_ct_cbcdec.o src/symcipher/aes_ct_cbcdec.c - -$(BUILD)/aes_ct_cbcenc.o: src/symcipher/aes_ct_cbcenc.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/aes_ct_cbcenc.o src/symcipher/aes_ct_cbcenc.c - -$(BUILD)/aes_ct_ctr.o: src/symcipher/aes_ct_ctr.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/aes_ct_ctr.o src/symcipher/aes_ct_ctr.c - -$(BUILD)/aes_ct_dec.o: src/symcipher/aes_ct_dec.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/aes_ct_dec.o src/symcipher/aes_ct_dec.c - -$(BUILD)/aes_ct_enc.o: src/symcipher/aes_ct_enc.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/aes_ct_enc.o src/symcipher/aes_ct_enc.c - -$(BUILD)/aes_small_cbcdec.o: src/symcipher/aes_small_cbcdec.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/aes_small_cbcdec.o src/symcipher/aes_small_cbcdec.c - -$(BUILD)/aes_small_cbcenc.o: src/symcipher/aes_small_cbcenc.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/aes_small_cbcenc.o src/symcipher/aes_small_cbcenc.c - -$(BUILD)/aes_small_ctr.o: src/symcipher/aes_small_ctr.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/aes_small_ctr.o src/symcipher/aes_small_ctr.c - -$(BUILD)/aes_small_dec.o: src/symcipher/aes_small_dec.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/aes_small_dec.o src/symcipher/aes_small_dec.c - -$(BUILD)/aes_small_enc.o: src/symcipher/aes_small_enc.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/aes_small_enc.o src/symcipher/aes_small_enc.c - -$(BUILD)/chacha20_ct.o: src/symcipher/chacha20_ct.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/chacha20_ct.o src/symcipher/chacha20_ct.c - -$(BUILD)/des_ct.o: src/symcipher/des_ct.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/des_ct.o src/symcipher/des_ct.c - -$(BUILD)/des_ct_cbcdec.o: src/symcipher/des_ct_cbcdec.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/des_ct_cbcdec.o src/symcipher/des_ct_cbcdec.c - -$(BUILD)/des_ct_cbcenc.o: src/symcipher/des_ct_cbcenc.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/des_ct_cbcenc.o src/symcipher/des_ct_cbcenc.c - -$(BUILD)/des_support.o: src/symcipher/des_support.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/des_support.o src/symcipher/des_support.c - -$(BUILD)/des_tab.o: src/symcipher/des_tab.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/des_tab.o src/symcipher/des_tab.c - -$(BUILD)/des_tab_cbcdec.o: src/symcipher/des_tab_cbcdec.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/des_tab_cbcdec.o src/symcipher/des_tab_cbcdec.c - -$(BUILD)/des_tab_cbcenc.o: src/symcipher/des_tab_cbcenc.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/des_tab_cbcenc.o src/symcipher/des_tab_cbcenc.c - -$(BUILD)/poly1305_ctmul.o: src/symcipher/poly1305_ctmul.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/poly1305_ctmul.o src/symcipher/poly1305_ctmul.c - -$(BUILD)/poly1305_ctmul32.o: src/symcipher/poly1305_ctmul32.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/poly1305_ctmul32.o src/symcipher/poly1305_ctmul32.c - -$(BUILD)/poly1305_i15.o: src/symcipher/poly1305_i15.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/poly1305_i15.o src/symcipher/poly1305_i15.c - -$(BUILD)/skey_decoder.o: src/x509/skey_decoder.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/skey_decoder.o src/x509/skey_decoder.c - -$(BUILD)/x509_decoder.o: src/x509/x509_decoder.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/x509_decoder.o src/x509/x509_decoder.c - -$(BUILD)/x509_knownkey.o: src/x509/x509_knownkey.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/x509_knownkey.o src/x509/x509_knownkey.c - -$(BUILD)/x509_minimal.o: src/x509/x509_minimal.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/x509_minimal.o src/x509/x509_minimal.c - -$(BUILD)/x509_minimal_full.o: src/x509/x509_minimal_full.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/x509_minimal_full.o src/x509/x509_minimal_full.c - -$(BUILD)/test_crypto.o: test/test_crypto.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/test_crypto.o test/test_crypto.c - -$(BUILD)/test_math.o: test/test_math.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/test_math.o test/test_math.c - -$(BUILD)/test_speed.o: test/test_speed.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/test_speed.o test/test_speed.c - -$(BUILD)/test_x509.o: test/test_x509.c $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/test_x509.o test/test_x509.c - -$(BUILD)/brssl.o: tools/brssl.c tools/brssl.h $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/brssl.o tools/brssl.c - -$(BUILD)/certs.o: tools/certs.c tools/brssl.h $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/certs.o tools/certs.c - -$(BUILD)/chain.o: tools/chain.c tools/brssl.h $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/chain.o tools/chain.c - -$(BUILD)/client.o: tools/client.c tools/brssl.h $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/client.o tools/client.c - -$(BUILD)/errors.o: tools/errors.c tools/brssl.h $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/errors.o tools/errors.c - -$(BUILD)/files.o: tools/files.c tools/brssl.h $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/files.o tools/files.c - -$(BUILD)/keys.o: tools/keys.c tools/brssl.h $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/keys.o tools/keys.c - -$(BUILD)/names.o: tools/names.c tools/brssl.h $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/names.o tools/names.c - -$(BUILD)/server.o: tools/server.c tools/brssl.h $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/server.o tools/server.c - -$(BUILD)/skey.o: tools/skey.c tools/brssl.h $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/skey.o tools/skey.c - -$(BUILD)/sslio.o: tools/sslio.c tools/brssl.h $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/sslio.o tools/sslio.c - -$(BUILD)/ta.o: tools/ta.c tools/brssl.h $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/ta.o tools/ta.c - -$(BUILD)/vector.o: tools/vector.c tools/brssl.h $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/vector.o tools/vector.c - -$(BUILD)/verify.o: tools/verify.c tools/brssl.h $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/verify.o tools/verify.c - -$(BUILD)/xmem.o: tools/xmem.c tools/brssl.h $(HEADERS) - $(CC) $(CFLAGS) -c -o $(BUILD)/xmem.o tools/xmem.c +include mk/SingleUnix.mk +# \ +!endif diff --git a/README.txt b/README.txt index e72537d..a440e29 100644 --- a/README.txt +++ b/README.txt @@ -1,3 +1,8 @@ +# Documentation + +The most up-to-date documentation is supposed to be available on the +[BearSSL Web site](https://www.bearssl.org/). + # Disclaimer BearSSL is for now considered alpha-level software. This means that it @@ -27,61 +32,81 @@ The usage license is explicited in the `LICENSE.txt` file. This is the # Installation -As of version 0.1, BearSSL is a simple static library. Most of the -process is rather manual and old-style, and there is no installer (this -will be added in a later version, in particular when all the man pages -for BearSSL functions are written). - - 1. Have a look at the top of the `Makefile`. There you can configure the - command names and flags for invoking the C compiler, linker, and - static library archiver. - - 2. There are a few configurable switches in `src/config.h`. These switches - relate to compile-time options, e.g. support of a system-provided - random source. On usual platforms (e.g. Linux or OS X), auto-detection - should work, but you can always override things with `config.h`. - - 3. Type `make`. This should produce the static library (`libbearssl.a`), - the test executables (`testcrypto`, `testspeed` and `testx509`), and - the command-line debug tool (`brssl`). You might want to run the tests: - - - `testcrypto all` runs the cryptographic tests (test vectors on all - implemented cryptogaphic functions). It can be slow. - - - `testspeed all` runs a number of performance benchmarks, there again - on cryptographic functions. It gives a taste of how things go on the - current platform. - - - `testx509` runs X.509 validation tests. The test certificates are - all in `test/x509/`. - - 4. The `brssl` command-line tool is a stand-alone binary. It can exercise - some of the functionalities of BearSSL, in particular running a test - SSL client or server. It is not meant for production purposes (e.g. - the SSL client has a mode where it disregards the inability to validate - the server's certificate, which is inherently unsafe, but convenient - for debug). - - 5. Using the library means writing some application code that invokes it, - and linking with the static library. The header files are all in the - `inc` directory; copy them wherever makes sense (e.g. in the - `/usr/local/include` directory). The library itself (`libbearssl.a`) - is what you link against. - - Alternatively, you may want to copy the source files directly into - your own application code. This will make integrating ulterior versions - of BearSSL more difficult. If you still want to go down that road, - then simply copy all the `*.h` and `*.c` files from the `src` and `inc` - directories into your application source code. In the BearSSL source - archive, the source files are segregated into various sub-directories, - but this is for my convenience only. There is no technical requirement - for that, and all files can be dumped together in a simple directory. - - Dependencies are simple and systematic: - - - Each `*.c` file includes `inner.h` - - `inner.h` includes `config.h` and `bearssl.h` - - `bearssl.h` includes the other `bearssl_*.h` +Right now, BearSSL is a simple library, along with a few test and debug +command-line tools. There is no installer yet. The library _can_ be +compiled as a shared library on some systems, but since the binary API +is not fully stabilised, this is not a very good idea to do that right +now. + +To compile the code, just type `make`. This will try to use sane +"default" values. On a Windows system with Visual Studio, run a console +with the environment initialised for a specific version of the C compiler, +and type `nmake`. + +To override the default settings, create a custom configuration file in +the `conf` directory, and invoke `make` (or `nmake`) with an explicit +`CONF=` parameter. For instance, to use the provided `samd20.mk` +configuration file (that targets cross-compilation for an Atmel board +that features a Cortex-M0+ CPU), type: + + make CONF=samd20 + +The `conf/samd20.mk` file includes the `Unix.mk` file and then overrides +some of the parameters, including the destination directory. Any custom +configuration can be made the same way. + +Some compile-time options can be set through macros, either on the +compiler command-line, or in the `src/config.h` file. See the comments +in that file. Some settings are autodetected but they can still be +explicitly overridden. + +When compilation is done, the library (static and DLL, when appropriate) +and the command-line tools can be found in the designated build +directory (by default named `build`). The public headers (to be used +by applications linked against BearSSL) are in the `inc/` directory. + +To run the tests: + + - `testcrypto all` runs the cryptographic tests (test vectors on all + implemented cryptogaphic functions). It can be slow. You can also + run a selection of the tests by providing their names (run + `testcrypto` without any parameter to see the available names). + + - `testspeed all` runs a number of performance benchmarks, there again + on cryptographic functions. It gives a taste of how things go on the + current platform. As for `testcrypto`, specific named benchmarks can + be executed. + + - `testx509` runs X.509 validation tests. The test certificates are + all in `test/x509/`. + +The `brssl` command-line tool produced in the build directory is a +stand-alone binary. It can exercise some of the functionalities of +BearSSL, in particular running a test SSL client or server. It is not +meant for production purposes (e.g. the SSL client has a mode where it +disregards the inability to validate the server's certificate, which is +inherently unsafe, but convenient for debug). + +**Using the library** means writing some application code that invokes +it, and linking with the static library. The header files are all in the +`inc` directory; copy them wherever makes sense (e.g. in the +`/usr/local/include` directory). The library itself (`libbearssl.a`) is +what you link against. + +Alternatively, you may want to copy the source files directly into your +own application code. This will make integrating ulterior versions of +BearSSL more difficult. If you still want to go down that road, then +simply copy all the `*.h` and `*.c` files from the `src` and `inc` +directories into your application source code. In the BearSSL source +archive, the source files are segregated into various sub-directories, +but this is for my convenience only. There is no technical requirement +for that, and all files can be dumped together in a simple directory. + +Dependencies are simple and systematic: + + - Each `*.c` file includes `inner.h` + - `inner.h` includes `config.h` and `bearssl.h` + - `bearssl.h` includes the other `bearssl_*.h` # Versioning @@ -108,62 +133,3 @@ I follow this simple version numbering scheme: it can be expected that `1.3` will contain some extra functions when compared to `1.2`. The next version level (the `z` part) is for bugfixes that do not add any functionality. - -# API Usage - -Right now there is little documentation. The following principles are -maintained: - - - All public symbols (global functions and data elements, macros) have - a name that starts with `br_` or `BR_`. - - - The header files (the `bearssl_*.h` in the `inc` directory) contain - for now the most complete documentation (as comments). - - - Context structures are allocated by the caller. BearSSL does not - contain any single `malloc()` call; this means that there is no - "freeing up" call to be done. When you don't need some BearSSL - functionality, just cease to call it, and that's it. - - - BearSSL contains no modifiable static data. It is thus thread-safe - and reentrant, _for distinct contexts_. Accessing the same context - structure from distinct threads, though, is a recipe for disaster. - - - The main SSL I/O API is organised as a state machine. A running - SSL engine (client or server) has four I/O ports: - - - It can receive bytes from the transport medium ("record data"). - - It can send bytes to the transport medium. - - It can receive application data, to be sent to the peer through - the SSL tunnel. - - It can produce application data, built from the records sent by - the peer. - - BearSSL never performs I/O by itself; it expects the caller to - provide or retrieve the data. Each port consists in a pair of - functions: one yields the pointer to the buffer from which data - can be read or to which data can be written, and the maximum - size for such an operation; the other function is used to - inform the engine about how many bytes were actually read or - written. - - For instance, if the `br_ssl_engine_sendrec_buf()` function returns a - non-NULL pointer, then this means that there are bytes to be sent to - the transport medium. When the caller has indeed sent some or all of - these bytes, it informs the engine with - `br_ssl_engine_sendrec_ack()`. - - This state-machine API means that the engine never blocks. Each - invocation may trigger computations, but will always return as - promptly as the CPU power allows. All the I/O waiting is supposed to - be done on the outside. This structure allows managing several - concurrent SSL engines, along with other I/O tasks, with a single - mono-threaded loop using `select()` or `poll()`. It also makes it - easier to integrate BearSSL with various transport mechanisms (e.g. - messages in the EAP-TLS authentication framework). - - - Nevertheless, there are situations where simple blocking calls _can_ - be used, and are convenient. For these situations, use the - `br_sslio_context` wrapper. Then do blocking reads and writes with - `br_sslio_read()` and similar functions. The sample client code - in `samples/client_basic.c` shows how such things are done. diff --git a/T0/T0Comp.cs b/T0/T0Comp.cs index 20adc04..7a397f7 100644 --- a/T0/T0Comp.cs +++ b/T0/T0Comp.cs @@ -251,6 +251,12 @@ public class T0Comp { */ List extraCode; + /* + * 'extraCodeDefer' is for C code that is to be added in the C + * output _after_ the data and code blocks. + */ + List extraCodeDefer; + /* * 'dataBlock' is the data block in which constant data bytes * are accumulated. @@ -287,6 +293,7 @@ public class T0Comp { StringComparer.Ordinal); compiling = false; extraCode = new List(); + extraCodeDefer = new List(); enableFlowAnalysis = true; /* @@ -348,6 +355,15 @@ public class T0Comp { extraCode.Add(ParseCCode()); }); + /* + * postamble + * Parses a C code snippet, then adds it to the generated + * output after the data and code blocks. + */ + AddNative("postamble", false, SType.BLANK, cpu => { + extraCodeDefer.Add(ParseCCode()); + }); + /* * make-CX * Expects two integers and a string, and makes a @@ -1729,7 +1745,7 @@ t0_parse7E_signed(const unsigned char **p) #define T0_INT4(x) T0_VBYTE(x, 21), T0_VBYTE(x, 14), T0_VBYTE(x, 7), T0_FBYTE(x, 0) #define T0_INT5(x) T0_SBYTE(x), T0_VBYTE(x, 21), T0_VBYTE(x, 14), T0_VBYTE(x, 7), T0_FBYTE(x, 0) -static const uint8_t t0_datablock[]; +/* static const unsigned char t0_datablock[]; */ "); /* @@ -1757,7 +1773,8 @@ static const uint8_t t0_datablock[]; BlobWriter bw; tw.WriteLine(); - tw.Write("static const uint8_t t0_datablock[] = {"); + tw.Write("static const unsigned char" + + " t0_datablock[] = {"); bw = new BlobWriter(tw, 78, 1); bw.Append((byte)0); foreach (ConstData cd in blocks.Values) { @@ -1767,7 +1784,8 @@ static const uint8_t t0_datablock[]; tw.WriteLine("};"); tw.WriteLine(); - tw.Write("static const uint8_t t0_codeblock[] = {"); + tw.Write("static const unsigned char" + + " t0_codeblock[] = {"); bw = new BlobWriter(tw, 78, 1); foreach (CodeElement ce in gcode) { ce.Encode(bw, oneByteCode); @@ -1952,6 +1970,17 @@ t0_exit: ((t0_context *)t0ctx)->rp = rp; ((t0_context *)t0ctx)->ip = ip; }"); + + /* + * Add the "postamblr" elements here. These are + * elements that may need access to the data + * block or code block, so they must occur after + * their definition. + */ + foreach (string pp in extraCodeDefer) { + tw.WriteLine(); + tw.WriteLine("{0}", pp); + } } int codeLen = 0; diff --git a/T0Comp.exe b/T0Comp.exe index b951fab..80b7791 100755 Binary files a/T0Comp.exe and b/T0Comp.exe differ diff --git a/conf/Unix.mk b/conf/Unix.mk new file mode 100644 index 0000000..a9b6450 --- /dev/null +++ b/conf/Unix.mk @@ -0,0 +1,69 @@ +# Configuration for a native build on a generic Unix-like system. + +# Build directory. +BUILD = build + +# Extension for executable files. +E = + +# Extension for object files. +O = .o + +# Prefix for library file name. +LP = lib + +# Extension for library file name. +L = .a + +# Prefix for DLL file name. +DP = lib + +# Extension for DLL file name. +D = .so + +# Output file names can be overridden directly. By default, they are +# assembled using the prefix/extension macros defined above. +# BEARSSLLIB = libbearssl.a +# BEARSSLDLL = libbearssl.so +# BRSSL = brssl +# TESTCRYPTO = testcrypto +# TESTSPEED = testspeed +# TESTX509 = testx509 + +# File deletion tool. +RM = rm -f + +# Directory creation tool. +MKDIR = mkdir -p + +# C compiler and flags. +CC = gcc +CFLAGS = -W -Wall -Os -fPIC +CCOUT = -c -o + +# Static library building tool. +AR = ar +ARFLAGS = -rcs +AROUT = + +# DLL building tool. +LDDLL = gcc +LDDLLFLAGS = -shared +LDDLLOUT = -o + +# Static linker. +LD = gcc +LDFLAGS = +LDOUT = -o + +# C# compiler; we assume usage of Mono. +MKT0COMP = mk$PmkT0.sh +RUNT0COMP = mono T0Comp.exe + +# Set the values to 'no' to disable building of the corresponding element +# by default. Building can still be invoked with an explicit target call +# (e.g. 'make dll' to force build the DLL). +#STATICLIB = no +#DLL = no +#TOOLS = no +#TESTS = no diff --git a/conf/Win.mk b/conf/Win.mk new file mode 100644 index 0000000..2ed4bb6 --- /dev/null +++ b/conf/Win.mk @@ -0,0 +1,70 @@ +# Configuration for a native build on a Windows system with Visual Studio. + +# Build directory. +BUILD = build + +# Extension for executable files. +E = .exe + +# Extension for object files. +O = .obj + +# Prefix for static library file name. +LP = + +# Extension for static library file name. We add an 's' so that the +# name is distinct from the 'import library' generated along with the DLL. +L = s.lib + +# Prefix for DLL file name. +DP = + +# Extension for DLL file name. +D = .dll + +# Output file names can be overridden directly. By default, they are +# assembled using the prefix/extension macros defined above. +# BEARSSLLIB = bearssls.lib +# BEARSSLDLL = bearssl.dll +# BRSSL = brssl.exe +# TESTCRYPTO = testcrypto.exe +# TESTSPEED = testspeed.exe +# TESTX509 = testx509.exe + +# File deletion tool. +RM = del /Q + +# Directory creation tool. +MKDIR = mkdir + +# C compiler and flags. +CC = cl +CFLAGS = -nologo -W2 -O2 +CCOUT = -c -Fo + +# Static library building tool. +AR = lib +ARFLAGS = -nologo +AROUT = -out: + +# DLL building tool. +LDDLL = cl +LDDLLFLAGS = -nologo -LD -MT +LDDLLOUT = -Fe + +# Static linker. +LD = cl +LDFLAGS = -nologo +LDOUT = -Fe + +# C# compiler. +MKT0COMP = mk$PmkT0.cmd +RUNT0COMP = T0Comp.exe + +# Set the values to 'no' to disable building of the corresponding element +# by default. Building can still be invoked with an explicit target call +# (e.g. 'make dll' to force build the DLL). +#STATICLIB = no +#DLL = no +#TOOLS = no +#TESTS = no diff --git a/conf/samd20.mk b/conf/samd20.mk new file mode 100644 index 0000000..acb6272 --- /dev/null +++ b/conf/samd20.mk @@ -0,0 +1,20 @@ +# Example configuration file for compiling for an Atmel SAM D20 Xplained +# Pro evaluation kit, on a Unix-like system, with a GNU toolchain. + +# We are on a Unix system so we assume a Single Unix compatible 'make' +# utility, and Unix defaults. +include conf/Unix.mk + +# We override the build directory. +BUILD = samd20 + +# C compiler, linker, and static library builder. +CC = arm-none-eabi-gcc +CFLAGS = -W -Wall -Os -mthumb -ffunction-sections -fdata-sections -mcpu=cortex-m0plus +LD = arm-none-eabi-gcc +AR = arm-none-eabi-ar + +# We compile only the static library. +DLL = no +TOOLS = no +TESTS = no diff --git a/inc/bearssl_block.h b/inc/bearssl_block.h index eb20c8c..6641e6c 100644 --- a/inc/bearssl_block.h +++ b/inc/bearssl_block.h @@ -1000,10 +1000,10 @@ uint32_t br_aes_ct64_ctr_run(const br_aes_ct64_ctr_keys *ctx, */ typedef union { const br_block_cbcenc_class *vtable; - br_aes_big_cbcenc_keys big; - br_aes_small_cbcenc_keys small; - br_aes_ct_cbcenc_keys ct; - br_aes_ct64_cbcenc_keys ct64; + br_aes_big_cbcenc_keys c_big; + br_aes_small_cbcenc_keys c_small; + br_aes_ct_cbcenc_keys c_ct; + br_aes_ct64_cbcenc_keys c_ct64; } br_aes_gen_cbcenc_keys; /** @@ -1012,10 +1012,10 @@ typedef union { */ typedef union { const br_block_cbcdec_class *vtable; - br_aes_big_cbcdec_keys big; - br_aes_small_cbcdec_keys small; - br_aes_ct_cbcdec_keys ct; - br_aes_ct64_cbcdec_keys ct64; + br_aes_big_cbcdec_keys c_big; + br_aes_small_cbcdec_keys c_small; + br_aes_ct_cbcdec_keys c_ct; + br_aes_ct64_cbcdec_keys c_ct64; } br_aes_gen_cbcdec_keys; /** @@ -1024,10 +1024,10 @@ typedef union { */ typedef union { const br_block_ctr_class *vtable; - br_aes_big_ctr_keys big; - br_aes_small_ctr_keys small; - br_aes_ct_ctr_keys ct; - br_aes_ct64_ctr_keys ct64; + br_aes_big_ctr_keys c_big; + br_aes_small_ctr_keys c_small; + br_aes_ct_ctr_keys c_ct; + br_aes_ct64_ctr_keys c_ct64; } br_aes_gen_ctr_keys; /* @@ -1235,8 +1235,8 @@ typedef union { */ typedef union { const br_block_cbcdec_class *vtable; - br_des_tab_cbcdec_keys tab; - br_des_ct_cbcdec_keys ct; + br_des_tab_cbcdec_keys c_tab; + br_des_ct_cbcdec_keys c_ct; } br_des_gen_cbcdec_keys; /** diff --git a/mk/Defaults.mk b/mk/Defaults.mk new file mode 100644 index 0000000..4c66025 --- /dev/null +++ b/mk/Defaults.mk @@ -0,0 +1,41 @@ +# Copyright (c) 2017 Thomas Pornin +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS +# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +# ====================================================================== + +# This file sets variables with generic default values, which can be +# overridden in the selected configuration file. + +BUILD = build +OBJDIR = $(BUILD)$Pobj +BEARSSLLIB = $(BUILD)$P$(LP)bearssl$L +BEARSSLDLL = $(BUILD)$P$(DP)bearssl$D +BRSSL = $(BUILD)$Pbrssl$E +TESTCRYPTO = $(BUILD)$Ptestcrypto$E +TESTSPEED = $(BUILD)$Ptestspeed$E +TESTX509 = $(BUILD)$Ptestx509$E +INCFLAGS = -Isrc -Iinc +T0COMP = T0Comp.exe +STATICLIB = lib +DLL = dll +TOOLS = tools +TESTS = tests diff --git a/mk/NMake.mk b/mk/NMake.mk new file mode 100644 index 0000000..7a53704 --- /dev/null +++ b/mk/NMake.mk @@ -0,0 +1,38 @@ +# Copyright (c) 2017 Thomas Pornin +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS +# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +# ====================================================================== + +# This file sets variables for use with NMake.exe, as distributed with +# Visual Studio. + +# Load generic defaults. +!include mk/Defaults.mk + +# Default configuration is 'Win' (native build with Visual Studio). +CONF = Win + +# Path separator. +P = ^\ + +!include conf/$(CONF).mk +!include mk/Rules.mk diff --git a/mk/Rules.mk b/mk/Rules.mk new file mode 100644 index 0000000..d2e0957 --- /dev/null +++ b/mk/Rules.mk @@ -0,0 +1,678 @@ +# Automatically generated rules. Use 'mkrules.sh' to modify/regenerate. + +OBJ = $(OBJDIR)$Pccopy$O $(OBJDIR)$Pdec16be$O $(OBJDIR)$Pdec16le$O $(OBJDIR)$Pdec32be$O $(OBJDIR)$Pdec32le$O $(OBJDIR)$Pdec64be$O $(OBJDIR)$Pdec64le$O $(OBJDIR)$Penc16be$O $(OBJDIR)$Penc16le$O $(OBJDIR)$Penc32be$O $(OBJDIR)$Penc32le$O $(OBJDIR)$Penc64be$O $(OBJDIR)$Penc64le$O $(OBJDIR)$Ppemdec$O $(OBJDIR)$Pec_all_m15$O $(OBJDIR)$Pec_all_m31$O $(OBJDIR)$Pec_c25519_i15$O $(OBJDIR)$Pec_c25519_i31$O $(OBJDIR)$Pec_c25519_m15$O $(OBJDIR)$Pec_c25519_m31$O $(OBJDIR)$Pec_curve25519$O $(OBJDIR)$Pec_p256_m15$O $(OBJDIR)$Pec_p256_m31$O $(OBJDIR)$Pec_prime_i15$O $(OBJDIR)$Pec_prime_i31$O $(OBJDIR)$Pec_secp256r1$O $(OBJDIR)$Pec_secp384r1$O $(OBJDIR)$Pec_secp521r1$O $(OBJDIR)$Pecdsa_atr$O $(OBJDIR)$Pecdsa_i15_bits$O $(OBJDIR)$Pecdsa_i15_sign_asn1$O $(OBJDIR)$Pecdsa_i15_sign_raw$O $(OBJDIR)$Pecdsa_i15_vrfy_asn1$O $(OBJDIR)$Pecdsa_i15_vrfy_raw$O $(OBJDIR)$Pecdsa_i31_bits$O $(OBJDIR)$Pecdsa_i31_sign_asn1$O $(OBJDIR)$Pecdsa_i31_sign_raw$O $(OBJDIR)$Pecdsa_i31_vrfy_asn1$O $(OBJDIR)$Pecdsa_i31_vrfy_raw$O $(OBJDIR)$Pecdsa_rta$O $(OBJDIR)$Pdig_oid$O $(OBJDIR)$Pdig_size$O $(OBJDIR)$Pghash_ctmul$O $(OBJDIR)$Pghash_ctmul32$O $(OBJDIR)$Pghash_ctmul64$O $(OBJDIR)$Pmd5$O $(OBJDIR)$Pmd5sha1$O $(OBJDIR)$Pmultihash$O $(OBJDIR)$Psha1$O $(OBJDIR)$Psha2big$O $(OBJDIR)$Psha2small$O $(OBJDIR)$Pi15_add$O $(OBJDIR)$Pi15_bitlen$O $(OBJDIR)$Pi15_decmod$O $(OBJDIR)$Pi15_decode$O $(OBJDIR)$Pi15_decred$O $(OBJDIR)$Pi15_encode$O $(OBJDIR)$Pi15_fmont$O $(OBJDIR)$Pi15_iszero$O $(OBJDIR)$Pi15_modpow$O $(OBJDIR)$Pi15_montmul$O $(OBJDIR)$Pi15_mulacc$O $(OBJDIR)$Pi15_muladd$O $(OBJDIR)$Pi15_ninv15$O $(OBJDIR)$Pi15_reduce$O $(OBJDIR)$Pi15_rshift$O $(OBJDIR)$Pi15_sub$O $(OBJDIR)$Pi15_tmont$O $(OBJDIR)$Pi31_add$O $(OBJDIR)$Pi31_bitlen$O $(OBJDIR)$Pi31_decmod$O $(OBJDIR)$Pi31_decode$O $(OBJDIR)$Pi31_decred$O $(OBJDIR)$Pi31_encode$O $(OBJDIR)$Pi31_fmont$O $(OBJDIR)$Pi31_iszero$O $(OBJDIR)$Pi31_modpow$O $(OBJDIR)$Pi31_montmul$O $(OBJDIR)$Pi31_mulacc$O $(OBJDIR)$Pi31_muladd$O $(OBJDIR)$Pi31_ninv31$O $(OBJDIR)$Pi31_reduce$O $(OBJDIR)$Pi31_rshift$O $(OBJDIR)$Pi31_sub$O $(OBJDIR)$Pi31_tmont$O $(OBJDIR)$Pi32_add$O $(OBJDIR)$Pi32_bitlen$O $(OBJDIR)$Pi32_decmod$O $(OBJDIR)$Pi32_decode$O $(OBJDIR)$Pi32_decred$O $(OBJDIR)$Pi32_div32$O $(OBJDIR)$Pi32_encode$O $(OBJDIR)$Pi32_fmont$O $(OBJDIR)$Pi32_iszero$O $(OBJDIR)$Pi32_modpow$O $(OBJDIR)$Pi32_montmul$O $(OBJDIR)$Pi32_mulacc$O $(OBJDIR)$Pi32_muladd$O $(OBJDIR)$Pi32_ninv32$O $(OBJDIR)$Pi32_reduce$O $(OBJDIR)$Pi32_sub$O $(OBJDIR)$Pi32_tmont$O $(OBJDIR)$Phmac$O $(OBJDIR)$Phmac_ct$O $(OBJDIR)$Phmac_drbg$O $(OBJDIR)$Prsa_i15_pkcs1_sign$O $(OBJDIR)$Prsa_i15_pkcs1_vrfy$O $(OBJDIR)$Prsa_i15_priv$O $(OBJDIR)$Prsa_i15_pub$O $(OBJDIR)$Prsa_i31_pkcs1_sign$O $(OBJDIR)$Prsa_i31_pkcs1_vrfy$O $(OBJDIR)$Prsa_i31_priv$O $(OBJDIR)$Prsa_i31_pub$O $(OBJDIR)$Prsa_i32_pkcs1_sign$O $(OBJDIR)$Prsa_i32_pkcs1_vrfy$O $(OBJDIR)$Prsa_i32_priv$O $(OBJDIR)$Prsa_i32_pub$O $(OBJDIR)$Prsa_pkcs1_sig_pad$O $(OBJDIR)$Prsa_pkcs1_sig_unpad$O $(OBJDIR)$Prsa_ssl_decrypt$O $(OBJDIR)$Pprf$O $(OBJDIR)$Pprf_md5sha1$O $(OBJDIR)$Pprf_sha256$O $(OBJDIR)$Pprf_sha384$O $(OBJDIR)$Pssl_ccert_single_ec$O $(OBJDIR)$Pssl_ccert_single_rsa$O $(OBJDIR)$Pssl_client$O $(OBJDIR)$Pssl_client_full$O $(OBJDIR)$Pssl_engine$O $(OBJDIR)$Pssl_hashes$O $(OBJDIR)$Pssl_hs_client$O $(OBJDIR)$Pssl_hs_server$O $(OBJDIR)$Pssl_io$O $(OBJDIR)$Pssl_lru$O $(OBJDIR)$Pssl_rec_cbc$O $(OBJDIR)$Pssl_rec_chapol$O $(OBJDIR)$Pssl_rec_gcm$O $(OBJDIR)$Pssl_scert_single_ec$O $(OBJDIR)$Pssl_scert_single_rsa$O $(OBJDIR)$Pssl_server$O $(OBJDIR)$Pssl_server_full_ec$O $(OBJDIR)$Pssl_server_full_rsa$O $(OBJDIR)$Pssl_server_mine2c$O $(OBJDIR)$Pssl_server_mine2g$O $(OBJDIR)$Pssl_server_minf2c$O $(OBJDIR)$Pssl_server_minf2g$O $(OBJDIR)$Pssl_server_minr2g$O $(OBJDIR)$Pssl_server_minu2g$O $(OBJDIR)$Pssl_server_minv2g$O $(OBJDIR)$Paes_big_cbcdec$O $(OBJDIR)$Paes_big_cbcenc$O $(OBJDIR)$Paes_big_ctr$O $(OBJDIR)$Paes_big_dec$O $(OBJDIR)$Paes_big_enc$O $(OBJDIR)$Paes_common$O $(OBJDIR)$Paes_ct$O $(OBJDIR)$Paes_ct64$O $(OBJDIR)$Paes_ct64_cbcdec$O $(OBJDIR)$Paes_ct64_cbcenc$O $(OBJDIR)$Paes_ct64_ctr$O $(OBJDIR)$Paes_ct64_dec$O $(OBJDIR)$Paes_ct64_enc$O $(OBJDIR)$Paes_ct_cbcdec$O $(OBJDIR)$Paes_ct_cbcenc$O $(OBJDIR)$Paes_ct_ctr$O $(OBJDIR)$Paes_ct_dec$O $(OBJDIR)$Paes_ct_enc$O $(OBJDIR)$Paes_small_cbcdec$O $(OBJDIR)$Paes_small_cbcenc$O $(OBJDIR)$Paes_small_ctr$O $(OBJDIR)$Paes_small_dec$O $(OBJDIR)$Paes_small_enc$O $(OBJDIR)$Pchacha20_ct$O $(OBJDIR)$Pdes_ct$O $(OBJDIR)$Pdes_ct_cbcdec$O $(OBJDIR)$Pdes_ct_cbcenc$O $(OBJDIR)$Pdes_support$O $(OBJDIR)$Pdes_tab$O $(OBJDIR)$Pdes_tab_cbcdec$O $(OBJDIR)$Pdes_tab_cbcenc$O $(OBJDIR)$Ppoly1305_ctmul$O $(OBJDIR)$Ppoly1305_ctmul32$O $(OBJDIR)$Ppoly1305_i15$O $(OBJDIR)$Pskey_decoder$O $(OBJDIR)$Px509_decoder$O $(OBJDIR)$Px509_knownkey$O $(OBJDIR)$Px509_minimal$O $(OBJDIR)$Px509_minimal_full$O +OBJBRSSL = $(OBJDIR)$Pbrssl$O $(OBJDIR)$Pcerts$O $(OBJDIR)$Pchain$O $(OBJDIR)$Pclient$O $(OBJDIR)$Perrors$O $(OBJDIR)$Pfiles$O $(OBJDIR)$Pkeys$O $(OBJDIR)$Pnames$O $(OBJDIR)$Pserver$O $(OBJDIR)$Pskey$O $(OBJDIR)$Psslio$O $(OBJDIR)$Pta$O $(OBJDIR)$Pvector$O $(OBJDIR)$Pverify$O $(OBJDIR)$Pxmem$O +OBJTESTCRYPTO = $(OBJDIR)$Ptest_crypto$O +OBJTESTSPEED = $(OBJDIR)$Ptest_speed$O +OBJTESTX509 = $(OBJDIR)$Ptest_x509$O +HEADERSPUB = inc$Pbearssl.h inc$Pbearssl_block.h inc$Pbearssl_ec.h inc$Pbearssl_hash.h inc$Pbearssl_hmac.h inc$Pbearssl_pem.h inc$Pbearssl_prf.h inc$Pbearssl_rand.h inc$Pbearssl_rsa.h inc$Pbearssl_ssl.h inc$Pbearssl_x509.h +HEADERSPRIV = $(HEADERSPUB) src$Pconfig.h src$Pinner.h +HEADERSTOOLS = $(HEADERSPUB) tools$Pbrssl.h +T0SRC = T0$PBlobWriter.cs T0$PCPU.cs T0$PCodeElement.cs T0$PCodeElementJump.cs T0$PCodeElementUInt.cs T0$PCodeElementUIntExpr.cs T0$PCodeElementUIntInt.cs T0$PCodeElementUIntUInt.cs T0$PConstData.cs T0$POpcode.cs T0$POpcodeCall.cs T0$POpcodeConst.cs T0$POpcodeGetLocal.cs T0$POpcodeJump.cs T0$POpcodeJumpIf.cs T0$POpcodeJumpIfNot.cs T0$POpcodeJumpUncond.cs T0$POpcodePutLocal.cs T0$POpcodeRet.cs T0$PSType.cs T0$PT0Comp.cs T0$PTPointerBase.cs T0$PTPointerBlob.cs T0$PTPointerExpr.cs T0$PTPointerNull.cs T0$PTPointerXT.cs T0$PTValue.cs T0$PWord.cs T0$PWordBuilder.cs T0$PWordData.cs T0$PWordInterpreted.cs T0$PWordNative.cs +T0KERN = + +all: $(STATICLIB) $(DLL) $(TOOLS) $(TESTS) + +no: + +lib: $(BEARSSLLIB) + +dll: $(BEARSSLDLL) + +tools: $(BRSSL) + +tests: $(TESTCRYPTO) $(TESTSPEED) $(TESTX509) + +T0: $(T0COMP) + $(RUNT0COMP) -o src$Pcodec$Ppemdec -r br_pem_decoder src$Pcodec$Ppemdec.t0 + $(RUNT0COMP) -o src$Pssl$Pssl_hs_client -r br_ssl_hs_client src$Pssl$Pssl_hs_common.t0 src$Pssl$Pssl_hs_client.t0 + $(RUNT0COMP) -o src$Pssl$Pssl_hs_server -r br_ssl_hs_server src$Pssl$Pssl_hs_common.t0 src$Pssl$Pssl_hs_server.t0 + $(RUNT0COMP) -o src$Px509$Pskey_decoder -r br_skey_decoder src$Px509$Pasn1.t0 src$Px509$Pskey_decoder.t0 + $(RUNT0COMP) -o src$Px509$Px509_decoder -r br_x509_decoder src$Px509$Pasn1.t0 src$Px509$Px509_decoder.t0 + $(RUNT0COMP) -o src$Px509$Px509_minimal -r br_x509_minimal src$Px509$Pasn1.t0 src$Px509$Px509_minimal.t0 + +$(T0COMP): $(T0SRC) $(T0KERN) + $(MKT0COMP) + +clean: + -$(RM) $(OBJDIR)$P*$O + -$(RM) $(BEARSSLLIB) $(BEARSSLDLL) $(BRSSL) $(TESTCRYPTO) $(TESTSPEED) $(TESTX509) + +$(OBJDIR): + -$(MKDIR) $(OBJDIR) + +$(BEARSSLLIB): $(OBJDIR) $(OBJ) + $(AR) $(ARFLAGS) $(AROUT)$(BEARSSLLIB) $(OBJ) + +$(BEARSSLDLL): $(OBJDIR) $(OBJ) + $(LDDLL) $(LDDLLFLAGS) $(LDDLLOUT)$(BEARSSLDLL) $(OBJ) + +$(BRSSL): $(BEARSSLLIB) $(OBJBRSSL) + $(LD) $(LDFLAGS) $(LDOUT)$(BRSSL) $(OBJBRSSL) $(BEARSSLLIB) + +$(TESTCRYPTO): $(BEARSSLLIB) $(OBJTESTCRYPTO) + $(LD) $(LDFLAGS) $(LDOUT)$(TESTCRYPTO) $(OBJTESTCRYPTO) $(BEARSSLLIB) + +$(TESTSPEED): $(BEARSSLLIB) $(OBJTESTSPEED) + $(LD) $(LDFLAGS) $(LDOUT)$(TESTSPEED) $(OBJTESTSPEED) $(BEARSSLLIB) + +$(TESTX509): $(BEARSSLLIB) $(OBJTESTX509) + $(LD) $(LDFLAGS) $(LDOUT)$(TESTX509) $(OBJTESTX509) $(BEARSSLLIB) + +$(OBJDIR)$Pccopy$O: src$Pcodec$Pccopy.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pccopy$O src$Pcodec$Pccopy.c + +$(OBJDIR)$Pdec16be$O: src$Pcodec$Pdec16be.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pdec16be$O src$Pcodec$Pdec16be.c + +$(OBJDIR)$Pdec16le$O: src$Pcodec$Pdec16le.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pdec16le$O src$Pcodec$Pdec16le.c + +$(OBJDIR)$Pdec32be$O: src$Pcodec$Pdec32be.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pdec32be$O src$Pcodec$Pdec32be.c + +$(OBJDIR)$Pdec32le$O: src$Pcodec$Pdec32le.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pdec32le$O src$Pcodec$Pdec32le.c + +$(OBJDIR)$Pdec64be$O: src$Pcodec$Pdec64be.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pdec64be$O src$Pcodec$Pdec64be.c + +$(OBJDIR)$Pdec64le$O: src$Pcodec$Pdec64le.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pdec64le$O src$Pcodec$Pdec64le.c + +$(OBJDIR)$Penc16be$O: src$Pcodec$Penc16be.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Penc16be$O src$Pcodec$Penc16be.c + +$(OBJDIR)$Penc16le$O: src$Pcodec$Penc16le.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Penc16le$O src$Pcodec$Penc16le.c + +$(OBJDIR)$Penc32be$O: src$Pcodec$Penc32be.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Penc32be$O src$Pcodec$Penc32be.c + +$(OBJDIR)$Penc32le$O: src$Pcodec$Penc32le.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Penc32le$O src$Pcodec$Penc32le.c + +$(OBJDIR)$Penc64be$O: src$Pcodec$Penc64be.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Penc64be$O src$Pcodec$Penc64be.c + +$(OBJDIR)$Penc64le$O: src$Pcodec$Penc64le.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Penc64le$O src$Pcodec$Penc64le.c + +$(OBJDIR)$Ppemdec$O: src$Pcodec$Ppemdec.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Ppemdec$O src$Pcodec$Ppemdec.c + +$(OBJDIR)$Pec_all_m15$O: src$Pec$Pec_all_m15.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pec_all_m15$O src$Pec$Pec_all_m15.c + +$(OBJDIR)$Pec_all_m31$O: src$Pec$Pec_all_m31.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pec_all_m31$O src$Pec$Pec_all_m31.c + +$(OBJDIR)$Pec_c25519_i15$O: src$Pec$Pec_c25519_i15.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pec_c25519_i15$O src$Pec$Pec_c25519_i15.c + +$(OBJDIR)$Pec_c25519_i31$O: src$Pec$Pec_c25519_i31.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pec_c25519_i31$O src$Pec$Pec_c25519_i31.c + +$(OBJDIR)$Pec_c25519_m15$O: src$Pec$Pec_c25519_m15.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pec_c25519_m15$O src$Pec$Pec_c25519_m15.c + +$(OBJDIR)$Pec_c25519_m31$O: src$Pec$Pec_c25519_m31.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pec_c25519_m31$O src$Pec$Pec_c25519_m31.c + +$(OBJDIR)$Pec_curve25519$O: src$Pec$Pec_curve25519.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pec_curve25519$O src$Pec$Pec_curve25519.c + +$(OBJDIR)$Pec_p256_m15$O: src$Pec$Pec_p256_m15.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pec_p256_m15$O src$Pec$Pec_p256_m15.c + +$(OBJDIR)$Pec_p256_m31$O: src$Pec$Pec_p256_m31.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pec_p256_m31$O src$Pec$Pec_p256_m31.c + +$(OBJDIR)$Pec_prime_i15$O: src$Pec$Pec_prime_i15.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pec_prime_i15$O src$Pec$Pec_prime_i15.c + +$(OBJDIR)$Pec_prime_i31$O: src$Pec$Pec_prime_i31.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pec_prime_i31$O src$Pec$Pec_prime_i31.c + +$(OBJDIR)$Pec_secp256r1$O: src$Pec$Pec_secp256r1.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pec_secp256r1$O src$Pec$Pec_secp256r1.c + +$(OBJDIR)$Pec_secp384r1$O: src$Pec$Pec_secp384r1.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pec_secp384r1$O src$Pec$Pec_secp384r1.c + +$(OBJDIR)$Pec_secp521r1$O: src$Pec$Pec_secp521r1.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pec_secp521r1$O src$Pec$Pec_secp521r1.c + +$(OBJDIR)$Pecdsa_atr$O: src$Pec$Pecdsa_atr.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pecdsa_atr$O src$Pec$Pecdsa_atr.c + +$(OBJDIR)$Pecdsa_i15_bits$O: src$Pec$Pecdsa_i15_bits.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pecdsa_i15_bits$O src$Pec$Pecdsa_i15_bits.c + +$(OBJDIR)$Pecdsa_i15_sign_asn1$O: src$Pec$Pecdsa_i15_sign_asn1.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pecdsa_i15_sign_asn1$O src$Pec$Pecdsa_i15_sign_asn1.c + +$(OBJDIR)$Pecdsa_i15_sign_raw$O: src$Pec$Pecdsa_i15_sign_raw.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pecdsa_i15_sign_raw$O src$Pec$Pecdsa_i15_sign_raw.c + +$(OBJDIR)$Pecdsa_i15_vrfy_asn1$O: src$Pec$Pecdsa_i15_vrfy_asn1.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pecdsa_i15_vrfy_asn1$O src$Pec$Pecdsa_i15_vrfy_asn1.c + +$(OBJDIR)$Pecdsa_i15_vrfy_raw$O: src$Pec$Pecdsa_i15_vrfy_raw.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pecdsa_i15_vrfy_raw$O src$Pec$Pecdsa_i15_vrfy_raw.c + +$(OBJDIR)$Pecdsa_i31_bits$O: src$Pec$Pecdsa_i31_bits.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pecdsa_i31_bits$O src$Pec$Pecdsa_i31_bits.c + +$(OBJDIR)$Pecdsa_i31_sign_asn1$O: src$Pec$Pecdsa_i31_sign_asn1.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pecdsa_i31_sign_asn1$O src$Pec$Pecdsa_i31_sign_asn1.c + +$(OBJDIR)$Pecdsa_i31_sign_raw$O: src$Pec$Pecdsa_i31_sign_raw.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pecdsa_i31_sign_raw$O src$Pec$Pecdsa_i31_sign_raw.c + +$(OBJDIR)$Pecdsa_i31_vrfy_asn1$O: src$Pec$Pecdsa_i31_vrfy_asn1.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pecdsa_i31_vrfy_asn1$O src$Pec$Pecdsa_i31_vrfy_asn1.c + +$(OBJDIR)$Pecdsa_i31_vrfy_raw$O: src$Pec$Pecdsa_i31_vrfy_raw.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pecdsa_i31_vrfy_raw$O src$Pec$Pecdsa_i31_vrfy_raw.c + +$(OBJDIR)$Pecdsa_rta$O: src$Pec$Pecdsa_rta.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pecdsa_rta$O src$Pec$Pecdsa_rta.c + +$(OBJDIR)$Pdig_oid$O: src$Phash$Pdig_oid.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pdig_oid$O src$Phash$Pdig_oid.c + +$(OBJDIR)$Pdig_size$O: src$Phash$Pdig_size.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pdig_size$O src$Phash$Pdig_size.c + +$(OBJDIR)$Pghash_ctmul$O: src$Phash$Pghash_ctmul.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pghash_ctmul$O src$Phash$Pghash_ctmul.c + +$(OBJDIR)$Pghash_ctmul32$O: src$Phash$Pghash_ctmul32.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pghash_ctmul32$O src$Phash$Pghash_ctmul32.c + +$(OBJDIR)$Pghash_ctmul64$O: src$Phash$Pghash_ctmul64.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pghash_ctmul64$O src$Phash$Pghash_ctmul64.c + +$(OBJDIR)$Pmd5$O: src$Phash$Pmd5.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pmd5$O src$Phash$Pmd5.c + +$(OBJDIR)$Pmd5sha1$O: src$Phash$Pmd5sha1.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pmd5sha1$O src$Phash$Pmd5sha1.c + +$(OBJDIR)$Pmultihash$O: src$Phash$Pmultihash.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pmultihash$O src$Phash$Pmultihash.c + +$(OBJDIR)$Psha1$O: src$Phash$Psha1.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Psha1$O src$Phash$Psha1.c + +$(OBJDIR)$Psha2big$O: src$Phash$Psha2big.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Psha2big$O src$Phash$Psha2big.c + +$(OBJDIR)$Psha2small$O: src$Phash$Psha2small.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Psha2small$O src$Phash$Psha2small.c + +$(OBJDIR)$Pi15_add$O: src$Pint$Pi15_add.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pi15_add$O src$Pint$Pi15_add.c + +$(OBJDIR)$Pi15_bitlen$O: src$Pint$Pi15_bitlen.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pi15_bitlen$O src$Pint$Pi15_bitlen.c + +$(OBJDIR)$Pi15_decmod$O: src$Pint$Pi15_decmod.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pi15_decmod$O src$Pint$Pi15_decmod.c + +$(OBJDIR)$Pi15_decode$O: src$Pint$Pi15_decode.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pi15_decode$O src$Pint$Pi15_decode.c + +$(OBJDIR)$Pi15_decred$O: src$Pint$Pi15_decred.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pi15_decred$O src$Pint$Pi15_decred.c + +$(OBJDIR)$Pi15_encode$O: src$Pint$Pi15_encode.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pi15_encode$O src$Pint$Pi15_encode.c + +$(OBJDIR)$Pi15_fmont$O: src$Pint$Pi15_fmont.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pi15_fmont$O src$Pint$Pi15_fmont.c + +$(OBJDIR)$Pi15_iszero$O: src$Pint$Pi15_iszero.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pi15_iszero$O src$Pint$Pi15_iszero.c + +$(OBJDIR)$Pi15_modpow$O: src$Pint$Pi15_modpow.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pi15_modpow$O src$Pint$Pi15_modpow.c + +$(OBJDIR)$Pi15_montmul$O: src$Pint$Pi15_montmul.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pi15_montmul$O src$Pint$Pi15_montmul.c + +$(OBJDIR)$Pi15_mulacc$O: src$Pint$Pi15_mulacc.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pi15_mulacc$O src$Pint$Pi15_mulacc.c + +$(OBJDIR)$Pi15_muladd$O: src$Pint$Pi15_muladd.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pi15_muladd$O src$Pint$Pi15_muladd.c + +$(OBJDIR)$Pi15_ninv15$O: src$Pint$Pi15_ninv15.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pi15_ninv15$O src$Pint$Pi15_ninv15.c + +$(OBJDIR)$Pi15_reduce$O: src$Pint$Pi15_reduce.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pi15_reduce$O src$Pint$Pi15_reduce.c + +$(OBJDIR)$Pi15_rshift$O: src$Pint$Pi15_rshift.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pi15_rshift$O src$Pint$Pi15_rshift.c + +$(OBJDIR)$Pi15_sub$O: src$Pint$Pi15_sub.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pi15_sub$O src$Pint$Pi15_sub.c + +$(OBJDIR)$Pi15_tmont$O: src$Pint$Pi15_tmont.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pi15_tmont$O src$Pint$Pi15_tmont.c + +$(OBJDIR)$Pi31_add$O: src$Pint$Pi31_add.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pi31_add$O src$Pint$Pi31_add.c + +$(OBJDIR)$Pi31_bitlen$O: src$Pint$Pi31_bitlen.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pi31_bitlen$O src$Pint$Pi31_bitlen.c + +$(OBJDIR)$Pi31_decmod$O: src$Pint$Pi31_decmod.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pi31_decmod$O src$Pint$Pi31_decmod.c + +$(OBJDIR)$Pi31_decode$O: src$Pint$Pi31_decode.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pi31_decode$O src$Pint$Pi31_decode.c + +$(OBJDIR)$Pi31_decred$O: src$Pint$Pi31_decred.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pi31_decred$O src$Pint$Pi31_decred.c + +$(OBJDIR)$Pi31_encode$O: src$Pint$Pi31_encode.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pi31_encode$O src$Pint$Pi31_encode.c + +$(OBJDIR)$Pi31_fmont$O: src$Pint$Pi31_fmont.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pi31_fmont$O src$Pint$Pi31_fmont.c + +$(OBJDIR)$Pi31_iszero$O: src$Pint$Pi31_iszero.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pi31_iszero$O src$Pint$Pi31_iszero.c + +$(OBJDIR)$Pi31_modpow$O: src$Pint$Pi31_modpow.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pi31_modpow$O src$Pint$Pi31_modpow.c + +$(OBJDIR)$Pi31_montmul$O: src$Pint$Pi31_montmul.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pi31_montmul$O src$Pint$Pi31_montmul.c + +$(OBJDIR)$Pi31_mulacc$O: src$Pint$Pi31_mulacc.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pi31_mulacc$O src$Pint$Pi31_mulacc.c + +$(OBJDIR)$Pi31_muladd$O: src$Pint$Pi31_muladd.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pi31_muladd$O src$Pint$Pi31_muladd.c + +$(OBJDIR)$Pi31_ninv31$O: src$Pint$Pi31_ninv31.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pi31_ninv31$O src$Pint$Pi31_ninv31.c + +$(OBJDIR)$Pi31_reduce$O: src$Pint$Pi31_reduce.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pi31_reduce$O src$Pint$Pi31_reduce.c + +$(OBJDIR)$Pi31_rshift$O: src$Pint$Pi31_rshift.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pi31_rshift$O src$Pint$Pi31_rshift.c + +$(OBJDIR)$Pi31_sub$O: src$Pint$Pi31_sub.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pi31_sub$O src$Pint$Pi31_sub.c + +$(OBJDIR)$Pi31_tmont$O: src$Pint$Pi31_tmont.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pi31_tmont$O src$Pint$Pi31_tmont.c + +$(OBJDIR)$Pi32_add$O: src$Pint$Pi32_add.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pi32_add$O src$Pint$Pi32_add.c + +$(OBJDIR)$Pi32_bitlen$O: src$Pint$Pi32_bitlen.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pi32_bitlen$O src$Pint$Pi32_bitlen.c + +$(OBJDIR)$Pi32_decmod$O: src$Pint$Pi32_decmod.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pi32_decmod$O src$Pint$Pi32_decmod.c + +$(OBJDIR)$Pi32_decode$O: src$Pint$Pi32_decode.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pi32_decode$O src$Pint$Pi32_decode.c + +$(OBJDIR)$Pi32_decred$O: src$Pint$Pi32_decred.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pi32_decred$O src$Pint$Pi32_decred.c + +$(OBJDIR)$Pi32_div32$O: src$Pint$Pi32_div32.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pi32_div32$O src$Pint$Pi32_div32.c + +$(OBJDIR)$Pi32_encode$O: src$Pint$Pi32_encode.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pi32_encode$O src$Pint$Pi32_encode.c + +$(OBJDIR)$Pi32_fmont$O: src$Pint$Pi32_fmont.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pi32_fmont$O src$Pint$Pi32_fmont.c + +$(OBJDIR)$Pi32_iszero$O: src$Pint$Pi32_iszero.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pi32_iszero$O src$Pint$Pi32_iszero.c + +$(OBJDIR)$Pi32_modpow$O: src$Pint$Pi32_modpow.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pi32_modpow$O src$Pint$Pi32_modpow.c + +$(OBJDIR)$Pi32_montmul$O: src$Pint$Pi32_montmul.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pi32_montmul$O src$Pint$Pi32_montmul.c + +$(OBJDIR)$Pi32_mulacc$O: src$Pint$Pi32_mulacc.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pi32_mulacc$O src$Pint$Pi32_mulacc.c + +$(OBJDIR)$Pi32_muladd$O: src$Pint$Pi32_muladd.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pi32_muladd$O src$Pint$Pi32_muladd.c + +$(OBJDIR)$Pi32_ninv32$O: src$Pint$Pi32_ninv32.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pi32_ninv32$O src$Pint$Pi32_ninv32.c + +$(OBJDIR)$Pi32_reduce$O: src$Pint$Pi32_reduce.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pi32_reduce$O src$Pint$Pi32_reduce.c + +$(OBJDIR)$Pi32_sub$O: src$Pint$Pi32_sub.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pi32_sub$O src$Pint$Pi32_sub.c + +$(OBJDIR)$Pi32_tmont$O: src$Pint$Pi32_tmont.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pi32_tmont$O src$Pint$Pi32_tmont.c + +$(OBJDIR)$Phmac$O: src$Pmac$Phmac.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Phmac$O src$Pmac$Phmac.c + +$(OBJDIR)$Phmac_ct$O: src$Pmac$Phmac_ct.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Phmac_ct$O src$Pmac$Phmac_ct.c + +$(OBJDIR)$Phmac_drbg$O: src$Prand$Phmac_drbg.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Phmac_drbg$O src$Prand$Phmac_drbg.c + +$(OBJDIR)$Prsa_i15_pkcs1_sign$O: src$Prsa$Prsa_i15_pkcs1_sign.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Prsa_i15_pkcs1_sign$O src$Prsa$Prsa_i15_pkcs1_sign.c + +$(OBJDIR)$Prsa_i15_pkcs1_vrfy$O: src$Prsa$Prsa_i15_pkcs1_vrfy.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Prsa_i15_pkcs1_vrfy$O src$Prsa$Prsa_i15_pkcs1_vrfy.c + +$(OBJDIR)$Prsa_i15_priv$O: src$Prsa$Prsa_i15_priv.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Prsa_i15_priv$O src$Prsa$Prsa_i15_priv.c + +$(OBJDIR)$Prsa_i15_pub$O: src$Prsa$Prsa_i15_pub.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Prsa_i15_pub$O src$Prsa$Prsa_i15_pub.c + +$(OBJDIR)$Prsa_i31_pkcs1_sign$O: src$Prsa$Prsa_i31_pkcs1_sign.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Prsa_i31_pkcs1_sign$O src$Prsa$Prsa_i31_pkcs1_sign.c + +$(OBJDIR)$Prsa_i31_pkcs1_vrfy$O: src$Prsa$Prsa_i31_pkcs1_vrfy.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Prsa_i31_pkcs1_vrfy$O src$Prsa$Prsa_i31_pkcs1_vrfy.c + +$(OBJDIR)$Prsa_i31_priv$O: src$Prsa$Prsa_i31_priv.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Prsa_i31_priv$O src$Prsa$Prsa_i31_priv.c + +$(OBJDIR)$Prsa_i31_pub$O: src$Prsa$Prsa_i31_pub.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Prsa_i31_pub$O src$Prsa$Prsa_i31_pub.c + +$(OBJDIR)$Prsa_i32_pkcs1_sign$O: src$Prsa$Prsa_i32_pkcs1_sign.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Prsa_i32_pkcs1_sign$O src$Prsa$Prsa_i32_pkcs1_sign.c + +$(OBJDIR)$Prsa_i32_pkcs1_vrfy$O: src$Prsa$Prsa_i32_pkcs1_vrfy.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Prsa_i32_pkcs1_vrfy$O src$Prsa$Prsa_i32_pkcs1_vrfy.c + +$(OBJDIR)$Prsa_i32_priv$O: src$Prsa$Prsa_i32_priv.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Prsa_i32_priv$O src$Prsa$Prsa_i32_priv.c + +$(OBJDIR)$Prsa_i32_pub$O: src$Prsa$Prsa_i32_pub.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Prsa_i32_pub$O src$Prsa$Prsa_i32_pub.c + +$(OBJDIR)$Prsa_pkcs1_sig_pad$O: src$Prsa$Prsa_pkcs1_sig_pad.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Prsa_pkcs1_sig_pad$O src$Prsa$Prsa_pkcs1_sig_pad.c + +$(OBJDIR)$Prsa_pkcs1_sig_unpad$O: src$Prsa$Prsa_pkcs1_sig_unpad.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Prsa_pkcs1_sig_unpad$O src$Prsa$Prsa_pkcs1_sig_unpad.c + +$(OBJDIR)$Prsa_ssl_decrypt$O: src$Prsa$Prsa_ssl_decrypt.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Prsa_ssl_decrypt$O src$Prsa$Prsa_ssl_decrypt.c + +$(OBJDIR)$Pprf$O: src$Pssl$Pprf.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pprf$O src$Pssl$Pprf.c + +$(OBJDIR)$Pprf_md5sha1$O: src$Pssl$Pprf_md5sha1.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pprf_md5sha1$O src$Pssl$Pprf_md5sha1.c + +$(OBJDIR)$Pprf_sha256$O: src$Pssl$Pprf_sha256.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pprf_sha256$O src$Pssl$Pprf_sha256.c + +$(OBJDIR)$Pprf_sha384$O: src$Pssl$Pprf_sha384.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pprf_sha384$O src$Pssl$Pprf_sha384.c + +$(OBJDIR)$Pssl_ccert_single_ec$O: src$Pssl$Pssl_ccert_single_ec.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pssl_ccert_single_ec$O src$Pssl$Pssl_ccert_single_ec.c + +$(OBJDIR)$Pssl_ccert_single_rsa$O: src$Pssl$Pssl_ccert_single_rsa.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pssl_ccert_single_rsa$O src$Pssl$Pssl_ccert_single_rsa.c + +$(OBJDIR)$Pssl_client$O: src$Pssl$Pssl_client.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pssl_client$O src$Pssl$Pssl_client.c + +$(OBJDIR)$Pssl_client_full$O: src$Pssl$Pssl_client_full.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pssl_client_full$O src$Pssl$Pssl_client_full.c + +$(OBJDIR)$Pssl_engine$O: src$Pssl$Pssl_engine.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pssl_engine$O src$Pssl$Pssl_engine.c + +$(OBJDIR)$Pssl_hashes$O: src$Pssl$Pssl_hashes.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pssl_hashes$O src$Pssl$Pssl_hashes.c + +$(OBJDIR)$Pssl_hs_client$O: src$Pssl$Pssl_hs_client.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pssl_hs_client$O src$Pssl$Pssl_hs_client.c + +$(OBJDIR)$Pssl_hs_server$O: src$Pssl$Pssl_hs_server.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pssl_hs_server$O src$Pssl$Pssl_hs_server.c + +$(OBJDIR)$Pssl_io$O: src$Pssl$Pssl_io.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pssl_io$O src$Pssl$Pssl_io.c + +$(OBJDIR)$Pssl_lru$O: src$Pssl$Pssl_lru.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pssl_lru$O src$Pssl$Pssl_lru.c + +$(OBJDIR)$Pssl_rec_cbc$O: src$Pssl$Pssl_rec_cbc.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pssl_rec_cbc$O src$Pssl$Pssl_rec_cbc.c + +$(OBJDIR)$Pssl_rec_chapol$O: src$Pssl$Pssl_rec_chapol.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pssl_rec_chapol$O src$Pssl$Pssl_rec_chapol.c + +$(OBJDIR)$Pssl_rec_gcm$O: src$Pssl$Pssl_rec_gcm.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pssl_rec_gcm$O src$Pssl$Pssl_rec_gcm.c + +$(OBJDIR)$Pssl_scert_single_ec$O: src$Pssl$Pssl_scert_single_ec.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pssl_scert_single_ec$O src$Pssl$Pssl_scert_single_ec.c + +$(OBJDIR)$Pssl_scert_single_rsa$O: src$Pssl$Pssl_scert_single_rsa.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pssl_scert_single_rsa$O src$Pssl$Pssl_scert_single_rsa.c + +$(OBJDIR)$Pssl_server$O: src$Pssl$Pssl_server.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pssl_server$O src$Pssl$Pssl_server.c + +$(OBJDIR)$Pssl_server_full_ec$O: src$Pssl$Pssl_server_full_ec.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pssl_server_full_ec$O src$Pssl$Pssl_server_full_ec.c + +$(OBJDIR)$Pssl_server_full_rsa$O: src$Pssl$Pssl_server_full_rsa.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pssl_server_full_rsa$O src$Pssl$Pssl_server_full_rsa.c + +$(OBJDIR)$Pssl_server_mine2c$O: src$Pssl$Pssl_server_mine2c.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pssl_server_mine2c$O src$Pssl$Pssl_server_mine2c.c + +$(OBJDIR)$Pssl_server_mine2g$O: src$Pssl$Pssl_server_mine2g.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pssl_server_mine2g$O src$Pssl$Pssl_server_mine2g.c + +$(OBJDIR)$Pssl_server_minf2c$O: src$Pssl$Pssl_server_minf2c.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pssl_server_minf2c$O src$Pssl$Pssl_server_minf2c.c + +$(OBJDIR)$Pssl_server_minf2g$O: src$Pssl$Pssl_server_minf2g.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pssl_server_minf2g$O src$Pssl$Pssl_server_minf2g.c + +$(OBJDIR)$Pssl_server_minr2g$O: src$Pssl$Pssl_server_minr2g.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pssl_server_minr2g$O src$Pssl$Pssl_server_minr2g.c + +$(OBJDIR)$Pssl_server_minu2g$O: src$Pssl$Pssl_server_minu2g.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pssl_server_minu2g$O src$Pssl$Pssl_server_minu2g.c + +$(OBJDIR)$Pssl_server_minv2g$O: src$Pssl$Pssl_server_minv2g.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pssl_server_minv2g$O src$Pssl$Pssl_server_minv2g.c + +$(OBJDIR)$Paes_big_cbcdec$O: src$Psymcipher$Paes_big_cbcdec.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Paes_big_cbcdec$O src$Psymcipher$Paes_big_cbcdec.c + +$(OBJDIR)$Paes_big_cbcenc$O: src$Psymcipher$Paes_big_cbcenc.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Paes_big_cbcenc$O src$Psymcipher$Paes_big_cbcenc.c + +$(OBJDIR)$Paes_big_ctr$O: src$Psymcipher$Paes_big_ctr.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Paes_big_ctr$O src$Psymcipher$Paes_big_ctr.c + +$(OBJDIR)$Paes_big_dec$O: src$Psymcipher$Paes_big_dec.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Paes_big_dec$O src$Psymcipher$Paes_big_dec.c + +$(OBJDIR)$Paes_big_enc$O: src$Psymcipher$Paes_big_enc.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Paes_big_enc$O src$Psymcipher$Paes_big_enc.c + +$(OBJDIR)$Paes_common$O: src$Psymcipher$Paes_common.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Paes_common$O src$Psymcipher$Paes_common.c + +$(OBJDIR)$Paes_ct$O: src$Psymcipher$Paes_ct.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Paes_ct$O src$Psymcipher$Paes_ct.c + +$(OBJDIR)$Paes_ct64$O: src$Psymcipher$Paes_ct64.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Paes_ct64$O src$Psymcipher$Paes_ct64.c + +$(OBJDIR)$Paes_ct64_cbcdec$O: src$Psymcipher$Paes_ct64_cbcdec.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Paes_ct64_cbcdec$O src$Psymcipher$Paes_ct64_cbcdec.c + +$(OBJDIR)$Paes_ct64_cbcenc$O: src$Psymcipher$Paes_ct64_cbcenc.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Paes_ct64_cbcenc$O src$Psymcipher$Paes_ct64_cbcenc.c + +$(OBJDIR)$Paes_ct64_ctr$O: src$Psymcipher$Paes_ct64_ctr.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Paes_ct64_ctr$O src$Psymcipher$Paes_ct64_ctr.c + +$(OBJDIR)$Paes_ct64_dec$O: src$Psymcipher$Paes_ct64_dec.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Paes_ct64_dec$O src$Psymcipher$Paes_ct64_dec.c + +$(OBJDIR)$Paes_ct64_enc$O: src$Psymcipher$Paes_ct64_enc.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Paes_ct64_enc$O src$Psymcipher$Paes_ct64_enc.c + +$(OBJDIR)$Paes_ct_cbcdec$O: src$Psymcipher$Paes_ct_cbcdec.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Paes_ct_cbcdec$O src$Psymcipher$Paes_ct_cbcdec.c + +$(OBJDIR)$Paes_ct_cbcenc$O: src$Psymcipher$Paes_ct_cbcenc.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Paes_ct_cbcenc$O src$Psymcipher$Paes_ct_cbcenc.c + +$(OBJDIR)$Paes_ct_ctr$O: src$Psymcipher$Paes_ct_ctr.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Paes_ct_ctr$O src$Psymcipher$Paes_ct_ctr.c + +$(OBJDIR)$Paes_ct_dec$O: src$Psymcipher$Paes_ct_dec.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Paes_ct_dec$O src$Psymcipher$Paes_ct_dec.c + +$(OBJDIR)$Paes_ct_enc$O: src$Psymcipher$Paes_ct_enc.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Paes_ct_enc$O src$Psymcipher$Paes_ct_enc.c + +$(OBJDIR)$Paes_small_cbcdec$O: src$Psymcipher$Paes_small_cbcdec.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Paes_small_cbcdec$O src$Psymcipher$Paes_small_cbcdec.c + +$(OBJDIR)$Paes_small_cbcenc$O: src$Psymcipher$Paes_small_cbcenc.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Paes_small_cbcenc$O src$Psymcipher$Paes_small_cbcenc.c + +$(OBJDIR)$Paes_small_ctr$O: src$Psymcipher$Paes_small_ctr.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Paes_small_ctr$O src$Psymcipher$Paes_small_ctr.c + +$(OBJDIR)$Paes_small_dec$O: src$Psymcipher$Paes_small_dec.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Paes_small_dec$O src$Psymcipher$Paes_small_dec.c + +$(OBJDIR)$Paes_small_enc$O: src$Psymcipher$Paes_small_enc.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Paes_small_enc$O src$Psymcipher$Paes_small_enc.c + +$(OBJDIR)$Pchacha20_ct$O: src$Psymcipher$Pchacha20_ct.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pchacha20_ct$O src$Psymcipher$Pchacha20_ct.c + +$(OBJDIR)$Pdes_ct$O: src$Psymcipher$Pdes_ct.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pdes_ct$O src$Psymcipher$Pdes_ct.c + +$(OBJDIR)$Pdes_ct_cbcdec$O: src$Psymcipher$Pdes_ct_cbcdec.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pdes_ct_cbcdec$O src$Psymcipher$Pdes_ct_cbcdec.c + +$(OBJDIR)$Pdes_ct_cbcenc$O: src$Psymcipher$Pdes_ct_cbcenc.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pdes_ct_cbcenc$O src$Psymcipher$Pdes_ct_cbcenc.c + +$(OBJDIR)$Pdes_support$O: src$Psymcipher$Pdes_support.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pdes_support$O src$Psymcipher$Pdes_support.c + +$(OBJDIR)$Pdes_tab$O: src$Psymcipher$Pdes_tab.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pdes_tab$O src$Psymcipher$Pdes_tab.c + +$(OBJDIR)$Pdes_tab_cbcdec$O: src$Psymcipher$Pdes_tab_cbcdec.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pdes_tab_cbcdec$O src$Psymcipher$Pdes_tab_cbcdec.c + +$(OBJDIR)$Pdes_tab_cbcenc$O: src$Psymcipher$Pdes_tab_cbcenc.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pdes_tab_cbcenc$O src$Psymcipher$Pdes_tab_cbcenc.c + +$(OBJDIR)$Ppoly1305_ctmul$O: src$Psymcipher$Ppoly1305_ctmul.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Ppoly1305_ctmul$O src$Psymcipher$Ppoly1305_ctmul.c + +$(OBJDIR)$Ppoly1305_ctmul32$O: src$Psymcipher$Ppoly1305_ctmul32.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Ppoly1305_ctmul32$O src$Psymcipher$Ppoly1305_ctmul32.c + +$(OBJDIR)$Ppoly1305_i15$O: src$Psymcipher$Ppoly1305_i15.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Ppoly1305_i15$O src$Psymcipher$Ppoly1305_i15.c + +$(OBJDIR)$Pskey_decoder$O: src$Px509$Pskey_decoder.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pskey_decoder$O src$Px509$Pskey_decoder.c + +$(OBJDIR)$Px509_decoder$O: src$Px509$Px509_decoder.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Px509_decoder$O src$Px509$Px509_decoder.c + +$(OBJDIR)$Px509_knownkey$O: src$Px509$Px509_knownkey.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Px509_knownkey$O src$Px509$Px509_knownkey.c + +$(OBJDIR)$Px509_minimal$O: src$Px509$Px509_minimal.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Px509_minimal$O src$Px509$Px509_minimal.c + +$(OBJDIR)$Px509_minimal_full$O: src$Px509$Px509_minimal_full.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Px509_minimal_full$O src$Px509$Px509_minimal_full.c + +$(OBJDIR)$Pbrssl$O: tools$Pbrssl.c $(HEADERSTOOLS) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pbrssl$O tools$Pbrssl.c + +$(OBJDIR)$Pcerts$O: tools$Pcerts.c $(HEADERSTOOLS) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pcerts$O tools$Pcerts.c + +$(OBJDIR)$Pchain$O: tools$Pchain.c $(HEADERSTOOLS) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pchain$O tools$Pchain.c + +$(OBJDIR)$Pclient$O: tools$Pclient.c $(HEADERSTOOLS) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pclient$O tools$Pclient.c + +$(OBJDIR)$Perrors$O: tools$Perrors.c $(HEADERSTOOLS) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Perrors$O tools$Perrors.c + +$(OBJDIR)$Pfiles$O: tools$Pfiles.c $(HEADERSTOOLS) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pfiles$O tools$Pfiles.c + +$(OBJDIR)$Pkeys$O: tools$Pkeys.c $(HEADERSTOOLS) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pkeys$O tools$Pkeys.c + +$(OBJDIR)$Pnames$O: tools$Pnames.c $(HEADERSTOOLS) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pnames$O tools$Pnames.c + +$(OBJDIR)$Pserver$O: tools$Pserver.c $(HEADERSTOOLS) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pserver$O tools$Pserver.c + +$(OBJDIR)$Pskey$O: tools$Pskey.c $(HEADERSTOOLS) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pskey$O tools$Pskey.c + +$(OBJDIR)$Psslio$O: tools$Psslio.c $(HEADERSTOOLS) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Psslio$O tools$Psslio.c + +$(OBJDIR)$Pta$O: tools$Pta.c $(HEADERSTOOLS) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pta$O tools$Pta.c + +$(OBJDIR)$Pvector$O: tools$Pvector.c $(HEADERSTOOLS) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pvector$O tools$Pvector.c + +$(OBJDIR)$Pverify$O: tools$Pverify.c $(HEADERSTOOLS) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pverify$O tools$Pverify.c + +$(OBJDIR)$Pxmem$O: tools$Pxmem.c $(HEADERSTOOLS) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Pxmem$O tools$Pxmem.c + +$(OBJDIR)$Ptest_crypto$O: test$Ptest_crypto.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Ptest_crypto$O test$Ptest_crypto.c + +$(OBJDIR)$Ptest_speed$O: test$Ptest_speed.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) $(CCOUT)$(OBJDIR)$Ptest_speed$O test$Ptest_speed.c + +$(OBJDIR)$Ptest_x509$O: test$Ptest_x509.c $(HEADERSPRIV) + $(CC) $(CFLAGS) $(INCFLAGS) -DSRCDIRNAME=".." $(CCOUT)$(OBJDIR)$Ptest_x509$O test$Ptest_x509.c diff --git a/mk/SingleUnix.mk b/mk/SingleUnix.mk new file mode 100644 index 0000000..e169617 --- /dev/null +++ b/mk/SingleUnix.mk @@ -0,0 +1,38 @@ +# Copyright (c) 2017 Thomas Pornin +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS +# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +# ====================================================================== + +# This file sets variables for use with a SingleUnix-compatible 'make' +# utility. + +# Load generic default. +include mk/Defaults.mk + +# Path separator. +P = / + +# Default configuration is 'Unix' (native build on a Unix-like system). +CONF = Unix + +include conf/$(CONF).mk +include mk/Rules.mk diff --git a/mk/mkT0.cmd b/mk/mkT0.cmd new file mode 100644 index 0000000..9895562 --- /dev/null +++ b/mk/mkT0.cmd @@ -0,0 +1,32 @@ +@echo off + +rem ===================================================================== +rem This script uses the command-line C# compiler csc.exe, which is +rem provided with the .NET framework. We need framework 3.5 or later +rem (some of the code uses features not available in the language version +rem implemented in the compiler provided with framework 2.0.50727). +rem ===================================================================== + +if exist "%SystemRoot%\Microsoft.NET\Framework\v3.5\csc.exe" ( + set CSC="%SystemRoot%\Microsoft.NET\Framework\v3.5\csc.exe" + goto do_compile +) +if exist "%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\csc.exe" ( + set CSC="%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\csc.exe" + goto do_compile +) +if exist "%SystemRoot%\Microsoft.NET\Framework64\v3.5\csc.exe" ( + set CSC="%SystemRoot%\Microsoft.NET\Framework64\v3.5\csc.exe" + goto do_compile +) +if exist "%SystemRoot%\Microsoft.NET\Framework64\v4.0.30319\csc.exe" ( + set CSC="%SystemRoot%\Microsoft.NET\Framework64\v4.0.30319\csc.exe" + goto do_compile +) + +echo C# compiler not found +exit 1 + +:do_compile +%CSC% /nologo /out:T0Comp.exe /main:T0Comp /res:T0\kern.t0,t0-kernel T0\*.cs +if %errorlevel% neq 0 exit /b %errorlevel% diff --git a/mkT0.sh b/mk/mkT0.sh similarity index 100% rename from mkT0.sh rename to mk/mkT0.sh diff --git a/mk/mkrules.sh b/mk/mkrules.sh new file mode 100755 index 0000000..c83a426 --- /dev/null +++ b/mk/mkrules.sh @@ -0,0 +1,458 @@ +#! /bin/sh + +# ======================================================================== +# +# Copyright (c) 2017 Thomas Pornin +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS +# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# +# ======================================================================== +# +# This script is used to generate the 'Rules.mk' file from the list +# of source file included below. If the list changes (e.g. to add a +# new source file), then add it here and rerun this script. +# +# ======================================================================== + +# Solaris compatibility: switch to a more POSIX-compliant /bin/sh. +if [ -z "$BR_SCRIPT_LOOP" ] ; then + BR_SCRIPT_LOOP=yes + export BR_SCRIPT_LOOP + if [ -x /usr/xpg6/bin/sh ] ; then + exec /usr/xpg6/bin/sh "$0" "$@" + fi + if [ -x /usr/xpg4/bin/sh ] ; then + exec /usr/xpg4/bin/sh "$0" "$@" + fi +fi + +# Exit on first error. +set -e + +# Source files. Please keep in alphabetical order. +coresrc=" \ + src/codec/ccopy.c \ + src/codec/dec16be.c \ + src/codec/dec16le.c \ + src/codec/dec32be.c \ + src/codec/dec32le.c \ + src/codec/dec64be.c \ + src/codec/dec64le.c \ + src/codec/enc16be.c \ + src/codec/enc16le.c \ + src/codec/enc32be.c \ + src/codec/enc32le.c \ + src/codec/enc64be.c \ + src/codec/enc64le.c \ + src/codec/pemdec.c \ + src/ec/ec_all_m15.c \ + src/ec/ec_all_m31.c \ + src/ec/ec_c25519_i15.c \ + src/ec/ec_c25519_i31.c \ + src/ec/ec_c25519_m15.c \ + src/ec/ec_c25519_m31.c \ + src/ec/ec_curve25519.c \ + src/ec/ec_p256_m15.c \ + src/ec/ec_p256_m31.c \ + src/ec/ec_prime_i15.c \ + src/ec/ec_prime_i31.c \ + src/ec/ec_secp256r1.c \ + src/ec/ec_secp384r1.c \ + src/ec/ec_secp521r1.c \ + src/ec/ecdsa_atr.c \ + src/ec/ecdsa_i15_bits.c \ + src/ec/ecdsa_i15_sign_asn1.c \ + src/ec/ecdsa_i15_sign_raw.c \ + src/ec/ecdsa_i15_vrfy_asn1.c \ + src/ec/ecdsa_i15_vrfy_raw.c \ + src/ec/ecdsa_i31_bits.c \ + src/ec/ecdsa_i31_sign_asn1.c \ + src/ec/ecdsa_i31_sign_raw.c \ + src/ec/ecdsa_i31_vrfy_asn1.c \ + src/ec/ecdsa_i31_vrfy_raw.c \ + src/ec/ecdsa_rta.c \ + src/hash/dig_oid.c \ + src/hash/dig_size.c \ + src/hash/ghash_ctmul.c \ + src/hash/ghash_ctmul32.c \ + src/hash/ghash_ctmul64.c \ + src/hash/md5.c \ + src/hash/md5sha1.c \ + src/hash/multihash.c \ + src/hash/sha1.c \ + src/hash/sha2big.c \ + src/hash/sha2small.c \ + src/int/i15_add.c \ + src/int/i15_bitlen.c \ + src/int/i15_decmod.c \ + src/int/i15_decode.c \ + src/int/i15_decred.c \ + src/int/i15_encode.c \ + src/int/i15_fmont.c \ + src/int/i15_iszero.c \ + src/int/i15_modpow.c \ + src/int/i15_montmul.c \ + src/int/i15_mulacc.c \ + src/int/i15_muladd.c \ + src/int/i15_ninv15.c \ + src/int/i15_reduce.c \ + src/int/i15_rshift.c \ + src/int/i15_sub.c \ + src/int/i15_tmont.c \ + src/int/i31_add.c \ + src/int/i31_bitlen.c \ + src/int/i31_decmod.c \ + src/int/i31_decode.c \ + src/int/i31_decred.c \ + src/int/i31_encode.c \ + src/int/i31_fmont.c \ + src/int/i31_iszero.c \ + src/int/i31_modpow.c \ + src/int/i31_montmul.c \ + src/int/i31_mulacc.c \ + src/int/i31_muladd.c \ + src/int/i31_ninv31.c \ + src/int/i31_reduce.c \ + src/int/i31_rshift.c \ + src/int/i31_sub.c \ + src/int/i31_tmont.c \ + src/int/i32_add.c \ + src/int/i32_bitlen.c \ + src/int/i32_decmod.c \ + src/int/i32_decode.c \ + src/int/i32_decred.c \ + src/int/i32_div32.c \ + src/int/i32_encode.c \ + src/int/i32_fmont.c \ + src/int/i32_iszero.c \ + src/int/i32_modpow.c \ + src/int/i32_montmul.c \ + src/int/i32_mulacc.c \ + src/int/i32_muladd.c \ + src/int/i32_ninv32.c \ + src/int/i32_reduce.c \ + src/int/i32_sub.c \ + src/int/i32_tmont.c \ + src/mac/hmac.c \ + src/mac/hmac_ct.c \ + src/rand/hmac_drbg.c \ + src/rsa/rsa_i15_pkcs1_sign.c \ + src/rsa/rsa_i15_pkcs1_vrfy.c \ + src/rsa/rsa_i15_priv.c \ + src/rsa/rsa_i15_pub.c \ + src/rsa/rsa_i31_pkcs1_sign.c \ + src/rsa/rsa_i31_pkcs1_vrfy.c \ + src/rsa/rsa_i31_priv.c \ + src/rsa/rsa_i31_pub.c \ + src/rsa/rsa_i32_pkcs1_sign.c \ + src/rsa/rsa_i32_pkcs1_vrfy.c \ + src/rsa/rsa_i32_priv.c \ + src/rsa/rsa_i32_pub.c \ + src/rsa/rsa_pkcs1_sig_pad.c \ + src/rsa/rsa_pkcs1_sig_unpad.c \ + src/rsa/rsa_ssl_decrypt.c \ + src/ssl/prf.c \ + src/ssl/prf_md5sha1.c \ + src/ssl/prf_sha256.c \ + src/ssl/prf_sha384.c \ + src/ssl/ssl_ccert_single_ec.c \ + src/ssl/ssl_ccert_single_rsa.c \ + src/ssl/ssl_client.c \ + src/ssl/ssl_client_full.c \ + src/ssl/ssl_engine.c \ + src/ssl/ssl_hashes.c \ + src/ssl/ssl_hs_client.c \ + src/ssl/ssl_hs_server.c \ + src/ssl/ssl_io.c \ + src/ssl/ssl_lru.c \ + src/ssl/ssl_rec_cbc.c \ + src/ssl/ssl_rec_chapol.c \ + src/ssl/ssl_rec_gcm.c \ + src/ssl/ssl_scert_single_ec.c \ + src/ssl/ssl_scert_single_rsa.c \ + src/ssl/ssl_server.c \ + src/ssl/ssl_server_full_ec.c \ + src/ssl/ssl_server_full_rsa.c \ + src/ssl/ssl_server_mine2c.c \ + src/ssl/ssl_server_mine2g.c \ + src/ssl/ssl_server_minf2c.c \ + src/ssl/ssl_server_minf2g.c \ + src/ssl/ssl_server_minr2g.c \ + src/ssl/ssl_server_minu2g.c \ + src/ssl/ssl_server_minv2g.c \ + src/symcipher/aes_big_cbcdec.c \ + src/symcipher/aes_big_cbcenc.c \ + src/symcipher/aes_big_ctr.c \ + src/symcipher/aes_big_dec.c \ + src/symcipher/aes_big_enc.c \ + src/symcipher/aes_common.c \ + src/symcipher/aes_ct.c \ + src/symcipher/aes_ct64.c \ + src/symcipher/aes_ct64_cbcdec.c \ + src/symcipher/aes_ct64_cbcenc.c \ + src/symcipher/aes_ct64_ctr.c \ + src/symcipher/aes_ct64_dec.c \ + src/symcipher/aes_ct64_enc.c \ + src/symcipher/aes_ct_cbcdec.c \ + src/symcipher/aes_ct_cbcenc.c \ + src/symcipher/aes_ct_ctr.c \ + src/symcipher/aes_ct_dec.c \ + src/symcipher/aes_ct_enc.c \ + src/symcipher/aes_small_cbcdec.c \ + src/symcipher/aes_small_cbcenc.c \ + src/symcipher/aes_small_ctr.c \ + src/symcipher/aes_small_dec.c \ + src/symcipher/aes_small_enc.c \ + src/symcipher/chacha20_ct.c \ + src/symcipher/des_ct.c \ + src/symcipher/des_ct_cbcdec.c \ + src/symcipher/des_ct_cbcenc.c \ + src/symcipher/des_support.c \ + src/symcipher/des_tab.c \ + src/symcipher/des_tab_cbcdec.c \ + src/symcipher/des_tab_cbcenc.c \ + src/symcipher/poly1305_ctmul.c \ + src/symcipher/poly1305_ctmul32.c \ + src/symcipher/poly1305_i15.c \ + src/x509/skey_decoder.c \ + src/x509/x509_decoder.c \ + src/x509/x509_knownkey.c \ + src/x509/x509_minimal.c \ + src/x509/x509_minimal_full.c" + +# Source files for the 'brssl' command-line tool. +toolssrc=" \ + tools/brssl.c \ + tools/certs.c \ + tools/chain.c \ + tools/client.c \ + tools/errors.c \ + tools/files.c \ + tools/keys.c \ + tools/names.c \ + tools/server.c \ + tools/skey.c \ + tools/sslio.c \ + tools/ta.c \ + tools/vector.c \ + tools/verify.c \ + tools/xmem.c" + +# Source files the the 'testcrypto' command-line tool. +testcryptosrc=" \ + test/test_crypto.c" + +# Source files the the 'testspeed' command-line tool. +testspeedsrc=" \ + test/test_speed.c" + +# Source files the the 'testx509' command-line tool. +testx509src=" \ + test/test_x509.c" + +# Public header files. +headerspub=" \ + inc/bearssl.h \ + inc/bearssl_block.h \ + inc/bearssl_ec.h \ + inc/bearssl_hash.h \ + inc/bearssl_hmac.h \ + inc/bearssl_pem.h \ + inc/bearssl_prf.h \ + inc/bearssl_rand.h \ + inc/bearssl_rsa.h \ + inc/bearssl_ssl.h \ + inc/bearssl_x509.h" + +# Private header files. +headerspriv=" \ + src/config.h \ + src/inner.h" + +# Header files for the 'brssl' command-line tool. +headerstools=" \ + tools/brssl.h" + +# T0 compiler source code. +t0compsrc=" \ + T0/BlobWriter.cs \ + T0/CPU.cs \ + T0/CodeElement.cs \ + T0/CodeElementJump.cs \ + T0/CodeElementUInt.cs \ + T0/CodeElementUIntExpr.cs \ + T0/CodeElementUIntInt.cs \ + T0/CodeElementUIntUInt.cs \ + T0/ConstData.cs \ + T0/Opcode.cs \ + T0/OpcodeCall.cs \ + T0/OpcodeConst.cs \ + T0/OpcodeGetLocal.cs \ + T0/OpcodeJump.cs \ + T0/OpcodeJumpIf.cs \ + T0/OpcodeJumpIfNot.cs \ + T0/OpcodeJumpUncond.cs \ + T0/OpcodePutLocal.cs \ + T0/OpcodeRet.cs \ + T0/SType.cs \ + T0/T0Comp.cs \ + T0/TPointerBase.cs \ + T0/TPointerBlob.cs \ + T0/TPointerExpr.cs \ + T0/TPointerNull.cs \ + T0/TPointerXT.cs \ + T0/TValue.cs \ + T0/Word.cs \ + T0/WordBuilder.cs \ + T0/WordData.cs \ + T0/WordInterpreted.cs \ + T0/WordNative.cs" + +t0compkern=" \ + T0/kern.t0" + +# Function to turn slashes into $P (macro for path separator). +escsep() { + printf '%s' "$1" | sed 's/\//$P/g' +} + +# Create rules file. +rm -f Rules.mk +cat > Rules.mk <> Rules.mk + +cat >> Rules.mk <> Rules.mk diff --git a/src/codec/pemdec.c b/src/codec/pemdec.c index 04999f2..51e610b 100644 --- a/src/codec/pemdec.c +++ b/src/codec/pemdec.c @@ -58,7 +58,7 @@ t0_parse7E_signed(const unsigned char **p) #define T0_INT4(x) T0_VBYTE(x, 21), T0_VBYTE(x, 14), T0_VBYTE(x, 7), T0_FBYTE(x, 0) #define T0_INT5(x) T0_SBYTE(x), T0_VBYTE(x, 21), T0_VBYTE(x, 14), T0_VBYTE(x, 7), T0_FBYTE(x, 0) -static const uint8_t t0_datablock[]; +/* static const unsigned char t0_datablock[]; */ void br_pem_decoder_init_main(void *t0ctx); @@ -109,12 +109,12 @@ br_pem_decoder_event(br_pem_decoder_context *ctx) -static const uint8_t t0_datablock[] = { +static const unsigned char t0_datablock[] = { 0x00, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x42, 0x45, 0x47, 0x49, 0x4E, 0x20, 0x00, 0x2D, 0x2D, 0x2D, 0x2D, 0x45, 0x4E, 0x44, 0x20, 0x00 }; -static const uint8_t t0_codeblock[] = { +static const unsigned char t0_codeblock[] = { 0x00, 0x01, 0x00, 0x09, 0x00, 0x00, 0x01, 0x01, 0x07, 0x00, 0x00, 0x01, 0x01, 0x08, 0x00, 0x00, 0x13, 0x13, 0x00, 0x00, 0x01, T0_INT2(offsetof(br_pem_decoder_context, event)), 0x00, 0x00, 0x01, diff --git a/src/inner.h b/src/inner.h index 8ada612..e5c45b3 100644 --- a/src/inner.h +++ b/src/inner.h @@ -31,6 +31,15 @@ #include "config.h" #include "bearssl.h" +/* + * On MSVC, disable the warning about applying unary minus on an + * unsigned type: it is standard, we do it all the time, and for + * good reasons. + */ +#if _MSC_VER +#pragma warning( disable : 4146 ) +#endif + /* * Maximum size for a RSA modulus (in bits). Allocated stack buffers * depend on that size, so this value should be kept small. Currently, @@ -300,7 +309,7 @@ static inline void br_multihash_copyimpl(br_multihash_context *dst, const br_multihash_context *src) { - memcpy(dst->impl, src->impl, sizeof src->impl); + memcpy((void *)dst->impl, src->impl, sizeof src->impl); } /* ==================================================================== */ diff --git a/src/ssl/ssl_hs_client.c b/src/ssl/ssl_hs_client.c index c703f8c..25b2906 100644 --- a/src/ssl/ssl_hs_client.c +++ b/src/ssl/ssl_hs_client.c @@ -58,7 +58,7 @@ t0_parse7E_signed(const unsigned char **p) #define T0_INT4(x) T0_VBYTE(x, 21), T0_VBYTE(x, 14), T0_VBYTE(x, 7), T0_FBYTE(x, 0) #define T0_INT5(x) T0_SBYTE(x), T0_VBYTE(x, 21), T0_VBYTE(x, 14), T0_VBYTE(x, 7), T0_FBYTE(x, 0) -static const uint8_t t0_datablock[]; +/* static const unsigned char t0_datablock[]; */ void br_ssl_hs_client_init_main(void *t0ctx); @@ -416,7 +416,7 @@ make_client_sign(br_ssl_client_context *ctx) -static const uint8_t t0_datablock[] = { +static const unsigned char t0_datablock[] = { 0x00, 0x00, 0x0A, 0x00, 0x24, 0x00, 0x2F, 0x01, 0x24, 0x00, 0x35, 0x02, 0x24, 0x00, 0x3C, 0x01, 0x44, 0x00, 0x3D, 0x02, 0x44, 0x00, 0x9C, 0x03, 0x04, 0x00, 0x9D, 0x04, 0x05, 0xC0, 0x03, 0x40, 0x24, 0xC0, 0x04, 0x41, @@ -432,7 +432,7 @@ static const uint8_t t0_datablock[] = { 0x04, 0xCC, 0xA9, 0x25, 0x04, 0x00, 0x00 }; -static const uint8_t t0_codeblock[] = { +static const unsigned char t0_codeblock[] = { 0x00, 0x01, 0x00, 0x0A, 0x00, 0x00, 0x01, 0x00, 0x0D, 0x00, 0x00, 0x01, 0x00, 0x0E, 0x00, 0x00, 0x01, 0x00, 0x0F, 0x00, 0x00, 0x01, 0x01, 0x08, 0x00, 0x00, 0x01, 0x01, 0x09, 0x00, 0x00, 0x01, 0x02, 0x08, 0x00, 0x00, diff --git a/src/ssl/ssl_hs_server.c b/src/ssl/ssl_hs_server.c index 380fd7b..489fd74 100644 --- a/src/ssl/ssl_hs_server.c +++ b/src/ssl/ssl_hs_server.c @@ -58,7 +58,7 @@ t0_parse7E_signed(const unsigned char **p) #define T0_INT4(x) T0_VBYTE(x, 21), T0_VBYTE(x, 14), T0_VBYTE(x, 7), T0_FBYTE(x, 0) #define T0_INT5(x) T0_SBYTE(x), T0_VBYTE(x, 21), T0_VBYTE(x, 14), T0_VBYTE(x, 7), T0_FBYTE(x, 0) -static const uint8_t t0_datablock[]; +/* static const unsigned char t0_datablock[]; */ void br_ssl_hs_server_init_main(void *t0ctx); @@ -445,7 +445,7 @@ verify_CV_sig(br_ssl_server_context *ctx, size_t sig_len) -static const uint8_t t0_datablock[] = { +static const unsigned char t0_datablock[] = { 0x00, 0x00, 0x0A, 0x00, 0x24, 0x00, 0x2F, 0x01, 0x24, 0x00, 0x35, 0x02, 0x24, 0x00, 0x3C, 0x01, 0x44, 0x00, 0x3D, 0x02, 0x44, 0x00, 0x9C, 0x03, 0x04, 0x00, 0x9D, 0x04, 0x05, 0xC0, 0x03, 0x40, 0x24, 0xC0, 0x04, 0x41, @@ -461,7 +461,7 @@ static const uint8_t t0_datablock[] = { 0x04, 0xCC, 0xA9, 0x25, 0x04, 0x00, 0x00 }; -static const uint8_t t0_codeblock[] = { +static const unsigned char t0_codeblock[] = { 0x00, 0x01, 0x00, 0x0B, 0x00, 0x00, 0x01, 0x00, 0x0E, 0x00, 0x00, 0x01, 0x00, 0x0F, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x00, 0x01, 0x01, 0x08, 0x00, 0x00, 0x01, 0x01, 0x09, 0x00, 0x00, 0x01, 0x02, 0x08, 0x00, 0x00, diff --git a/src/x509/skey_decoder.c b/src/x509/skey_decoder.c index be681dd..4c486d5 100644 --- a/src/x509/skey_decoder.c +++ b/src/x509/skey_decoder.c @@ -58,7 +58,7 @@ t0_parse7E_signed(const unsigned char **p) #define T0_INT4(x) T0_VBYTE(x, 21), T0_VBYTE(x, 14), T0_VBYTE(x, 7), T0_FBYTE(x, 0) #define T0_INT5(x) T0_SBYTE(x), T0_VBYTE(x, 21), T0_VBYTE(x, 14), T0_VBYTE(x, 7), T0_FBYTE(x, 0) -static const uint8_t t0_datablock[]; +/* static const unsigned char t0_datablock[]; */ void br_skey_decoder_init_main(void *t0ctx); @@ -101,14 +101,14 @@ br_skey_decoder_push(br_skey_decoder_context *ctx, -static const uint8_t t0_datablock[] = { +static const unsigned char t0_datablock[] = { 0x00, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x07, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x02, 0x01, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x03, 0x01, 0x07, 0x05, 0x2B, 0x81, 0x04, 0x00, 0x22, 0x05, 0x2B, 0x81, 0x04, 0x00, 0x23 }; -static const uint8_t t0_codeblock[] = { +static const unsigned char t0_codeblock[] = { 0x00, 0x01, 0x01, 0x07, 0x00, 0x00, 0x01, 0x01, 0x08, 0x00, 0x00, 0x13, 0x13, 0x00, 0x00, 0x01, T0_INT1(BR_ERR_X509_BAD_TAG_CLASS), 0x00, 0x00, 0x01, T0_INT1(BR_ERR_X509_BAD_TAG_VALUE), 0x00, 0x00, 0x01, diff --git a/src/x509/x509_decoder.c b/src/x509/x509_decoder.c index 64a7996..42620c6 100644 --- a/src/x509/x509_decoder.c +++ b/src/x509/x509_decoder.c @@ -58,7 +58,7 @@ t0_parse7E_signed(const unsigned char **p) #define T0_INT4(x) T0_VBYTE(x, 21), T0_VBYTE(x, 14), T0_VBYTE(x, 7), T0_FBYTE(x, 0) #define T0_INT5(x) T0_SBYTE(x), T0_VBYTE(x, 21), T0_VBYTE(x, 14), T0_VBYTE(x, 7), T0_FBYTE(x, 0) -static const uint8_t t0_datablock[]; +/* static const unsigned char t0_datablock[]; */ void br_x509_decoder_init_main(void *t0ctx); @@ -110,7 +110,7 @@ br_x509_decoder_push(br_x509_decoder_context *ctx, -static const uint8_t t0_datablock[] = { +static const unsigned char t0_datablock[] = { 0x00, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x05, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x0E, 0x09, 0x2A, 0x86, 0x48, 0x86, @@ -129,7 +129,7 @@ static const uint8_t t0_datablock[] = { 0x29, 0xFF, 0x03, 0x55, 0x1D, 0x13 }; -static const uint8_t t0_codeblock[] = { +static const unsigned char t0_codeblock[] = { 0x00, 0x01, 0x00, 0x10, 0x00, 0x00, 0x01, 0x00, 0x11, 0x00, 0x00, 0x01, 0x01, 0x09, 0x00, 0x00, 0x01, 0x01, 0x0A, 0x00, 0x00, 0x1A, 0x1A, 0x00, 0x00, 0x01, T0_INT1(BR_ERR_X509_BAD_BOOLEAN), 0x00, 0x00, 0x01, diff --git a/src/x509/x509_minimal.c b/src/x509/x509_minimal.c index 0476a29..59dc1b8 100644 --- a/src/x509/x509_minimal.c +++ b/src/x509/x509_minimal.c @@ -58,7 +58,7 @@ t0_parse7E_signed(const unsigned char **p) #define T0_INT4(x) T0_VBYTE(x, 21), T0_VBYTE(x, 14), T0_VBYTE(x, 7), T0_FBYTE(x, 0) #define T0_INT5(x) T0_SBYTE(x), T0_VBYTE(x, 21), T0_VBYTE(x, 14), T0_VBYTE(x, 7), T0_FBYTE(x, 0) -static const uint8_t t0_datablock[]; +/* static const unsigned char t0_datablock[]; */ void br_x509_minimal_init_main(void *t0ctx); @@ -392,55 +392,6 @@ eqbigint(const unsigned char *b1, size_t len1, return memcmp(b1, b2, len1) == 0; } -/* - * Verify the signature on the certificate with the provided public key. - * This function checks the public key type with regards to the expected - * type. Returned value is either 0 on success, or a non-zero error code. - */ -static int -verify_signature(br_x509_minimal_context *ctx, const br_x509_pkey *pk) -{ - int kt; - - kt = ctx->cert_signer_key_type; - if ((pk->key_type & 0x0F) != kt) { - return BR_ERR_X509_WRONG_KEY_TYPE; - } - switch (kt) { - unsigned char tmp[64]; - - case BR_KEYTYPE_RSA: - if (ctx->irsa == 0) { - return BR_ERR_X509_UNSUPPORTED; - } - if (!ctx->irsa(ctx->cert_sig, ctx->cert_sig_len, - &t0_datablock[ctx->cert_sig_hash_oid], - ctx->cert_sig_hash_len, &pk->key.rsa, tmp)) - { - return BR_ERR_X509_BAD_SIGNATURE; - } - if (memcmp(ctx->tbs_hash, tmp, ctx->cert_sig_hash_len) != 0) { - return BR_ERR_X509_BAD_SIGNATURE; - } - return 0; - - case BR_KEYTYPE_EC: - if (ctx->iecdsa == 0) { - return BR_ERR_X509_UNSUPPORTED; - } - if (!ctx->iecdsa(ctx->iec, ctx->tbs_hash, - ctx->cert_sig_hash_len, &pk->key.ec, - ctx->cert_sig, ctx->cert_sig_len)) - { - return BR_ERR_X509_BAD_SIGNATURE; - } - return 0; - - default: - return BR_ERR_X509_UNSUPPORTED; - } -} - /* * Compare two strings for equality, in a case-insensitive way. This * function handles casing only for ASCII letters. @@ -470,9 +421,12 @@ eqnocase(const void *s1, const void *s2, size_t len) return 1; } +static int verify_signature(br_x509_minimal_context *ctx, + const br_x509_pkey *pk); -static const uint8_t t0_datablock[] = { + +static const unsigned char t0_datablock[] = { 0x00, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x05, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x0E, 0x09, 0x2A, 0x86, 0x48, 0x86, @@ -499,7 +453,7 @@ static const uint8_t t0_datablock[] = { 0x01, 0x08, 0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x01, 0x0B }; -static const uint8_t t0_codeblock[] = { +static const unsigned char t0_codeblock[] = { 0x00, 0x01, 0x00, 0x0D, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x00, 0x01, 0x00, 0x11, 0x00, 0x00, 0x01, 0x01, 0x09, 0x00, 0x00, 0x01, 0x01, 0x0A, 0x00, 0x00, 0x24, 0x24, 0x00, 0x00, 0x01, @@ -1704,3 +1658,56 @@ t0_exit: ((t0_context *)t0ctx)->rp = rp; ((t0_context *)t0ctx)->ip = ip; } + + + +/* + * Verify the signature on the certificate with the provided public key. + * This function checks the public key type with regards to the expected + * type. Returned value is either 0 on success, or a non-zero error code. + */ +static int +verify_signature(br_x509_minimal_context *ctx, const br_x509_pkey *pk) +{ + int kt; + + kt = ctx->cert_signer_key_type; + if ((pk->key_type & 0x0F) != kt) { + return BR_ERR_X509_WRONG_KEY_TYPE; + } + switch (kt) { + unsigned char tmp[64]; + + case BR_KEYTYPE_RSA: + if (ctx->irsa == 0) { + return BR_ERR_X509_UNSUPPORTED; + } + if (!ctx->irsa(ctx->cert_sig, ctx->cert_sig_len, + &t0_datablock[ctx->cert_sig_hash_oid], + ctx->cert_sig_hash_len, &pk->key.rsa, tmp)) + { + return BR_ERR_X509_BAD_SIGNATURE; + } + if (memcmp(ctx->tbs_hash, tmp, ctx->cert_sig_hash_len) != 0) { + return BR_ERR_X509_BAD_SIGNATURE; + } + return 0; + + case BR_KEYTYPE_EC: + if (ctx->iecdsa == 0) { + return BR_ERR_X509_UNSUPPORTED; + } + if (!ctx->iecdsa(ctx->iec, ctx->tbs_hash, + ctx->cert_sig_hash_len, &pk->key.ec, + ctx->cert_sig, ctx->cert_sig_len)) + { + return BR_ERR_X509_BAD_SIGNATURE; + } + return 0; + + default: + return BR_ERR_X509_UNSUPPORTED; + } +} + + diff --git a/src/x509/x509_minimal.t0 b/src/x509/x509_minimal.t0 index f8c7f25..7b7b2e6 100644 --- a/src/x509/x509_minimal.t0 +++ b/src/x509/x509_minimal.t0 @@ -341,6 +341,42 @@ eqbigint(const unsigned char *b1, size_t len1, return memcmp(b1, b2, len1) == 0; } +/* + * Compare two strings for equality, in a case-insensitive way. This + * function handles casing only for ASCII letters. + */ +static int +eqnocase(const void *s1, const void *s2, size_t len) +{ + const unsigned char *buf1, *buf2; + + buf1 = s1; + buf2 = s2; + while (len -- > 0) { + int x1, x2; + + x1 = *buf1 ++; + x2 = *buf2 ++; + if (x1 >= 'A' && x1 <= 'Z') { + x1 += 'a' - 'A'; + } + if (x2 >= 'A' && x2 <= 'Z') { + x2 += 'a' - 'A'; + } + if (x1 != x2) { + return 0; + } + } + return 1; +} + +static int verify_signature(br_x509_minimal_context *ctx, + const br_x509_pkey *pk); + +} + +postamble { + /* * Verify the signature on the certificate with the provided public key. * This function checks the public key type with regards to the expected @@ -390,35 +426,6 @@ verify_signature(br_x509_minimal_context *ctx, const br_x509_pkey *pk) } } -/* - * Compare two strings for equality, in a case-insensitive way. This - * function handles casing only for ASCII letters. - */ -static int -eqnocase(const void *s1, const void *s2, size_t len) -{ - const unsigned char *buf1, *buf2; - - buf1 = s1; - buf2 = s2; - while (len -- > 0) { - int x1, x2; - - x1 = *buf1 ++; - x2 = *buf2 ++; - if (x1 >= 'A' && x1 <= 'Z') { - x1 += 'a' - 'A'; - } - if (x2 >= 'A' && x2 <= 'Z') { - x2 += 'a' - 'A'; - } - if (x1 != x2) { - return 0; - } - } - return 1; -} - } cc: read8-low ( -- x ) { diff --git a/test/test_x509.c b/test/test_x509.c index 344f8d9..6f75feb 100644 --- a/test/test_x509.c +++ b/test/test_x509.c @@ -27,6 +27,12 @@ #include #include +#ifdef _WIN32 +#include +#else +#include +#endif + #include "bearssl.h" #define STR(x) STR_(x) @@ -1976,10 +1982,59 @@ test_name_extraction(void) } int -main(void) +main(int argc, const char *argv[]) { size_t u; +#ifdef SRCDIRNAME + /* + * We want to change the current directory to that of the + * executable, so that test files are reliably located. We + * do that only if SRCDIRNAME is defined (old Makefile would + * not do that). + */ + if (argc >= 1) { + const char *arg, *c; + + arg = argv[0]; + for (c = arg + strlen(arg);; c --) { + int sep, r; + +#ifdef _WIN32 + sep = (*c == '/') || (*c == '\\'); +#else + sep = (*c == '/'); +#endif + if (sep) { + size_t len; + char *dn; + + len = 1 + (c - arg); + dn = xmalloc(len + 1); + memcpy(dn, arg, len); + dn[len] = 0; +#ifdef _WIN32 + r = _chdir(dn); +#else + r = chdir(dn); +#endif + if (r != 0) { + fprintf(stderr, "warning: could not" + " set directory to '%s'\n", dn); + } + xfree(dn); + break; + } + if (c == arg) { + break; + } + } + } +#else + (void)argc; + (void)argv; +#endif + process_conf_file(CONFFILE); max_dp_usage = 0; diff --git a/tools/brssl.c b/tools/brssl.c index 982dc18..aba79e1 100644 --- a/tools/brssl.c +++ b/tools/brssl.c @@ -28,8 +28,16 @@ #include #include +/* + * Network stuff on Windows requires some specific code. + */ +#ifdef _WIN32 +#include +#include +#pragma comment(lib, "Ws2_32.lib") +#endif + #include "brssl.h" -#include "bearssl.h" static void usage(void) @@ -53,6 +61,18 @@ main(int argc, char *argv[]) usage(); return EXIT_FAILURE; } +#ifdef _WIN32 + { + WSADATA wd; + int r; + + r = WSAStartup(MAKEWORD(2, 2), &wd); + if (r != 0) { + fprintf(stderr, "WARNING: network initialisation" + " failed (WSAStartup() returned %d)\n", r); + } + } +#endif cmd = argv[1]; if (eqstr(cmd, "client")) { if (do_client(argc - 2, argv + 2) < 0) { diff --git a/tools/brssl.h b/tools/brssl.h index d889b08..8c84b04 100644 --- a/tools/brssl.h +++ b/tools/brssl.h @@ -475,13 +475,17 @@ const char *find_error_name(int err, const char **comment); * Run a SSL engine, with a socket connected to the peer, and using * stdin/stdout to exchange application data. * + * To help with Win32 compatibility, the socket descriptor is provided + * as an "unsigned long" value. + * * Returned value: * 0 SSL connection closed successfully * x > 0 SSL error "x" * -1 early socket close * -2 stdout was closed, or something failed badly */ -int run_ssl_engine(br_ssl_engine_context *eng, int fd, unsigned flags); +int run_ssl_engine(br_ssl_engine_context *eng, + unsigned long fd, unsigned flags); #define RUN_ENGINE_VERBOSE 0x0001 /* enable verbose messages */ #define RUN_ENGINE_TRACE 0x0002 /* hex dump of records */ diff --git a/tools/client.c b/tools/client.c index ce3c6d6..37b8877 100644 --- a/tools/client.c +++ b/tools/client.c @@ -29,6 +29,10 @@ #include #include +#ifdef _WIN32 +#include +#include +#else #include #include #include @@ -37,14 +41,17 @@ #include #include +#define SOCKET int +#define INVALID_SOCKET (-1) +#endif + #include "brssl.h" -#include "bearssl.h" static int host_connect(const char *host, const char *port, int verbose) { struct addrinfo hints, *si, *p; - int fd; + SOCKET fd; int err; memset(&hints, 0, sizeof hints); @@ -54,9 +61,9 @@ host_connect(const char *host, const char *port, int verbose) if (err != 0) { fprintf(stderr, "ERROR: getaddrinfo(): %s\n", gai_strerror(err)); - return -1; + return INVALID_SOCKET; } - fd = -1; + fd = INVALID_SOCKET; for (p = si; p != NULL; p = p->ai_next) { if (verbose) { struct sockaddr *sa; @@ -84,17 +91,21 @@ host_connect(const char *host, const char *port, int verbose) fprintf(stderr, "connecting to: %s\n", tmp); } fd = socket(p->ai_family, p->ai_socktype, p->ai_protocol); - if (fd < 0) { + if (fd == INVALID_SOCKET) { if (verbose) { perror("socket()"); } continue; } - if (connect(fd, p->ai_addr, p->ai_addrlen) < 0) { + if (connect(fd, p->ai_addr, p->ai_addrlen) == INVALID_SOCKET) { if (verbose) { perror("connect()"); } +#ifdef _WIN32 + closesocket(fd); +#else close(fd); +#endif continue; } break; @@ -102,7 +113,7 @@ host_connect(const char *host, const char *port, int verbose) if (p == NULL) { freeaddrinfo(si); fprintf(stderr, "ERROR: failed to connect\n"); - return -1; + return INVALID_SOCKET; } freeaddrinfo(si); if (verbose) { @@ -111,9 +122,18 @@ host_connect(const char *host, const char *port, int verbose) /* * We make the socket non-blocking, since we are going to use - * poll() to organise I/O. + * poll() or select() to organise I/O. */ +#ifdef _WIN32 + { + u_long arg; + + arg = 1; + ioctlsocket(fd, FIONBIO, &arg); + } +#else fcntl(fd, F_SETFL, O_NONBLOCK); +#endif return fd; } @@ -494,7 +514,7 @@ do_client(int argc, char *argv[]) const char *sni; anchor_list anchors = VEC_INIT; unsigned vmin, vmax; - VECTOR(const char *) alpn_names = VEC_INIT; + VECTOR(char *) alpn_names = VEC_INIT; cipher_suite *suites; size_t num_suites; uint16_t *suite_ids; @@ -514,7 +534,7 @@ do_client(int argc, char *argv[]) size_t minhello_len; int fallback; uint32_t flags; - int fd; + SOCKET fd; retcode = 0; verbose = 1; @@ -539,7 +559,7 @@ do_client(int argc, char *argv[]) minhello_len = (size_t)-1; fallback = 0; flags = 0; - fd = -1; + fd = INVALID_SOCKET; for (i = 0; i < argc; i ++) { const char *arg; @@ -1031,7 +1051,8 @@ do_client(int argc, char *argv[]) br_ssl_engine_set_all_flags(&cc.eng, flags); if (VEC_LEN(alpn_names) != 0) { br_ssl_engine_set_protocol_names(&cc.eng, - &VEC_ELT(alpn_names, 0), VEC_LEN(alpn_names)); + (const char **)&VEC_ELT(alpn_names, 0), + VEC_LEN(alpn_names)); } if (chain != NULL) { @@ -1055,15 +1076,17 @@ do_client(int argc, char *argv[]) br_ssl_client_reset(&cc, sni, 0); /* - * We need to avoid SIGPIPE. + * On Unix systems, we need to avoid SIGPIPE. */ +#ifndef _WIN32 signal(SIGPIPE, SIG_IGN); +#endif /* * Connect to the peer. */ fd = host_connect(host, port, verbose); - if (fd < 0) { + if (fd == INVALID_SOCKET) { goto client_exit_error; } @@ -1092,8 +1115,12 @@ client_exit: free_certificates(chain, chain_len); free_private_key(sk); xfree(iobuf); - if (fd >= 0) { + if (fd != INVALID_SOCKET) { +#ifdef _WIN32 + closesocket(fd); +#else close(fd); +#endif } return retcode; diff --git a/tools/server.c b/tools/server.c index a62302f..fbc7786 100644 --- a/tools/server.c +++ b/tools/server.c @@ -29,6 +29,10 @@ #include #include +#ifdef _WIN32 +#include +#include +#else #include #include #include @@ -37,14 +41,18 @@ #include #include +#define SOCKET int +#define INVALID_SOCKET (-1) +#define SOCKADDR_STORAGE struct sockaddr_storage +#endif + #include "brssl.h" -#include "bearssl.h" -static int +static SOCKET host_bind(const char *host, const char *port, int verbose) { struct addrinfo hints, *si, *p; - int fd; + SOCKET fd; int err; memset(&hints, 0, sizeof hints); @@ -54,9 +62,9 @@ host_bind(const char *host, const char *port, int verbose) if (err != 0) { fprintf(stderr, "ERROR: getaddrinfo(): %s\n", gai_strerror(err)); - return -1; + return INVALID_SOCKET; } - fd = -1; + fd = INVALID_SOCKET; for (p = si; p != NULL; p = p->ai_next) { struct sockaddr *sa; struct sockaddr_in sa4; @@ -102,21 +110,27 @@ host_bind(const char *host, const char *port, int verbose) fprintf(stderr, "binding to: %s\n", tmp); } fd = socket(p->ai_family, p->ai_socktype, p->ai_protocol); - if (fd < 0) { + if (fd == INVALID_SOCKET) { if (verbose) { perror("socket()"); } continue; } opt = 1; - setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof opt); + setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, + (void *)&opt, sizeof opt); opt = 0; - setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &opt, sizeof opt); + setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, + (void *)&opt, sizeof opt); if (bind(fd, sa, sa_len) < 0) { if (verbose) { perror("bind()"); } +#ifdef _WIN32 + closesocket(fd); +#else close(fd); +#endif continue; } break; @@ -124,15 +138,19 @@ host_bind(const char *host, const char *port, int verbose) if (p == NULL) { freeaddrinfo(si); fprintf(stderr, "ERROR: failed to bind\n"); - return -1; + return INVALID_SOCKET; } freeaddrinfo(si); if (listen(fd, 5) < 0) { if (verbose) { perror("listen()"); } +#ifdef _WIN32 + closesocket(fd); +#else close(fd); - return -1; +#endif + return INVALID_SOCKET; } if (verbose) { fprintf(stderr, "bound.\n"); @@ -140,27 +158,27 @@ host_bind(const char *host, const char *port, int verbose) return fd; } -static int -accept_client(int server_fd, int verbose) +static SOCKET +accept_client(SOCKET server_fd, int verbose) { int fd; - struct sockaddr sa; + SOCKADDR_STORAGE sa; socklen_t sa_len; sa_len = sizeof sa; - fd = accept(server_fd, &sa, &sa_len); - if (fd < 0) { + fd = accept(server_fd, (struct sockaddr *)&sa, &sa_len); + if (fd == INVALID_SOCKET) { if (verbose) { perror("accept()"); } - return -1; + return INVALID_SOCKET; } if (verbose) { char tmp[INET6_ADDRSTRLEN + 50]; const char *name; name = NULL; - switch (sa.sa_family) { + switch (((struct sockaddr *)&sa)->sa_family) { case AF_INET: name = inet_ntop(AF_INET, &((struct sockaddr_in *)&sa)->sin_addr, @@ -173,8 +191,8 @@ accept_client(int server_fd, int verbose) break; } if (name == NULL) { - sprintf(tmp, "", - (unsigned long)sa.sa_family); + sprintf(tmp, "", (unsigned long) + ((struct sockaddr *)&sa)->sa_family); name = tmp; } fprintf(stderr, "accepting connection from: %s\n", name); @@ -182,9 +200,18 @@ accept_client(int server_fd, int verbose) /* * We make the socket non-blocking, since we are going to use - * poll() to organise I/O. + * poll() or select() to organise I/O. */ +#ifdef _WIN32 + { + u_long arg; + + arg = 1; + ioctlsocket(fd, FIONBIO, &arg); + } +#else fcntl(fd, F_SETFL, O_NONBLOCK); +#endif return fd; } @@ -606,7 +633,7 @@ do_server(int argc, char *argv[]) int cert_signer_algo; private_key *sk; anchor_list anchors = VEC_INIT; - VECTOR(const char *) alpn_names = VEC_INIT; + VECTOR(char *) alpn_names = VEC_INIT; br_x509_minimal_context xc; const br_hash_class *dnhash; size_t u; @@ -616,7 +643,7 @@ do_server(int argc, char *argv[]) unsigned char *iobuf, *cache; size_t iobuf_len, cache_len; uint32_t flags; - int server_fd, fd; + SOCKET server_fd, fd; retcode = 0; verbose = 1; @@ -639,8 +666,8 @@ do_server(int argc, char *argv[]) cache = NULL; cache_len = (size_t)-1; flags = 0; - server_fd = -1; - fd = -1; + server_fd = INVALID_SOCKET; + fd = INVALID_SOCKET; for (i = 0; i < argc; i ++) { const char *arg; @@ -1089,7 +1116,8 @@ do_server(int argc, char *argv[]) if (VEC_LEN(alpn_names) != 0) { br_ssl_engine_set_protocol_names(&cc.eng, - &VEC_ELT(alpn_names, 0), VEC_LEN(alpn_names)); + (const char **)&VEC_ELT(alpn_names, 0), + VEC_LEN(alpn_names)); } /* @@ -1139,15 +1167,17 @@ do_server(int argc, char *argv[]) br_ssl_engine_set_buffer(&cc.eng, iobuf, iobuf_len, bidi); /* - * We need to ignore SIGPIPE. + * On Unix systems, we need to ignore SIGPIPE. */ +#ifndef _WIN32 signal(SIGPIPE, SIG_IGN); +#endif /* * Open the server socket. */ server_fd = host_bind(bind_name, port, verbose); - if (server_fd < 0) { + if (server_fd == INVALID_SOCKET) { goto server_exit_error; } @@ -1162,15 +1192,19 @@ do_server(int argc, char *argv[]) int x; fd = accept_client(server_fd, verbose); - if (fd < 0) { + if (fd == INVALID_SOCKET) { goto server_exit_error; } br_ssl_server_reset(&cc); x = run_ssl_engine(&cc.eng, fd, (verbose ? RUN_ENGINE_VERBOSE : 0) | (trace ? RUN_ENGINE_TRACE : 0)); +#ifdef _WIN32 + closesocket(fd); +#else close(fd); - fd = -1; +#endif + fd = INVALID_SOCKET; if (x < -1) { goto server_exit_error; } @@ -1188,8 +1222,12 @@ server_exit: VEC_CLEAREXT(alpn_names, &free_alpn); xfree(iobuf); xfree(cache); - if (fd >= 0) { + if (fd != INVALID_SOCKET) { +#ifdef _WIN32 + closesocket(fd); +#else close(fd); +#endif } return retcode; diff --git a/tools/sslio.c b/tools/sslio.c index 14a3138..9941090 100644 --- a/tools/sslio.c +++ b/tools/sslio.c @@ -28,6 +28,10 @@ #include #include +#ifdef _WIN32 +#include +#include +#else #include #include #include @@ -37,8 +41,11 @@ #include #include +#define SOCKET int +#define INVALID_SOCKET (-1) +#endif + #include "brssl.h" -#include "bearssl.h" static void dump_blob(const char *name, const void *data, size_t len) @@ -134,25 +141,173 @@ run_command(br_ssl_engine_context *cc, unsigned char *buf, size_t len) } } +#ifdef _WIN32 + +typedef struct { + unsigned char buf[1024]; + size_t ptr, len; +} in_buffer; + +static int +in_return_bytes(in_buffer *bb, unsigned char *buf, size_t len) +{ + if (bb->ptr < bb->len) { + size_t clen; + + if (buf == NULL) { + return 1; + } + clen = bb->len - bb->ptr; + if (clen > len) { + clen = len; + } + memcpy(buf, bb->buf + bb->ptr, clen); + bb->ptr += clen; + if (bb->ptr == bb->len) { + bb->ptr = bb->len = 0; + } + return (int)clen; + } + return 0; +} + +/* + * A buffered version of in_read(), using a buffer to return only + * full lines when feasible. + */ +static int +in_read_buffered(HANDLE h_in, in_buffer *bb, unsigned char *buf, size_t len) +{ + int n; + + if (len == 0) { + return 0; + } + n = in_return_bytes(bb, buf, len); + if (n != 0) { + return n; + } + for (;;) { + INPUT_RECORD inrec; + DWORD v; + + if (!PeekConsoleInput(h_in, &inrec, 1, &v)) { + fprintf(stderr, "ERROR: PeekConsoleInput()" + " failed with 0x%08lX\n", + (unsigned long)GetLastError()); + return -1; + } + if (v == 0) { + return 0; + } + if (!ReadConsoleInput(h_in, &inrec, 1, &v)) { + fprintf(stderr, "ERROR: ReadConsoleInput()" + " failed with 0x%08lX\n", + (unsigned long)GetLastError()); + return -1; + } + if (v == 0) { + return 0; + } + if (inrec.EventType == KEY_EVENT + && inrec.Event.KeyEvent.bKeyDown) + { + int c; + + c = inrec.Event.KeyEvent.uChar.AsciiChar; + if (c == '\n' || c == '\r' || c == '\t' + || (c >= 32 && c != 127)) + { + if (c == '\r') { + c = '\n'; + } + bb->buf[bb->ptr ++] = (unsigned char)c; + printf("%c", c); + fflush(stdout); + bb->len = bb->ptr; + if (bb->len == sizeof bb->buf || c == '\n') { + bb->ptr = 0; + return in_return_bytes(bb, buf, len); + } + } + } + } +} + +static int +in_avail_buffered(HANDLE h_in, in_buffer *bb) +{ + return in_read_buffered(h_in, bb, NULL, 1); +} + +#endif + /* see brssl.h */ int -run_ssl_engine(br_ssl_engine_context *cc, int fd, unsigned flags) +run_ssl_engine(br_ssl_engine_context *cc, unsigned long fd, unsigned flags) { int hsdetails; int retcode; int verbose; int trace; +#ifdef _WIN32 + WSAEVENT fd_event; + int can_send, can_recv; + HANDLE h_in, h_out; + in_buffer bb; +#endif hsdetails = 0; retcode = 0; verbose = (flags & RUN_ENGINE_VERBOSE) != 0; trace = (flags & RUN_ENGINE_TRACE) != 0; +#ifdef _WIN32 + fd_event = WSA_INVALID_EVENT; + can_send = 0; + can_recv = 0; + bb.ptr = bb.len = 0; +#endif + + /* + * On Unix systems, we need to follow three descriptors: + * standard input (0), standard output (1), and the socket + * itself (for both read and write). This is done with a poll() + * call. + * + * On Windows systems, we use WSAEventSelect() to associate + * an event handle with the network activity, and we use + * WaitForMultipleObjectsEx() on that handle and the standard + * input handle, when appropriate. Standard output is assumed + * to be always writeable, and standard input to be the console; + * this does not work well (or at all) with redirections (to + * pipes or files) but it should be enough for a debug tool + * (TODO: make something that handles redirections as well). + */ + +#ifdef _WIN32 + fd_event = WSACreateEvent(); + if (fd_event == WSA_INVALID_EVENT) { + fprintf(stderr, "ERROR: WSACreateEvent() failed with %d\n", + WSAGetLastError()); + retcode = -2; + goto engine_exit; + } + WSAEventSelect(fd, fd_event, FD_READ | FD_WRITE | FD_CLOSE); + h_in = GetStdHandle(STD_INPUT_HANDLE); + h_out = GetStdHandle(STD_OUTPUT_HANDLE); + SetConsoleMode(h_in, ENABLE_ECHO_INPUT + | ENABLE_LINE_INPUT + | ENABLE_PROCESSED_INPUT + | ENABLE_PROCESSED_OUTPUT + | ENABLE_WRAP_AT_EOL_OUTPUT); +#else /* * Make sure that stdin and stdout are non-blocking. */ fcntl(0, F_SETFL, O_NONBLOCK); fcntl(1, F_SETFL, O_NONBLOCK); +#endif /* * Perform the loop. @@ -160,9 +315,15 @@ run_ssl_engine(br_ssl_engine_context *cc, int fd, unsigned flags) for (;;) { unsigned st; int sendrec, recvrec, sendapp, recvapp; +#ifdef _WIN32 + HANDLE pfd[2]; + DWORD wt; +#else struct pollfd pfd[3]; int n; +#endif size_t u, k_fd, k_in, k_out; + int sendrec_ok, recvrec_ok, sendapp_ok, recvapp_ok; /* * Get current engine state. @@ -257,11 +418,74 @@ run_ssl_engine(br_ssl_engine_context *cc, int fd, unsigned flags) hsdetails = 1; } - k_fd = 0; - k_in = 0; - k_out = 0; + k_fd = (size_t)-1; + k_in = (size_t)-1; + k_out = (size_t)-1; u = 0; +#ifdef _WIN32 + /* + * If we recorded that we can send or receive data, and we + * want to do exactly that, then we don't wait; we just do + * it. + */ + recvapp_ok = 0; + sendrec_ok = 0; + recvrec_ok = 0; + sendapp_ok = 0; + + if (sendrec && can_send) { + sendrec_ok = 1; + } else if (recvrec && can_recv) { + recvrec_ok = 1; + } else if (recvapp) { + recvapp_ok = 1; + } else if (sendapp && in_avail_buffered(h_in, &bb)) { + sendapp_ok = 1; + } else { + /* + * If we cannot do I/O right away, then we must + * wait for some event, and try again. + */ + pfd[u] = (HANDLE)fd_event; + k_fd = u; + u ++; + if (sendapp) { + pfd[u] = h_in; + k_in = u; + u ++; + } + wt = WaitForMultipleObjectsEx(u, pfd, + FALSE, INFINITE, FALSE); + if (wt == WAIT_FAILED) { + fprintf(stderr, "ERROR:" + " WaitForMultipleObjectsEx()" + " failed with 0x%08lX", + (unsigned long)GetLastError()); + retcode = -2; + goto engine_exit; + } + if (wt == k_fd) { + WSANETWORKEVENTS e; + + if (WSAEnumNetworkEvents(fd, fd_event, &e)) { + fprintf(stderr, "ERROR:" + " WSAEnumNetworkEvents()" + " failed with %d\n", + WSAGetLastError()); + retcode = -2; + goto engine_exit; + } + if (e.lNetworkEvents & (FD_WRITE | FD_CLOSE)) { + can_send = 1; + } + if (e.lNetworkEvents & (FD_READ | FD_CLOSE)) { + can_recv = 1; + } + } + continue; + } +#else if (sendrec || recvrec) { pfd[u].fd = fd; pfd[u].revents = 0; @@ -313,96 +537,142 @@ run_ssl_engine(br_ssl_engine_context *cc, int fd, unsigned flags) } } + recvapp_ok = recvapp && (pfd[k_out].revents & POLLOUT) != 0; + sendrec_ok = sendrec && (pfd[k_fd].revents & POLLOUT) != 0; + recvrec_ok = recvrec && (pfd[k_fd].revents & POLLIN) != 0; + sendapp_ok = sendapp && (pfd[k_in].revents & POLLIN) != 0; +#endif + /* * We give preference to outgoing data, on stdout and on * the socket. */ - if (recvapp) { - if (pfd[k_out].revents & POLLOUT) { - unsigned char *buf; - size_t len; - ssize_t wlen; - - buf = br_ssl_engine_recvapp_buf(cc, &len); - wlen = write(1, buf, len); - if (wlen <= 0) { - if (verbose) { - fprintf(stderr, - "stdout closed...\n"); - } - retcode = -2; - goto engine_exit; + if (recvapp_ok) { + unsigned char *buf; + size_t len; +#ifdef _WIN32 + DWORD wlen; +#else + ssize_t wlen; +#endif + + buf = br_ssl_engine_recvapp_buf(cc, &len); +#ifdef _WIN32 + if (!WriteFile(h_out, buf, len, &wlen, NULL)) { + if (verbose) { + fprintf(stderr, "stdout closed...\n"); } - br_ssl_engine_recvapp_ack(cc, wlen); - continue; + retcode = -2; + goto engine_exit; } +#else + wlen = write(1, buf, len); + if (wlen <= 0) { + if (verbose) { + fprintf(stderr, "stdout closed...\n"); + } + retcode = -2; + goto engine_exit; + } +#endif + br_ssl_engine_recvapp_ack(cc, wlen); + continue; } - if (sendrec) { - if (pfd[k_fd].revents & POLLOUT) { - unsigned char *buf; - size_t len; - ssize_t wlen; - - buf = br_ssl_engine_sendrec_buf(cc, &len); - wlen = write(fd, buf, len); - if (wlen <= 0) { - if (verbose) { - fprintf(stderr, - "socket closed...\n"); - } - retcode = -1; - goto engine_exit; + if (sendrec_ok) { + unsigned char *buf; + size_t len; + int wlen; + + buf = br_ssl_engine_sendrec_buf(cc, &len); + wlen = send(fd, buf, len, 0); + if (wlen <= 0) { +#ifdef _WIN32 + int err; + + err = WSAGetLastError(); + if (err == EWOULDBLOCK + || err == WSAEWOULDBLOCK) + { + can_send = 0; + continue; } - if (trace) { - dump_blob("Outgoing bytes", buf, wlen); +#else + if (errno == EINTR || errno == EWOULDBLOCK) { + continue; } - br_ssl_engine_sendrec_ack(cc, wlen); - continue; +#endif + if (verbose) { + fprintf(stderr, "socket closed...\n"); + } + retcode = -1; + goto engine_exit; } + if (trace) { + dump_blob("Outgoing bytes", buf, wlen); + } + br_ssl_engine_sendrec_ack(cc, wlen); + continue; } - if (recvrec) { - if (pfd[k_fd].revents & POLLIN) { - unsigned char *buf; - size_t len; - ssize_t rlen; - - buf = br_ssl_engine_recvrec_buf(cc, &len); - rlen = read(fd, buf, len); - if (rlen <= 0) { - if (verbose) { - fprintf(stderr, - "socket closed...\n"); - } - retcode = -1; - goto engine_exit; + if (recvrec_ok) { + unsigned char *buf; + size_t len; + int rlen; + + buf = br_ssl_engine_recvrec_buf(cc, &len); + rlen = recv(fd, buf, len, 0); + if (rlen <= 0) { +#ifdef _WIN32 + int err; + + err = WSAGetLastError(); + if (err == EWOULDBLOCK + || err == WSAEWOULDBLOCK) + { + can_recv = 0; + continue; } - if (trace) { - dump_blob("Incoming bytes", buf, rlen); +#else + if (errno == EINTR || errno == EWOULDBLOCK) { + continue; } - br_ssl_engine_recvrec_ack(cc, rlen); - continue; +#endif + if (verbose) { + fprintf(stderr, "socket closed...\n"); + } + retcode = -1; + goto engine_exit; } + if (trace) { + dump_blob("Incoming bytes", buf, rlen); + } + br_ssl_engine_recvrec_ack(cc, rlen); + continue; } - if (sendapp) { - if (pfd[k_in].revents & POLLIN) { - unsigned char *buf; - size_t len; - ssize_t rlen; - - buf = br_ssl_engine_sendapp_buf(cc, &len); - rlen = read(0, buf, len); - if (rlen <= 0) { - if (verbose) { - fprintf(stderr, - "stdin closed...\n"); - } - br_ssl_engine_close(cc); - } else if (!run_command(cc, buf, rlen)) { - br_ssl_engine_sendapp_ack(cc, rlen); + if (sendapp_ok) { + unsigned char *buf; + size_t len; +#ifdef _WIN32 + int rlen; +#else + ssize_t rlen; +#endif + + buf = br_ssl_engine_sendapp_buf(cc, &len); +#ifdef _WIN32 + rlen = in_read_buffered(h_in, &bb, buf, len); +#else + rlen = read(0, buf, len); +#endif + if (rlen <= 0) { + if (verbose) { + fprintf(stderr, "stdin closed...\n"); } - br_ssl_engine_flush(cc, 0); - continue; + br_ssl_engine_close(cc); + } else if (!run_command(cc, buf, rlen)) { + br_ssl_engine_sendapp_ack(cc, rlen); } + br_ssl_engine_flush(cc, 0); + continue; } /* We should never reach that point. */ @@ -415,5 +685,10 @@ run_ssl_engine(br_ssl_engine_context *cc, int fd, unsigned flags) * Release allocated structures. */ engine_exit: +#ifdef _WIN32 + if (fd_event != WSA_INVALID_EVENT) { + WSACloseEvent(fd_event); + } +#endif return retcode; }