Taylor Venable avatar Taylor Venable committed 2b9591a

Improve safety of encrypted port functions

Comments (0)

Files changed (1)

   (algorithm  ::symbol)
   (key        ::vector)
   (real-in    ::binary-input-port)
-  (inter-in   ::Object) ;string-input-port
+  (inter-in   ::string-input-port)
   (data       ::vector)
   (output     ::vector)
   (closed?    ::boolean #f)
 (define (read-encrypted enc)
   (if (not (encrypted-input-port? enc))
     (error "not an encrypted input port"))
-  (enc:read-all))
+  ((as encrypted-input-port enc):read-all))
 
 ;;; ============================================================================
 ;;;  WRITING ENCRYPTED FILES
 ;; Write plaintext data to the intermediary output port, which is a string
 ;; port. Here it sits until we flush it.
 
-(define (write-encrypted port s)
-  (if (not (encrypted-output-port? port))
+(define (write-encrypted enc s)
+  (if (not (encrypted-output-port? enc))
     (error "not an encrypted output port"))
-  (encrypted-output-port:write* port s))
+  ((as encrypted-output-port enc):write* s))
 
 ;; Write plaintext data to the intermediary output port, which is a string
 ;; port. Here it sits until we flush it.
 
-(define (display-encrypted port s)
-  (if (not (encrypted-output-port? port))
+(define (display-encrypted enc s)
+  (if (not (encrypted-output-port? enc))
     (error "not an encrypted output port"))
-  (encrypted-output-port:display* port s))
+  ((as encrypted-output-port enc):display* s))
 
 ;; Flush the plaintext data from the intermediary output port to the real
 ;; output port. This encrypts the data from the intermediary output port in the
 ;; process. After encrypting and writing the data, it's removed from the
 ;; intermediary output port, so the user can add more.
 
-(define (flush-encrypted port)
-  (if (not (encrypted-output-port? port))
+(define (flush-encrypted enc)
+  (if (not (encrypted-output-port? enc))
     (error "not an encrypted output port"))
-  (encrypted-output-port:flush port))
+  ((as encrypted-output-port enc):flush))
 
 ;; =============================================================================
 ;;  GENERIC ENCRYPTED PORT FUNCTIONS
 
 ;; Close an encrypted output port.
 
-(define (close-encrypted-port port)
-  (if (not (encrypted-port? port))
+(define (close-encrypted-port enc)
+  (if (not (encrypted-port? enc))
     (error "not an encrypted port"))
-  (encrypted-port:close port))
+  ((as encrypted-port enc):close))
 
 ;; =============================================================================
 ;;  MODULE EXPORTS
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.