summaryrefslogtreecommitdiff
path: root/src/backend.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend.lisp')
-rw-r--r--src/backend.lisp15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/backend.lisp b/src/backend.lisp
index 8d1405b..d2b81b2 100644
--- a/src/backend.lisp
+++ b/src/backend.lisp
@@ -27,11 +27,14 @@
"Using the BACKEND, return a stream that decodes the provided READ-CAPABILITY
object."))
-(defgeneric store-data (input backend &key secret &allow-other-keys)
+(defgeneric store-data (input backend &key secret block-size &allow-other-keys)
(:documentation
"Using the BACKEND, store the INPUT, which is either a stream or an octet
vector. An additional 32-byte octet-vector SECRET can be provided in order to
-protect the data from attacks against convergent encryption."))
+protect the data from attacks against convergent encryption.
+
+BLOCK-SIZE is by default 32kib, except if the input is a file or vector with a
+size less than 16kib. It should be set either to 1024b or 32kib."))
;; Default methods
@@ -41,13 +44,15 @@ protect the data from attacks against convergent encryption."))
(with-slots (fetch-function) backend
(eris-decode read-capability fetch-function)))
-(defmethod store-data (input (backend encoding-backend) &key (secret null-secret) &allow-other-keys)
+(defmethod store-data (input (backend encoding-backend) &key (secret null-secret) (block-size 32kib) &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)))
+ (pathname (file-size input))
+ (file-stream (file-length input))
+ (vector (length input))
+ (t block-size))
16384)
32kib
1kib)