Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libvmod-gcrypt
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
libvmod-gcrypt
Commits
dc391344
Commit
dc391344
authored
Apr 08, 2017
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Properly allocate the cipher handle for symmetric objects.
parent
2c4d27f9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
10 deletions
+10
-10
vmod_gcrypt.c
src/vmod_gcrypt.c
+10
-10
No files found.
src/vmod_gcrypt.c
View file @
dc391344
...
...
@@ -63,7 +63,7 @@
struct
vmod_gcrypt_symmetric
{
unsigned
magic
;
#define VMOD_GCRYPT_SYMMETRIC_MAGIC 0x82c7ffe2
gcry_cipher_hd_t
*
hd
;
gcry_cipher_hd_t
hd
;
char
*
vcl_name
;
size_t
blocklen
;
};
...
...
@@ -117,7 +117,7 @@ vmod_symmetric__init(VRT_CTX, struct vmod_gcrypt_symmetric **symmetricp,
VCL_BOOL
enable_sync
,
VCL_BOOL
cbc_cts
,
VCL_BOOL
cbc_mac
)
{
struct
vmod_gcrypt_symmetric
*
symmetric
;
gcry_cipher_hd_t
*
hd
=
NULL
;
gcry_cipher_hd_t
hd
;
int
algo
=
GCRY_CIPHER_NONE
,
mode
=
GCRY_CIPHER_MODE_NONE
;
unsigned
int
flags
=
0
;
gcry_error_t
err
=
GPG_ERR_NO_ERROR
;
...
...
@@ -172,13 +172,13 @@ vmod_symmetric__init(VRT_CTX, struct vmod_gcrypt_symmetric **symmetricp,
if
(
cbc_mac
)
flags
|=
GCRY_CIPHER_CBC_MAC
;
if
((
err
=
gcry_cipher_open
(
hd
,
algo
,
mode
,
flags
))
if
((
err
=
gcry_cipher_open
(
&
hd
,
algo
,
mode
,
flags
))
!=
GPG_ERR_NO_ERROR
)
{
VERR
(
ctx
,
"Cannot open cipher in %s constructor: %s/%s"
,
vcl_name
,
gcry_strsource
(
err
),
gcry_strerror
(
err
));
return
;
}
if
((
err
=
gcry_cipher_setkey
(
*
hd
,
key
->
priv
,
key
->
len
))
if
((
err
=
gcry_cipher_setkey
(
hd
,
key
->
priv
,
key
->
len
))
!=
GPG_ERR_NO_ERROR
)
{
VERR
(
ctx
,
"Cannot set key in %s constructor: %s/%s"
,
vcl_name
,
gcry_strsource
(
err
),
gcry_strerror
(
err
));
...
...
@@ -186,7 +186,7 @@ vmod_symmetric__init(VRT_CTX, struct vmod_gcrypt_symmetric **symmetricp,
}
if
(
iv
!=
NULL
&&
iv
->
priv
!=
NULL
)
{
assert
(
iv
->
len
>=
0
);
if
((
err
=
gcry_cipher_setiv
(
*
hd
,
iv
->
priv
,
iv
->
len
))
if
((
err
=
gcry_cipher_setiv
(
hd
,
iv
->
priv
,
iv
->
len
))
!=
GPG_ERR_NO_ERROR
)
{
VERR
(
ctx
,
"Cannot set initialization vector in %s "
"constructor: %s/%s"
,
vcl_name
,
...
...
@@ -196,7 +196,7 @@ vmod_symmetric__init(VRT_CTX, struct vmod_gcrypt_symmetric **symmetricp,
}
if
(
ctr
!=
NULL
&&
ctr
->
priv
!=
NULL
)
{
assert
(
ctr
->
len
>=
0
);
if
((
err
=
gcry_cipher_setctr
(
*
hd
,
ctr
->
priv
,
ctr
->
len
))
if
((
err
=
gcry_cipher_setctr
(
hd
,
ctr
->
priv
,
ctr
->
len
))
!=
GPG_ERR_NO_ERROR
)
{
VERR
(
ctx
,
"Cannot set counter vector in %s "
"constructor: %s/%s"
,
vcl_name
,
...
...
@@ -208,7 +208,7 @@ vmod_symmetric__init(VRT_CTX, struct vmod_gcrypt_symmetric **symmetricp,
ALLOC_OBJ
(
symmetric
,
VMOD_GCRYPT_SYMMETRIC_MAGIC
);
AN
(
symmetric
);
*
symmetricp
=
symmetric
;
symmetric
->
hd
=
hd
;
memcpy
(
&
symmetric
->
hd
,
&
hd
,
sizeof
(
hd
))
;
symmetric
->
vcl_name
=
strdup
(
vcl_name
);
AN
(
symmetric
->
vcl_name
);
symmetric
->
blocklen
=
len
;
...
...
@@ -227,7 +227,7 @@ vmod_symmetric__fini(struct vmod_gcrypt_symmetric **symmetricp)
CHECK_OBJ
(
symmetric
,
VMOD_GCRYPT_SYMMETRIC_MAGIC
);
if
(
symmetric
->
vcl_name
!=
NULL
)
free
(
symmetric
->
vcl_name
);
gcry_cipher_close
(
*
symmetric
->
hd
);
gcry_cipher_close
(
symmetric
->
hd
);
FREE_OBJ
(
symmetric
);
}
...
...
@@ -264,7 +264,7 @@ vmod_symmetric_encrypt(VRT_CTX, struct vmod_gcrypt_symmetric *symmetric,
return
NULL
;
}
if
((
err
=
gcry_cipher_encrypt
(
*
symmetric
->
hd
,
ciphertext
->
priv
,
if
((
err
=
gcry_cipher_encrypt
(
symmetric
->
hd
,
ciphertext
->
priv
,
len
,
plaintext
->
priv
,
plaintext
->
len
))
!=
GPG_ERR_NO_ERROR
)
{
VERR
(
ctx
,
"in %s.encrypt: %s/%s"
,
symmetric
->
vcl_name
,
...
...
@@ -307,7 +307,7 @@ vmod_symmetric_decrypt(VRT_CTX, struct vmod_gcrypt_symmetric *symmetric,
return
NULL
;
}
if
((
err
=
gcry_cipher_decrypt
(
*
symmetric
->
hd
,
plaintext
->
priv
,
if
((
err
=
gcry_cipher_decrypt
(
symmetric
->
hd
,
plaintext
->
priv
,
ciphertext
->
len
,
ciphertext
->
priv
,
ciphertext
->
len
))
!=
GPG_ERR_NO_ERROR
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment