diff --git a/libs/jpg_bin.py b/libs/jpg_bin.py index 6a1fa52..3c65454 100644 --- a/libs/jpg_bin.py +++ b/libs/jpg_bin.py @@ -1,5 +1,5 @@ # -# +# This Class handles the binary parsing of a jpg file # # # 0xFF,0xD8 - Start of Image (0xFFD8FF to be used as JPG file marker) @@ -258,13 +258,3 @@ class JpgBin: def __repr__(self): return repr(self.jpg_fp) - # - def findMarkers222(self): - last_idx = len(self.data_buf) - - while ord(self.data_buf[self.data_idx]) != 0xFF: - self.data_idx = self.data_idx+1 - - for idx in range(last_idx): - pass - diff --git a/libs/jpg_bin_w.py b/libs/jpg_bin_w.py new file mode 100644 index 0000000..10731f9 --- /dev/null +++ b/libs/jpg_bin_w.py @@ -0,0 +1,24 @@ +# +# +# +class JpgBinWrite: + + soi = 0xffd8 + + def __init__(self): + pass + + + def writeJpgPicSeal(self): + pass + + + def writeJpgMetadata(self): + pass + + + # + def writeJpgImgData(self): + pass + + diff --git a/libs/jpg_fp.py b/libs/jpg_fp.py index 5a65860..8436c34 100644 --- a/libs/jpg_fp.py +++ b/libs/jpg_fp.py @@ -1,5 +1,5 @@ # -# +# This Class contains information for the jpg markers, length, an position in the file # class JpgFingerprint: @@ -55,7 +55,7 @@ class JpgMarker: self.hex = mhex self.hexstr = self.hex.to_bytes(2, 'big').hex() self.fpos = fpos - self.len = mlen + self.len = mlen self.type = mstr diff --git a/libs/jpg_picseal.py b/libs/jpg_picseal.py index 616289c..7a1bf38 100644 --- a/libs/jpg_picseal.py +++ b/libs/jpg_picseal.py @@ -8,18 +8,15 @@ class JpgPicSeal: def __init_(self): - self.pubkey = None - self.pvtkey = None - self.imghash = None - self.imgsig = None + self.sig = None pass # - def writePicSealJpg(self, fname): + def serilize(self, fname): pass # - def readPicSealJpg(self, fname): + def deserialize(self, fname): pass diff --git a/libs/jpg_tools.py b/libs/jpg_proc.py similarity index 80% rename from libs/jpg_tools.py rename to libs/jpg_proc.py index ab8eea5..b374c66 100644 --- a/libs/jpg_tools.py +++ b/libs/jpg_proc.py @@ -7,10 +7,11 @@ from libs.jpg_bin import JpgBin from libs.crypto_pub import Signature -class JpgTools: +class JpgProc: def __init__(self): self.fh = None + self.fn = "" self.jpg = None self.sig = None self.is_processed = False @@ -18,8 +19,9 @@ class JpgTools: # # process a jpg file, read only # - def getJpgBin(self, fname): + def jpgProc(self, fname): self.fh = open(fname, "rb") + self.fn = fname self.jpg = JpgBin() retval = self.jpg.processFile(self.fh) logging.info("processFile()=={}".format(retval)) @@ -31,10 +33,18 @@ class JpgTools: # def jpgHash(self): if (not self.is_processed): - self.getJpgBin(fname) + return 0xdeadbeef # hash the jpg image data self.sig = Signature() img_hash = self.jpg.genHash(self.sig.hh) logging.info("img_hash-size=={}, img_hash=={}".format(len(img_hash), img_hash)) return img_hash + + + def writePicSealJpg(self, fname=None): + if not fname: + pass + pass + + diff --git a/picseal.py b/picseal.py index 06d2b1d..3e67841 100644 --- a/picseal.py +++ b/picseal.py @@ -7,7 +7,7 @@ import logging from shutil import copyfile #from subprocess import Popen, PIPE, check_call from libs.toolbox import Toolbox -from libs.jpg_tools import JpgTools +from libs.jpg_proc import JpgProc printall = False printmeta = False @@ -22,8 +22,8 @@ def main(): # create new pub keys, sign hash # export signature & public key to a new image file def processImage(image_fn): - jpg = JpgTools() - jpg_bin = jpg.getJpgBin(image_fn) + jpg = JpgProc() + jpg.getProc(image_fn) img_hash = jpg.jpgHash() printImageInfo(jpg_bin)