Compare commits

..

No commits in common. "master" and "ps-read" have entirely different histories.

9 changed files with 25 additions and 432 deletions

11
.gitignore vendored
View File

@ -1,11 +1,3 @@
# Project specific files
#
# binaries
*.jpg
# Python Files
#
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
@ -45,8 +37,11 @@ coverage.xml
*.mo
*.pot
# Django stuff:
*.log
# Sphinx documentation
docs/_build/
#binaries
*.jpg

39
README
View File

@ -1,39 +0,0 @@
***** ***** ***** *****
*** Picseal ***
***** ***** ***** *****
Your Photo is your Crypto Key
-protect from photo modification
-verify photo ownership
-proof of photo originality, proof of photo ownership. (hash time stamp, Certified Secret tech)
-use a photo as authentication (what you have), requires chain-of-custody, requires time stamp verify
-generate a new key pair to share with every photo
[[ Requirements ]]
Python 3
pycrypto==2.6.1
[[ Usage ]]
Create PicSeal images
picseal.py -i <image_file>
***** ***** ***** *****
usage: picseal.py [-h] [-f FILE] [-v] [-vv] [-l] [-pm] [-pi] [-pa] [-w]
optional arguments:
-h, --help show this help message and exit
-f FILE, --file FILE source image file
-v, --verbose will set logging level to INFO
-vv, --vverbose will set logging level to DEBUG
-l, --logging will supercede the -v option and send all logging to a
file, logging.DEBUG
-pm, --printmeta print the metadata markers
-pi, --printimage print the image markers
-pa, --printall print all markers
-w, --write write picseal files

17
docs/README Normal file
View File

@ -0,0 +1,17 @@
***** ***** ***** *****
*** Picseal ***
***** ***** ***** *****
Your Photo is your Crypto Key
Generate a new Crypto Key to share with every photo
[[ Requirements ]]
Python 3
pycrypto==2.6.1
[[ Usage ]]

View File

@ -1,26 +0,0 @@
[[[ PicSeal Agile ]]]
[[ BACKLOG ]]
[ current (ver 1.0) ]
[ future ]
* add option "-d" to decrypt file
* add option "-e" to encrypt file
* add option "-ex" to export the key to .PEM file
* add visual stamp to the file so that a picseal photo can be recognized
* use block-chain for "certified secret" technology, insert hash signature into block-chain
[[ COMPLETED ]]
[ current (ver 1.0) ]
* reads a picseal .jpg file, understands pub/pvt keys from file
* writes new .jpg files with crypto keys
* verbose output of image data chunks
* reads .jpg file, parses data tags

View File

@ -1,60 +0,0 @@
[[[ PicSeal Design Document ]]]
[[ JPG file parse Pseudo Code ]]
1) Verify File
a. read JPG file: find record markers, save file locations
b. verify no parsing issues
c. save file locations for metatdate
d. save file locations for image data
2) Generate Hash
a. hash all image data
3) Digital Signature
a. generate new public key pair
b. sign hash data with priv key
4) Write new PicSeal Public file
a. write encrypted original metadata
b. write PicSeal metadata
i. write JSON
b. write image data
5) Write new PicSeal Private file
a. create thumbnail (smaller files)
b. write PicSeal metadata (JSON)
c. write image data
[[ PicSeal Metadata ]]
[ binary data blob format ]
# Pub: [app15:2|size:2|'picseal':7|type:1|sig:512|pubkey:550]
# Pvt: [app15:2|size:2|'picseal':7|type:1|sig:512|pvtkey:2347]
# 1. app15 jpg marker
app15_marker = b'\xff\xef'
# 2. ascii code for "picseal"
picseal_marker = b'\x70\x69\x63\x73\x65\x61\x6C'
# 3. type
pub_marker = b'\x01'
pvt_marker = b'\x02'
# 4. signature is the hash of the image, signed by the private key
# 5. JSON crypto blob data
[ crypto blob format ]
JSON:
{
"format_ver": "50",
"pubkey_alg": "rsa",
"pubkey_size": 4096,
"pubkey_pem": "MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAnvdAyn5JuiRcoL8s+rAV\nMpoEUioB1NTV97EDG4z/R5pm89v86UkH0xeeB6OS2EacsPHmbIY6oY0IXKA+0EX6\nSZdVSya2vv36fy/CByfHgZsDUxpzMnRZLdYbITBwil7keCTOC4EfnYIMUDsvrx6s\nA+BSEbR1rUkIXMe7NJ2Qssj68lXKMOfhrJ9wUgPLVSTIiDytiX4Wd+yAuo9lUqUk\nxt7FwjEEBV5Nj0yKZp2sJZnqp+pL5dsLsYz9xKNQHonMkGuj+3IthenTkfuXm9a6\nx+Qm3B+6AN4qBd7Uz65tffS2e2OQCzSRVoqEaRUrQKvQcSfJv+w0lh4xoZs41CJE\nc8XmmJeaDqt/zYBQWWYJlvZfpq0oh3mKGmHRtNOnKQmMd+FRJj/5fUvG7WedcHt1\noAkUg1qKu/HBgPNTVN9PWaikM1fA1E8T1koCYN0ecP29Zo8SHwcL6g82ou+fGtae\nSrXW0bFKV1JbF+hF3nBzCw+xDPAXXpUGPTwSXYZa6Gvgfckk4qP17vfFaR9f+hiL\nmW8GUmgfupvbapcG189M+UB9nDUSj3557TJpqItdbH5m4FGNv9tcMRYSwIniVVxw\n+F5FuT7nhd8vC+simwyjlB3hteICya1c7tVo5rav/LBBzHYg9ywPJCdZKUvN3qRE\n4Txbp7DC99x/xZhGck2Cpj8CAwEAAQ==",
"image_sig": "6acda44a9e492ddcc0e6ddadbdbd2cc20fdbb06a9264f36268b03aff921332919edb541d9bcdafa2b958276fb553682e5b67d92a127ec8d5d89b29774db86c50",
"metadata_sig": ""
}

View File

@ -1,215 +0,0 @@
[[[ Picseal ]]]
"crypto key sharing using your photos"
"exif data providing photo integrity, ownership, and crypto key"
[[ Formats]]
@ http://stackoverflow.com/questions/12749858/rsa-public-key-format
@ http://security.stackexchange.com/questions/57043/most-popular-rsa-key-format
DER: binary encoded format, sometimes Asn.1 BER-encoded
PEM: base64 format of the same DER-encoded file with header&footer lines
XML: xml format
-----BEGIN RSA PUBLIC KEY-----
-----END RSA PUBLIC KEY-----
---- BEGIN SSH2 PUBLIC KEY ----
---- END SSH2 PUBLIC KEY ----
[[ WolfSSL ]]
[ Compile Mac ]
@ https://www.wolfssl.com/wolfSSL/Docs-wolfssl-manual-toc.html
@ https://www.wolfssl.com/wolfSSL/Docs-wolfssl-manual-2-building-wolfssl.html
@ https://wolfssl.github.io/wolfcrypt-py/
$ brew install autoconf automake libtool
$ glibtoolize
$ git clone https://github.com/wolfssl/wolfssl.git
$ cd wolfssl/
$ ./autogen.sh
$ ./configure --help
$ ./configure --enable-sha512
$ make
"In order to prevent conflicts with Apple's own libtool we have prepended a "g"
so, you have instead: glibtool and glibtoolize."
[[ gexiv2 ]]
# gobject wrapper of the libexiv2 library (which is the engine for exiv2)
@ https://wiki.gnome.org/Projects/gexiv2
@ http://wiki.gnome.org/GObjectIntrospection
@ http://wiki.gnome.org/PyGObject/IntrospectionPorting
# API docs
@ http://lazka.github.io/pgi-docs/#GExiv2-0.10
[ XMP ]
# adding new XMP namespaces
@ http://dev.exiv2.org/boards/3/topics/1039
[ install ubuntu ]
$ sudo apt-get install libexiv2-dev libgexiv2-dev gir1.2-gexiv2-0.10
[ install mac ]
# install globally (python2)
$ brew install exiv2 gexiv2 pygobject3
# install for python3
$ brew reinstall pygobject3 --with-python3
[ build ]
$ git clone git://git.gnome.org/gexiv2
$ sudo apt-get install gobject-introspection
$ sudo apt-get install glib libgirepository1.0-dev
$ sudo apt-get install libglib2.0-dev libexiv2-dev python-gobject-dev
$
$ ./autogen.sh
$ ./configure --enable-introspection
[[ EXIF ]]
[ exiv2 ]
# BUILD
http://dev.exiv2.org/projects/exiv2/wiki/How_do_I_build_Exiv2_on_the_XYZ_platform
[ pyexiv2 ]
@ http://tilloy.net/dev/pyexiv2/
[ exiftool]
# perl program
@ http://www.sno.phy.queensu.ca/~phil/exiftool/
$ brew install exiftool
[[ exiftool]]
# perl program
# http://www.sno.phy.queensu.ca/~phil/exiftool/
$ brew install exiftool
[[ Competitors ]]
[ authentication ]
https://getclef.com/
[[ Debug ]]
$ exiv2 -ps image.jpg
[[ Crypto ]]
[ Public Key ]
# encrypt
@ https://pythonhosted.org/pycrypto/Crypto.Cipher.PKCS1_v1_5.PKCS115_Cipher-class.html#encrypt
[ OpenSSL ]
openssl genrsa -out ~/myTestKey.pem -passout pass:"f00bar" -des3 2048
openssl rsa -pubout -in ~/myTestKey.pem -passin pass:"f00bar" -out ~/myTestKey.pub
[ Cryptography.io ]
Fernet (Public Key)
@ https://cryptography.io/en/latest/fernet/
[[ MVP Plan ]]
[ C ]
libexiv --> exif read/write
libwolfss --> crypto generation
[ Functions ]
# load image file
picseal.init(image_file)
# create pub/priv key pair
# add new public key to exif
# store priv key in memory
picseal.add_new_key(CIPHER_TYPE)
# hash the image, encrypt hash with priv-key
# hash the image & specific exif tags, encrypt hash with priv-key
# add signatures to exif
picseal.seal_image(HASH_TYPE)
# write the image with public key, and signature
picseal.write_pub(FILE_HANDLE)
# write the image with private key, and signature
# ADD PIN??
picseal.write_priv(FILE_HANDLE)
[ seal ]
sha-512,public-key
[[ Libraries ]]
libexiv2-14 (= 0.25-2.1), libc6 (>= 2.14), libgcc1 (>= 1:4.1.1), libstdc++6 (>= 5.2)
[[ Crypto ]]
@ http://security.stackexchange.com/
@ http://security.stackexchange.com/questions/135946/when-should-i-generate-new-public-private-keys-using-rsa
[[ Images ]]
[ PIL Pillow ]
# use pillow, a PIL fork
@ https://github.com/python-pillow/Pillow
@ http://pillow.readthedocs.io/en/3.0.x/handbook/tutorial.html#reading-and-writing-images
# no python 3 version :(
ver 1.1.7, for Python 2.7, Nov 15 2009
[[ JPG ]]
@ http://stackoverflow.com/questions/4550296/how-to-identify-contents-of-a-byte-is-a-jpeg?rq=1
@ https://en.wikipedia.org/wiki/Magic_number_%28programming%29
@ http://www.effbot.org/imagingbook/image.htm#tag-Image.Image.tobitmap
[[ Testing ]]
[ crypto test ]
b'-----BEGIN PUBLIC KEY-----\nMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAnvdAyn5JuiRcoL8s+rAV\nMpoEUioB1NTV97EDG4z/R5pm89v86UkH0xeeB6OS2EacsPHmbIY6oY0IXKA+0EX6\nSZdVSya2vv36fy/CByfHgZsDUxpzMnRZLdYbITBwil7keCTOC4EfnYIMUDsvrx6s\nA+BSEbR1rUkIXMe7NJ2Qssj68lXKMOfhrJ9wUgPLVSTIiDytiX4Wd+yAuo9lUqUk\nxt7FwjEEBV5Nj0yKZp2sJZnqp+pL5dsLsYz9xKNQHonMkGuj+3IthenTkfuXm9a6\nx+Qm3B+6AN4qBd7Uz65tffS2e2OQCzSRVoqEaRUrQKvQcSfJv+w0lh4xoZs41CJE\nc8XmmJeaDqt/zYBQWWYJlv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xc0\x89.%\xeb\xdd\xc8.P\x03\x87\xe4C7e\xe9\xd1\x13\n\x83\xe9\x89\x0f^\xfb\xc8$\x95\x7f\xe3\x80G\xf9\x96_l\x03\x92\x01\x9e\xd1\x13\x9e\x8b\xdc-C\x02/^\xb5Nl\xcc\x7f\xb6\xb8v\x95\x998\x0c\x18?@\xaf\xaa\x1e\xea;gt\x83d(G\xefO\x1a\rq9>\xc4\xa5\x01-\xcd?q\x94\xf9\xa0\xa0\xe6}\x9aJjp\xa0\x05\xaf\xda\xf2\xc9\xd8\xf0\x1b\xbe\x0b\x80\xdc\x9c\xed\xabu\xc6\x0eT\x11\xbd8\x12\x10@\x9c\xf8\x97E\xea;\xcb\xf3\xaf\xf9\xc7\xad@\xf3#G\xc9&yE=\xa3nZ\xc7(9\xf15e\xae\xe4\xbdXmw\x98\xf5B\x885$w\x9b\x82\x89\xfa\xf6\xe9\xc9\xea\x95[22\xf4\xc9\xb9\xf9\xfb\xe2\xb4\xe8\xe7\xb2J\xc59\xac\x9e\xa9e\x13\xb4\x1c\xea\x18\xacy+\xb3\x01@$\xef\x15Ao\xb7Y\xf5]0I(\xd1\xd8E\x01^\xba\xa4W\x96D\xe5i\xf4e\x08c\xd37\x15\x1fb\xe5\xca\x9eAN^\xc0\xc8\x82\xa9\xb5N\xd2~\xc6d\xf7\xcbq\x02\x90\x1a#I\xf4\xf8\xe7i\xba\xcdQ\xeb\x87Agn\x8f'
text: b'attack at dawn'

View File

@ -1,79 +0,0 @@
#
# I tihnk this is support for the website =)
# instead of reading from a file, read from memory
# goal is to avoid reading/writing to the file system
#
from libs.jpg_bin import JpgBin
from libs.jpg_picseal import JpgPicSeal
class JpgBinWriteMem:
#
def __init__(self, jpg_in):
self.fhr = jpg_in
self.mem = none
#
# input is the Crypto Sig class
#
def writeJpgPicSealPub(self, crypto_sig, fp):
self.__writeJpgHeader()
ps = JpgPicSeal(crypto_sig)
ps.writePub(self.fhw)
self.__writeJpgImg(fp)
#
# input is the Crypto Sig class
#
def writeJpgPicSealPvt(self, crypto_sig, fp):
self.__writeJpgHeader()
ps = JpgPicSeal(crypto_sig)
ps.writePvt(self.fhw)
self.__writeJpgImg(fp)
#
def __writeJpgImg(self, fp):
self.__writeJpgMetadata(fp.markers_meta)
self.__writeJpgImgData(fp.markers_img)
self.__writeJpgFooter()
self.fhw.flush()
self.fhw.close()
#
# array of the marker information
#
def __writeJpgMetadata(self, markers):
for marker in markers:
self.fhr.seek(marker.fpos)
data = self.fhr.read(marker.len)
self.fhw.write(data)
self.fhw.flush()
#
# array of the marker information
#
def __writeJpgImgData(self, markers):
for marker in markers:
# most of the image data is sequential
cpos = self.fhr.tell()
if (marker.fpos != cpos):
self.fhr.seek(marker.fpos)
data = self.fhr.read(marker.len)
self.fhw.write(data)
self.fhw.flush()
#
def __writeJpgHeader(self):
self.fhw.write(bytes(JpgBin.soi_marker))
#
def __writeJpgFooter(self):
self.fhw.write(bytes(JpgBin.eof_marker))

View File

@ -1,5 +1,5 @@
#
# This Class contains information for the jpg markers, length, and position in the file
# This Class contains information for the jpg markers, length, an position in the file
#
class JpgFingerprint:

View File

@ -84,10 +84,10 @@ def parseArgs():
if (args.file):
processImage(args.file)
else:
print('***** ***** ***** *****')
print('ERROR: missing image file')
print(' picseal.py -f <image_file>')
print('***** ***** ***** *****')
print('Create PicSeal images')
print(' picseal.py -i <image_file>')
print('\n***** ***** ***** *****\n')
parser.print_help()