File: libgfshare.5.in

package info (click to toggle)
libgfshare 2.0.0-8
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,628 kB
  • sloc: sh: 11,402; ansic: 845; makefile: 63
file content (164 lines) | stat: -rw-r--r-- 5,254 bytes parent folder | download | duplicates (6)
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
.\" This is the man page for libgfshare
.TH LIBGFSHARE "5" "June 2015" "@PACKAGE_VERSION@" "Shamir Secret Sharing in gf(2**8)"
.SH NAME
gfshare_ctx_init_enc, etc. \- Shamir Secret Sharing
.SH SYNOPSIS
.nf
.B #include <libgfshare.h>
.sp
.BI "gfshare_rand_func_t gfshare_fill_rand;"
.sp
.BI "gfshare_rand_func_t gfshare_bad_idea_but_fill_rand_using_random;"
.sp
.BI "gfshare_ctx *gfshare_ctx_init_enc( unsigned char *" sharenrs ,
.br
.BI "                                   unsigned int   " sharecount ,
.br
.BI "                                   unsigned char  " threshold ,
.br
.BI "                                   unsigned int   " size " );"
.sp
.BI "gfshare_ctx *gfshare_ctx_init_dec( unsigned char *" sharenrs ,
.br
.BI "                                   unsigned int   " sharecount ,
.br
.BI "                                   unsigned int   " size " );"
.sp
.BI "void gfshare_ctx_free( gfshare_ctx *" ctx " );"
.sp
.BI "void gfshare_ctx_enc_setsecret( gfshare_ctx   *" ctx ,
.br
.BI "                                unsigned char *" secret " );"
.sp
.BI "void gfshare_ctx_enc_getshare( gfshare_ctx   *" ctx ,
.br
.BI "                               unsigned char  " sharenr ,
.br
.BI "                               unsigned char *" share " );"
.sp
.BI "void gfshare_ctx_dec_newshares( gfshare_ctx   *" ctx ,
.br
.BI "                                unsigned char *" sharenrs " );"
.sp
.BI "void gfshare_ctx_dec_giveshare( gfshare_ctx   *" ctx ,
.br
.BI "                                unsigned char  " sharenr ,
.br
.BI "                                unsigned char *" share " );"
.sp
.BI "void gfshare_ctx_dec_extract( gfshare_ctx   *" ctx ,
.br
.BI "                              unsigned char *" secretbuf " );"
.SH DESCRIPTION
The
.BR gfshare_fill_rand
variable must contain a pointer to a function which takes an
.BR unsigned
.BR char
.BR *
and an
.BR unsigned
.BR int
and fills the given buffer with the given number of random bytes before
calling any of the functions which create or populate contexts.
.br
If you cannot do this with a cryptographically secure mechanism then
the library provides the
.BR gfshare_bad_idea_but_fill_rand_using_random
value which you can put into
.BR gfshare_fill_rand
and which will use the C library function
.BR random ()
to fill the buffer.  You should ensure you call
.BR srandom ()
at least once before using any of the other functions though.
.PP
The
.BR gfshare_ctx_init_enc ()
function returns a context object which can be used for encoding
shares of a secret. The context encodes against
.IR sharecount
shares which are numbered in the array
.IR sharenrs .
The secret is always
.IR size
bytes long and the resultant shares will need at least
.IR threshold
of the shares present for recombination. It is critical that
.IR threshold
be at least one lower than
.IR sharecount .
.PP
The
.BR gfshare_ctx_init_dec ()
function returns a context object which can be used to recombine shares to
recover a secret. Each share and the resulting secret will be
.IR size
bytes long. The context can be used to recombine
.IR sharecount
shares which are numbered in the
.IR sharenrs
array.
.PP
The
.BR gfshare_ctx_free ()
function frees all the memory associated with a gfshare context including
the memory belonging to the context itself.
.PP
The
.BR gfshare_ctx_enc_setsecret ()
function provides the secret you wish to encode to the context. The
.IR secret
will be copied into the internal buffer of the library.
.PP
The
.BR gfshare_ctx_enc_getshare ()
function extracts a particular share from the context. The
.IR share
buffer must be preallocated to the size of the shares and the
.IR sharenr
parameter is an index into the
.IR sharenrs
array used to initialise the context
.PP
The
.BR gfshare_ctx_dec_newshares ()
function informs the decode context of a change in the share numbers
available to the context. The number of shares cannot be changed but the
.IR sharenrs
can be zero to indicate that a particular share is missing currently.
.PP
The
.BR gfshare_ctx_dec_giveshare ()
function provides the decode context with a given share. The share number
itself was previously provided in a
.IR sharenrs
array and the
.IR sharenr
parameter is the index into that array of the number of the share being
provided in the
.IR share
memory block.
.PP
The
.BR gfshare_ctx_dec_extract ()
function combines the provided shares to recalculate the secret. It is
recommended that you \fBmlock()\fR the
.IR secretbuf
before calling this function, so that the recombined secret will never be
written to swap. This may help to prevent a malicious party discovering the
content of your secret. You should also randomise the content of the buffer
once you are finished using the recombined secret.
.SH ERRORS
Any function which can fail for any reason will return NULL on error.
.SH AUTHOR
Written by Daniel Silverstone.
.SH "REPORTING BUGS"
Report bugs against the libgfshare product on www.launchpad.net.
.SH COPYRIGHT
Copyright \(co 2006,2015 Daniel Silverstone.
.br
This is free software. You may redistribute copies of it under the terms of the MIT licence (the COPYRIGHT file in the source distribution).
There is NO WARRANTY, to the extent permitted by law.
.SH "SEE ALSO"
gfsplit(1), gfcombine(1), gfshare(7)