algorithms.h
1.63 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
*
* algorithms.h
* algorithm prototypes.
*
*/
#include <PR/bbtypes.h>
#include "binary_field.h"
#include "poly_math.h"
#include "elliptic_math.h"
#ifndef ALGORITHMS_H
#define ALGORITHMS_H
typedef struct {
field_2n c;
field_2n d;
}bsl_signature;
typedef struct {
field_2n private_key;
point public_key;
}ec_keypair;
typedef struct {
curve par_curve;
point par_point;
field_2n point_order;
field_2n cofactor;
}ec_parameter;
void Init_233_bit_ECDSA(ec_parameter *base, int num_bits);
BSL_error poly_key_gen_primitive(ec_parameter *Base, ec_keypair *key, unsigned long *random_input);
BSL_error poly_ECDSA_signature(char *message, unsigned long length, ec_parameter *public_curve, field_2n *private_key, bsl_signature *signature, unsigned long *rand_input, u32 identity);
BSL_error poly_DSA_verify(char *message, unsigned long length, ec_parameter *public_curve, point *signer_point, bsl_signature *signature, BSL_boolean *result, u32 identity);
BSL_error generate_public_key(point *base_point, curve *E, field_2n *my_private, point *my_public);
BSL_error generate_shared_key(point *base_point, curve *E, point *recipient_public, field_2n *my_private, field_2n *shared_secret);
BSL_error eccGenAesKey(BbEccPublicKey publicKey, BbEccPrivateKey privateKey, BbAesKey sharedKey);
BSL_error
eccGenPublicKey(BbEccPublicKey publicKey, BbEccPrivateKey privateKey);
BSL_error
bsl_compute_ecc_sig(u8 *data, u32 datasize, BbEccPrivateKey private_key, u32 *random_data, BbEccSig sign, u32 identity);
void
bsl_verify_ecc_sig(u8 *data, u32 datasize, BbEccPublicKey public_key, BbEccSig sign, BSL_boolean *res, u32 identity);
#endif