Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libdap
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
cellframe
libdap
Commits
4687ae68
Commit
4687ae68
authored
6 years ago
by
Ivan Deniskin
Browse files
Options
Downloads
Patches
Plain Diff
AES tail block bug fixed
parent
5cd397c1
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
crypto/dap_enc_aes.c
+7
-6
7 additions, 6 deletions
crypto/dap_enc_aes.c
with
7 additions
and
6 deletions
crypto/dap_enc_aes.c
+
7
−
6
View file @
4687ae68
...
@@ -9,8 +9,6 @@
...
@@ -9,8 +9,6 @@
#define AES_BLOCKSIZE 16
#define AES_BLOCKSIZE 16
#define AES_KEYSIZE 16
#define AES_KEYSIZE 16
uint8_t
tail_block
[]
=
{
21
,
27
,
20
,
36
,
16
,
20
,
27
,
31
,
22
,
41
,
27
,
33
,
30
,
21
,
32
,
28
};
#define DAP_ENC_AES_KEY(a) ((dap_enc_aes_key_t *)((a)->_inheritor) )
#define DAP_ENC_AES_KEY(a) ((dap_enc_aes_key_t *)((a)->_inheritor) )
static
void
print_bytes
(
uint8_t
*
bytes
,
size_t
num_bytes
)
{
static
void
print_bytes
(
uint8_t
*
bytes
,
size_t
num_bytes
)
{
...
@@ -133,8 +131,12 @@ size_t dap_enc_aes_decode(struct dap_enc_key* a_key, const void * a_in, size_t a
...
@@ -133,8 +131,12 @@ size_t dap_enc_aes_decode(struct dap_enc_key* a_key, const void * a_in, size_t a
OQS_AES128_ECB_dec
(
a_in
,
a_in_size
,
a_key
->
data
,
a_out
);
OQS_AES128_ECB_dec
(
a_in
,
a_in_size
,
a_key
->
data
,
a_out
);
int
tail
=
0
;
int
tail
=
0
;
for
(
size_t
i
=
a_in_size
-
1
;
i
>
a_in_size
-
15
;
i
--
)
for
(
size_t
i
=
a_in_size
-
1
;
i
>
a_in_size
-
15
;
i
--
)
if
(
*
(
char
*
)(
a_out
+
i
)
==
(
char
)
tail_block
[
i
%
16
])
{
tail
++
;
if
(
*
(
char
*
)(
a_out
+
i
)
==
(
char
)
0
)
tail
++
;
else
break
;
}
return
a_in_size
-
tail
;
return
a_in_size
-
tail
;
}
}
...
@@ -155,8 +157,7 @@ size_t dap_enc_aes_encode(struct dap_enc_key* a_key, const void * a_in, size_t a
...
@@ -155,8 +157,7 @@ size_t dap_enc_aes_encode(struct dap_enc_key* a_key, const void * a_in, size_t a
tail
=
16
-
a_in_size
%
16
;
tail
=
16
-
a_in_size
%
16
;
void
*
a_in_new
=
(
void
*
)
malloc
(
a_in_size
+
tail
);
void
*
a_in_new
=
(
void
*
)
malloc
(
a_in_size
+
tail
);
memcpy
(
a_in_new
,
a_in
,
a_in_size
);
memcpy
(
a_in_new
,
a_in
,
a_in_size
);
uint8_t
*
pointer
=
&
tail_block
;
memset
(
a_in_new
+
a_in_size
,
0
,
tail
);
memcpy
(
a_in_new
+
a_in_size
,
pointer
+
(
16
-
tail
),
tail
);
OQS_AES128_ECB_enc
(
a_in_new
,
a_in_size
+
tail
,
a_key
->
data
,
a_out
);
OQS_AES128_ECB_enc
(
a_in_new
,
a_in_size
+
tail
,
a_key
->
data
,
a_out
);
return
a_in_size
+
tail
;
return
a_in_size
+
tail
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment