Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
N
nettle
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Show more breadcrumbs
Wim Lewis
nettle
Commits
28b7678e
Commit
28b7678e
authored
10 years ago
by
Niels Möller
Browse files
Options
Downloads
Patches
Plain Diff
New function curve25519_base.
parent
2ac6d737
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
ChangeLog
+6
-0
6 additions, 0 deletions
ChangeLog
Makefile.in
+2
-1
2 additions, 1 deletion
Makefile.in
curve25519-base.c
+71
-0
71 additions, 0 deletions
curve25519-base.c
curve25519.h
+49
-0
49 additions, 0 deletions
curve25519.h
with
128 additions
and
1 deletion
ChangeLog
+
6
−
0
View file @
28b7678e
2014-08-06 Niels Möller <nisse@lysator.liu.se>
* curve25519-base.c (curve25519_base): New file, new function.
Analogous to NaCl's crypto_scalarmult_base.
* curve25519.h: New file.
* Makefile.in (hogweed_SOURCES): Added curve25519-base.c.
(HEADERS): Added curve25519.h.
* gmp-glue.c (mpn_set_base256_le, mpn_get_base256_le): New functions.
* gmp-glue.h: Declare them.
...
...
This diff is collapsed.
Click to expand it.
Makefile.in
+
2
−
1
View file @
28b7678e
...
...
@@ -174,12 +174,13 @@ hogweed_SOURCES = sexp.c sexp-format.c \
ecc-point.c ecc-scalar.c ecc-point-mul.c ecc-point-mul-g.c
\
ecc-ecdsa-sign.c ecdsa-sign.c
\
ecc-ecdsa-verify.c ecdsa-verify.c ecdsa-keygen.c
\
curve25519-base.c
\
$(
OPT_HOGWEED_SOURCES
)
HEADERS
=
aes.h arcfour.h arctwo.h asn1.h blowfish.h
\
base16.h base64.h buffer.h camellia.h cast128.h
\
cbc.h ccm.h chacha.h chacha-poly1305.h ctr.h
\
des.h des-compat.h dsa.h dsa-compat.h eax.h
\
curve25519.h
des.h des-compat.h dsa.h dsa-compat.h eax.h
\
ecc-curve.h ecc.h ecdsa.h
\
gcm.h gosthash94.h hmac.h
\
knuth-lfib.h
\
...
...
This diff is collapsed.
Click to expand it.
curve25519-base.c
0 → 100644
+
71
−
0
View file @
28b7678e
/* curve25519-base.c
Copyright (C) 2014 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
<string.h>
#include
"curve25519.h"
#include
"ecc.h"
#include
"ecc-internal.h"
/* Intended to be compatible with NaCl's crypto_scalarmult_base. */
void
curve25519_base
(
uint8_t
*
r
,
const
uint8_t
*
n
)
{
uint8_t
t
[
CURVE25519_SIZE
];
mp_limb_t
*
scratch
;
mp_size_t
ecc_size
;
mp_size_t
itch
;
#define p scratch
#define x (scratch + 3*ecc_size)
#define scratch_out (scratch + 4*ecc_size)
memcpy
(
t
,
n
,
sizeof
(
t
));
t
[
0
]
&=
~
7
;
t
[
CURVE25519_SIZE
-
1
]
=
(
t
[
CURVE25519_SIZE
-
1
]
&
0x3f
)
|
0x40
;
ecc_size
=
nettle_curve25519
.
size
;
itch
=
4
*
ecc_size
+
ECC_MUL_G_EH_ITCH
(
ecc_size
);
scratch
=
gmp_alloc_limbs
(
itch
);
mpn_set_base256_le
(
x
,
ecc_size
,
t
,
CURVE25519_SIZE
);
ecc_mul_g_eh
(
&
nettle_curve25519
,
p
,
x
,
scratch_out
);
ecc_eh_to_a
(
&
nettle_curve25519
,
2
,
x
,
p
,
scratch_out
);
mpn_get_base256_le
(
r
,
CURVE25519_SIZE
,
x
,
ecc_size
);
gmp_free_limbs
(
scratch
,
itch
);
}
This diff is collapsed.
Click to expand it.
curve25519.h
0 → 100644
+
49
−
0
View file @
28b7678e
/* curve25519.h
Copyright (C) 2014 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_CURVE25519_H
#define NETTLE_CURVE25519_H
#include
"nettle-types.h"
#ifdef __cplusplus
extern
"C"
{
#endif
/* Name mangling */
#define curve25519_base nettle_curve25519_base
#define CURVE25519_SIZE 32
void
curve25519_base
(
uint8_t
*
q
,
const
uint8_t
*
n
);
#endif
/* NETTLE_CURVE25519_H */
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