#include <stddef.h>
#include <stdint.h>
Go to the source code of this file.
|
struct | bytes |
| Structure that's stores a pointer that points to data_len bytes. More...
|
|
|
bytes_t * | tc_init_bytes (void *bs, size_t len) |
|
bytes_t * | tc_init_bytes_copy (void *bs, size_t len) |
|
key_share_t ** | tc_generate_keys (key_metainfo_t **metainfo, size_t bit_size, uint16_t k, uint16_t l, bytes_t *e) |
|
signature_share_t * | tc_node_sign (const key_share_t *share, const bytes_t *doc, const key_metainfo_t *info) |
|
bytes_t * | tc_join_signatures (const signature_share_t **signatures, const bytes_t *document, const key_metainfo_t *info) |
|
int | tc_verify_signature (const signature_share_t *signature, const bytes_t *doc, const key_metainfo_t *info) |
|
bytes_t * | tc_prepare_document (const bytes_t *doc, tc_hash_type_t hash_type, const key_metainfo_t *metainfo) |
|
int | tc_rsa_verify (bytes_t *signature, bytes_t *doc, key_metainfo_t *info, tc_hash_type_t hashtype) |
|
int | tc_key_meta_info_k (const key_metainfo_t *i) |
|
int | tc_key_meta_info_l (const key_metainfo_t *i) |
|
const public_key_t * | tc_key_meta_info_public_key (const key_metainfo_t *i) |
|
int | tc_key_share_id (const key_share_t *k) |
|
const bytes_t * | tc_public_key_n (const public_key_t *pk) |
|
const bytes_t * | tc_public_key_e (const public_key_t *pk) |
|
int | tc_signature_share_id (const signature_share_t *s) |
|
char * | tc_bytes_b64 (const bytes_t *b) |
|
bytes_t * | tc_b64_bytes (const char *s) |
|
char * | tc_serialize_key_share (const key_share_t *ks) |
|
char * | tc_serialize_signature_share (const signature_share_t *ss) |
|
char * | tc_serialize_key_metainfo (const key_metainfo_t *kmi) |
|
key_share_t * | tc_deserialize_key_share (const char *b64) |
|
signature_share_t * | tc_deserialize_signature_share (const char *b64) |
|
key_metainfo_t * | tc_deserialize_key_metainfo (const char *b64) |
|
void | tc_clear_bytes (bytes_t *bytes) |
|
void * | tc_release_bytes (bytes_t *bytes, uint32_t *len) |
|
void | tc_clear_bytes_n (bytes_t *bytes,...) |
|
void | tc_clear_key_metainfo (key_metainfo_t *info) |
|
void | tc_clear_signature_share (signature_share_t *ss) |
|
void | tc_clear_key_share (key_share_t *share) |
|
void | tc_clear_key_shares (key_share_t **shares, key_metainfo_t *info) |
|
Definition at line 18 of file tc.h.
Definition at line 30 of file tc.h.
Definition at line 36 of file tc.h.
Definition at line 24 of file tc.h.
Definition at line 42 of file tc.h.
Definition at line 51 of file tc.h.
Hash functions to be used when preparing a document to be signed.
Enumerator |
---|
TC_SHA256 |
|
TC_NONE |
|
Definition at line 47 of file tc.h.
bytes_t* tc_b64_bytes |
( |
const char * |
s | ) |
|
- Parameters
-
[in] | s | a C string in the Base64 format. |
- Returns
- a bytes_t structure with the binary data in s.
Definition at line 144 of file algorithms_base64.c.
char* tc_bytes_b64 |
( |
const bytes_t * |
b | ) |
|
- Parameters
-
[in] | b | a bytes_t structure. |
- Returns
- a C string with the data of bytes serialized in the Base64 format.
Definition at line 140 of file algorithms_base64.c.
void tc_clear_bytes |
( |
bytes_t * |
bytes | ) |
|
Clears the memory stored in bytes and its structure.
Definition at line 39 of file structs_init.c.
void tc_clear_bytes_n |
( |
bytes_t * |
bytes, |
|
|
|
... |
|
) |
| |
Clears several bytes_t structures at once. The parameter list should end with a NULL sentinel.
Definition at line 61 of file structs_init.c.
Clears the memory of all the key shares in the shares structure
Definition at line 172 of file structs_init.c.
key_share_t* tc_deserialize_key_share |
( |
const char * |
b64 | ) |
|
Function that generates an array with l key shares. The bit_size parameter is used to generates key shares with a security level equivalent to a RSA private of that size. The generated key shares have a threshold parameter of k. This means that k valid signatures are needed to sign.
- Parameters
-
Definition at line 42 of file algorithms_generate_keys.c.
bytes_t* tc_init_bytes |
( |
void * |
bs, |
|
|
size_t |
len |
|
) |
| |
Function that allocates and initialize a bytes_t structure that contains len bytes in the bs pointer. The bytes_t structure will own the data pointed by bs. Any bytes_t structure initialized by this function should be deinitialized by tc_clear_bytes.
- Parameters
-
[in] | bs | pointer to data |
[in] | len | data stored in len |
- Returns
- a new bytes_t structure that stores bs with its len
Definition at line 18 of file structs_init.c.
bytes_t* tc_init_bytes_copy |
( |
void * |
bs, |
|
|
size_t |
len |
|
) |
| |
Function that allocates and initialize a bytes_t structure that contains a copy of the len bytes stored by the bs pointer. The data stored in the structure is a copy of the original data. Any bytes_t structure initialized by this function should be deinitialized by tc_clear_bytes.
- Parameters
-
[in] | bs | pointer to data |
[in] | len | data stored in len |
- Returns
- a new bytes_t structure that stores a copy of bs with its len
Definition at line 26 of file structs_init.c.
Function that takes several signature shares (at least the threshold number stored in info), and generates a standard RSA signature.
- Parameters
-
[in] | signatures | an array of the needed number of signature shares to be joined. |
[in] | | |
Definition at line 25 of file algorithms_join_signatures.c.
- Parameters
-
[in] | i | the metainfo of the key shares array. |
- Returns
- the threshold number of the key shares array.
Definition at line 108 of file structs_init.c.
- Parameters
-
[in] | i | the metainfo of the key shares array. |
- Returns
- the number of key shares in the originally generated key shares array.
Definition at line 112 of file structs_init.c.
- Parameters
-
[in] | i | the metainfo of the key shares array. |
- Returns
- the public key structure of the key shares array
Definition at line 116 of file structs_init.c.
- Parameters
-
- Returns
- the id of the node that stores that key share
Definition at line 120 of file structs_init.c.
Function that generates a signature share using a key share. A standard RSA signature is generated using several signature shares. The document to be signed should be prepared (hashed and padded) before using this function. In order to prepare the document we provide the tc_prepare_document function. But any other padder function may be used. For example, the Botan library provides a complete set of procedures that provide that functionality.
- Parameters
-
[in] | share | the key share to be used in the signature operation. |
[in] | doc | the document to be signed. |
[in] | the | metainfo of the key shares array. |
- Returns
- a signature share.
Definition at line 23 of file algorithms_node_sign.c.
Function that hashes and adds the PKCS1 padding to the document to be signed. This function should be only used in testing environments. In production environments, any function that does the PSS padding should be used. Such functions are provided by general cryptography suites such as OpenSSL or Botan.
- Parameters
-
[in] | doc | the document to be prepared. |
[in] | hash_type | the hash function to be used in the document. |
[in] | metainfo | the metainfo of the key shares array, with the public key. |
- Returns
- the prepared document.
Definition at line 91 of file algorithms_pkcs1_encoding.c.
- Parameters
-
- Returns
- the public exponent of the RSA public key.
Definition at line 128 of file structs_init.c.
- Parameters
-
- Returns
- the modulus of the RSA public key.
Definition at line 124 of file structs_init.c.
void* tc_release_bytes |
( |
bytes_t * |
bytes, |
|
|
uint32_t * |
len |
|
) |
| |
Clears just the bytes structure, and returns a pointer to bytes' data.
- Parameters
-
[in] | bytes | the bytes_t structure to be freed. |
[out] | len | a pointer to store the length of the data stored in bytes. |
- Returns
- a pointer to the data stored by bytes
Definition at line 44 of file structs_init.c.
Function that verifies a standard RSA signature using the PKCS1 padding. Should be used only for testing purposed.
- Parameters
-
[in] | the | signature to be verified. |
[in] | the | signed document. |
[in] | the | metainfo of the key shares array. |
[in] | the | hash function used in the PKCS1 padding. |
- Returns
- 1 if the signature verifies the document, 0 otherwise.
Definition at line 14 of file algorithms_rsa_verify.c.
Serializes a key shares array metainfo as a C string in the Base64 format
Definition at line 86 of file structs_serialization.c.
- Parameters
-
- Returns
- the id of the node that generated the signature share.
Definition at line 132 of file structs_init.c.
Function that verifies that a signature share was generated by any key shares that shares the same key metainfo. That means, any key shares that came from the same key_share array.
- Parameters
-
signature | the signature to be verified. |
doc | the document used to generate the signature share. |
info | the metainfo of the key shares array used to sign. |
- Returns
- 1 if the signature share was generated by any key from the original key shares array. 0 otherwise.
Definition at line 9 of file algorithms_verify_signature.c.