summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/eris-decode.lisp11
-rw-r--r--src/eris.lisp17
-rw-r--r--src/package.lisp2
3 files changed, 19 insertions, 11 deletions
diff --git a/src/eris-decode.lisp b/src/eris-decode.lisp
index 806bd37..b3629a2 100644
--- a/src/eris-decode.lisp
+++ b/src/eris-decode.lisp
@@ -111,7 +111,8 @@ represents."
This function walks the tree in order to get the next block, which is then put
in the buffer object of the STREAM. It sets the EOF indicator of the buffer if
it is necessary and sets the position in the buffer to 0."
- (declare (optimize (speed 3) (debug 0)))
+ (declare (optimize (speed 3) (debug 0))
+ (type eris-decode-stream stream))
(with-slots (buffer position eof block-size root get-block nonce-array) stream
(declare (type integer position eof)
(type block-size block-size)
@@ -140,7 +141,7 @@ it is necessary and sets the position in the buffer to 0."
(defun read-to-seq (sequence buf &key (start 0) (end (length sequence)) stream)
(declare (optimize (speed 3) (debug 0))
- (type integer end start sum)
+ (type array-total-size end start)
#+sbcl (sb-ext:muffle-conditions sb-ext:compiler-note))
(with-slots (data pos eof) buf
(declare (type (integer 0 32768) pos eof)
@@ -218,7 +219,11 @@ hash-table is used, a (copy-seq) needs to be done on the return value of
gethash.
The keyword argument CACHE-CAPACITY indicates the amount of blocks stored in the
-cache. It may be NIL to turn off caching entirely."
+cache. It may be NIL to turn off caching entirely.
+
+The conditions ERIS:MISSING-BLOCK, ERIS:PADDING, ERIS:HASH-MISMATCH and ERIS:EOF
+may be signaled by operations on the stream. Any condition signaled from within
+FETCH-FUNCTION is not handled."
(declare (type read-capability read-capability)
(type function fetch-function)
(type (or integer null) cache-capacity))
diff --git a/src/eris.lisp b/src/eris.lisp
index ed4a05e..91200a1 100644
--- a/src/eris.lisp
+++ b/src/eris.lisp
@@ -70,7 +70,7 @@ object, using the bytes from the OCTETS vector from at START."
(make-instance 'reference-pair :key key :reference reference)))
(defun encrypt-internal-block (input reference nonce)
- (declare (type octet-vector input secret reference))
+ (declare (type octet-vector input reference))
(let ((key (make-array 32 :element-type 'octet)))
(ironclad:digest-sequence :blake2/256 input :digest key)
;; NOT the IETF chacha. Need to fix this by patching ironclad. Maybe.
@@ -109,10 +109,13 @@ a (simple-array (unsigned-byte 8)) object."
(setf (aref cap 1) (level read-capability))
(reference-pair-to-octets (reference-pair read-capability) cap 2)))
-(-> octets-to-read-capability ((octet-vector 66)) read-capability)
+(-> octets-to-read-capability ((octet-vector 66)) (values read-capability &optional))
(defun octets-to-read-capability (octets)
"Convert the standard binary representation for ERIS read capabilities into a
-read-capability object. Returns the read-capability."
+read-capability object. Returns the read-capability.
+
+An ERIS:VERSION-MISMATCH condition may be signaled if the corresponding
+versioning bytes are not supported by eris-cl."
(declare (type (octet-vector 66) octets))
(let ((capability (make-instance 'read-capability)))
(setf (block-size capability)
@@ -134,7 +137,7 @@ read-capability object. Returns the read-capability."
"urn:eris:"
(bytes-to-base32-unpadded (read-capability-to-octets capability))))
-(-> urn-to-read-capability (string) read-capability)
+(-> urn-to-read-capability (string) (values read-capability &optional))
(defun urn-to-read-capability (urn)
"Convert a urn:eris URN string into a read-capability object."
(declare (type string urn))
@@ -146,7 +149,7 @@ read-capability object. Returns the read-capability."
(declare (type (octet-vector 32) reference))
(concatenate 'string "urn:blake2b:" (bytes-to-base32-unpadded reference)))
-(-> block-urn-to-reference (string) (octet-vector 32))
+(-> block-urn-to-reference (string) (values (octet-vector 32) &optional))
(defun block-urn-to-reference (urn)
"Convert a urn:blake2b URN string into a 32-byte block reference vector."
(declare (type string urn))
@@ -220,6 +223,7 @@ guarantee that a reference is only output once."))
(eris-create-tree reference-vector block-size output-function :hash-output hash-output)))
(defmethod eris-encode ((input stream) block-size output-function &key (secret null-secret) hash-output)
+ "This method does not handle any IO related conditions."
(declare (type block-size block-size)
(type function output-function)
(type (octet-vector 32) secret))
@@ -236,8 +240,7 @@ guarantee that a reference is only output once."))
(defun eris-create-tree (reference-vector block-size output-function &key hash-output)
(declare (type block-size block-size)
- (type function output-function)
- (type (octet-vector 32) secret))
+ (type function output-function))
(loop with block-keys = (/ block-size 64)
with level = 0
with reference-vector-l = (make-array 16 :adjustable t :fill-pointer 0)
diff --git a/src/package.lisp b/src/package.lisp
index 0265f74..c618c75 100644
--- a/src/package.lisp
+++ b/src/package.lisp
@@ -15,7 +15,7 @@
(defpackage eris
- (:use common-lisp trivial-gray-streams alexandria serapeum function-cache)
+ (:use #:common-lisp #:trivial-gray-streams #:alexandria #:serapeum #:function-cache)
(:export
#:eris-encode
#:eris-decode