Skip to content

Commit

Permalink
work on streams
Browse files Browse the repository at this point in the history
  • Loading branch information
fjames86 committed Jan 6, 2019
1 parent 5d17063 commit 5038fae
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion schannel.asd
Expand Up @@ -13,6 +13,6 @@
(:file "errors")
(:file "ffi")
(:file "classes"))
:depends-on (:cffi))
:depends-on (:cffi :trivial-gray-streams))


13 changes: 13 additions & 0 deletions streams.lisp
Expand Up @@ -71,6 +71,12 @@ offets to point to end of plaintext and remaining undecrypted bytes from next me
(read-next-msg stream)
(read-plaintext))))))

;;; TODO:
;;; 1. buffer unwritten plaintext in sbuf. when buffer full or force-output is called
;;; we should then encrypt and send it.
;;; This would allow us to support write-byte etc



(defmethod trivial-gray-streams:stream-write-sequence ((stream schannel-stream) seq start end &key)
;; copy into send buffer and encrypt.
Expand All @@ -93,11 +99,16 @@ offets to point to end of plaintext and remaining undecrypted bytes from next me

(defmethod close ((stream schannel-stream) &key abort)
(declare (ignore abort))
;; TODO: initiate a TLS socket shutdown. this requires exchanging messages (close notify)
(schannel:free-schannel-context (stream-cxt stream)))



(defclass client-stream (schannel-stream)
())



(defun make-client-stream (base-stream hostname &key ignore-certificates-p)
(let ((cxt (schannel:make-client-context
hostname
Expand All @@ -113,6 +124,8 @@ offets to point to end of plaintext and remaining undecrypted bytes from next me
;; return instance
(make-instance 'client-stream :stream base-stream :cxt cxt))))



(defclass server-stream (schannel-stream)
())

Expand Down

0 comments on commit 5038fae

Please sign in to comment.