Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libvmod-ece
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-ece
Commits
ab9552e1
Commit
ab9552e1
authored
Sep 08, 2019
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move code around in anticipation of adding the encryption VFP.
parent
e834e299
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
33 deletions
+35
-33
vfp.c
src/vfp.c
+35
-33
No files found.
src/vfp.c
View file @
ab9552e1
...
...
@@ -95,6 +95,41 @@ suck_bytes(struct vfp_ctx *ctx, void *ptr, size_t *lenp)
return
(
vp
);
}
static
inline
void
seq_inc
(
struct
ece
*
ece
)
{
CHECK_OBJ_NOTNULL
(
ece
,
ECE_MAGIC
);
if
(
ece
->
seq_lo
<
UINT64_MAX
)
ece
->
seq_lo
++
;
else
{
assert
(
ece
->
seq_hi
!=
UINT32_MAX
);
ece
->
seq_hi
++
;
ece
->
seq_lo
=
0
;
}
}
static
inline
void
nonce_xor_seq
(
struct
ece
*
ece
,
uint8_t
*
nonce
)
{
uint32_t
nonce_hi
;
uint64_t
nonce_lo
;
CHECK_OBJ_NOTNULL
(
ece
,
ECE_MAGIC
);
CHECK_OBJ_NOTNULL
(
ece
->
crypto
,
ECE_CRYPTO_MAGIC
);
AN
(
nonce
);
nonce_hi
=
ece
->
crypto
->
prenonce_hi
^
ece
->
seq_hi
;
nonce_lo
=
ece
->
crypto
->
prenonce_lo
^
ece
->
seq_lo
;
vbe32enc
(
nonce
,
nonce_hi
);
vbe64enc
(
nonce
+
4
,
nonce_lo
);
}
/**
** VFP decrypt
**/
/*
* RFC8188 ch 2: "The final encoding consists of a header ... and zero or
* more fixed-size encrypted records ..."
...
...
@@ -175,37 +210,6 @@ decrypt_init(struct ece *ece, struct vfp_ctx *ctx)
return
(
VFP_OK
);
}
static
inline
void
seq_inc
(
struct
ece
*
ece
)
{
CHECK_OBJ_NOTNULL
(
ece
,
ECE_MAGIC
);
if
(
ece
->
seq_lo
<
UINT64_MAX
)
ece
->
seq_lo
++
;
else
{
assert
(
ece
->
seq_hi
!=
UINT32_MAX
);
ece
->
seq_hi
++
;
ece
->
seq_lo
=
0
;
}
}
static
inline
void
nonce_xor_seq
(
struct
ece
*
ece
,
uint8_t
*
nonce
)
{
uint32_t
nonce_hi
;
uint64_t
nonce_lo
;
CHECK_OBJ_NOTNULL
(
ece
,
ECE_MAGIC
);
CHECK_OBJ_NOTNULL
(
ece
->
crypto
,
ECE_CRYPTO_MAGIC
);
AN
(
nonce
);
nonce_hi
=
ece
->
crypto
->
prenonce_hi
^
ece
->
seq_hi
;
nonce_lo
=
ece
->
crypto
->
prenonce_lo
^
ece
->
seq_lo
;
vbe32enc
(
nonce
,
nonce_hi
);
vbe64enc
(
nonce
+
4
,
nonce_lo
);
}
static
enum
vfp_status
decrypt
(
struct
ece
*
ece
,
struct
vfp_ctx
*
ctx
,
unsigned
char
*
plaintext
,
size_t
*
lenp
,
enum
vfp_status
vp
)
...
...
@@ -242,8 +246,6 @@ decrypt(struct ece *ece, struct vfp_ctx *ctx, unsigned char *plaintext,
return
(
vp
);
}
/* VFP interface */
static
enum
vfp_status
v_matchproto_
(
vfp_init_f
)
vfp_decrypt_init
(
struct
vfp_ctx
*
ctx
,
struct
vfp_entry
*
ent
)
{
...
...
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