Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nettle
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
5
Merge Requests
5
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Nettle
nettle
Commits
1a0a8dce
Commit
1a0a8dce
authored
Sep 03, 2016
by
Niels Möller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New public function memeql_sec, declared in memops.h.
parent
d15a9b5c
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
115 additions
and
17 deletions
+115
-17
ChangeLog
ChangeLog
+8
-0
Makefile.in
Makefile.in
+2
-2
ccm.c
ccm.c
+1
-14
examples/rsa-decrypt.c
examples/rsa-decrypt.c
+2
-1
memeql-sec.c
memeql-sec.c
+51
-0
memops.h
memops.h
+51
-0
No files found.
ChangeLog
View file @
1a0a8dce
...
...
@@ -43,6 +43,14 @@
* tools/nettle-pbkdf2.c (main): Fix some pointer signedness warning.
* tools/nettle-hash.c (hash_file): Likewise.
* examples/rsa-decrypt.c (process_file): Use memeql_sec to check
the digest.
* memeql-sec.c (memeql_sec): New public function, moved from...
* ccm.c (memeql_sec): ... previous location.
* memops.h: New header file, generalizing memxor.h.
2016-08-29 Niels Möller <nisse@lysator.liu.se>
* sexp-format.c (strlen_u8): New helper function.
...
...
Makefile.in
View file @
1a0a8dce
...
...
@@ -109,7 +109,7 @@ nettle_SOURCES = aes-decrypt-internal.c aes-decrypt.c \
knuth-lfib.c
\
md2.c md2-meta.c md4.c md4-meta.c
\
md5.c md5-compress.c md5-compat.c md5-meta.c
\
memxor.c memxor3.c
\
mem
eql-sec.c mem
xor.c memxor3.c
\
nettle-meta-aeads.c nettle-meta-armors.c
\
nettle-meta-ciphers.c nettle-meta-hashes.c
\
pbkdf2.c pbkdf2-hmac-sha1.c pbkdf2-hmac-sha256.c
\
...
...
@@ -193,7 +193,7 @@ HEADERS = aes.h arcfour.h arctwo.h asn1.h blowfish.h \
macros.h
\
md2.h md4.h
\
md5.h md5-compat.h
\
memxor.h
\
mem
ops.h mem
xor.h
\
nettle-meta.h nettle-types.h
\
pbkdf2.h
\
pgp.h pkcs1.h realloc.h ripemd160.h rsa.h
\
...
...
ccm.c
View file @
1a0a8dce
...
...
@@ -44,7 +44,7 @@
#include "ccm.h"
#include "ctr.h"
#include "mem
xor
.h"
#include "mem
ops
.h"
#include "nettle-internal.h"
#include "macros.h"
...
...
@@ -246,19 +246,6 @@ ccm_encrypt_message(const void *cipher, nettle_cipher_func *f,
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
ccm_decrypt_message
(
const
void
*
cipher
,
nettle_cipher_func
*
f
,
size_t
nlength
,
const
uint8_t
*
nonce
,
...
...
examples/rsa-decrypt.c
View file @
1a0a8dce
...
...
@@ -49,6 +49,7 @@
#include "cbc.h"
#include "hmac.h"
#include "macros.h"
#include "memops.h"
#include "rsa.h"
#include "yarrow.h"
...
...
@@ -189,7 +190,7 @@ process_file(struct rsa_session *ctx,
}
}
hmac_sha1_digest
(
&
ctx
->
hmac
,
SHA1_DIGEST_SIZE
,
digest
);
if
(
memcmp
(
digest
,
buffer
+
AES_BLOCK_SIZE
,
SHA1_DIGEST_SIZE
)
!=
0
)
if
(
!
memeql_sec
(
digest
,
buffer
+
AES_BLOCK_SIZE
,
SHA1_DIGEST_SIZE
)
)
{
werror
(
"Decryption failed: Invalid mac.
\n
"
);
return
0
;
...
...
memeql-sec.c
0 → 100644
View file @
1a0a8dce
/* memeql-sec.c
Copyright (C) 2016 Niels Möller
This file is part of GNU Nettle.
GNU Nettle is free software: you can redistribute it and/or
modify it under the terms of either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* the GNU General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your
option) any later version.
or both in parallel, as here.
GNU Nettle is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received copies of the GNU General Public License and
the GNU Lesser General Public License along with this program. If
not, see http://www.gnu.org/licenses/.
*/
#if HAVE_CONFIG_H
# include "config.h"
#endif
#include "memops.h"
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
diff
;
size_t
i
;
for
(
i
=
diff
=
0
;
i
<
n
;
i
++
)
diff
|=
(
ap
[
i
]
^
bp
[
i
]);
return
diff
==
0
;
}
memops.h
0 → 100644
View file @
1a0a8dce
/* memops.h
Copyright (C) 2016 Niels Möller
This file is part of GNU Nettle.
GNU Nettle is free software: you can redistribute it and/or
modify it under the terms of either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* the GNU General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your
option) any later version.
or both in parallel, as here.
GNU Nettle is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received copies of the GNU General Public License and
the GNU Lesser General Public License along with this program. If
not, see http://www.gnu.org/licenses/.
*/
#ifndef NETTLE_MEMOPS_H_INCLUDED
#define NETTLE_MEMOPS_H_INCLUDED
#include "memxor.h"
#ifdef __cplusplus
extern
"C"
{
#endif
/* Name mangling */
#define memeql_sec nettle_memeql_sec
int
memeql_sec
(
const
void
*
a
,
const
void
*
b
,
size_t
n
);
#ifdef __cplusplus
}
#endif
#endif
/* NETTLE_MEMOPS_H_INCLUDED */
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