Commit c5227cab authored by Nils Goroll's avatar Nils Goroll

wip

parent 69c40e1d
...@@ -41,11 +41,11 @@ ...@@ -41,11 +41,11 @@
#include <fcntl.h> #include <fcntl.h>
#include <float.h> #include <float.h>
#include "vcl.h"
#include "cache/cache.h" #include "cache/cache.h"
#include "vrt.h" //#include "vcl.h"
//#include "vrt.h"
#include "vas.h" #include "vas.h"
#include "vdef.h" //#include "vdef.h"
#include "vqueue.h" #include "vqueue.h"
#include "vcc_if.h" #include "vcc_if.h"
...@@ -469,10 +469,10 @@ vmod_symmetric_encrypt(VRT_CTX, struct vmod_gcrypt_symmetric *symmetric, ...@@ -469,10 +469,10 @@ vmod_symmetric_encrypt(VRT_CTX, struct vmod_gcrypt_symmetric *symmetric,
{ {
size_t len, blocklen; size_t len, blocklen;
uintptr_t snap; uintptr_t snap;
void *plaintext; void *plaintext, *ciphertext;
struct vmod_priv *ciphertext;
gcry_error_t err = GPG_ERR_NO_ERROR; gcry_error_t err = GPG_ERR_NO_ERROR;
gcry_cipher_hd_t *hd; gcry_cipher_hd_t *hd;
VCL_BLOB b;
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(symmetric, VMOD_GCRYPT_SYMMETRIC_MAGIC); CHECK_OBJ_NOTNULL(symmetric, VMOD_GCRYPT_SYMMETRIC_MAGIC);
...@@ -483,11 +483,6 @@ vmod_symmetric_encrypt(VRT_CTX, struct vmod_gcrypt_symmetric *symmetric, ...@@ -483,11 +483,6 @@ vmod_symmetric_encrypt(VRT_CTX, struct vmod_gcrypt_symmetric *symmetric,
} }
snap = WS_Snapshot(ctx->ws); snap = WS_Snapshot(ctx->ws);
if ((ciphertext = WS_Alloc(ctx->ws, sizeof(*ciphertext))) == NULL) {
VERRNOMEM(ctx, "Allocating BLOB result in %s.encrypt()",
symmetric->vcl_name);
return NULL;
}
blocklen = gcry_cipher_get_algo_blklen(symmetric->algo); blocklen = gcry_cipher_get_algo_blklen(symmetric->algo);
AN(blocklen); AN(blocklen);
if (symmetric->padding != NONE) { if (symmetric->padding != NONE) {
...@@ -504,7 +499,7 @@ vmod_symmetric_encrypt(VRT_CTX, struct vmod_gcrypt_symmetric *symmetric, ...@@ -504,7 +499,7 @@ vmod_symmetric_encrypt(VRT_CTX, struct vmod_gcrypt_symmetric *symmetric,
plaintext = plainblob->priv; plaintext = plainblob->priv;
len = plainblob->len; len = plainblob->len;
} }
if ((ciphertext->priv = WS_Alloc(ctx->ws, len)) == NULL) { if ((ciphertext = WS_Alloc(ctx->ws, len)) == NULL) {
VERRNOMEM(ctx, "Allocating ciphertext result in %s.encrypt", VERRNOMEM(ctx, "Allocating ciphertext result in %s.encrypt",
symmetric->vcl_name); symmetric->vcl_name);
goto fail; goto fail;
...@@ -546,13 +541,15 @@ vmod_symmetric_encrypt(VRT_CTX, struct vmod_gcrypt_symmetric *symmetric, ...@@ -546,13 +541,15 @@ vmod_symmetric_encrypt(VRT_CTX, struct vmod_gcrypt_symmetric *symmetric,
goto fail; goto fail;
} }
} }
if ((err = gcry_cipher_encrypt(*hd, ciphertext->priv, len, plaintext, if ((err = gcry_cipher_encrypt(*hd, ciphertext, len, plaintext,
len)) len))
!= GPG_ERR_NO_ERROR) { != GPG_ERR_NO_ERROR) {
VERR(ctx, "in %s.encrypt(): %s/%s", symmetric->vcl_name, VERR(ctx, "in %s.encrypt(): %s/%s", symmetric->vcl_name,
gcry_strsource(err), gcry_strerror(err)); gcry_strsource(err), gcry_strerror(err));
goto fail; goto fail;
} }
b = VRT_
ciphertext->len = len; ciphertext->len = len;
ciphertext->free = NULL; ciphertext->free = NULL;
return ciphertext; return ciphertext;
......
...@@ -339,7 +339,7 @@ Examples:: ...@@ -339,7 +339,7 @@ Examples::
cbc_cts=true, secure=true); cbc_cts=true, secure=true);
} }
$Method BLOB .encrypt(BLOB plaintext, BLOB iv=0, BLOB ctr=0) $Method BLOB .encrypt(BLOB plaintext, [BLOB iv], [BLOB ctr])
Encrypt the contents of ``plaintext`` according to the parameters Encrypt the contents of ``plaintext`` according to the parameters
specified for this ``symmetric`` object, and return the ciphertext as specified for this ``symmetric`` object, and return the ciphertext as
...@@ -396,7 +396,7 @@ Examples:: ...@@ -396,7 +396,7 @@ Examples::
iv=blobcode.decode(BASE64, resp.http.X-IV-256))); iv=blobcode.decode(BASE64, resp.http.X-IV-256)));
} }
$Method BLOB .decrypt(BLOB ciphertext, BLOB iv=0, BLOB ctr=0) $Method BLOB .decrypt(BLOB ciphertext, [BLOB iv], [BLOB ctr])
Decrypt the contents of ``ciphertext`` according to the parameters Decrypt the contents of ``ciphertext`` according to the parameters
specified for this ``symmetric`` object, and return the plaintext as specified for this ``symmetric`` object, and return the plaintext as
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment