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
a7770022
Commit
a7770022
authored
Aug 28, 2014
by
Niels Möller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ecc_ecdsa_verify: Use struct ecc_curve function pointers.
parent
79a4cff0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
6 deletions
+13
-6
ChangeLog
ChangeLog
+7
-0
ecc-ecdsa-verify.c
ecc-ecdsa-verify.c
+6
-6
No files found.
ChangeLog
View file @
a7770022
2014-08-28 Niels Möller <nisse@lysator.liu.se>
2014-08-28 Niels Möller <nisse@lysator.liu.se>
* ecc-ecdsa-verify.c (ecc_ecdsa_verify): Use the struct ecc_curve
function pointers: mul, mul_g, add_hhh, h_to_a.
* ecc-internal.h (ECC_ECDSA_VERIFY_ITCH): Deleted macro. Needed
* ecc-internal.h (ECC_ECDSA_VERIFY_ITCH): Deleted macro. Needed
scratch depends on curve type, not just size.
scratch depends on curve type, not just size.
(ecc_add_func): New typedef.
(struct ecc_curve): New function pointer add_hhh, and constant
add_hhh_itch. Updated all instances.
* ecdsa-verify.c (ecdsa_verify): Use the ecc_ecdsa_verify_itch
* ecdsa-verify.c (ecdsa_verify): Use the ecc_ecdsa_verify_itch
function, not the corresponding macro.
function, not the corresponding macro.
* ecc-ecdsa-verify.c (ecc_ecdsa_verify_itch): Take ecc->mul_itch
* ecc-ecdsa-verify.c (ecc_ecdsa_verify_itch): Take ecc->mul_itch
...
...
ecc-ecdsa-verify.c
View file @
a7770022
/* ecc-ecdsa-verify.c
/* ecc-ecdsa-verify.c
Copyright (C) 2013 Niels Möller
Copyright (C) 2013
, 2014
Niels Möller
This file is part of GNU Nettle.
This file is part of GNU Nettle.
...
@@ -113,7 +113,7 @@ ecc_ecdsa_verify (const struct ecc_curve *ecc,
...
@@ -113,7 +113,7 @@ ecc_ecdsa_verify (const struct ecc_curve *ecc,
ecc_modq_mul
(
ecc
,
u2
,
rp
,
sinv
);
ecc_modq_mul
(
ecc
,
u2
,
rp
,
sinv
);
/* Total storage: 5*ecc->size + ecc->mul_itch */
/* Total storage: 5*ecc->size + ecc->mul_itch */
ecc
_
mul
_a
(
ecc
,
P2
,
u2
,
pp
,
u2
+
ecc
->
size
);
ecc
->
mul
(
ecc
,
P2
,
u2
,
pp
,
u2
+
ecc
->
size
);
/* u1 = h / s, P1 = u1 * G */
/* u1 = h / s, P1 = u1 * G */
ecc_hash
(
ecc
,
hp
,
length
,
digest
);
ecc_hash
(
ecc
,
hp
,
length
,
digest
);
...
@@ -124,7 +124,7 @@ ecc_ecdsa_verify (const struct ecc_curve *ecc,
...
@@ -124,7 +124,7 @@ ecc_ecdsa_verify (const struct ecc_curve *ecc,
if
(
!
zero_p
(
u1
,
ecc
->
size
))
if
(
!
zero_p
(
u1
,
ecc
->
size
))
{
{
/* Total storage: 6*ecc->size + ecc->mul_g_itch (ecc->size) */
/* Total storage: 6*ecc->size + ecc->mul_g_itch (ecc->size) */
ecc
_
mul_g
(
ecc
,
P1
,
u1
,
u1
+
ecc
->
size
);
ecc
->
mul_g
(
ecc
,
P1
,
u1
,
u1
+
ecc
->
size
);
/* NOTE: ecc_add_jjj and/or ecc_j_to_a will produce garbage in
/* NOTE: ecc_add_jjj and/or ecc_j_to_a will produce garbage in
case u1 G = +/- u2 V. However, anyone who gets his or her
case u1 G = +/- u2 V. However, anyone who gets his or her
...
@@ -140,11 +140,11 @@ ecc_ecdsa_verify (const struct ecc_curve *ecc,
...
@@ -140,11 +140,11 @@ ecc_ecdsa_verify (const struct ecc_curve *ecc,
s_1 = z. Hitting that is about as unlikely as finding the
s_1 = z. Hitting that is about as unlikely as finding the
private key by guessing.
private key by guessing.
*/
*/
/* Total storage: 6*ecc->size +
ECC_ADD_JJJ_ITCH (ecc->size)
*/
/* Total storage: 6*ecc->size +
ecc->add_hhh_itch
*/
ecc
_
add_
jjj
(
ecc
,
P1
,
P1
,
P2
,
u1
);
ecc
->
add_
hhh
(
ecc
,
P1
,
P1
,
P2
,
u1
);
}
}
/* x coordinate only, modulo q */
/* x coordinate only, modulo q */
ecc
_j
_to_a
(
ecc
,
2
,
P2
,
P1
,
u1
);
ecc
->
h
_to_a
(
ecc
,
2
,
P2
,
P1
,
u1
);
return
(
mpn_cmp
(
rp
,
P2
,
ecc
->
size
)
==
0
);
return
(
mpn_cmp
(
rp
,
P2
,
ecc
->
size
)
==
0
);
#undef P2
#undef P2
...
...
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