diff mbox series

[v2,01/11] qcrypto: add suport for amend options

Message ID 20190912223028.18496-2-mlevitsk@redhat.com (mailing list archive)
State New, archived
Headers show
Series RFC crypto/luks: encryption key managment using amend interface | expand

Commit Message

Maxim Levitsky Sept. 12, 2019, 10:30 p.m. UTC
This adds the qcrypto_amend_options and corresponding
crypto driver callbacks for the  for encrypted
key managedment

Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
---
 crypto/block.c         | 31 +++++++++++++++++++++++++++++++
 crypto/blockpriv.h     |  8 ++++++++
 include/crypto/block.h | 22 ++++++++++++++++++++++
 3 files changed, 61 insertions(+)

Comments

Eric Blake Sept. 23, 2019, 1:08 p.m. UTC | #1
On 9/12/19 5:30 PM, Maxim Levitsky wrote:
> This adds the qcrypto_amend_options and corresponding
> crypto driver callbacks for the  for encrypted

grammar is off, did you miss a word where that double space is?

> key managedment

management

> 
> Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
>  crypto/block.c         | 31 +++++++++++++++++++++++++++++++
>  crypto/blockpriv.h     |  8 ++++++++
>  include/crypto/block.h | 22 ++++++++++++++++++++++
>  3 files changed, 61 insertions(+)
> 
> diff --git a/crypto/block.c b/crypto/block.c
> index 325752871c..14b684de7f 100644
> --- a/crypto/block.c
> +++ b/crypto/block.c
> @@ -115,6 +115,37 @@ QCryptoBlock *qcrypto_block_create(QCryptoBlockCreateOptions *options,
>  }
>  
>  
> +int qcrypto_block_amend_options(QCryptoBlock *block,
> +                                QCryptoBlockReadFunc readfunc,
> +                                QCryptoBlockWriteFunc writefunc,
> +                                void *opaque,
> +                                QCryptoBlockCreateOptions *options,
> +                                bool force,
> +                                Error **errp)
> +{
> +    if (options->format != block->format) {
> +        error_setg(errp,
> +                   "Its not possible to change encryption format with amend interface");
> +        return -1;

"It's" (here, you want the form meaning "It is")

Or reword the entire error to something shorter:

error_setg(errp, "cannot amend encryption format")
Maxim Levitsky Sept. 23, 2019, 1:24 p.m. UTC | #2
On Mon, 2019-09-23 at 08:08 -0500, Eric Blake wrote:
> On 9/12/19 5:30 PM, Maxim Levitsky wrote:
> > This adds the qcrypto_amend_options and corresponding
> > crypto driver callbacks for the  for encrypted
> 
> grammar is off, did you miss a word where that double space is?
> 
> > key managedment
> 
> management


Thank you!
I'll try my best in the future to have less spelling and
grammar errors like that. I need to double check every
message prior to sending the patches.

> 
> > 
> > Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
> > Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
> > ---
> >  crypto/block.c         | 31 +++++++++++++++++++++++++++++++
> >  crypto/blockpriv.h     |  8 ++++++++
> >  include/crypto/block.h | 22 ++++++++++++++++++++++
> >  3 files changed, 61 insertions(+)
> > 
> > diff --git a/crypto/block.c b/crypto/block.c
> > index 325752871c..14b684de7f 100644
> > --- a/crypto/block.c
> > +++ b/crypto/block.c
> > @@ -115,6 +115,37 @@ QCryptoBlock *qcrypto_block_create(QCryptoBlockCreateOptions *options,
> >  }
> >  
> >  
> > +int qcrypto_block_amend_options(QCryptoBlock *block,
> > +                                QCryptoBlockReadFunc readfunc,
> > +                                QCryptoBlockWriteFunc writefunc,
> > +                                void *opaque,
> > +                                QCryptoBlockCreateOptions *options,
> > +                                bool force,
> > +                                Error **errp)
> > +{
> > +    if (options->format != block->format) {
> > +        error_setg(errp,
> > +                   "Its not possible to change encryption format with amend interface");
> > +        return -1;
> 
> "It's" (here, you want the form meaning "It is")
> 
> Or reword the entire error to something shorter:
> 
> error_setg(errp, "cannot amend encryption format")


Same here.
> 


Thanks for the review,
Best regards,
	Maxim Levitsky
diff mbox series

Patch

diff --git a/crypto/block.c b/crypto/block.c
index 325752871c..14b684de7f 100644
--- a/crypto/block.c
+++ b/crypto/block.c
@@ -115,6 +115,37 @@  QCryptoBlock *qcrypto_block_create(QCryptoBlockCreateOptions *options,
 }
 
 
+int qcrypto_block_amend_options(QCryptoBlock *block,
+                                QCryptoBlockReadFunc readfunc,
+                                QCryptoBlockWriteFunc writefunc,
+                                void *opaque,
+                                QCryptoBlockCreateOptions *options,
+                                bool force,
+                                Error **errp)
+{
+    if (options->format != block->format) {
+        error_setg(errp,
+                   "Its not possible to change encryption format with amend interface");
+        return -1;
+    }
+
+    if (!block->driver->amend) {
+        error_setg(errp,
+                   "Crypto format %s doesn't support format options amendment",
+                   QCryptoBlockFormat_str(block->format));
+        return -1;
+    }
+
+    return block->driver->amend(block,
+                                readfunc,
+                                writefunc,
+                                opaque,
+                                options,
+                                force,
+                                errp);
+}
+
+
 QCryptoBlockInfo *qcrypto_block_get_info(QCryptoBlock *block,
                                          Error **errp)
 {
diff --git a/crypto/blockpriv.h b/crypto/blockpriv.h
index 71c59cb542..c18a4e0b43 100644
--- a/crypto/blockpriv.h
+++ b/crypto/blockpriv.h
@@ -62,6 +62,14 @@  struct QCryptoBlockDriver {
                   void *opaque,
                   Error **errp);
 
+    int (*amend)(QCryptoBlock *block,
+                 QCryptoBlockReadFunc readfunc,
+                 QCryptoBlockWriteFunc writefunc,
+                 void *opaque,
+                 QCryptoBlockCreateOptions *options,
+                 bool force,
+                 Error **errp);
+
     int (*get_info)(QCryptoBlock *block,
                     QCryptoBlockInfo *info,
                     Error **errp);
diff --git a/include/crypto/block.h b/include/crypto/block.h
index d49d2c2da9..777fd51ebe 100644
--- a/include/crypto/block.h
+++ b/include/crypto/block.h
@@ -144,6 +144,28 @@  QCryptoBlock *qcrypto_block_create(QCryptoBlockCreateOptions *options,
                                    void *opaque,
                                    Error **errp);
 
+/**
+ * qcrypto_block_amend_options:
+ * @block: the block encryption object
+ *
+ * @readfunc: callback for reading data from the volume header
+ * @writefunc: callback for writing data to the volume header
+ * @opaque: data to pass to @readfunc and @writefunc
+ * @options: the new/amended encryption options
+ * @force: hint for the driver to allow unsafe operation
+ * @errp: error pointer
+ *
+ * Changes the crypto options of the encryption format
+ *
+ */
+int qcrypto_block_amend_options(QCryptoBlock *block,
+                                QCryptoBlockReadFunc readfunc,
+                                QCryptoBlockWriteFunc writefunc,
+                                void *opaque,
+                                QCryptoBlockCreateOptions *options,
+                                bool force,
+                                Error **errp);
+
 
 /**
  * qcrypto_block_get_info: