Skip to content

Commit b077cd4

Browse files
committed
Adding historic version of SSSS -- v0.5.
1 parent 9648320 commit b077cd4

File tree

5 files changed

+258
-13
lines changed

5 files changed

+258
-13
lines changed

HISTORY

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
v0.5: (January 2006)
2+
- introduction of memory locking and tty echo suppression
3+
- a buffer overflow was fixed. It seems to be exploitable.
4+
5+
v0.4: (October 2005)
6+
- the security level now can be chosen freely in the range
7+
8..1024 bits in steps of 8.
8+
9+
v0.3: (July 2005)
10+
- separation of ssss into ssss-split and ssss-combine
11+
- introduction of a man page
12+
13+
v0.2: (June 2005)
14+
- introduction of the diffusion layer
15+
16+
v0.1: (May 2005)
17+
- initial release
18+

THANKS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
I would like to thank the following people for comments and code:
2+
3+
Tam�s Tevesz (documentation)
4+
Stefan Schlesinger, Daniel Bielefeldt (error reporting)
5+
Olaf Mersmann (memory locking, echo suppression)
6+
Alex Popov (windows port)

doc.html

Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2+
<html>
3+
<head>
4+
<title>ssss: Shamir's Secret Sharing Scheme</title>
5+
</head>
6+
7+
<body>
8+
<small>The following text is licensed under the
9+
<a href="http://www.gnu.org/licenses/gpl.html">
10+
GNU General Public License</a>. Copyright 2005, 2006 by
11+
B. Poettering.</small>
12+
<hr noshade="noshade"/>
13+
14+
<h4>What is "Secret Sharing"?</h4>
15+
16+
Citing from the <a href="http://en.wikipedia.org/">Wikipedia</a>
17+
article about <a
18+
href="http://en.wikipedia.org/wiki/Secret_sharing">Secret
19+
Sharing</a>:
20+
<blockquote>
21+
<p>
22+
In <a
23+
href="http://en.wikipedia.org/wiki/Cryptography">cryptography</a>, a
24+
<b>secret sharing scheme</b> is a method for distributing a <a
25+
href="http://en.wikipedia.org/wiki/Secrecy"><i>secret</i></a> amongst
26+
a group of participants, each of which is allocated a <i>share</i> of
27+
the secret. The secret can only be reconstructed when the shares are
28+
combined together; individual shares are of no use on their own.
29+
</p>
30+
<p>
31+
More formally, in a secret sharing scheme there is one <i>dealer</i>
32+
and <i>n</i> <i>players</i>. The dealer gives a secret to the players,
33+
but only when specific conditions are fulfilled. The dealer
34+
accomplishes this by giving each player a share in such a way that any
35+
group of <i>t</i> (for <i>threshold</i>) or more players can together
36+
reconstruct the secret but no group of less than <i>t</i> players
37+
can. Such a system is called a <i>(t,n)</i>-threshold scheme.
38+
</p>
39+
</blockquote>
40+
<p>
41+
A popular technique to implement threshold schemes uses <a
42+
href="http://en.wikipedia.org/wiki/Polynomial_interpolation">
43+
polynomial interpolation</a> ("Lagrange interpolation"). This
44+
method was invented by <a
45+
href="http://en.wikipedia.org/wiki/Adi_Shamir"> Adi Shamir</a> in
46+
1979. You can play around with a threshold scheme on the <a
47+
href="http://point-at-infinity.org/ssss/demo.html">demo page</a>.
48+
</p>
49+
<p>
50+
Note that Shamir's scheme is provable secure, that means: in a
51+
<i>(t,n)</i> scheme one can prove that it makes no difference
52+
whether an attacker has <i>t-1</i> valid shares at his disposal or
53+
none at all; as long as he has less than
54+
<i>t</i> shares, there is no better option than guessing to find
55+
out the secret.
56+
</p>
57+
<h4>Where is "Secret Sharing" used?</h4> Some popular examples are:
58+
<ul>
59+
<li>
60+
Good passwords are hard to memorize. A clever user could use a
61+
secret sharing scheme to generate a set of shares for a given
62+
password and store one share in his address book, one in his
63+
bank deposit safe, leave one share with a friend, etc. If one day he
64+
forgets his password, he can reconstruct it easily. Of
65+
course, writing passwords directly into the address book would
66+
pose a security risk, as it could be stolen by an "enemy". If
67+
a secret sharing scheme is used, the attacker has to steal
68+
many shares from different places.
69+
</li>
70+
<li>
71+
"A dealer could send <i>t</i> shares, all of which are
72+
necessary to recover the original secret, to a single
73+
recipient, using <i>t</i> different channels. An attacker
74+
would have to intercept all <i>t</i> shares to recover the
75+
secret, a task which may be more difficult than intercepting a
76+
single message" (<a
77+
href="http://en.wikipedia.org/wiki/Secret_sharing">Wikipedia</a>).
78+
</li>
79+
<li>
80+
The director of a bank could generate shares for the bank's
81+
vault unlocking code and hand them out to his employees. Even
82+
if the director is not available, the vault can be opened, but only,
83+
when a certain number of employees do it together. Here secret
84+
sharing schemes allow the employment of not fully trusted
85+
people.
86+
</li>
87+
</ul>
88+
89+
<h4>What is "ssss"? Where can I download "ssss"?</h4>
90+
<p>
91+
<b>ssss</b> is an implementation of Shamir's secret sharing
92+
scheme for UNIX systems, especially developed for linux
93+
machines. The code is licensed under the <a
94+
href="http://www.gnu.org/licenses/gpl.html">GNU GPL</a>.
95+
<b>ssss</b> does both: the generation of shares for a known
96+
secret and the reconstruction of a secret using user provided
97+
shares. The software was written in 2006 by B. Poettering, it
98+
links against the <a href="http://swox.com/gmp/">GNU libgmp</a>
99+
multiprecision library (version 4.1.4 works well) and requires
100+
the <tt>/dev/random</tt> entropy source. Please send bug reports
101+
to <b><tt>ssss AT point-at-infinity.org</tt></b>.
102+
</p>
103+
<p>There is a <a
104+
href="http://freshmeat.net/projects/ssss/">freshmeat page</a> for
105+
<b>ssss</b>. A <a
106+
href="http://packages.debian.org/unstable/utils/ssss">debian
107+
package</a> is also available. If you are the lucky owner of a
108+
debian system just run <tt>apt-get update &amp;&amp; apt-get
109+
install ssss</tt> to install <b>ssss</b>. Someone even ported (an
110+
outdated version of) <b>ssss</b> to <a
111+
href="http://www.seidlitz.ca/ssss/">Windows</a> (but with a
112+
lightly too sloppy random number generation, in my opinion).
113+
</p>
114+
<p>
115+
Download on the <a href="http://point-at-infinity.org/ssss">ssss homepage</a>.
116+
</p>
117+
118+
<h4>How is "ssss" used? Is there an online demonstration?</h4>
119+
<p>The generation of shares given a
120+
known secret is shown first. A (3,5)-threshold scheme is used, that is:
121+
5 shares are generated, the secret can be reconstructed by any
122+
subset of size 3.
123+
</p>
124+
<pre>
125+
% ssss-split -t 3 -n 5
126+
Generating shares using a (3,5) scheme with dynamic security level.
127+
Enter the secret, at most 128 ASCII characters: my secret root password
128+
Using a 184 bit security level.
129+
1-1c41ef496eccfbeba439714085df8437236298da8dd824
130+
2-fbc74a03a50e14ab406c225afb5f45c40ae11976d2b665
131+
3-fa1c3a9c6df8af0779c36de6c33f6e36e989d0e0b91309
132+
4-468de7d6eb36674c9cf008c8e8fc8c566537ad6301eb9e
133+
5-4756974923c0dce0a55f4774d09ca7a4865f64f56a4ee0
134+
</pre>
135+
These shares can be combined to recreate the secret:
136+
<pre>
137+
% ssss-combine -t 3
138+
Enter 3 shares separated by newlines:
139+
Share [1/3]: 3-fa1c3a9c6df8af0779c36de6c33f6e36e989d0e0b91309
140+
Share [2/3]: 5-4756974923c0dce0a55f4774d09ca7a4865f64f56a4ee0
141+
Share [3/3]: 2-fbc74a03a50e14ab406c225afb5f45c40ae11976d2b665
142+
Resulting secret: my secret root password
143+
</pre>
144+
You can try it out on the
145+
<a href="http://point-at-infinity.org/ssss/demo.html">demo page</a>.
146+
147+
<p>
148+
If larger secrets are to be shared a hybrid technique has to be
149+
applied: encrypt the secret with a block cipher (using openssl,
150+
gpg, etc) and apply secret sharing to just the key. See the man
151+
page for more information about this topic.
152+
</p>
153+
154+
155+
<h4>Where is the manpage?</h4>
156+
Read it as <a href="http://point-at-infinity.org/ssss/ssss.1.html">html</a> or
157+
<a href="http://point-at-infinity.org/ssss/ssss.1">*roff</a>!
158+
159+
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
160+
<input name="cmd" value="_xclick" type="hidden">
161+
<input name="business" value="[email protected]" type="hidden">
162+
<input name="no_note" value="1" type="hidden">
163+
<input name="currency_code" value="EUR" type="hidden">
164+
<p>
165+
If you like this software, think about donating some money via
166+
<input src="https://www.paypal.com/en_US/i/btn/x-click-but7.gif" name="submit" alt="PayPal" type="image">.
167+
</p>
168+
</form>
169+
<hr>
170+
<small>
171+
<!-- hhmts start -->
172+
Last modified: Sun Jan 15 12:08:48 CET 2006
173+
<!-- hhmts end -->
174+
</small>
175+
</body>
176+
</html>

ssss.c

Lines changed: 46 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* ssss version 0.4 - Copyright 2005 B. Poettering
2+
* ssss version 0.5 - Copyright 2005,2006 B. Poettering
33
*
44
* This program is free software; you can redistribute it and/or
55
* modify it under the terms of the GNU General Public License as
@@ -31,21 +31,26 @@
3131
* Compile with
3232
* "gcc -O2 -lgmp -o ssss-split ssss.c && ln ssss-split ssss-combine"
3333
*
34+
* Compile with -DNOMLOCK to obtain a version without memory locking.
35+
*
3436
* Report bugs to: ssss AT point-at-infinity.org
3537
*
3638
*/
3739

3840
#include <stdlib.h>
3941
#include <string.h>
42+
#include <errno.h>
4043
#include <fcntl.h>
4144
#include <unistd.h>
4245
#include <stdio.h>
4346
#include <stdint.h>
4447
#include <assert.h>
48+
#include <termios.h>
49+
#include <sys/mman.h>
4550

4651
#include <gmp.h>
4752

48-
#define VERSION "0.4"
53+
#define VERSION "0.5"
4954
#define RANDOM_SOURCE "/dev/random"
5055
#define MAXDEGREE 1024
5156
#define MAXTOKENLEN 128
@@ -77,25 +82,27 @@ int opt_threshold = -1;
7782
int opt_number = -1;
7883
char *opt_token = NULL;
7984

80-
int ttyoutput;
81-
8285
unsigned int degree;
8386
mpz_t poly;
8487
int cprng;
88+
struct termios echo_orig, echo_off;
8589

8690
#define mpz_lshift(A, B, l) mpz_mul_2exp(A, B, l)
8791
#define mpz_sizeinbits(A) (mpz_cmp_ui(A, 0) ? mpz_sizeinbase(A, 2) : 0)
8892

93+
/* emergency abort and warning functions */
94+
8995
void fatal(char *msg)
9096
{
91-
fprintf(stderr, "%sFATAL: %s.\n", ttyoutput ? "\a" : "", msg);
97+
tcsetattr(0, TCSANOW, &echo_orig);
98+
fprintf(stderr, "%sFATAL: %s.\n", isatty(2) ? "\a" : "", msg);
9299
exit(1);
93100
}
94101

95102
void warning(char *msg)
96103
{
97104
if (! opt_QUIET)
98-
fprintf(stderr, "%sWARNING: %s.\n", ttyoutput ? "\a" : "", msg);
105+
fprintf(stderr, "%sWARNING: %s.\n", isatty(2) ? "\a" : "", msg);
99106
}
100107

101108
/* field arithmetic routines */
@@ -110,6 +117,7 @@ int field_size_valid(int deg)
110117

111118
void field_init(int deg)
112119
{
120+
assert(field_size_valid(deg));
113121
mpz_init_set_ui(poly, 0);
114122
mpz_setbit(poly, deg);
115123
mpz_setbit(poly, irred_coeff[3 * (deg / 8 - 1) + 0]);
@@ -385,7 +393,7 @@ void split(void)
385393
unsigned int fmt_len;
386394
mpz_t x, y, coeff[opt_threshold];
387395
char buf[MAXLINELEN];
388-
int i;
396+
int deg, i;
389397
for(fmt_len = 1, i = opt_number; i >= 10; i /= 10, fmt_len++);
390398
if (! opt_quiet) {
391399
printf("Generating shares using a (%d,%d) scheme with ",
@@ -396,23 +404,27 @@ void split(void)
396404
printf("dynamic");
397405
printf(" security level.\n");
398406

399-
int deg = opt_security ? opt_security : MAXDEGREE;
407+
deg = opt_security ? opt_security : MAXDEGREE;
400408
fprintf(stderr, "Enter the secret, ");
401409
if (opt_hex)
402410
fprintf(stderr, "as most %d hex digits: ", deg / 4);
403411
else
404412
fprintf(stderr, "at most %d ASCII characters: ", deg / 8);
405413
}
414+
tcsetattr(0, TCSANOW, &echo_off);
406415
if (! fgets(buf, sizeof(buf), stdin))
407416
fatal("I/O error while reading secret");
417+
tcsetattr(0, TCSANOW, &echo_orig);
408418
buf[strcspn(buf, "\r\n")] = '\0';
409419

410420
if (! opt_security) {
411421
opt_security = opt_hex ? 4 * ((strlen(buf) + 1) & ~1): 8 * strlen(buf);
412-
422+
if (! field_size_valid(opt_security))
423+
fatal("security level invalid (secret too long?)");
413424
if (! opt_quiet)
414425
fprintf(stderr, "Using a %d bit security level.\n", opt_security);
415426
}
427+
416428
field_init(opt_security);
417429

418430
mpz_init(coeff[0]);
@@ -528,9 +540,31 @@ int main(int argc, char *argv[])
528540
{
529541
char *name;
530542
int i;
531-
if ((i = fileno(stderr)) < 0)
532-
fatal("couldn't determine fileno of stderr");
533-
ttyoutput = isatty(i);
543+
544+
#if ! NOMLOCK
545+
if (mlockall(MCL_CURRENT | MCL_FUTURE) < 0)
546+
switch(errno) {
547+
case ENOMEM:
548+
warning("couldn't get memory lock (ENOMEM, try to adjust RLIMIT_MEMLOCK!)");
549+
break;
550+
case EPERM:
551+
warning("couldn't get memory lock (EPERM, try UID 0!)");
552+
break;
553+
case ENOSYS:
554+
warning("couldn't get memory lock (ENOSYS, kernel doesn't allow page locking)");
555+
break;
556+
default:
557+
warning("couldn't get memory lock");
558+
break;
559+
}
560+
#endif
561+
562+
if (getuid() != geteuid())
563+
seteuid(getuid());
564+
565+
tcgetattr(0, &echo_orig);
566+
echo_off = echo_orig;
567+
echo_off.c_lflag &= ~ECHO;
534568

535569
opt_help = argc == 1;
536570
while((i = getopt(argc, argv, "vDhqQxs:t:n:w:")) != -1)

ssss.manpage.xml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,19 @@ gpg -c &lt; file.plain &gt; file.encrypted
136136

137137
</section>
138138

139+
<section name="Security">
140+
<p>
141+
<opt>ssss</opt> tries to lock its virtual address space into RAM for
142+
privacy reasons. But this may fail for two reasons: either the current uid
143+
doesn't permit page locking, or the RLIMIT_MEMLOCK is set too
144+
low. After printing a warning message <opt>ssss</opt> will run even without
145+
obtaining the desired mlock.
146+
</p>
147+
148+
</section>
149+
139150
<section name="Author">
140-
This software (v0.4) was written in 2005 by B. Poettering
151+
This software (v0.5) was written in 2006 by B. Poettering
141152
(ssss AT point-at-infinity.org). Find the newest version of
142153
ssss on the project's homepage: <url
143154
href="http://point-at-infinity.org/ssss/"/>.

0 commit comments

Comments
 (0)