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
eacd95c4
Commit
eacd95c4
authored
May 16, 2017
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Redeuce code repetition for exit on failure from .encrypt().
parent
fe3cd1b4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
18 deletions
+13
-18
vmod_gcrypt.c
src/vmod_gcrypt.c
+13
-18
No files found.
src/vmod_gcrypt.c
View file @
eacd95c4
...
...
@@ -466,8 +466,7 @@ vmod_symmetric_encrypt(VRT_CTX, struct vmod_gcrypt_symmetric *symmetric,
if
(
plaintext
==
NULL
)
{
VERRNOMEM
(
ctx
,
"Allocating padded plaintext in "
"%s.encrypt()"
,
symmetric
->
vcl_name
);
WS_Reset
(
ctx
->
ws
,
snap
);
return
NULL
;
goto
fail
;
}
}
else
{
...
...
@@ -477,21 +476,17 @@ vmod_symmetric_encrypt(VRT_CTX, struct vmod_gcrypt_symmetric *symmetric,
if
((
ciphertext
->
priv
=
WS_Alloc
(
ctx
->
ws
,
len
))
==
NULL
)
{
VERRNOMEM
(
ctx
,
"Allocating ciphertext result in %s.encrypt"
,
symmetric
->
vcl_name
);
WS_Reset
(
ctx
->
ws
,
snap
);
return
NULL
;
goto
fail
;
}
hd
=
get_symmetric_hd
(
ctx
,
symmetric
,
"encrypt"
);
if
(
hd
==
NULL
)
{
WS_Reset
(
ctx
->
ws
,
snap
);
return
NULL
;
}
if
(
hd
==
NULL
)
goto
fail
;
if
(
need_iv
[
symmetric
->
mode
])
{
if
(
iv
==
NULL
)
{
VERR
(
ctx
,
"Required initialization vector is NULL in "
"%s.encrypt()"
,
symmetric
->
vcl_name
);
WS_Reset
(
ctx
->
ws
,
snap
);
return
NULL
;
goto
fail
;
}
assert
(
iv
->
len
>=
0
);
/* A NULL iv of length 0 is permitted. */
...
...
@@ -502,16 +497,14 @@ vmod_symmetric_encrypt(VRT_CTX, struct vmod_gcrypt_symmetric *symmetric,
VERR
(
ctx
,
"Cannot set initialization vector in "
"%s.encrypt(): %s/%s"
,
symmetric
->
vcl_name
,
gcry_strsource
(
err
),
gcry_strerror
(
err
));
WS_Reset
(
ctx
->
ws
,
snap
);
return
NULL
;
goto
fail
;
}
}
if
(
need_ctr
[
symmetric
->
mode
])
{
if
(
ctr
==
NULL
||
ctr
->
priv
==
NULL
)
{
VERR
(
ctx
,
"Required counter vector is NULL in "
"%s.encrypt()"
,
symmetric
->
vcl_name
);
WS_Reset
(
ctx
->
ws
,
snap
);
return
NULL
;
goto
fail
;
}
assert
(
ctr
->
len
>=
0
);
if
((
err
=
gcry_cipher_setctr
(
*
hd
,
ctr
->
priv
,
ctr
->
len
))
...
...
@@ -519,8 +512,7 @@ vmod_symmetric_encrypt(VRT_CTX, struct vmod_gcrypt_symmetric *symmetric,
VERR
(
ctx
,
"Cannot set counter vector in %s.encrypt(): "
"%s/%s"
,
symmetric
->
vcl_name
,
gcry_strsource
(
err
),
gcry_strerror
(
err
));
WS_Reset
(
ctx
->
ws
,
snap
);
return
NULL
;
goto
fail
;
}
}
if
((
err
=
gcry_cipher_encrypt
(
*
hd
,
ciphertext
->
priv
,
len
,
plaintext
,
...
...
@@ -528,12 +520,15 @@ vmod_symmetric_encrypt(VRT_CTX, struct vmod_gcrypt_symmetric *symmetric,
!=
GPG_ERR_NO_ERROR
)
{
VERR
(
ctx
,
"in %s.encrypt(): %s/%s"
,
symmetric
->
vcl_name
,
gcry_strsource
(
err
),
gcry_strerror
(
err
));
WS_Reset
(
ctx
->
ws
,
snap
);
return
NULL
;
goto
fail
;
}
ciphertext
->
len
=
len
;
ciphertext
->
free
=
NULL
;
return
ciphertext
;
fail:
WS_Reset
(
ctx
->
ws
,
snap
);
return
NULL
;
}
VCL_BLOB
...
...
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