Unverified Commit 39f621a5 authored by kladko's avatar kladko

SKALE-1880-add-return-parameter-to-function

parent 3226d366
...@@ -82,16 +82,19 @@ void point_set(point R, point P) ...@@ -82,16 +82,19 @@ void point_set(point R, point P)
} }
/*Set point from strings of a base from 2-62*/ /*Set point from strings of a base from 2-62*/
void point_set_str(point p, const char *x, const char *y, int base) int point_set_str(point p, const char *x, const char *y, int base)
{ {
mpz_set_str(p->x, x, base); if (mpz_set_str(p->x, x, base) != 0 || mpz_set_str(p->y, y, base) != 0) {
mpz_set_str(p->y, y, base); return 1;
}
return 0;
} }
/*Set point from hexadecimal strings*/ /*Set point from hexadecimal strings*/
void point_set_hex(point p, const char *x, const char *y) int point_set_hex(point p, const char *x, const char *y)
{ {
point_set_str(p,x,y,16); return point_set_str(p,x,y,16);
} }
/*Set point from decimal unsigned long ints*/ /*Set point from decimal unsigned long ints*/
......
...@@ -46,7 +46,7 @@ EXTERNC void point_inverse(point R, point P, domain_parameters curve); ...@@ -46,7 +46,7 @@ EXTERNC void point_inverse(point R, point P, domain_parameters curve);
EXTERNC void point_print(point p); EXTERNC void point_print(point p);
/*Set point from hexadecimal strings*/ /*Set point from hexadecimal strings*/
EXTERNC void point_set_hex(point p, const char *x, const char *y); EXTERNC int point_set_hex(point p, const char *x, const char *y);
/*Set point from decimal unsigned long ints*/ /*Set point from decimal unsigned long ints*/
EXTERNC void point_set_ui(point p, unsigned long int x, unsigned long int y); EXTERNC void point_set_ui(point p, unsigned long int x, unsigned long int y);
...@@ -61,7 +61,7 @@ EXTERNC void point_doubling(point R, point P, domain_parameters curve); ...@@ -61,7 +61,7 @@ EXTERNC void point_doubling(point R, point P, domain_parameters curve);
EXTERNC void point_multiplication(point R, mpz_t multiplier, point P, domain_parameters curve); EXTERNC void point_multiplication(point R, mpz_t multiplier, point P, domain_parameters curve);
/*Set point from strings of a base from 2-62*/ /*Set point from strings of a base from 2-62*/
EXTERNC void point_set_str(point p, const char *x, const char *y, int base); EXTERNC int point_set_str(point p, const char *x, const char *y, int base);
/*Compare two points return 1 if not the same, returns 0 if they are the same*/ /*Compare two points return 1 if not the same, returns 0 if they are the same*/
EXTERNC bool point_cmp(point P, point Q); EXTERNC bool point_cmp(point P, point Q);
......
...@@ -59,14 +59,16 @@ void signature_print(signature sig) { ...@@ -59,14 +59,16 @@ void signature_print(signature sig) {
} }
/*Set signature from strings of a base from 2-62*/ /*Set signature from strings of a base from 2-62*/
void signature_set_str(signature sig, const char *r, const char *s, int base) { int signature_set_str(signature sig, const char *r, const char *s, int base) {
mpz_set_str(sig->r, r, base); if ( mpz_set_str(sig->r, r, base) !=0 || mpz_set_str(sig->s, s, base) != 0) {
mpz_set_str(sig->s, s, base); return 1;
}
return 0;
} }
/*Set signature from hexadecimal strings*/ /*Set signature from hexadecimal strings*/
void signature_set_hex(signature sig, const char *r, const char *s) { int signature_set_hex(signature sig, const char *r, const char *s) {
signature_set_str(sig, r, s, 16); return signature_set_str(sig, r, s, 16);
} }
/*Set signature from decimal unsigned long ints*/ /*Set signature from decimal unsigned long ints*/
......
...@@ -44,10 +44,10 @@ typedef struct signature_s* signature; ...@@ -44,10 +44,10 @@ typedef struct signature_s* signature;
EXTERNC signature signature_init(); EXTERNC signature signature_init();
/*Set signature from strings of a base from 2-62*/ /*Set signature from strings of a base from 2-62*/
EXTERNC void signature_set_str(signature sig, const char *r, const char *s, int base); EXTERNC int signature_set_str(signature sig, const char *r, const char *s, int base);
/*Set signature from hexadecimal strings*/ /*Set signature from hexadecimal strings*/
EXTERNC void signature_set_hex(signature sig, const char *r, const char *s); EXTERNC int signature_set_hex(signature sig, const char *r, const char *s);
/*Set signature from decimal unsigned long ints*/ /*Set signature from decimal unsigned long ints*/
EXTERNC void signature_set_ui(signature sig, unsigned long int r, unsigned long int s); EXTERNC void signature_set_ui(signature sig, unsigned long int r, unsigned long int s);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment