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
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nettle
nettle
Commits
2ac6d737
Commit
2ac6d737
authored
Aug 6, 2014
by
Niels Möller
Browse files
Options
Downloads
Patches
Plain Diff
New functions mpn_set_base256_le and mpn_get_base256_le.
parent
b6c44563
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
ChangeLog
+5
-0
5 additions, 0 deletions
ChangeLog
gmp-glue.c
+62
-0
62 additions, 0 deletions
gmp-glue.c
gmp-glue.h
+11
-1
11 additions, 1 deletion
gmp-glue.h
with
78 additions
and
1 deletion
ChangeLog
+
5
−
0
View file @
2ac6d737
2014-08-06 Niels Möller <nisse@lysator.liu.se>
* gmp-glue.c (mpn_set_base256_le, mpn_get_base256_le): New functions.
* gmp-glue.h: Declare them.
2014-08-02 Niels Möller <nisse@lysator.liu.se>
* testsuite/curve25519-dh-test.c (curve25519_sqrt): Fixed memory
...
...
This diff is collapsed.
Click to expand it.
gmp-glue.c
+
62
−
0
View file @
2ac6d737
...
...
@@ -227,6 +227,68 @@ mpn_set_base256 (mp_limb_t *rp, mp_size_t rn,
}
}
void
mpn_set_base256_le
(
mp_limb_t
*
rp
,
mp_size_t
rn
,
const
uint8_t
*
xp
,
size_t
xn
)
{
size_t
xi
;
mp_limb_t
out
;
unsigned
bits
;
for
(
xi
=
0
,
out
=
bits
=
0
;
xi
<
xn
&&
rn
>
0
;
)
{
mp_limb_t
in
=
xp
[
xi
++
];
out
|=
(
in
<<
bits
)
&
GMP_NUMB_MASK
;
bits
+=
8
;
if
(
bits
>=
GMP_NUMB_BITS
)
{
*
rp
++
=
out
;
rn
--
;
bits
-=
GMP_NUMB_BITS
;
out
=
in
>>
(
8
-
bits
);
}
}
if
(
rn
>
0
)
{
*
rp
++
=
out
;
if
(
--
rn
>
0
)
mpn_zero
(
rp
,
rn
);
}
}
void
mpn_get_base256_le
(
uint8_t
*
rp
,
size_t
rn
,
const
mp_limb_t
*
xp
,
mp_size_t
xn
)
{
unsigned
bits
;
mp_limb_t
in
;
for
(
bits
=
in
=
0
;
xn
>
0
&&
rn
>
0
;
)
{
if
(
bits
>=
8
)
{
*
rp
++
=
in
;
rn
--
;
in
>>=
8
;
bits
-=
8
;
}
else
{
uint8_t
old
=
in
;
in
=
*
xp
++
;
xn
--
;
*
rp
++
=
old
|
(
in
<<
bits
);
in
>>=
(
8
-
bits
);
bits
+=
GMP_NUMB_BITS
-
8
;
}
}
while
(
rn
>
0
)
{
*
rp
++
=
in
;
rn
--
;
in
>>=
8
;
}
}
mp_limb_t
*
gmp_alloc_limbs
(
mp_size_t
n
)
{
...
...
This diff is collapsed.
Click to expand it.
gmp-glue.h
+
11
−
1
View file @
2ac6d737
...
...
@@ -71,6 +71,8 @@
#define mpz_limbs_copy _nettle_mpz_limbs_copy
#define mpz_set_n _nettle_mpz_set_n
#define mpn_set_base256 _nettle_mpn_set_base256
#define mpn_set_base256_le _nettle_mpn_set_base256_le
#define mpn_get_base256_le _nettle_mpn_get_base256_le
#define gmp_alloc_limbs _nettle_gmp_alloc_limbs
#define gmp_free_limbs _nettle_gmp_free_limbs
#define gmp_free _nettle_gmp_free
...
...
@@ -153,7 +155,7 @@ mpz_limbs_read_n (mpz_ptr x, mp_size_t n);
/* Copy limbs, with zero-padding. */
/* FIXME: Reorder arguments, on the theory that the first argument of
an _mpz_* fu
c
ntion should be an mpz_t? Or rename to _mpz_get_limbs,
an _mpz_* fun
c
tion should be an mpz_t? Or rename to _mpz_get_limbs,
with argument order consistent with mpz_get_*. */
void
mpz_limbs_copy
(
mp_limb_t
*
xp
,
mpz_srcptr
x
,
mp_size_t
n
);
...
...
@@ -167,6 +169,14 @@ void
mpn_set_base256
(
mp_limb_t
*
rp
,
mp_size_t
rn
,
const
uint8_t
*
xp
,
size_t
xn
);
void
mpn_set_base256_le
(
mp_limb_t
*
rp
,
mp_size_t
rn
,
const
uint8_t
*
xp
,
size_t
xn
);
void
mpn_get_base256_le
(
uint8_t
*
rp
,
size_t
rn
,
const
mp_limb_t
*
xp
,
mp_size_t
xn
);
mp_limb_t
*
gmp_alloc_limbs
(
mp_size_t
n
);
...
...
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