-
Notifications
You must be signed in to change notification settings - Fork 203
Removed bn_conversion.c in favor of individual files #311
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#include "tommath_private.h" | ||
#ifdef BN_MP_GET_I32_C | ||
/* LibTomMath, multiple-precision integer library -- Tom St Denis */ | ||
/* SPDX-License-Identifier: Unlicense */ | ||
|
||
|
||
/* Return the least significant 32 bits */ | ||
int32_t mp_get_i32(const mp_int *a) | ||
{ | ||
uint64_t res = mp_get_mag32(a); | ||
return (a->sign == MP_NEG) ? (int32_t)-res : (int32_t)res; | ||
nijtmans marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
|
||
#endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#include "tommath_private.h" | ||
#ifdef BN_MP_GET_I64_C | ||
/* LibTomMath, multiple-precision integer library -- Tom St Denis */ | ||
/* SPDX-License-Identifier: Unlicense */ | ||
|
||
|
||
/* Return the least significant 64 bits */ | ||
int64_t mp_get_i64(const mp_int *a) | ||
{ | ||
uint64_t res = mp_get_mag64(a); | ||
return (a->sign == MP_NEG) ? (int64_t)-res : (int64_t)res; | ||
nijtmans marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
|
||
#endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include "tommath_private.h" | ||
#ifdef BN_MP_GET_MAG32_C | ||
/* LibTomMath, multiple-precision integer library -- Tom St Denis */ | ||
/* SPDX-License-Identifier: Unlicense */ | ||
|
||
|
||
/* Return the absolute value of the least significant 32 bits */ | ||
uint32_t mp_get_mag32(const mp_int *a) | ||
{ | ||
unsigned i = MP_MIN((unsigned)a->used, (unsigned)((32 + MP_DIGIT_BIT - 1) / MP_DIGIT_BIT)); | ||
uint32_t res = 0uL; | ||
while (i-- > 0) { | ||
res <<= ((32 <= MP_DIGIT_BIT) ? 0 : MP_DIGIT_BIT); | ||
res |= (uint32_t)a->dp[i]; | ||
if (32 <= MP_DIGIT_BIT) { | ||
break; | ||
} | ||
} | ||
return res; | ||
} | ||
#endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include "tommath_private.h" | ||
#ifdef BN_MP_GET_MAG64_C | ||
/* LibTomMath, multiple-precision integer library -- Tom St Denis */ | ||
/* SPDX-License-Identifier: Unlicense */ | ||
|
||
|
||
/* Return the absolute value of the least significant 64 bits */ | ||
uint64_t mp_get_mag64(const mp_int *a) | ||
{ | ||
unsigned i = MP_MIN((unsigned)a->used, (unsigned)((64 + MP_DIGIT_BIT - 1) / MP_DIGIT_BIT)); | ||
uint64_t res = 0uL; | ||
while (i-- > 0) { | ||
res <<= ((64 <= MP_DIGIT_BIT) ? 0 : MP_DIGIT_BIT); | ||
res |= (uint64_t)a->dp[i]; | ||
if (64 <= MP_DIGIT_BIT) { | ||
break; | ||
} | ||
} | ||
return res; | ||
} | ||
|
||
|
||
#endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include "tommath_private.h" | ||
#ifdef BN_MP_INIT_I32_C | ||
/* LibTomMath, multiple-precision integer library -- Tom St Denis */ | ||
/* SPDX-License-Identifier: Unlicense */ | ||
|
||
|
||
/* initialize "a" with a signed 32-bit integer */ | ||
mp_err mp_init_i32(mp_int *a, int32_t b) | ||
{ | ||
mp_err err; | ||
if ((err = mp_init(a)) != 0) { | ||
return err; | ||
} | ||
mp_set_i32(a, b); | ||
return 0; | ||
} | ||
|
||
|
||
#endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include "tommath_private.h" | ||
#ifdef BN_MP_INIT_I64_C | ||
/* LibTomMath, multiple-precision integer library -- Tom St Denis */ | ||
/* SPDX-License-Identifier: Unlicense */ | ||
|
||
|
||
/* initialize "a" with a signed 64-bit integer */ | ||
mp_err mp_init_i64(mp_int *a, int64_t b) | ||
{ | ||
mp_err err; | ||
if ((err = mp_init(a)) != 0) { | ||
return err; | ||
} | ||
mp_set_i64(a, b); | ||
return 0; | ||
} | ||
|
||
|
||
#endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include "tommath_private.h" | ||
#ifdef BN_MP_INIT_U32_C | ||
/* LibTomMath, multiple-precision integer library -- Tom St Denis */ | ||
/* SPDX-License-Identifier: Unlicense */ | ||
|
||
|
||
/* initialize "a" with an unsigned 32-bit integer */ | ||
mp_err mp_init_u32(mp_int *a, uint32_t b) | ||
{ | ||
mp_err err; | ||
if ((err = mp_init(a)) != 0) { | ||
return err; | ||
} | ||
mp_set_u32(a, b); | ||
return 0; | ||
} | ||
|
||
|
||
|
||
#endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include "tommath_private.h" | ||
#ifdef BN_MP_INIT_U64_C | ||
/* LibTomMath, multiple-precision integer library -- Tom St Denis */ | ||
/* SPDX-License-Identifier: Unlicense */ | ||
|
||
|
||
/* initialize "a" with an unsigned 64-bit integer */ | ||
mp_err mp_init_u64(mp_int *a, uint64_t b) | ||
{ | ||
mp_err err; | ||
if ((err = mp_init(a)) != 0) { | ||
return err; | ||
} | ||
mp_set_u64(a, b); | ||
return 0; | ||
} | ||
|
||
|
||
|
||
#endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#include "tommath_private.h" | ||
#ifdef BN_MP_SET_I32_C | ||
/* LibTomMath, multiple-precision integer library -- Tom St Denis */ | ||
/* SPDX-License-Identifier: Unlicense */ | ||
|
||
|
||
/* Set the least signficant 32 bit of "a" to b, signed */ | ||
void mp_set_i32(mp_int *a, int32_t b) | ||
{ | ||
mp_set_u32(a, (b < 0) ? -(uint32_t)b : (uint32_t)b); | ||
nijtmans marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (b < 0) { | ||
a->sign = MP_NEG; | ||
} | ||
} | ||
#endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include "tommath_private.h" | ||
#ifdef BN_MP_SET_I64_C | ||
/* LibTomMath, multiple-precision integer library -- Tom St Denis */ | ||
/* SPDX-License-Identifier: Unlicense */ | ||
|
||
|
||
/* Set the least signficant 64 bit of "a" to b, signed */ | ||
void mp_set_i64(mp_int *a, int64_t b) | ||
{ | ||
mp_set_u64(a, (b < 0) ? -(uint64_t)b : (uint64_t)b); | ||
nijtmans marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (b < 0) { | ||
a->sign = MP_NEG; | ||
} | ||
} | ||
|
||
|
||
#endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#include "tommath_private.h" | ||
#ifdef BN_MP_SET_U32_C | ||
/* LibTomMath, multiple-precision integer library -- Tom St Denis */ | ||
/* SPDX-License-Identifier: Unlicense */ | ||
|
||
|
||
/* Set the least signficant 32 bit of "a" to b, unsigned */ | ||
void mp_set_u32(mp_int *a, uint32_t b) | ||
{ | ||
int i = 0; | ||
while (b != 0u) { | ||
a->dp[i++] = ((mp_digit)b & MP_MASK); | ||
if (32 <= MP_DIGIT_BIT) { | ||
break; | ||
} | ||
b >>= ((32 <= MP_DIGIT_BIT) ? 0 : MP_DIGIT_BIT); | ||
} | ||
a->used = i; | ||
a->sign = MP_ZPOS; | ||
MP_ZERO_DIGITS(a->dp + a->used, a->alloc - a->used); | ||
} | ||
#endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include "tommath_private.h" | ||
#ifdef BN_MP_SET_U64_C | ||
/* LibTomMath, multiple-precision integer library -- Tom St Denis */ | ||
/* SPDX-License-Identifier: Unlicense */ | ||
|
||
|
||
/* Set the least signficant 64 bit of "a" to b, unsigned */ | ||
void mp_set_u64(mp_int *a, uint64_t b) | ||
{ | ||
int i = 0; | ||
while (b != 0u) { | ||
a->dp[i++] = ((mp_digit)b & MP_MASK); | ||
if (64 <= MP_DIGIT_BIT) { | ||
break; | ||
} | ||
b >>= ((64 <= MP_DIGIT_BIT) ? 0 : MP_DIGIT_BIT); | ||
} | ||
a->used = i; | ||
a->sign = MP_ZPOS; | ||
MP_ZERO_DIGITS(a->dp + a->used, a->alloc - a->used); | ||
} | ||
|
||
|
||
#endif |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.