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
308c1089
Commit
308c1089
authored
Aug 23, 2014
by
Niels Möller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Deleted unused INITIAL argument for ecc_mul_a.
parent
b9f98cb7
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
23 additions
and
31 deletions
+23
-31
ChangeLog
ChangeLog
+7
-0
ecc-ecdsa-verify.c
ecc-ecdsa-verify.c
+1
-1
ecc-mul-a.c
ecc-mul-a.c
+6
-6
ecc-point-mul.c
ecc-point-mul.c
+1
-1
ecc.h
ecc.h
+3
-5
examples/ecc-benchmark.c
examples/ecc-benchmark.c
+1
-1
testsuite/ecc-mul-a-test.c
testsuite/ecc-mul-a-test.c
+4
-17
No files found.
ChangeLog
View file @
308c1089
2014-08-23 Niels Möller <nisse@lysator.liu.se>
* ecc-mul-a.c (ecc_mul_a): Deleted INITIAL argument, all callers,
except the tests, pass 1. Updated all callers.
(table_init): Likewise deleted INITIAL.
* ecc.h (ecc_mul_a): Updated prototype.
* testsuite/ecc-mul-a-test.c (test_main): Deleted tests for
ecc_mul_a with INITIAL == 0.
* ecc-internal.h (struct ecc_curve): Reordered struct, moved
function pointers before pointers to bignum constants.
...
...
ecc-ecdsa-verify.c
View file @
308c1089
...
...
@@ -114,7 +114,7 @@ ecc_ecdsa_verify (const struct ecc_curve *ecc,
ecc_modq_mul
(
ecc
,
u2
,
rp
,
sinv
);
/* Total storage: 5*ecc->size + ECC_MUL_A_ITCH (ecc->size) */
ecc_mul_a
(
ecc
,
1
,
P2
,
u2
,
pp
,
u2
+
ecc
->
size
);
ecc_mul_a
(
ecc
,
P2
,
u2
,
pp
,
u2
+
ecc
->
size
);
/* u1 = h / s, P1 = u1 * G */
ecc_hash
(
ecc
,
hp
,
length
,
digest
);
...
...
ecc-mul-a.c
View file @
308c1089
...
...
@@ -55,7 +55,7 @@ ecc_mul_a_itch (const struct ecc_curve *ecc)
#if ECC_MUL_A_WBITS == 0
void
ecc_mul_a
(
const
struct
ecc_curve
*
ecc
,
int
initial
,
mp_limb_t
*
r
,
mp_limb_t
*
r
,
const
mp_limb_t
*
np
,
const
mp_limb_t
*
p
,
mp_limb_t
*
scratch
)
{
...
...
@@ -67,7 +67,7 @@ ecc_mul_a (const struct ecc_curve *ecc,
unsigned
i
;
ecc_a_to_j
(
ecc
,
initial
,
pj
,
p
);
ecc_a_to_j
(
ecc
,
1
,
pj
,
p
);
mpn_zero
(
r
,
3
*
ecc
->
size
);
for
(
i
=
ecc
->
size
,
is_zero
=
1
;
i
--
>
0
;
)
...
...
@@ -104,14 +104,14 @@ ecc_mul_a (const struct ecc_curve *ecc,
static
void
table_init
(
const
struct
ecc_curve
*
ecc
,
mp_limb_t
*
table
,
unsigned
bits
,
int
initial
,
const
mp_limb_t
*
p
,
const
mp_limb_t
*
p
,
mp_limb_t
*
scratch
)
{
unsigned
size
=
1
<<
bits
;
unsigned
j
;
mpn_zero
(
TABLE
(
0
),
3
*
ecc
->
size
);
ecc_a_to_j
(
ecc
,
initial
,
TABLE
(
1
),
p
);
ecc_a_to_j
(
ecc
,
1
,
TABLE
(
1
),
p
);
for
(
j
=
2
;
j
<
size
;
j
+=
2
)
{
...
...
@@ -122,7 +122,7 @@ table_init (const struct ecc_curve *ecc,
void
ecc_mul_a
(
const
struct
ecc_curve
*
ecc
,
int
initial
,
mp_limb_t
*
r
,
mp_limb_t
*
r
,
const
mp_limb_t
*
np
,
const
mp_limb_t
*
p
,
mp_limb_t
*
scratch
)
{
...
...
@@ -140,7 +140,7 @@ ecc_mul_a (const struct ecc_curve *ecc,
unsigned
shift
=
bit_index
%
GMP_NUMB_BITS
;
mp_limb_t
w
,
bits
;
table_init
(
ecc
,
table
,
ECC_MUL_A_WBITS
,
initial
,
p
,
scratch_out
);
table_init
(
ecc
,
table
,
ECC_MUL_A_WBITS
,
p
,
scratch_out
);
w
=
np
[
limb_index
];
bits
=
w
>>
shift
;
...
...
ecc-point-mul.c
View file @
308c1089
...
...
@@ -51,7 +51,7 @@ ecc_point_mul (struct ecc_point *r, const struct ecc_scalar *n,
assert
(
n
->
ecc
==
p
->
ecc
);
assert
(
r
->
ecc
==
p
->
ecc
);
ecc_mul_a
(
p
->
ecc
,
1
,
scratch
,
n
->
p
,
p
->
p
,
scratch
+
3
*
size
);
ecc_mul_a
(
p
->
ecc
,
scratch
,
n
->
p
,
p
->
p
,
scratch
+
3
*
size
);
ecc_j_to_a
(
r
->
ecc
,
1
,
r
->
p
,
scratch
,
scratch
+
3
*
size
);
gmp_free_limbs
(
scratch
,
itch
);
}
ecc.h
View file @
308c1089
...
...
@@ -285,15 +285,13 @@ ecc_mul_g (const struct ecc_curve *ecc, mp_limb_t *r,
const
mp_limb_t
*
np
,
mp_limb_t
*
scratch
);
/* Computes N * P. The scalar N is the same as for ecc_mul_g. P is a
non-zero point on the curve, in affine coordinates. Pass a non-zero
INITIAL if the point coordinates have not previously been converted
to Montgomery representation. Output R is a non-zero point, in
Jacobian coordinates. */
non-zero point on the curve, in affine coordinates. Output R is a
non-zero point, in Jacobian coordinates. */
mp_size_t
ecc_mul_a_itch
(
const
struct
ecc_curve
*
ecc
);
void
ecc_mul_a
(
const
struct
ecc_curve
*
ecc
,
int
initial
,
mp_limb_t
*
r
,
mp_limb_t
*
r
,
const
mp_limb_t
*
np
,
const
mp_limb_t
*
p
,
mp_limb_t
*
scratch
);
...
...
examples/ecc-benchmark.c
View file @
308c1089
...
...
@@ -234,7 +234,7 @@ static void
bench_mul_a
(
void
*
p
)
{
struct
ecc_ctx
*
ctx
=
(
struct
ecc_ctx
*
)
p
;
ecc_mul_a
(
ctx
->
ecc
,
1
,
ctx
->
rp
,
ctx
->
ap
,
ctx
->
bp
,
ctx
->
tp
);
ecc_mul_a
(
ctx
->
ecc
,
ctx
->
rp
,
ctx
->
ap
,
ctx
->
bp
,
ctx
->
tp
);
}
static
void
...
...
testsuite/ecc-mul-a-test.c
View file @
308c1089
...
...
@@ -31,34 +31,21 @@ test_main (void)
mpn_zero
(
n
,
size
);
n
[
0
]
=
1
;
ecc_mul_a
(
ecc
,
1
,
p
,
n
,
ecc
->
g
,
scratch
);
ecc_mul_a
(
ecc
,
p
,
n
,
ecc
->
g
,
scratch
);
ecc_j_to_a
(
ecc
,
1
,
p
,
p
,
scratch
);
if
(
mpn_cmp
(
p
,
ecc
->
g
,
2
*
size
!=
0
))
die
(
"curve %d: ecc_mul_a with n = 1 failed.
\n
"
,
ecc
->
bit_size
);
if
(
ecc
->
use_redc
)
{
ecc_mul_a
(
ecc
,
0
,
p
,
n
,
ecc
->
redc_g
,
scratch
);
ecc_j_to_a
(
ecc
,
1
,
p
,
p
,
scratch
);
if
(
mpn_cmp
(
p
,
ecc
->
g
,
2
*
size
!=
0
))
die
(
"curve %d: ecc_mul_a with n = 1 and redc failed.
\n
"
,
ecc
->
bit_size
);
}
for
(
n
[
0
]
=
2
;
n
[
0
]
<=
4
;
n
[
0
]
++
)
{
ecc_mul_a
(
ecc
,
1
,
p
,
n
,
ecc
->
g
,
scratch
);
ecc_mul_a
(
ecc
,
p
,
n
,
ecc
->
g
,
scratch
);
test_ecc_mul_j
(
i
,
n
[
0
],
p
);
if
(
ecc
->
use_redc
)
{
ecc_mul_a
(
ecc
,
0
,
p
,
n
,
ecc
->
redc_g
,
scratch
);
test_ecc_mul_j
(
i
,
n
[
0
],
p
);
}
}
/* (order - 1) * g = - g */
mpn_sub_1
(
n
,
ecc
->
q
,
size
,
1
);
ecc_mul_a
(
ecc
,
1
,
p
,
n
,
ecc
->
g
,
scratch
);
ecc_mul_a
(
ecc
,
p
,
n
,
ecc
->
g
,
scratch
);
ecc_j_to_a
(
ecc
,
1
,
p
,
p
,
scratch
);
mpn_sub_n
(
p
+
size
,
ecc
->
p
,
p
+
size
,
size
);
if
(
mpn_cmp
(
p
,
ecc
->
g
,
2
*
size
)
!=
0
)
...
...
@@ -80,7 +67,7 @@ test_main (void)
mpz_limbs_copy
(
n
,
r
,
size
);
n
[
size
-
1
]
%=
ecc
->
q
[
size
-
1
];
ecc_mul_a
(
ecc
,
1
,
p
,
n
,
ecc
->
g
,
scratch
);
ecc_mul_a
(
ecc
,
p
,
n
,
ecc
->
g
,
scratch
);
ecc_j_to_a
(
ecc
,
1
,
p
,
p
,
scratch
);
ecc_mul_g
(
ecc
,
q
,
n
,
scratch
);
...
...
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