diff --git a/docs/README_DSN b/docs/README_DSN new file mode 100644 index 0000000..50a3979 --- /dev/null +++ b/docs/README_DSN @@ -0,0 +1,33 @@ + + +[[ 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 keys + b. sign hash data with priv key +4) Write new PicSeal file + a. write encrypted original metadata + b. write PicSeal metadata + i. write JSON + b. write image data + + +[[ PicSeal Metadata ]] +JSON Format + +{ + "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": "" +} + diff --git a/docs/picseal_metadata.json b/docs/picseal_metadata.json new file mode 100644 index 0000000..2c4941f --- /dev/null +++ b/docs/picseal_metadata.json @@ -0,0 +1,7 @@ +{ + "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" +} \ No newline at end of file diff --git a/test/GExiv2_.py b/ex/GExiv2_.py similarity index 100% rename from test/GExiv2_.py rename to ex/GExiv2_.py diff --git a/test/exif_r.py b/ex/exif_r.py similarity index 100% rename from test/exif_r.py rename to ex/exif_r.py diff --git a/test/exif_w.py b/ex/exif_w.py similarity index 100% rename from test/exif_w.py rename to ex/exif_w.py diff --git a/test/sort.py b/ex/sort.py similarity index 100% rename from test/sort.py rename to ex/sort.py diff --git a/test/bmw_rim_640.jpg b/img/bmw_rim_640.jpg similarity index 100% rename from test/bmw_rim_640.jpg rename to img/bmw_rim_640.jpg diff --git a/test/bmw_rim_full.jpg b/img/bmw_rim_full.jpg similarity index 100% rename from test/bmw_rim_full.jpg rename to img/bmw_rim_full.jpg diff --git a/test/space.jpg b/img/space.jpg similarity index 100% rename from test/space.jpg rename to img/space.jpg diff --git a/test/space_test.jpg b/img/space_test.jpg similarity index 100% rename from test/space_test.jpg rename to img/space_test.jpg diff --git a/libs/jpg_bin.py b/libs/jpg_bin.py index fefb658..0886b5d 100644 --- a/libs/jpg_bin.py +++ b/libs/jpg_bin.py @@ -61,7 +61,7 @@ class JpgBin: return False while(self.continue_process): - self.findAllMarker() + self.findAllMarkers() self.getMoreBytes() return True @@ -70,7 +70,7 @@ class JpgBin: # def genHash(self, file_h, hash_h): self.hh = hash_h - self.processFile(file_h) + #self.processFile(file_h) while(self.continue_process): if (self.findMarker(self.makers['SOS'])): @@ -120,7 +120,7 @@ class JpgBin: pass # - def findAllMarker(self): + def findAllMarkers(self): (word_b,) = struct.unpack('>H', self.data_buf[self.data_idx:self.data_idx+2]) hex_str = word_b.to_bytes(2, 'big').hex() # RST 0xD(n) (n==0..7) diff --git a/libs/jpg_tools.py b/libs/jpg_tools.py index b559f8c..b475ca1 100644 --- a/libs/jpg_tools.py +++ b/libs/jpg_tools.py @@ -12,9 +12,14 @@ class JpgTools: def __init__(self): pass + # + # process a jpg file, read only + # def getJpgBin(self, fname): self.processFile(fname) + # + # process a jpg file, create new jpg with crypto keys # def jpgHash(self): self.fh = open(fname, "rb") diff --git a/test/decrypt_rsa.py b/test/decrypt_rsa.py deleted file mode 100644 index 7cab933..0000000 --- a/test/decrypt_rsa.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/python -# -# -from Crypto.PublicKey import RSA - -def decrypt(): - externKey="/home/borrajax/myTestKey.pub" - publickey = open(externKey, "r") - decryptor = RSA.importKey(publickey, passphrase="f00bar") - retval=None - - file = open("/tmp/cryptThingy.txt", "rb") - retval = decryptor.decrypt(file.read()) - file.close() - return retval - - -if __name__ == "__main__": - decryptedThingy=decrypt() - print "Decrypted: %s" % decryptedThingy diff --git a/test/encrypt_rsa.py b/test/encrypt_rsa.py deleted file mode 100644 index 081ac37..0000000 --- a/test/encrypt_rsa.py +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/python -# -# -from Crypto.PublicKey import RSA - -def encrypt(message): - externKey="/home/borrajax/myTestKey.pem" - privatekey = open(externKey, "r") - encryptor = RSA.importKey(privatekey, passphrase="f00bar") - encriptedData=encryptor.encrypt(message, 0) - file = open("/tmp/cryptThingy.txt", "wb") - file.write(encriptedData[0]) - file.close() - -if __name__ == "__main__": - encryptedThingy=encrypt("Loren ipsum") - \ No newline at end of file diff --git a/test/hieee.sdf.sdf.. b/test/hieee.sdf.sdf.. deleted file mode 100644 index e69de29..0000000 diff --git a/test/signature_test.py b/test/signature_test.py index 3b34ad1..502bd47 100644 --- a/test/signature_test.py +++ b/test/signature_test.py @@ -1,7 +1,8 @@ # # Test Signature Class # -from ..libs.crypto_pub import Signature +# run from root of project +from libs.crypto_pub import Signature msg = b'Hieee, this is a test =)'