diff options
author | Ranieri Althoff | 2019-10-27 20:16:55 -0300 |
---|---|---|
committer | Ranieri Althoff | 2019-10-27 20:17:39 -0300 |
commit | 9d95efb5e6cd78aa9d9fa2b96ab8f1d57a4e10cb (patch) | |
tree | 810405aa8792cd118436d91097067f75de9b4634 | |
download | aur-9d95efb5e6cd78aa9d9fa2b96ab8f1d57a4e10cb.tar.gz |
Initial commit
-rw-r--r-- | .SRCINFO | 13 | ||||
-rw-r--r-- | .gitignore | 125 | ||||
-rw-r--r-- | PKGBUILD | 15 | ||||
-rw-r--r-- | wpa-psk.py | 41 |
4 files changed, 194 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO new file mode 100644 index 000000000000..e5fbcab2e65e --- /dev/null +++ b/.SRCINFO @@ -0,0 +1,13 @@ +pkgbase = wpa-psk + pkgdesc = Generate a WPA PSK from an ASCII passphrase for a SSID + pkgver = 0.1.0 + pkgrel = 1 + url = https://aur.archlinux.org/packages/wpa-psk + arch = any + license = MIT + depends = python + source = wpa-psk.py + sha256sums = 8dddd39534c9c48574222bef1d81efbb34992a6143a786f07c051d58904b1fff + +pkgname = wpa-psk + diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000000..8b4837731b35 --- /dev/null +++ b/.gitignore @@ -0,0 +1,125 @@ + +# Created by https://www.gitignore.io/api/archlinuxpackages,python +# Edit at https://www.gitignore.io/?templates=archlinuxpackages,python + +### ArchLinuxPackages ### +*.tar +*.tar.* +*.jar +*.exe +*.msi +*.zip +*.tgz +*.log +*.log.* +*.sig + +pkg/ +src/ + +### Python ### +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +pip-wheel-metadata/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# pyenv +.python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# Mr Developer +.mr.developer.cfg +.project +.pydevproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# End of https://www.gitignore.io/api/archlinuxpackages,python diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 000000000000..14581c774622 --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,15 @@ +# Maintainer: Ranieri Althoff <@domain.com> +pkgname=wpa-psk +pkgver=0.1.0 +pkgrel=1 +pkgdesc='Generate a WPA PSK from an ASCII passphrase for a SSID' +arch=('any') +url="https://aur.archlinux.org/packages/$pkgname" +license=('MIT') +depends=('python') +source=("$pkgname.py") +sha256sums=('8dddd39534c9c48574222bef1d81efbb34992a6143a786f07c051d58904b1fff') + +package() { + install -Dm755 "$srcdir/$pkgname.py" "$pkgdir/usr/bin/$pkgname" +} diff --git a/wpa-psk.py b/wpa-psk.py new file mode 100644 index 000000000000..f0012f64317e --- /dev/null +++ b/wpa-psk.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python3 + +import sys +from argparse import ArgumentParser +from getpass import getpass +from hashlib import pbkdf2_hmac + +parser = ArgumentParser( + description="%(prog)s pre-computes PSK entries for network configuration blocks of a wpa_supplicant.conf file. An ASCII passphrase and SSID are used to generate a 256-bit PSK." +) +parser.add_argument("ssid", help="The SSID whose passphrase should be derived.") +parser.add_argument( + "passphrase", + help="The passphrase to use. If not included on the command line, passphrase will be read from standard input.", + nargs="?", +) +args = parser.parse_args() + +if not args.passphrase: + print("# reading passphrase from stdin") + args.passphrase = getpass(prompt="") + +if not 8 <= len(args.passphrase) <= 63: + print("Passphrase must be 8..63 characters") + sys.exit(1) +args.ssid.encode() +passphrase = args.passphrase.encode() +if any(b < 32 or b == 127 for b in passphrase): + print("Invalid passphrase character") + sys.exit(1) + +ssid = args.ssid.encode() +psk = pbkdf2_hmac("sha1", passphrase, ssid, iterations=4096, dklen=32) +print( + "network={", + f'\tssid="{args.ssid}"', + f'\t#psk="{args.passphrase}"', + f"\tpsk={psk.hex()}", + "}", + sep="\n", +) |