MOD: dusted off this project. made some modifications. verified it is working
This commit is contained in:
parent
912a9a123c
commit
3d1fed9049
|
@ -1,3 +1,11 @@
|
|||
# Project specific files
|
||||
#
|
||||
# binaries
|
||||
*.jpg
|
||||
|
||||
|
||||
# Python Files
|
||||
#
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
|
@ -37,11 +45,8 @@ coverage.xml
|
|||
*.mo
|
||||
*.pot
|
||||
|
||||
# Django stuff:
|
||||
*.log
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
|
||||
#binaries
|
||||
*.jpg
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
[[[ 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
|
||||
|
||||
|
||||
|
||||
|
||||
[[ 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
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
[[[ PicSeal Design Document ]]]
|
||||
|
||||
|
||||
[[ JPG file parse Pseudo Code ]]
|
||||
|
@ -10,7 +11,7 @@
|
|||
2) Generate Hash
|
||||
a. hash all image data
|
||||
3) Digital Signature
|
||||
a. generate new public keys
|
||||
a. generate new public key pair
|
||||
b. sign hash data with priv key
|
||||
4) Write new PicSeal Public file
|
||||
a. write encrypted original metadata
|
||||
|
@ -23,9 +24,31 @@
|
|||
c. write image data
|
||||
|
||||
|
||||
[[ PicSeal Metadata ]]
|
||||
JSON Format
|
||||
|
||||
[[ 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",
|
|
@ -38,7 +38,7 @@ $ make
|
|||
|
||||
|
||||
"In order to prevent conflicts with Apple's own libtool we have prepended a "g"
|
||||
so, you have instead: glibtool and glibtoolize.""
|
||||
so, you have instead: glibtool and glibtoolize."
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
#
|
||||
# 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))
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# This Class contains information for the jpg markers, length, an position in the file
|
||||
# This Class contains information for the jpg markers, length, and position in the file
|
||||
#
|
||||
class JpgFingerprint:
|
||||
|
||||
|
|
|
@ -84,10 +84,10 @@ def parseArgs():
|
|||
if (args.file):
|
||||
processImage(args.file)
|
||||
else:
|
||||
print('Create PicSeal images')
|
||||
print(' picseal.py -i <image_file>')
|
||||
print('\n***** ***** ***** *****\n')
|
||||
parser.print_help()
|
||||
print('***** ***** ***** *****')
|
||||
print('ERROR: missing image file')
|
||||
print(' picseal.py -f <image_file>')
|
||||
print('***** ***** ***** *****')
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue