Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Nettle
nettle
Commits
8d5a38a5
Commit
8d5a38a5
authored
Mar 14, 2015
by
Niels Möller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New function memeql_sec.
parent
b175384e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
1 deletion
+20
-1
ChangeLog
ChangeLog
+6
-0
ccm.c
ccm.c
+14
-1
No files found.
ChangeLog
View file @
8d5a38a5
2015-03-14 Niels Möller <nisse@diamant.hack.org>
* ccm.c (memeql_sec): New function, more side-channel silent than
memcmp.
(ccm_decrypt_message): Use it.
2015-03-12 Niels Möller <nisse@diamant.hack.org>
2015-03-12 Niels Möller <nisse@diamant.hack.org>
* base64.h (struct base64_encode_ctx): Micro optimization of
* base64.h (struct base64_encode_ctx): Micro optimization of
...
...
ccm.c
View file @
8d5a38a5
...
@@ -246,6 +246,19 @@ ccm_encrypt_message(const void *cipher, nettle_cipher_func *f,
...
@@ -246,6 +246,19 @@ ccm_encrypt_message(const void *cipher, nettle_cipher_func *f,
ccm_digest
(
&
ctx
,
cipher
,
f
,
tlength
,
tag
);
ccm_digest
(
&
ctx
,
cipher
,
f
,
tlength
,
tag
);
}
}
/* FIXME: Should be made public, under some suitable name. */
static
int
memeql_sec
(
const
void
*
a
,
const
void
*
b
,
size_t
n
)
{
volatile
const
unsigned
char
*
ap
=
(
const
unsigned
char
*
)
a
;
volatile
const
unsigned
char
*
bp
=
(
const
unsigned
char
*
)
b
;
volatile
unsigned
char
d
;
size_t
i
;
for
(
d
=
i
=
0
;
i
<
n
;
i
++
)
d
|=
(
ap
[
i
]
^
bp
[
i
]);
return
d
==
0
;
}
int
int
ccm_decrypt_message
(
const
void
*
cipher
,
nettle_cipher_func
*
f
,
ccm_decrypt_message
(
const
void
*
cipher
,
nettle_cipher_func
*
f
,
size_t
nlength
,
const
uint8_t
*
nonce
,
size_t
nlength
,
const
uint8_t
*
nonce
,
...
@@ -258,5 +271,5 @@ ccm_decrypt_message(const void *cipher, nettle_cipher_func *f,
...
@@ -258,5 +271,5 @@ ccm_decrypt_message(const void *cipher, nettle_cipher_func *f,
ccm_update
(
&
ctx
,
cipher
,
f
,
alength
,
adata
);
ccm_update
(
&
ctx
,
cipher
,
f
,
alength
,
adata
);
ccm_decrypt
(
&
ctx
,
cipher
,
f
,
mlength
,
dst
,
src
);
ccm_decrypt
(
&
ctx
,
cipher
,
f
,
mlength
,
dst
,
src
);
ccm_digest
(
&
ctx
,
cipher
,
f
,
tlength
,
tag
);
ccm_digest
(
&
ctx
,
cipher
,
f
,
tlength
,
tag
);
return
(
mem
cmp
(
tag
,
src
+
mlength
,
tlength
)
==
0
)
;
return
mem
eql_sec
(
tag
,
src
+
mlength
,
tlength
);
}
}
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