Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
N
non-destructive text micropython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
badge fixer
non-destructive text micropython
Commits
32ba6799
Commit
32ba6799
authored
6 years ago
by
Yonatan Goldschmidt
Committed by
Damien George
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
extmod/moducryptolib: Add AES-CTR support for axTLS builds.
parent
ef984365
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
extmod/moducryptolib.c
+27
-0
27 additions, 0 deletions
extmod/moducryptolib.c
with
27 additions
and
0 deletions
extmod/moducryptolib.c
+
27
−
0
View file @
32ba6799
...
...
@@ -139,6 +139,33 @@ STATIC void aes_process_cbc_impl(AES_CTX_IMPL *ctx, const uint8_t *in, uint8_t *
AES_cbc_decrypt
(
ctx
,
in
,
out
,
in_len
);
}
}
#if MICROPY_PY_UCRYPTOLIB_CTR
// axTLS doesn't have CTR support out of the box. This implements the counter part using the ECB primitive.
STATIC
void
aes_process_ctr_impl
(
AES_CTX_IMPL
*
ctx
,
const
uint8_t
*
in
,
uint8_t
*
out
,
size_t
in_len
,
struct
ctr_params
*
ctr_params
)
{
size_t
n
=
ctr_params
->
offset
;
uint8_t
*
const
counter
=
ctx
->
iv
;
while
(
in_len
--
)
{
if
(
n
==
0
)
{
aes_process_ecb_impl
(
ctx
,
counter
,
ctr_params
->
encrypted_counter
,
true
);
// increment the 128-bit counter
for
(
int
i
=
15
;
i
>=
0
;
--
i
)
{
if
(
++
counter
[
i
]
!=
0
)
{
break
;
}
}
}
*
out
++
=
*
in
++
^
ctr_params
->
encrypted_counter
[
n
];
n
=
(
n
+
1
)
&
0xf
;
}
ctr_params
->
offset
=
n
;
}
#endif
#endif
#if MICROPY_SSL_MBEDTLS
...
...
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