* added sha256,sha384 and sha512
* updated docs --HG-- extra : convert_revision : svn%3Aeebe1cee-a9af-4fe4-bd26-ad572b19c5ab/trunk%4039
This commit is contained in:
parent
5ea8c86f97
commit
569a19488c
11 changed files with 1212 additions and 47 deletions
|
@ -1,4 +1,8 @@
|
|||
Version 1.0
|
||||
2005-12-25:
|
||||
* added -auth sha256
|
||||
* added -auth sha384
|
||||
* added -auth sha512
|
||||
|
||||
2005-08-12:
|
||||
|
||||
|
|
2
README
2
README
|
@ -1,7 +1,7 @@
|
|||
alock - README
|
||||
==============
|
||||
Mathias Gumz <akira@fluxbox.org>
|
||||
v1.0, 01 June 2005
|
||||
v1.0, 25 December 2005
|
||||
|
||||
About
|
||||
-----
|
||||
|
|
28
SConstruct
28
SConstruct
|
@ -18,19 +18,19 @@ alock_optfile = [ 'scons.opts', 'user.opts' ]
|
|||
|
||||
alock_target = 'src/alock'
|
||||
|
||||
alock_meta_files = [
|
||||
'README',
|
||||
'CHANGELOG',
|
||||
'LICENSE',
|
||||
alock_meta_files = [
|
||||
'README',
|
||||
'CHANGELOG',
|
||||
'LICENSE',
|
||||
'alock.txt',
|
||||
'alock.html' ]
|
||||
alock_contrib_files = [
|
||||
'contrib/README',
|
||||
alock_contrib_files = [
|
||||
'contrib/README',
|
||||
'contrib/xcursor-fluxbox',
|
||||
'contrib/xcursor-pekwm' ]
|
||||
alock_manpage = 'alock.1'
|
||||
alock_doc_files = [
|
||||
'alock.html',
|
||||
alock_doc_files = [
|
||||
'alock.html',
|
||||
'alock.1' ]
|
||||
|
||||
Default(alock_target)
|
||||
|
@ -54,6 +54,7 @@ alock_options.AddOptions(
|
|||
|
||||
BoolOption('amd5', 'build a little md5-helper', 0),
|
||||
BoolOption('asha1', 'build a little sha1-helper', 0),
|
||||
BoolOption('asha2', 'build a little sha2-helper', 0),
|
||||
|
||||
PathOption('PREFIX', 'install-path base', '/usr/local'),
|
||||
PathOption('DESTDIR', 'install to $DESTDIR/$PREFIX', '/')
|
||||
|
@ -96,7 +97,7 @@ if not conf.CheckLibWithHeader('X11', 'X11/Xlib.h', 'C', 'XOpenDisplay(0);', 1):
|
|||
print "sorry, no headers or libs for X11 found, cant build alock."
|
||||
Exit(1)
|
||||
conf.Finish()
|
||||
|
||||
|
||||
if alock_env['debug']:
|
||||
alock_env.AppendUnique(
|
||||
CPPDEFINES = [ 'DEBUG' ],
|
||||
|
@ -179,12 +180,12 @@ if alock_env['static']:
|
|||
alock_env.Append(
|
||||
LINKFLAGS = [ '-static' ],
|
||||
LIBS = [ 'X11', 'pthread' ])
|
||||
|
||||
|
||||
|
||||
############################################################################
|
||||
#
|
||||
#
|
||||
|
||||
|
||||
default_targets = [ alock_target ]
|
||||
if alock_env['amd5']:
|
||||
default_targets += [ 'src/amd5' ]
|
||||
|
@ -192,6 +193,9 @@ if alock_env['amd5']:
|
|||
if alock_env['asha1']:
|
||||
default_targets += [ 'src/asha1' ]
|
||||
|
||||
if alock_env['asha2']:
|
||||
default_targets += [ 'src/asha2' ]
|
||||
|
||||
Default(default_targets)
|
||||
|
||||
alock_options.Save('scons.opts', alock_env)
|
||||
|
@ -211,7 +215,7 @@ alock_env.AddPostAction('alock.1', Chmod('alock.1', 0644))
|
|||
alock_env.AddPostAction('alock.html', Chmod('alock.html', 0644))
|
||||
|
||||
############################################################################
|
||||
#
|
||||
#
|
||||
# installing
|
||||
#alock_env.InstallAs(prefixCombiner(alock_instdir_bin, ['alock'], os.sep), [alock_target], 0755)
|
||||
#alock_env.InstallAs(prefixCombiner(alock_meta_files, alock_instdir_meta, os.sep), alock_meta_files, 0644)
|
||||
|
|
13
alock.txt
13
alock.txt
|
@ -1,7 +1,7 @@
|
|||
ALOCK(1)
|
||||
========
|
||||
Mathias Gumz <akira@fluxbox.org>
|
||||
v1.0, ?? May 2005
|
||||
v1.0, 25 December 2005
|
||||
|
||||
NAME
|
||||
----
|
||||
|
@ -42,6 +42,17 @@ OPTIONS
|
|||
- sha1 - alock creates a sha1-hash from the entered unlockpassword and compares it with the hash provided
|
||||
* hash=<hash> - use <hash> as reference
|
||||
* file=<filename> - use <filename> as reference
|
||||
- sha256 - alock creates a sha256-hash from the entered unlockpassword and compares it with the hash provided
|
||||
* hash=<hash> - use <hash> as reference
|
||||
* file=<filename> - use <filename> as reference
|
||||
- sha384 - alock creates a sha384-hash from the entered unlockpassword and compares it with the hash provided
|
||||
* hash=<hash> - use <hash> as reference
|
||||
* file=<filename> - use <filename> as reference
|
||||
- sha512 - alock creates a sha512-hash from the entered unlockpassword and compares it with the hash provided
|
||||
* hash=<hash> - use <hash> as reference
|
||||
* file=<filename> - use <filename> as reference
|
||||
|
||||
|
||||
|
||||
-bg type:options ::
|
||||
Define the type of alock should handle the background:
|
||||
|
|
|
@ -10,7 +10,7 @@ def createManPage(target, source, env):
|
|||
|
||||
def createHtml(target, source, env):
|
||||
"""Creates a html-site via asciidoc."""
|
||||
os.system('asciidoc -d manpage -b xhtml -o ' + str(target[0]) + ' ' +
|
||||
os.system('asciidoc -d manpage -b xhtml11 -o ' + str(target[0]) + ' ' +
|
||||
str(source[0]))
|
||||
|
||||
def prefixCombiner(prefix, itemlist, glue=''):
|
||||
|
|
|
@ -18,7 +18,7 @@ build = alock_env.Copy()
|
|||
if build['passwd']:
|
||||
auth_sources += [ 'auth_passwd.c' ]
|
||||
if build['hash']:
|
||||
auth_sources += [ 'auth_md5.c', 'auth_sha1.c' ]
|
||||
auth_sources += [ 'auth_md5.c', 'auth_sha1.c', 'auth_sha2.c' ]
|
||||
if build['pam']:
|
||||
auth_sources += [ 'auth_pam.c' ]
|
||||
|
||||
|
@ -37,13 +37,18 @@ alock_sources += auth_sources + bg_sources + cursor_sources
|
|||
alock = build.Program('alock', alock_sources)
|
||||
|
||||
if build['amd5']:
|
||||
md5 = alock_env.Copy()
|
||||
md5 = Environment()
|
||||
md5.AppendUnique(CPPDEFINES = [ 'STAND_ALONE' ])
|
||||
md5.Program('amd5', md5.StaticObject(target = 'amd5.o', source = 'auth_md5.c'))
|
||||
|
||||
if build['asha1']:
|
||||
sha1 = alock_env.Copy()
|
||||
sha1 = Environment()
|
||||
sha1.AppendUnique(CPPDEFINES = [ 'STAND_ALONE' ])
|
||||
sha1.Program('asha1', sha1.StaticObject(target = 'asha1', source = 'auth_sha1.c'))
|
||||
|
||||
if build['asha2']:
|
||||
sha1 = Environment()
|
||||
sha1.AppendUnique(CPPDEFINES = [ 'STAND_ALONE' ])
|
||||
sha1.Program('asha2', sha1.StaticObject(target = 'asha2', source = 'auth_sha2.c'))
|
||||
|
||||
# vim:ft=python
|
||||
|
|
24
src/alock.c
24
src/alock.c
|
@ -6,7 +6,7 @@
|
|||
copyr : copyright (c) 2005 by m. gumz
|
||||
|
||||
license : see LICENSE
|
||||
|
||||
|
||||
start : Sa 30 April 2005 14:19:44 CEST
|
||||
|
||||
$Id$
|
||||
|
@ -36,6 +36,9 @@ extern struct aAuth alock_auth_none;
|
|||
#ifdef HASH_PWD
|
||||
extern struct aAuth alock_auth_md5;
|
||||
extern struct aAuth alock_auth_sha1;
|
||||
extern struct aAuth alock_auth_sha256;
|
||||
extern struct aAuth alock_auth_sha384;
|
||||
extern struct aAuth alock_auth_sha512;
|
||||
#endif /* HASH_PWD */
|
||||
#ifdef PASSWD_PWD
|
||||
extern struct aAuth alock_auth_passwd;
|
||||
|
@ -55,6 +58,9 @@ static struct aAuth* alock_authmodules[] = {
|
|||
#ifdef HASH_PWD
|
||||
&alock_auth_md5,
|
||||
&alock_auth_sha1,
|
||||
&alock_auth_sha256,
|
||||
&alock_auth_sha384,
|
||||
&alock_auth_sha512,
|
||||
#endif /* HASH_PWD */
|
||||
NULL
|
||||
};
|
||||
|
@ -132,7 +138,7 @@ void initXInfo(struct aXInfo* xinfo, struct aOpts* opts) {
|
|||
}
|
||||
|
||||
int event_loop(struct aOpts* opts, struct aXInfo* xinfo) {
|
||||
|
||||
|
||||
XEvent ev;
|
||||
KeySym ks;
|
||||
char cbuf[10], rbuf[50];
|
||||
|
@ -145,7 +151,7 @@ int event_loop(struct aOpts* opts, struct aXInfo* xinfo) {
|
|||
XNextEvent(xinfo->display, &ev);
|
||||
switch (ev.type) {
|
||||
case KeyPress:
|
||||
|
||||
|
||||
if (ev.xkey.time < timeout) {
|
||||
XBell(xinfo->display, 0);
|
||||
break;
|
||||
|
@ -171,7 +177,7 @@ int event_loop(struct aOpts* opts, struct aXInfo* xinfo) {
|
|||
|
||||
if (opts->auth->auth(rbuf))
|
||||
return 1;
|
||||
|
||||
|
||||
XSync(xinfo->display, True); /* discard pending events to start really fresh */
|
||||
XBell(xinfo->display, 0);
|
||||
rlen = 0;
|
||||
|
@ -217,7 +223,7 @@ int main(int argc, char **argv) {
|
|||
opts.background = alock_backgrounds[0];
|
||||
|
||||
opts.auth->init(NULL);
|
||||
|
||||
|
||||
/* parse options */
|
||||
if (argc != 1) {
|
||||
for(arg = 1; arg <= argc; arg++) {
|
||||
|
@ -339,14 +345,14 @@ int main(int argc, char **argv) {
|
|||
initXInfo(&xinfo, &opts);
|
||||
|
||||
if (!opts.background->init(background_args, &xinfo)) {
|
||||
printf("alock: error, couldnt init [%s] with [%s].\n",
|
||||
printf("alock: error, couldnt init [%s] with [%s].\n",
|
||||
opts.background->name,
|
||||
background_args);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!opts.cursor->init(cursor_args, &xinfo)) {
|
||||
printf("alock: error, couldnt init [%s] with [%s].\n",
|
||||
printf("alock: error, couldnt init [%s] with [%s].\n",
|
||||
opts.cursor->name,
|
||||
cursor_args);
|
||||
exit(1);
|
||||
|
@ -355,7 +361,7 @@ int main(int argc, char **argv) {
|
|||
XSelectInput(xinfo.display, xinfo.window, KeyPressMask|KeyReleaseMask);
|
||||
XMapWindow(xinfo.display, xinfo.window);
|
||||
XRaiseWindow(xinfo.display, xinfo.window);
|
||||
|
||||
|
||||
/* try to grab 2 times, another process (windowmanager) may have grabbed
|
||||
* the keyboard already */
|
||||
if ((XGrabKeyboard(xinfo.display, xinfo.window, True, GrabModeAsync, GrabModeAsync,
|
||||
|
@ -381,7 +387,7 @@ int main(int argc, char **argv) {
|
|||
opts.cursor->deinit(&xinfo);
|
||||
opts.background->deinit(&xinfo);
|
||||
XCloseDisplay(xinfo.display);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ struct aXInfo {
|
|||
Display* display;
|
||||
Window root;
|
||||
Colormap colormap;
|
||||
|
||||
|
||||
Window window;
|
||||
Cursor cursor;
|
||||
};
|
||||
|
|
|
@ -313,7 +313,7 @@ static int alock_auth_md5_init(const char* args) {
|
|||
printf("alock: error, missing or incorrect hash for [md5].\n");
|
||||
free(arguments);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
} else if (strstr(arg, "file=") == arg && strlen(arg) > 6) {
|
||||
char* tmp_hash = NULL;
|
||||
FILE* hashfile = fopen(&arg[5], "r");
|
||||
|
@ -328,7 +328,7 @@ static int alock_auth_md5_init(const char* args) {
|
|||
}
|
||||
fclose(hashfile);
|
||||
} else {
|
||||
printf("alock: error, couldnt read [%s] for [md5].\n",
|
||||
printf("alock: error, couldnt read [%s] for [md5].\n",
|
||||
&arg[5]);
|
||||
free(arguments);
|
||||
return 0;
|
||||
|
@ -355,9 +355,9 @@ static int alock_auth_md5_init(const char* args) {
|
|||
printf("alock: error, missing hash for [md5].\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
alock_string2lower(userhash);
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -398,32 +398,31 @@ struct aAuth alock_auth_md5 = {
|
|||
|
||||
/* ---------------------------------------------------------------- *\
|
||||
\* ---------------------------------------------------------------- */
|
||||
#else
|
||||
#else
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
|
||||
|
||||
unsigned char digest[MD5_DIGEST_LENGTH];
|
||||
unsigned int i;
|
||||
unsigned char c;
|
||||
md5Context md5;
|
||||
|
||||
|
||||
if (argc > 1) {
|
||||
printf("amd5 - reads from stdin to calculate a md5-hash.\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
md5_init(&md5);
|
||||
while((c = fgetc(stdin)) != (unsigned char)EOF) {
|
||||
md5_update(&md5, &c, 1);
|
||||
}
|
||||
md5_final(digest, &md5);
|
||||
|
||||
printf("\n");
|
||||
for(i = 0; i < MD5_DIGEST_LENGTH; ++i)
|
||||
printf("%02x", digest[i]);
|
||||
printf("\n");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -249,7 +249,7 @@ static int alock_auth_sha1_init(const char* args) {
|
|||
printf("alock: error, missing or incorrect hash for [sha1].\n");
|
||||
free(arguments);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
} else if (strstr(arg, "file=") == arg && strlen(arg) > 6) {
|
||||
char* tmp_hash = NULL;
|
||||
FILE* hashfile = fopen(&arg[5], "r");
|
||||
|
@ -264,7 +264,7 @@ static int alock_auth_sha1_init(const char* args) {
|
|||
}
|
||||
fclose(hashfile);
|
||||
} else {
|
||||
printf("alock: error, couldnt read [%s] for [md5].\n",
|
||||
printf("alock: error, couldnt read [%s] for [sha1].\n",
|
||||
&arg[5]);
|
||||
free(arguments);
|
||||
return 0;
|
||||
|
@ -291,9 +291,9 @@ static int alock_auth_sha1_init(const char* args) {
|
|||
printf("alock: error, missing hash for [sha1].\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
alock_string2lower(userhash);
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -334,15 +334,15 @@ struct aAuth alock_auth_sha1 = {
|
|||
|
||||
/* ---------------------------------------------------------------- *\
|
||||
\* ---------------------------------------------------------------- */
|
||||
#else
|
||||
#else
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
|
||||
|
||||
unsigned char digest[SHA1_DIGEST_LENGTH];
|
||||
unsigned int i;
|
||||
unsigned char c;
|
||||
sha1Context sha1;
|
||||
|
||||
|
||||
if (argc > 1) {
|
||||
printf("asha1 - reads from stdin to calculate a sha1-hash.\n");
|
||||
exit(0);
|
||||
|
@ -354,12 +354,11 @@ int main(int argc, char* argv[]) {
|
|||
}
|
||||
sha1_final(digest, &sha1);
|
||||
|
||||
printf("\n");
|
||||
for(i = 0; i < SHA1_DIGEST_LENGTH; ++i)
|
||||
printf("%02x", digest[i]);
|
||||
printf("\n");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
1137
src/auth_sha2.c
Normal file
1137
src/auth_sha2.c
Normal file
File diff suppressed because it is too large
Load diff
Reference in a new issue