From 44460d383d09a7a085610b32ef17a60b4fd2041d Mon Sep 17 00:00:00 2001 From: Jordan Johnson Date: Sat, 24 May 2014 23:50:45 -0700 Subject: [PATCH] Lifted types & main openssl lib to separate files. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Noticed that typed wrappers for some other libs (e.g., db) would use the types but not necessarily the functions, so it seems logical to separate the types. Also, after I built Racket on my Mac, it failed to find openssl/main.rkt named as it was — signaled an error that indicated it was looking in /pkgs/htdp-pkgs/htdp-lib/typed/openssl.rkt — so I lifted openssl/main.rkt out to openssl.rkt --- .../typed/{openssl/main.rkt => openssl.rkt} | 29 +------------ .../typed-racket-more/typed/openssl/types.rkt | 43 +++++++++++++++++++ 2 files changed, 44 insertions(+), 28 deletions(-) rename pkgs/typed-racket-pkgs/typed-racket-more/typed/{openssl/main.rkt => openssl.rkt} (79%) create mode 100644 pkgs/typed-racket-pkgs/typed-racket-more/typed/openssl/types.rkt diff --git a/pkgs/typed-racket-pkgs/typed-racket-more/typed/openssl/main.rkt b/pkgs/typed-racket-pkgs/typed-racket-more/typed/openssl.rkt similarity index 79% rename from pkgs/typed-racket-pkgs/typed-racket-more/typed/openssl/main.rkt rename to pkgs/typed-racket-pkgs/typed-racket-more/typed/openssl.rkt index 1128a025f7..1da2b8bbe0 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-more/typed/openssl/main.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-more/typed/openssl.rkt @@ -1,14 +1,6 @@ #lang typed/racket/base -(require/opaque-type SSL-Client-Context ssl-client-context? openssl) -(define-type SSL-Protocol - (U 'sslv2-or-v3 'sslv2 'sslv3 'tls)) -(provide SSL-Client-Context - ssl-client-context? - SSL-Protocol) - -(require/opaque-type SSL-Listener ssl-listener? openssl) - +(require "openssl/types.rkt") (require/typed/provide openssl [ssl-available? Boolean] @@ -28,17 +20,6 @@ [ssl-make-client-context (SSL-Protocol -> SSL-Client-Context)] ) -;;;; Ports ;;;; - -(require/typed/provide openssl - ;; XXX Would be better if we could make SSL-Port be a subtype - ;; of Port, but for now that's impossible so we'll just provide - ;; this predicate. - [ssl-port? (-> Any Boolean)] - ) - -(require/opaque-type SSL-Server-Context ssl-server-context? openssl) - ;;;; 2: TCP-like Server Procedures (require/typed/provide openssl [ssl-listen (->* (Exact-Positive-Integer) ;; port, <= 65535 @@ -74,14 +55,6 @@ ;;;; 4: Context Procedures -(define-type SSL-Context (U SSL-Client-Context SSL-Server-Context)) - -(define-type SSL-Verify-Source - (U Path-String - (List 'directory Path-String) - (List 'win32-store String) - (List 'macosx-keychain Path-String))) - (require/typed/provide openssl [ssl-load-verify-source! (-> SSL-Context SSL-Verify-Source [#:try? Any] Void)] diff --git a/pkgs/typed-racket-pkgs/typed-racket-more/typed/openssl/types.rkt b/pkgs/typed-racket-pkgs/typed-racket-more/typed/openssl/types.rkt new file mode 100644 index 0000000000..4f35333f11 --- /dev/null +++ b/pkgs/typed-racket-pkgs/typed-racket-more/typed/openssl/types.rkt @@ -0,0 +1,43 @@ +#lang typed/racket/base + +#| Datatypes used by typed/openssl, based on the untyped openssl module. |# + +(provide SSL-Protocol + SSL-Client-Context ssl-client-context? + SSL-Server-Context ssl-server-context? + SSL-Context + SSL-Listener ssl-listener? + ;; ssl-port? is provided below + SSL-Verify-Source + ) + +(define-type SSL-Protocol + (U 'sslv2-or-v3 'sslv2 'sslv3 'tls)) + +(require/opaque-type SSL-Client-Context ssl-client-context? openssl) + +(require/opaque-type SSL-Listener ssl-listener? openssl) +(provide SSL-Listener ssl-listener?) + +(require/typed/provide openssl + ;; XXX Would be better if we could make a type SSL-Port as a subtype + ;; of Port, but for now that's impossible so we'll just provide this + ;; predicate that guarantees Port-ness. + [ssl-port? (-> Any Boolean ;; TODO: Add this --> : #:+ Port + )] + ) + +(require/opaque-type SSL-Server-Context ssl-server-context? openssl) + +(define-type SSL-Context (U SSL-Client-Context SSL-Server-Context)) + + + +;;;; Host Verification ;;;; + +(define-type SSL-Verify-Source + (U Path-String + (List 'directory Path-String) + (List 'win32-store String) + (List 'macosx-keychain Path-String))) +