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
c71d2c9d
Commit
c71d2c9d
authored
Dec 10, 2015
by
Niels Möller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed miscomputation bugs in secp-256r1 modulo functions.
parent
549f95f8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
4 deletions
+24
-4
ChangeLog
ChangeLog
+6
-0
ecc-256.c
ecc-256.c
+18
-4
No files found.
ChangeLog
View file @
c71d2c9d
2015-12-10 Niels Möller <nisse@lysator.liu.se>
* ecc-256.c (ecc_256_modp): Fixed carry propagation bug. Problem
reported by Hanno Böck.
(ecc_256_modq): Fixed another carry propagation bug.
2015-11-23 Niels Möller <nisse@lysator.liu.se>
* nettle.texinfo: Document rsa_encrypt, rsa_decrypt and
...
...
ecc-256.c
View file @
c71d2c9d
...
...
@@ -113,8 +113,19 @@ ecc_256_modp (const struct ecc_modulo *p, mp_limb_t *rp)
assert
(
q2
<
2
);
/* We multiply by two low limbs of p, 2^96 - 1, so we could use
shifts rather than mul. */
/*
n-1 n-2 n-3 n-4
+---+---+---+---+
| u1| u0| u low |
+---+---+---+---+
- | q1(2^96-1)|
+-------+---+
|q2(2^.)|
+-------+
We multiply by two low limbs of p, 2^96 - 1, so we could use
shifts rather than mul.
*/
t
=
mpn_submul_1
(
rp
+
n
-
4
,
p
->
m
,
2
,
q1
);
t
+=
cnd_sub_n
(
q2
,
rp
+
n
-
3
,
p
->
m
,
1
);
t
+=
(
-
q2
)
&
0xffffffff
;
...
...
@@ -124,7 +135,10 @@ ecc_256_modp (const struct ecc_modulo *p, mp_limb_t *rp)
u0
-=
t
;
t
=
(
u1
<
cy
);
u1
-=
cy
;
u1
+=
cnd_add_n
(
t
,
rp
+
n
-
4
,
p
->
m
,
3
);
cy
=
cnd_add_n
(
t
,
rp
+
n
-
4
,
p
->
m
,
2
);
u0
+=
cy
;
u1
+=
(
u0
<
cy
);
u1
-=
(
-
t
)
&
0xffffffff
;
}
rp
[
2
]
=
u0
;
...
...
@@ -211,7 +225,7 @@ ecc_256_modq (const struct ecc_modulo *q, mp_limb_t *rp)
/* Conditional add of p */
u1
+=
t
;
u2
+=
(
t
<<
32
)
+
(
u
0
<
t
);
u2
+=
(
t
<<
32
)
+
(
u
1
<
t
);
t
=
cnd_add_n
(
t
,
rp
+
n
-
4
,
q
->
m
,
2
);
u1
+=
t
;
...
...
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