69 #include "../fipsmodule/bn/internal.h"
77 static const char hextable[] =
"0123456789abcdef";
82 width * BN_BYTES * 2 + 1 );
98 for (
int i =
width - 1;
i >= 0;
i--) {
99 for (
int j = BN_BITS2 - 8; j >= 0; j -= 8) {
101 int v = ((
int)(bn->
d[
i] >> (
long)j)) & 0xff;
116 if (in_len > INT_MAX/4) {
128 int todo = BN_BYTES * 2;
135 for (j =
todo; j > 0; j--) {
136 char c =
in[in_len - j];
139 if (
c >=
'0' &&
c <=
'9') {
141 }
else if (
c >=
'a' &&
c <=
'f') {
143 }
else if (
c >=
'A' &&
c <=
'F') {
150 word = (word << 4) | hex;
156 assert(i <= bn->dmax);
167 j = BN_DEC_NUM - (in_len % BN_DEC_NUM);
168 if (j == BN_DEC_NUM) {
172 for (
i = 0;
i < in_len;
i++) {
175 if (++j == BN_DEC_NUM) {
195 if (
in == NULL || *
in == 0) {
204 for (
i = 0; want_char((
unsigned char)
in[
i]) &&
i + neg < INT_MAX;
i++) {}
268 if (word == (BN_ULONG)-1) {
273 for (
int i = 0;
i < BN_DEC_NUM && (add_leading_zeros || word != 0);
i++) {
295 for (
size_t i = 0;
i <
len/2;
i++) {
317 const char *
const orig_in =
in;
322 if (
in[0] ==
'0' && (
in[1] ==
'X' ||
in[1] ==
'x')) {
352 for (j = BN_BITS2 - 4; j >= 0; j -= 4) {
354 v = ((
int)(
a->d[
i] >> (
long)j)) & 0x0f;
394 (
len & 0xffffffff) !=
len) {
415 if (
in->neg &&
len > 0) {
426 const size_t in_len = ((size_t)
in[0] << 24) |
427 ((size_t)
in[1] << 16) |
428 ((size_t)
in[2] << 8) |
430 if (in_len !=
len - 4) {
435 int out_is_alloced = 0;
452 if (out_is_alloced) {
457 out->neg = ((*in) & 0x80) != 0;