Commit c5227cab authored by Nils Goroll's avatar Nils Goroll

wip

parent 69c40e1d
......@@ -41,11 +41,11 @@
#include <fcntl.h>
#include <float.h>
#include "vcl.h"
#include "cache/cache.h"
#include "vrt.h"
//#include "vcl.h"
//#include "vrt.h"
#include "vas.h"
#include "vdef.h"
//#include "vdef.h"
#include "vqueue.h"
#include "vcc_if.h"
......@@ -469,10 +469,10 @@ vmod_symmetric_encrypt(VRT_CTX, struct vmod_gcrypt_symmetric *symmetric,
{
size_t len, blocklen;
uintptr_t snap;
void *plaintext;
struct vmod_priv *ciphertext;
void *plaintext, *ciphertext;
gcry_error_t err = GPG_ERR_NO_ERROR;
gcry_cipher_hd_t *hd;
VCL_BLOB b;
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(symmetric, VMOD_GCRYPT_SYMMETRIC_MAGIC);
......@@ -483,11 +483,6 @@ vmod_symmetric_encrypt(VRT_CTX, struct vmod_gcrypt_symmetric *symmetric,
}
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);
AN(blocklen);
if (symmetric->padding != NONE) {
......@@ -504,7 +499,7 @@ vmod_symmetric_encrypt(VRT_CTX, struct vmod_gcrypt_symmetric *symmetric,
plaintext = plainblob->priv;
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",
symmetric->vcl_name);
goto fail;
......@@ -546,13 +541,15 @@ vmod_symmetric_encrypt(VRT_CTX, struct vmod_gcrypt_symmetric *symmetric,
goto fail;
}
}
if ((err = gcry_cipher_encrypt(*hd, ciphertext->priv, len, plaintext,
if ((err = gcry_cipher_encrypt(*hd, ciphertext, len, plaintext,
len))
!= GPG_ERR_NO_ERROR) {
VERR(ctx, "in %s.encrypt(): %s/%s", symmetric->vcl_name,
gcry_strsource(err), gcry_strerror(err));
goto fail;
}
b = VRT_
ciphertext->len = len;
ciphertext->free = NULL;
return ciphertext;
......
......@@ -339,7 +339,7 @@ Examples::
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
specified for this ``symmetric`` object, and return the ciphertext as
......@@ -396,7 +396,7 @@ Examples::
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
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