Added openssl, openssl/sha1, and openssl/md5.
Also, listed new libs in TR scribble docs.
This commit is contained in:
parent
0e9f468d3f
commit
a651845605
|
@ -67,6 +67,9 @@ The following libraries are included with Typed Racket in the
|
|||
@defmodule/incl[typed/net/smtp]
|
||||
@defmodule/incl[typed/net/uri-codec]
|
||||
@defmodule/incl[typed/net/url]
|
||||
@defmodule/incl[typed/openssl]
|
||||
@defmodule/incl[typed/openssl/md5]
|
||||
@defmodule/incl[typed/openssl/sha1]
|
||||
@defmodule/incl[typed/pict]
|
||||
@defmodule/incl[typed/rackunit]
|
||||
@defmodule/incl[typed/srfi/14]
|
||||
|
|
122
pkgs/typed-racket-pkgs/typed-racket-more/typed/openssl/main.rkt
Normal file
122
pkgs/typed-racket-pkgs/typed-racket-more/typed/openssl/main.rkt
Normal file
|
@ -0,0 +1,122 @@
|
|||
#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/typed/provide openssl
|
||||
[ssl-available? Boolean]
|
||||
[ssl-load-fail-reason (Option String)]
|
||||
|
||||
;; 1: TCP-like Client Procedures
|
||||
[ssl-connect
|
||||
(->* (String Exact-Positive-Integer)
|
||||
((U SSL-Client-Context SSL-Protocol))
|
||||
(Values Input-Port Output-Port))]
|
||||
[ssl-connect/enable-break
|
||||
(->* (String Exact-Positive-Integer)
|
||||
((U SSL-Client-Context SSL-Protocol))
|
||||
(Values Input-Port Output-Port))]
|
||||
|
||||
[ssl-secure-client-context (-> SSL-Client-Context)]
|
||||
[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
|
||||
(Exact-Nonnegative-Integer Boolean (Option String))
|
||||
SSL-Listener)]
|
||||
[ssl-close (-> SSL-Listener Void)]
|
||||
;; ssl-listener? provided above
|
||||
|
||||
[ssl-accept
|
||||
(-> SSL-Listener (Values Input-Port Output-Port))]
|
||||
[ssl-accept/enable-break
|
||||
(-> SSL-Listener (Values Input-Port Output-Port))]
|
||||
[ssl-abandon-port (-> Port Void)] ;; XXX SSL-Port
|
||||
|
||||
[ssl-make-server-context (SSL-Protocol -> SSL-Server-Context)]
|
||||
)
|
||||
|
||||
;;;; 3: SSL Wrapper Interface
|
||||
|
||||
(require/typed/provide openssl
|
||||
[ports->ssl-ports
|
||||
(-> Input-Port Output-Port
|
||||
[#:mode (U 'connect 'accept)]
|
||||
[#:context (U SSL-Client-Context SSL-Server-Context)]
|
||||
[#:encrypt SSL-Protocol]
|
||||
[#:close-original? Boolean]
|
||||
[#:shutdown-on-close? Boolean]
|
||||
[#:error/ssl (Any -> Void)] ;; FIXME find type for error proc
|
||||
[#:hostname (Option String)]
|
||||
; ->
|
||||
(Values Input-Port Output-Port))]
|
||||
)
|
||||
|
||||
;;;; 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)]
|
||||
[ssl-default-verify-sources (Parameterof SSL-Verify-Source)]
|
||||
[ssl-load-default-verify-sources! (-> SSL-Context Void)]
|
||||
[ssl-load-verify-root-certificates!
|
||||
(-> (U SSL-Context SSL-Listener) Path-String Void)]
|
||||
[ssl-set-ciphers! (-> SSL-Context String Void)]
|
||||
[ssl-seal-context! (-> SSL-Context Void)]
|
||||
[ssl-load-certificate-chain!
|
||||
(-> (U SSL-Context SSL-Listener) Path-String Void)]
|
||||
[ssl-load-private-key!
|
||||
(->* ((U SSL-Context SSL-Listener) Path-String)
|
||||
(Boolean Boolean)
|
||||
Void)]
|
||||
[ssl-load-suggested-certificate-authorities!
|
||||
(-> (U SSL-Context SSL-Listener) Path-String Void)]
|
||||
)
|
||||
|
||||
;;;; 5: Peer Verification
|
||||
|
||||
(require/typed/provide openssl
|
||||
[ssl-set-verify!
|
||||
(-> (U SSL-Context SSL-Listener Port) Any ;; XXX SSL-Port
|
||||
Void)]
|
||||
[ssl-try-verify!
|
||||
(-> (U SSL-Context SSL-Listener Port) Any ;; XXX SSL-Port
|
||||
Void)]
|
||||
[ssl-peer-verified? (-> Port Boolean)] ;; XXX SSL-Port
|
||||
[ssl-set-verify-hostname! (-> SSL-Context Any Void)]
|
||||
[ssl-peer-certificate-hostnames
|
||||
(-> Port (Listof String))] ;; XXX SSL-Port
|
||||
[ssl-peer-check-hostname
|
||||
(-> Port String Boolean)] ;; XXX SSL-Port
|
||||
[ssl-peer-subject-name (-> Port (Option Bytes))] ;; XXX SSL-Port
|
||||
[ssl-peer-issuer-name (-> Port (Option Bytes))] ;; XXX SSL-Port
|
||||
)
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
#lang typed/racket/base
|
||||
|
||||
(require/typed/provide openssl/md5
|
||||
[md5 (-> Input-Port String)]
|
||||
[md5-bytes (-> Input-Port Bytes)]
|
||||
)
|
|
@ -0,0 +1,8 @@
|
|||
#lang typed/racket/base
|
||||
|
||||
(require/typed/provide openssl/sha1
|
||||
[sha1 (-> Input-Port String)]
|
||||
[sha1-bytes (-> Input-Port Bytes)]
|
||||
[bytes->hex-string (-> Bytes String)]
|
||||
[hex-string->bytes (-> String Bytes)]
|
||||
)
|
Loading…
Reference in New Issue
Block a user