summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/backend.lisp21
-rw-r--r--src/file-backend.lisp18
-rw-r--r--src/hash-backend.lisp14
-rw-r--r--src/package.lisp2
4 files changed, 23 insertions, 32 deletions
diff --git a/src/backend.lisp b/src/backend.lisp
index 0230b24..381c96c 100644
--- a/src/backend.lisp
+++ b/src/backend.lisp
@@ -33,3 +33,24 @@ object."))
vector. An additional 32-byte octet-vector SECRET can be provided in order to
protect the data from attacks against convergent encryption."))
+
+;; Default methods
+
+(defmethod fetch-data (read-capability (backend decoding-backend) &key &allow-other-keys)
+ (declare (type read-capability read-capability))
+ (with-slots (fetch-function) backend
+ (eris-decode read-capability fetch-function)))
+
+(defmethod store-data (input (backend encoding-backend) &key (secret null-secret) (hash-output nil) &allow-other-keys)
+ (declare (type octet-vector secret))
+ (with-slots (output-function) backend
+ (eris-encode input ;; According to ERIS spec recommendation.
+ (if (> (etypecase input
+ (stream (file-length input))
+ (vector (length input)))
+ (* 2 16384))
+ 32kib
+ 1kib)
+ output-function
+ :hash-output hash-output
+ :secret secret)))
diff --git a/src/file-backend.lisp b/src/file-backend.lisp
index 1a1c5b0..6174cf7 100644
--- a/src/file-backend.lisp
+++ b/src/file-backend.lisp
@@ -54,21 +54,3 @@
(alexandria:write-byte-vector-into-file block file)))
block))))
-(defmethod fetch-data (read-capability (backend file-backend) &key &allow-other-keys)
- (declare (type read-capability read-capability))
- (with-slots (fetch-function) backend
- (eris-decode read-capability fetch-function)))
-
-(defmethod store-data (input (backend file-backend) &key (secret null-secret) &allow-other-keys)
- (declare (type octet-vector secret))
- (with-slots (output-function) backend
- (eris-encode input
- (if (> (etypecase input
- (stream (file-length input))
- (vector (length input)))
- (* 2 16384))
- 32kib
- 1kib)
- output-function
- :hash-output nil
- :secret secret)))
diff --git a/src/hash-backend.lisp b/src/hash-backend.lisp
index 0fa095a..7568db3 100644
--- a/src/hash-backend.lisp
+++ b/src/hash-backend.lisp
@@ -35,18 +35,4 @@
(copy-seq block))
block)))))
-(defmethod fetch-data (read-capability (backend hash-backend) &key &allow-other-keys)
- (declare (type read-capability read-capability))
- (with-slots (fetch-function) backend
- (eris-decode read-capability fetch-function :cache-capacity nil)))
-
-(defmethod store-data (input (backend hash-backend) &key (secret null-secret) (block-size 1kib) &allow-other-keys)
- (declare (type octet-vector secret))
- (with-slots (output-function) backend
- (eris-encode input
- block-size
- output-function
- :hash-output nil
- :secret secret)))
-
diff --git a/src/package.lisp b/src/package.lisp
index 364b768..dd6aa0f 100644
--- a/src/package.lisp
+++ b/src/package.lisp
@@ -46,6 +46,8 @@
#:hash-mismatch
#:invalid-internal-block
#:missing-block
+ #:directory-error
+ #:file-backend-error
#:store-data
#:fetch-data