-
Notifications
You must be signed in to change notification settings - Fork 6
/
ecs_inits.c
44 lines (34 loc) · 826 Bytes
/
ecs_inits.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
* ecs_lib.c
*
* Created on: Nov 12, 2015
* Author: tslld
*/
#include "ecdsa.h"
#include "ec.h"
#include "ec_point.h"
#include "field_ops.h"
/** Allocates and initialize a ECDSA_SIG structure
* \return pointer to a ECDSA_SIG structure or NULL if an error occurred
*/
ecdsa_sig ecs_init() {
ecdsa_sig sig;
sig = malloc(sizeof(struct ecdsa_sig_st));
assert(sig != NULL);
mpz_init(sig->r);
mpz_init(sig->s);
return sig;
}
/** Initialize and set values for a ECDSA_SIG structure
* \param R big number
* \param S big number
* \return pointer to a ECDSA_SIG structure or NULL if an error occurred
*/
ecdsa_sig ecs_init_set(mpz_t R, mpz_t S) {
ecdsa_sig sig;
sig = malloc(sizeof(struct ecdsa_sig_st));
assert(sig != NULL);
mpz_init_set(sig->r, R);
mpz_init_set(sig->s, S);
return sig;
}