Skip to content

Commit

Permalink
Merge pull request #88 from CyberShadow/no-object-files
Browse files Browse the repository at this point in the history
Properly make these bindings a "header-only" (.di) library
  • Loading branch information
Geod24 authored Jun 8, 2022
2 parents 2dfc552 + 14681ce commit c6e18bc
Show file tree
Hide file tree
Showing 82 changed files with 33 additions and 47 deletions.
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ jobs:
# We don't checkout in $GITHUB_WORKSPACE to avoid polluting the repository with artifacts,
# e.g. the C openssl library or Vibe.d
cd ${{ github.workspace }}/deimos-openssl/
dub test
cd examples/sslecho/
${{ github.workspace }}/openssl/install/bin/openssl req -batch -newkey rsa:4096 -x509 -sha256 -days 3650 -subj "/C=GB/CN=localhost" -nodes -out cert.pem -keyout key.pem
dub build
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Generated version file
/source/deimos/openssl/version_.d
/source/deimos/openssl/version_.di

# DUB artifacts
/.dub/
Expand Down
9 changes: 0 additions & 9 deletions dub.sdl
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,3 @@ configuration "library-manual-version" {
configuration "library-applink" {
targetType "sourceLibrary"
}

configuration "unittest" {
targetType "executable"
targetName "openssl-test-library"
dflags "-main"
excludedSourceFiles "source/deimos/openssl/applink.d"
preGenerateCommands `${DUB} scripts/generate_version.d` platform="posix"
versions `DeimosOpenSSLAutoDetect`
}
8 changes: 4 additions & 4 deletions scripts/generate_version.d
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*
* It is called directly as a `preGenerateCommand` (see dub.sdl).
* To use it with another build system, pass the directory in which to write
* the `version_.d` file as first and only argument. The directory
* the `version_.di` file as first and only argument. The directory
* must exist, this script will not create it.
*/
module generate_version;
Expand Down Expand Up @@ -42,14 +42,14 @@ void main(string[] args)
{
assert(args[1].isDir(),
"OpenSSL version detection: Argument '" ~ args[1] ~ "' is not a directory");
target = args[1].buildPath("version_.d");
target = args[1].buildPath("version_.di");
}
else
{
assert(args.length == 1,
"OpenSSL version detection expects only one argument, " ~
"a directory path where to write `version_.d`");
target = TARGET_DIR_PATH.buildPath("version_.d");
"a directory path where to write `version_.di`");
target = TARGET_DIR_PATH.buildPath("version_.di");
}

string opensslVersion;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* crypto/aes/aes.h -*- mode:C; c-file-style: "eay" -*- */
/* ====================================================================
* Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved.
*
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ enum ASN1_TFLG_NDEF = (0x1<<11);
/* This is the actual ASN1 item itself */

struct ASN1_ITEM_st {
char itype; /* The item type, primitive, SEQUENCE, CHOICE or extern */
ubyte itype; /* The item type, primitive, SEQUENCE, CHOICE or extern */
c_long utype; /* underlying type */
const(ASN1_TEMPLATE)* templates; /* If SEQUENCE or CHOICE this contains the contents */
c_long tcount; /* Number of templates if SEQUENCE or CHOICE */
Expand Down Expand Up @@ -639,7 +639,7 @@ enum ASN1_ITYPE_NDEF_SEQUENCE = 0x6;
*/

struct ASN1_TLC_st{
char valid; /* Values below are valid */
ubyte valid; /* Values below are valid */
int ret; /* return value */
c_long plen; /* length */
int ptag; /* class value */
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* crypto/camellia/camellia.h -*- mode:C; c-file-style: "eay" -*- */
/* ====================================================================
* Copyright (c) 2006 The OpenSSL Project. All rights reserved.
*
Expand Down Expand Up @@ -81,7 +80,7 @@ alias uint[CAMELLIA_TABLE_WORD_LEN] KEY_TABLE_TYPE; /* to match with WORD */
struct camellia_key_st
{
union u_ {
double d; /* ensures 64-bit align */
double d = void; /* ensures 64-bit align */
KEY_TABLE_TYPE rd_key;
}
u_ u;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ static if (OPENSSL_VERSION_BEFORE(1, 1, 0))
}
else
{
auto DSA_get_ex_new_index(c_long l, void* p, CRYPTO_EX_new* newf,
auto DSA_get_ex_new_index()(c_long l, void* p, CRYPTO_EX_new* newf,
CRYPTO_EX_dup* dupf, CRYPTO_EX_free* freef)
{
return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_DSA, l, p, newf, dupf, freef);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* dso.h -*- mode:C; c-file-style: "eay" -*- */
/* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL
* project 2000.
*/
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions source/deimos/openssl/ec.d → source/deimos/openssl/ec.di
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ static if (!is(typeof(OPENSSL_ECC_MAX_FIELD_BITS))) {
/** Enum for the point conversion form as defined in X9.62 (ECDSA)
* for the encoding of a elliptic curve point (x,y) */
enum point_conversion_form_t {
init = 0, // Ensure initial values in D is zero
/** the point is encoded as z||x, where the octet z specifies
* which solution of the quadratic equation y is */
POINT_CONVERSION_COMPRESSED = 2,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ enum KSSL_CLOCKSKEW = 300;;
enum KSSL_ERR_MAX = 255;
struct kssl_err_st {
int reason;
char[KSSL_ERR_MAX+1] text;
char[KSSL_ERR_MAX+1] text = 0;
}
alias kssl_err_st KSSL_ERR;

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ enum OPENSSL_VERSION_PATCH = OpenSSLVersion.patch;

enum OPENSSL_VERSION_BUILD = OpenSSLVersion.build;

int OPENSSL_MAKE_VERSION(int major, int minor, int patch, int build)
int OPENSSL_MAKE_VERSION()(int major, int minor, int patch, int build)
{
return (major << 28) | (minor << 20) | (patch << 12) | (build << 4) | 0xf;
}
Expand All @@ -131,12 +131,12 @@ enum OPENSSL_VERSION_NUMBER =
OPENSSL_MAKE_VERSION(OpenSSLVersion.major, OpenSSLVersion.minor,
OpenSSLVersion.patch, OpenSSLVersion.build);

bool OPENSSL_VERSION_AT_LEAST(int major, int minor, int patch = 0, int build = 0)
bool OPENSSL_VERSION_AT_LEAST()(int major, int minor, int patch = 0, int build = 0)
{
return OPENSSL_VERSION_NUMBER >= OPENSSL_MAKE_VERSION(major, minor, patch, build);
}

bool OPENSSL_VERSION_BEFORE(int major, int minor, int patch = 0, int build = 0)
bool OPENSSL_VERSION_BEFORE()(int major, int minor, int patch = 0, int build = 0)
{
return OPENSSL_VERSION_NUMBER < OPENSSL_MAKE_VERSION(major, minor, patch, build);
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
16 changes: 8 additions & 8 deletions source/deimos/openssl/ssl.d → source/deimos/openssl/ssl.di
Original file line number Diff line number Diff line change
Expand Up @@ -1830,16 +1830,16 @@ static if (OPENSSL_VERSION_AT_LEAST(1, 1, 0))
enum SSL_CTRL_SET_MIN_PROTO_VERSION = 123;
enum SSL_CTRL_SET_MAX_PROTO_VERSION = 124;

auto SSL_CTX_set_min_proto_version(SSL_CTX* ctx, int version_) {
auto SSL_CTX_set_min_proto_version()(SSL_CTX* ctx, int version_) {
return SSL_CTX_ctrl(ctx, SSL_CTRL_SET_MIN_PROTO_VERSION, version_, null);
}
auto SSL_CTX_set_max_proto_version(SSL_CTX* ctx, int version_) {
auto SSL_CTX_set_max_proto_version()(SSL_CTX* ctx, int version_) {
return SSL_CTX_ctrl(ctx, SSL_CTRL_SET_MAX_PROTO_VERSION, version_, null);
}
auto SSL_set_min_proto_version(SSL* s, int version_) {
auto SSL_set_min_proto_version()(SSL* s, int version_) {
return SSL_ctrl(s, SSL_CTRL_SET_MIN_PROTO_VERSION, version_, null);
}
auto SSL_set_max_proto_version(SSL* s, int version_) {
auto SSL_set_max_proto_version()(SSL* s, int version_) {
return SSL_ctrl(s, SSL_CTRL_SET_MAX_PROTO_VERSION, version_, null);
}

Expand All @@ -1848,16 +1848,16 @@ static if (OPENSSL_VERSION_AT_LEAST(1, 1, 0))
enum SSL_CTRL_GET_MIN_PROTO_VERSION = 130;
enum SSL_CTRL_GET_MAX_PROTO_VERSION = 131;

auto SSL_CTX_get_min_proto_version(SSL_CTX* ctx) {
auto SSL_CTX_get_min_proto_version()(SSL_CTX* ctx) {
return SSL_CTX_ctrl(ctx, SSL_CTRL_GET_MIN_PROTO_VERSION, 0, null);
}
auto SSL_CTX_get_max_proto_version(SSL_CTX* ctx) {
auto SSL_CTX_get_max_proto_version()(SSL_CTX* ctx) {
return SSL_CTX_ctrl(ctx, SSL_CTRL_GET_MAX_PROTO_VERSION, 0, null);
}
auto SSL_get_min_proto_version(SSL* s) {
auto SSL_get_min_proto_version()(SSL* s) {
return SSL_ctrl(s, SSL_CTRL_GET_MIN_PROTO_VERSION, 0, null);
}
auto SSL_get_max_proto_version(SSL* s) {
auto SSL_get_max_proto_version()(SSL* s) {
return SSL_ctrl(s, SSL_CTRL_GET_MAX_PROTO_VERSION, 0, null);
}
}
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ version(OPENSSL_NO_ECDH) {} else {
/* used for certificate requests */
int cert_req;
int ctype_num;
char[SSL3_CT_NUMBER] ctype;
char[SSL3_CT_NUMBER] ctype = 0;
STACK_OF!(X509_NAME) *ca_names;

int use_rsa_tmp;
Expand Down Expand Up @@ -547,7 +547,7 @@ version(OPENSSL_NO_EC) {} else {
/* This is set to true if we believe that this is a version of Safari
* running on OS X 10.6 or newer. We wish to know this because Safari
* on 10.8 .. 10.8.3 has broken ECDHE-ECDSA support. */
char is_probably_safari;
char is_probably_safari = 0;
} /* !OPENSSL_NO_EC */
} /* !OPENSSL_NO_TLSEXT */
}
Expand Down
File renamed without changes.
File renamed without changes.
18 changes: 9 additions & 9 deletions source/deimos/openssl/tls1.d → source/deimos/openssl/tls1.di
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ auto SSL_set_tlsext_status_ocsp_resp()(SSL* ssl, void* arg, void* arglen) {
return SSL_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_OCSP_RESP,arglen, arg);
}

auto SSL_CTX_set_tlsext_servername_callback(SSL_CTX* ctx, ExternC!(void function()) cb) {
auto SSL_CTX_set_tlsext_servername_callback()(SSL_CTX* ctx, ExternC!(void function()) cb) {
return SSL_CTX_callback_ctrl(ctx,SSL_CTRL_SET_TLSEXT_SERVERNAME_CB,cb);
}

Expand All @@ -350,33 +350,33 @@ enum SSL_TLSEXT_ERR_ALERT_WARNING = 1;
enum SSL_TLSEXT_ERR_ALERT_FATAL = 2;
enum SSL_TLSEXT_ERR_NOACK = 3;

auto SSL_CTX_set_tlsext_servername_arg(SSL_CTX* ctx, void* arg) {
auto SSL_CTX_set_tlsext_servername_arg()(SSL_CTX* ctx, void* arg) {
return SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TLSEXT_SERVERNAME_ARG,0,arg);
}

auto SSL_CTX_get_tlsext_ticket_keys(SSL_CTX* ctx, c_long keylen, void* keys) {
auto SSL_CTX_get_tlsext_ticket_keys()(SSL_CTX* ctx, c_long keylen, void* keys) {
return SSL_CTX_ctrl(ctx,SSL_CTRL_GET_TLSEXT_TICKET_KEYS,keylen,keys);
}
auto SSL_CTX_set_tlsext_ticket_keys(SSL_CTX* ctx, c_long keylen, void* keys) {
auto SSL_CTX_set_tlsext_ticket_keys()(SSL_CTX* ctx, c_long keylen, void* keys) {
return SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TLSEXT_TICKET_KEYS,keylen,keys);
}

auto SSL_CTX_set_tlsext_status_cb(SSL_CTX* ctx, ExternC!(void function()) cb) {
auto SSL_CTX_set_tlsext_status_cb()(SSL_CTX* ctx, ExternC!(void function()) cb) {
return SSL_CTX_callback_ctrl(ctx,SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB,cb);
}

auto SSL_CTX_set_tlsext_status_arg(SSL_CTX* ctx, void* arg) {
auto SSL_CTX_set_tlsext_status_arg()(SSL_CTX* ctx, void* arg) {
return SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB_ARG,0,arg);
}

auto SSL_set_tlsext_opaque_prf_input(SSL* s, void* src, c_long len) {
auto SSL_set_tlsext_opaque_prf_input()(SSL* s, void* src, c_long len) {
return SSL_ctrl(s,SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT, len, src);
}

auto SSL_CTX_set_tlsext_opaque_prf_input_callback(SSL_CTX* ctx, ExternC!(void function()) cb) {
auto SSL_CTX_set_tlsext_opaque_prf_input_callback()(SSL_CTX* ctx, ExternC!(void function()) cb) {
return SSL_CTX_callback_ctrl(ctx,SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT_CB, cb);
}
auto SSL_CTX_set_tlsext_opaque_prf_input_callback_arg(SSL_CTX* ctx, void* arg) {
auto SSL_CTX_set_tlsext_opaque_prf_input_callback_arg()(SSL_CTX* ctx, void* arg) {
return SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT_CB_ARG, 0, arg);
}

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion source/deimos/openssl/ui.d → source/deimos/openssl/ui.di
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* crypto/ui/ui.h -*- mode:C; c-file-style: "eay" -*- */
/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL
* project 2001.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* crypto/ui/ui.h -*- mode:C; c-file-style: "eay" -*- */
/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL
* project 2001.
*/
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit c6e18bc

Please sign in to comment.