Skip to content

Commit

Permalink
Updated Host Interface library and integration into SSL library. #149
Browse files Browse the repository at this point in the history
  • Loading branch information
frehwagen authored and Falk Rehwagen committed Jul 8, 2024
1 parent 6f249a0 commit 80e3b66
Show file tree
Hide file tree
Showing 12 changed files with 180 additions and 264 deletions.
38 changes: 38 additions & 0 deletions Include/hostif.def
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,44 @@ EOF equ -1
global HostIfDetect:far
global HOSTIFDETECT:far

global HostIfCall:far
global HOSTIFCALL:far

HostIfFunctions etype word
HIF_CHECK enum HostIfFunctions, 1
HIF_SET_RECEIVE_HANDLE enum HostIfFunctions, 2
HIF_SET_SSL_CALLBACK enum HostIfFunctions, 3

HIF_NETWORKING_BASE enum HostIfFunctions, 1000
HIF_NC_RESOLVE_ADDR enum HostIfFunctions, HIF_NETWORKING_BASE
HIF_NC_ALLOC_CONNECTION enum HostIfFunctions, HIF_NETWORKING_BASE+1
HIF_NC_CONNECT_REQUEST enum HostIfFunctions, HIF_NETWORKING_BASE+2
HIF_NC_SEND_DATA enum HostIfFunctions, HIF_NETWORKING_BASE+3
HIF_NC_NEXT_RECV_SIZE enum HostIfFunctions, HIF_NETWORKING_BASE+4
HIF_NC_RECV_NEXT enum HostIfFunctions, HIF_NETWORKING_BASE+5
HIF_NC_RECV_NEXT_CLOSE enum HostIfFunctions, HIF_NETWORKING_BASE+6
HIF_NC_CLOSE enum HostIfFunctions, HIF_NETWORKING_BASE+7
HIF_NETWORKING_END enum HostIfFunctions, 1199

HIF_SSL_BASE enum HostIfFunctions, 1200
HIF_SSL_V2_GET_CLIENT_METHOD enum HostIfFunctions, HIF_SSL_BASE
HIF_SSL_SSLEAY_ADD_SSL_ALGO enum HostIfFunctions, HIF_SSL_BASE+1
HIF_SSL_CTX_NEW enum HostIfFunctions, HIF_SSL_BASE+2
HIF_SSL_CTX_FREE enum HostIfFunctions, HIF_SSL_BASE+3
HIF_SSL_NEW enum HostIfFunctions, HIF_SSL_BASE+4
HIF_SSL_FREE enum HostIfFunctions, HIF_SSL_BASE+5
HIF_SSL_SET_FD enum HostIfFunctions, HIF_SSL_BASE+6
HIF_SSL_CONNECT enum HostIfFunctions, HIF_SSL_BASE+7
HIF_SSL_SHUTDOWN enum HostIfFunctions, HIF_SSL_BASE+8
HIF_SSL_READ enum HostIfFunctions, HIF_SSL_BASE+9
HIF_SSL_WRITE enum HostIfFunctions, HIF_SSL_BASE+10
HIF_SSL_V23_CLIENT_METHOD enum HostIfFunctions, HIF_SSL_BASE+11
HIF_SSL_V3_CLIENT_METHOD enum HostIfFunctions, HIF_SSL_BASE+12
HIF_SSL_GET_SSL_METHOD enum HostIfFunctions, HIF_SSL_BASE+13
HIF_SSL_SET_CALLBACK enum HostIfFunctions, HIF_SSL_BASE+14
HIF_SSL_SET_TLSEXT_HOST_NAME enum HostIfFunctions, HIF_SSL_BASE+15
HIF_SSL_END enum HostIfFunctions, 1299

SetDefaultConvention

EndLibrary hostif
Expand Down
12 changes: 6 additions & 6 deletions Installed/Library/HostIf/dependencies.mk
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
hostif.obj \
hostif.eobj: geos.def heap.def geode.def resource.def library.def \
ec.def vm.def dbase.def object.def lmem.def graphics.def \
fontID.def font.def color.def thread.def gstring.def \
text.def char.def Objects/inputC.def Objects/metaC.def \
chunkarr.def geoworks.def Objects/winC.def win.def \
hostif.def
hostif.eobj: geos.def ec.def heap.def geode.def resource.def \
library.def vm.def dbase.def object.def lmem.def \
graphics.def fontID.def font.def color.def thread.def \
gstring.def text.def char.def Objects/inputC.def \
Objects/metaC.def chunkarr.def geoworks.def \
Objects/winC.def win.def hostif.def

hostifEC.geo hostif.geo : geos.ldf
10 changes: 5 additions & 5 deletions Installed/Library/SSL/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ RC4 = rc4_enc.c rc4_skey.c rc4.h rc4_locl.h
RSA = rsa_eay.c rsa_lib.c rsa_none.c rsa_pk1.c rsa_sign.c\
rsa_ssl.c rsa.h
SHA = sha1dgst.c sha.h sha_locl.h
SSL = sslManager.asm s23_clnt.c s23_lib.c s23_meth.c s23_pkt.c\
s2_clnt.c s2_enc.c s2_lib.c s2_meth.c s2_pkt.c s3_both.c\
s3_clnt.c s3_enc.c s3_lib.c s3_meth.c s3_pkt.c ssl_algs.c\
SSL = s23_clnt.c s23_lib.c s23_meth.c s23_pkt.c s2_clnt.c\
s2_enc.c s2_lib.c s2_meth.c s2_pkt.c s3_both.c s3_clnt.c\
s3_enc.c s3_lib.c s3_meth.c s3_pkt.c ssl_algs.c\
ssl_asn1.c ssl_cert.c ssl_ciph.c ssl_lib.c ssl_rsa.c\
ssl_sess.c t1_clnt.c t1_enc.c t1_lib.c t1_meth.c ssl.h\
ssl2.h ssl23.h ssl3.h ssl_locl.h tls1.h
Expand Down Expand Up @@ -72,8 +72,8 @@ OBJS = asn1_lib.obj a_bitstr.obj a_bmp.obj a_bool.obj\
t1_lib.obj t1_meth.obj stack.obj x509type.obj\
x509_cmp.obj x509_ext.obj x509_lu.obj x509_obj.obj\
x509_v3.obj x509_vfy.obj x_all.obj
COMMON = e_os.h ssl_host.h
MODULES = ssl
COMMON = e_os.h
MODULES =
CMODULES = asn1 bio bn buffer crypto err evp hmac lhash md5 objects\
rand rc4 rsa sha ssl stack x509
SRCS = $(ASN1) $(BIO) $(BN) $(BUFFER) $(CRYPTO) $(ERR) $(EVP)\
Expand Down
12 changes: 4 additions & 8 deletions Installed/Library/SSL/dependencies.mk
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
ssl.obj \
ssl.eobj: ssl/sslManager.asm \
geos.def heap.def geode.def ec.def file.def \
Internal/host.def
asn1_lib.obj \
asn1_lib.eobj: Ansi/stdio.h geos.h crypto/cryptlib.h Ansi/stdlib.h \
Ansi/string.h e_os.h resource.h geode.h heap.h ec.h \
Expand Down Expand Up @@ -637,7 +633,7 @@ s2_clnt.eobj: geos.h resource.h Ansi/stdio.h rand/rand.h buffer/buffer.h \
asn1/errno.h evp/evp.h md5/md5.h sha/sha.h rc4/rc4.h \
rsa/rsa.h x509/x509.h x509/x509_vfy.h lhash/lhash.h \
asn1/pkcs7.h err/err.h ssl/ssl.h ssl/ssl2.h ssl/ssl3.h \
ssl/tls1.h ssl/ssl23.h
ssl/tls1.h ssl/ssl23.h hostif.h
s2_enc.obj \
s2_enc.eobj: Ansi/stdio.h geos.h ssl/ssl_locl.h Ansi/stdlib.h timer.h \
Ansi/string.h asn1/errno.h e_os.h resource.h geode.h \
Expand Down Expand Up @@ -736,7 +732,7 @@ ssl_algs.eobj: Ansi/stdio.h geos.h objects/objects.h bio/bio.h \
asn1/errno.h buffer/buffer.h evp/evp.h md5/md5.h \
sha/sha.h rc4/rc4.h rsa/rsa.h x509/x509.h x509/x509_vfy.h \
asn1/pkcs7.h err/err.h ssl/ssl.h ssl/ssl2.h ssl/ssl3.h \
ssl/tls1.h ssl/ssl23.h
ssl/tls1.h ssl/ssl23.h hostif.h
ssl_asn1.obj \
ssl_asn1.eobj: Ansi/stdio.h geos.h Ansi/stdlib.h asn1/asn1_mac.h \
asn1/asn1.h timedate.h bn/bn.h e_os.h resource.h geode.h \
Expand Down Expand Up @@ -772,7 +768,7 @@ ssl_lib.eobj: Ansi/stdio.h geos.h objects/objects.h bio/bio.h \
timer.h asn1/errno.h buffer/buffer.h evp/evp.h md5/md5.h \
sha/sha.h rc4/rc4.h rsa/rsa.h x509/x509.h x509/x509_vfy.h \
asn1/pkcs7.h err/err.h ssl/ssl.h ssl/ssl2.h ssl/ssl3.h \
ssl/tls1.h ssl/ssl23.h
ssl/tls1.h ssl/ssl23.h hostif.h
ssl_rsa.obj \
ssl_rsa.eobj: Ansi/stdio.h geos.h bio/bio.h crypto/crypto.h \
stack/stack.h objects/objects.h asn1/asn1.h timedate.h \
Expand Down Expand Up @@ -897,4 +893,4 @@ x_all.eobj: Ansi/stdio.h geos.h stack/stack.h crypto/cryptlib.h \
objects/objects.h x509/x509.h x509/x509_vfy.h \
lhash/lhash.h asn1/pkcs7.h

sslEC.geo ssl.geo : geos.ldf ansic.ldf socket.ldf
sslEC.geo ssl.geo : geos.ldf ansic.ldf socket.ldf hostif.ldf
101 changes: 60 additions & 41 deletions Library/HostIf/hostif.asm
Original file line number Diff line number Diff line change
Expand Up @@ -42,58 +42,20 @@ include Objects/inputC.def

include Objects/winC.def


DefLib hostif.def

COORDINATE_OVERFLOW enum FatalErrors
; Some internal error in TransformInkBlock

udata segment
udata ends
HOST_API_INTERRUPT equ 0xA0

idata segment
idata ends

Code segment resource

COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
HostIfEntry
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

SYNOPSIS: Determine what the protocol # of the pen library is, so we
know if we need to add our workarounds.

CALLED BY: GLOBAL
PASS: di - LibraryCallType
RETURN: nada
DESTROYED: nada
PSEUDO CODE/STRATEGY:

KNOWN BUGS/SIDE EFFECTS/IDEAS:

REVISION HISTORY:
Name Date Description
---- ---- -----------
atw 10/22/93 Initial version

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@

HostIfEntry proc far
.enter
clc
.leave
ret
HostIfEntry endp

COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
HostIfDetect
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

SYNOPSIS: Determine what the protocol # of the pen library is, so we
know if we need to add our workarounds.
SYNOPSIS: Determine if host side API is available an and if what
version is supported.

CALLED BY: GLOBAL
PASS: nada
Expand All @@ -113,6 +75,8 @@ REVISION HISTORY:

.ioenable

SetGeosConvention

baseboxID byte "XOBESAB1"

HostIfDetect proc far
Expand Down Expand Up @@ -164,10 +128,65 @@ error:

HostIfDetect endp

COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
HostIfDetect
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

SYNOPSIS: Determine if host side API is available and in case it is
what version is supported.

CALLED BY: GLOBAL
PASS: nada
RETURN: ax - interface version, 0 mean no host interface found
DESTROYED: nada
PSEUDO CODE/STRATEGY:

KNOWN BUGS/SIDE EFFECTS/IDEAS:

REVISION HISTORY:
Name Date Description
---- ---- -----------
FR 12/21/23 Initial version

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@

HOSTIFDETECT proc far
GOTO HostIfDetect
HOSTIFDETECT endp

HostIfCall proc far
int HOST_API_INTERRUPT
ret
HostIfCall endp

HOSTIFCALL proc far func:word,
data1:dword,
data2:dword,
data3:word
uses di, si, cx, bx

.enter
mov di, data3
mov dx, data2.high
mov cx, data2.low
mov bx, data1.high
mov si, data1.low

mov ax, func
int HOST_API_INTERRUPT

.leave
ret

HOSTIFCALL endp

SetDefaultConvention

Code ends


6 changes: 3 additions & 3 deletions Library/HostIf/hostif.gp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# Parameters file for: hostif
#
# $Id: inkfix.gp,v 1.1 97/04/05 01:06:35 newdeal Exp $
# $Id: hostif.gp,v 1.1 23/12/05 01:06:35 bluewaysw Exp $
#
##############################################################################
#
Expand All @@ -27,8 +27,6 @@ longname "Host Interface Library"
tokenchars "HSTI"
tokenid 0

entry HostIfEntry

#
# Specify geode type
#
Expand All @@ -44,3 +42,5 @@ library geos
#
export HostIfDetect
export HOSTIFDETECT
export HostIfCall
export HOSTIFCALL
7 changes: 7 additions & 0 deletions Library/SSL/crypto/cryptlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ word mapped = 0;
MemHandle phyMemInfoBlk;
#endif

#ifdef COMPILE_OPTION_HOST_SERVICE
Boolean hostApiAvailable = FALSE;
#endif

int _far _pascal SSLLIBRARYENTRY(LibraryCallType ty, GeodeHandle client)
{
if (ty == LCT_ATTACH) {
Expand All @@ -171,6 +175,9 @@ int _far _pascal SSLLIBRARYENTRY(LibraryCallType ty, GeodeHandle client)
#ifdef FULL_EXECUTE_IN_PLACE
#pragma option -dc
#endif
#endif
#ifdef COMPILE_OPTION_HOST_SERVICE
hostApiAvailable = HostIfDetect() >= 1;
#endif
CRYPTO_thread_setup();
} else if (ty == LCT_DETACH) {
Expand Down
12 changes: 8 additions & 4 deletions Library/SSL/ssl/s2_clnt.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
#include "objects.h"
#include "ssl_locl.h"
#include "evp.h"
#include "ssl_host.h"
#include <hostif.h>

#ifndef NOPROTO
static int get_server_finished(SSL *s);
Expand All @@ -93,6 +93,10 @@ static int ssl_rsa_public_encrypt();

#define BREAK break

#ifdef COMPILE_OPTION_HOST_SERVICE
extern Boolean hostApiAvailable;
#endif

static SSL_METHOD *ssl2_get_client_method(ver)
int ver;
{
Expand All @@ -110,10 +114,10 @@ SSL_METHOD* _export _pascal SSLv2_client_method()
SSL_METHOD *ret;
#endif
#ifdef COMPILE_OPTION_HOST_SERVICE
if(SSLCheckHost())
if(hostApiAvailable)
{
return (SSL_METHOD *) SSLCallHost(
SSLHFN_SSLV2_CLIENT_METHOD,
return (SSL_METHOD *) HostIfCall(
HIF_SSL_V2_GET_CLIENT_METHOD,
(dword) NULL, (dword) NULL, 0);
}
#endif
Expand Down
Loading

0 comments on commit 80e3b66

Please sign in to comment.