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
3f9cbef7
Commit
3f9cbef7
authored
May 12, 2017
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reduce code repetition in failure exit from decrypt().
parent
44df0ec9
Pipeline
#205
skipped
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
21 deletions
+12
-21
vmod_gcrypt.c
src/vmod_gcrypt.c
+12
-21
No files found.
src/vmod_gcrypt.c
View file @
3f9cbef7
...
...
@@ -472,9 +472,7 @@ vmod_symmetric_decrypt(VRT_CTX, struct vmod_gcrypt_symmetric *symmetric,
if
(
iv
==
NULL
)
{
VERR
(
ctx
,
"Required initialization vector is NULL in "
"%s.decrypt()"
,
symmetric
->
vcl_name
);
WS_Release
(
ctx
->
ws
,
0
);
WS_Reset
(
ctx
->
ws
,
snap
);
return
NULL
;
goto
fail
;
}
assert
(
iv
->
len
>=
0
);
/* A NULL iv of length 0 is permitted. */
...
...
@@ -485,18 +483,14 @@ vmod_symmetric_decrypt(VRT_CTX, struct vmod_gcrypt_symmetric *symmetric,
VERR
(
ctx
,
"Cannot set initialization vector in "
"%s.decrypt(): %s/%s"
,
symmetric
->
vcl_name
,
gcry_strsource
(
err
),
gcry_strerror
(
err
));
WS_Release
(
ctx
->
ws
,
0
);
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.decrypt()"
,
symmetric
->
vcl_name
);
WS_Release
(
ctx
->
ws
,
0
);
WS_Reset
(
ctx
->
ws
,
snap
);
return
NULL
;
goto
fail
;
}
assert
(
ctr
->
len
>=
0
);
if
((
err
=
gcry_cipher_setctr
(
hd
,
ctr
->
priv
,
ctr
->
len
))
...
...
@@ -504,9 +498,7 @@ vmod_symmetric_decrypt(VRT_CTX, struct vmod_gcrypt_symmetric *symmetric,
VERR
(
ctx
,
"Cannot set counter vector in %s.decrypt(): "
"%s/%s"
,
symmetric
->
vcl_name
,
gcry_strsource
(
err
),
gcry_strerror
(
err
));
WS_Release
(
ctx
->
ws
,
0
);
WS_Reset
(
ctx
->
ws
,
snap
);
return
NULL
;
goto
fail
;
}
}
if
((
err
=
gcry_cipher_decrypt
(
hd
,
plaintext
->
priv
,
ciphertext
->
len
,
...
...
@@ -514,9 +506,7 @@ vmod_symmetric_decrypt(VRT_CTX, struct vmod_gcrypt_symmetric *symmetric,
!=
GPG_ERR_NO_ERROR
)
{
VERR
(
ctx
,
"in %s.decrypt(): %s/%s"
,
symmetric
->
vcl_name
,
gcry_strsource
(
err
),
gcry_strerror
(
err
));
WS_Release
(
ctx
->
ws
,
0
);
WS_Reset
(
ctx
->
ws
,
snap
);
return
NULL
;
goto
fail
;
}
plaintext
->
len
=
ciphertext
->
len
;
if
(
symmetric
->
padding
!=
NONE
)
{
...
...
@@ -525,9 +515,7 @@ vmod_symmetric_decrypt(VRT_CTX, struct vmod_gcrypt_symmetric *symmetric,
"plaintext length %d is not a multiple of block "
"length %d"
,
symmetric
->
vcl_name
,
plaintext
->
len
,
symmetric
->
blocklen
);
WS_Release
(
ctx
->
ws
,
0
);
WS_Reset
(
ctx
->
ws
,
snap
);
return
NULL
;
goto
fail
;
}
plaintext
->
len
=
(
unpadlenf
[
symmetric
->
padding
])(
plaintext
->
priv
,
...
...
@@ -536,14 +524,17 @@ vmod_symmetric_decrypt(VRT_CTX, struct vmod_gcrypt_symmetric *symmetric,
if
(
plaintext
->
len
<
0
)
{
VERR
(
ctx
,
"in %s.decrypt(): incorrect padding"
,
symmetric
->
vcl_name
);
WS_Release
(
ctx
->
ws
,
0
);
WS_Reset
(
ctx
->
ws
,
snap
);
return
NULL
;
goto
fail
;
}
}
WS_Release
(
ctx
->
ws
,
plaintext
->
len
);
plaintext
->
free
=
NULL
;
return
plaintext
;
fail:
WS_Release
(
ctx
->
ws
,
0
);
WS_Reset
(
ctx
->
ws
,
snap
);
return
NULL
;
}
/* Function random */
...
...
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