MOD: restructured folders and files
|
@ -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": ""
|
||||||
|
}
|
||||||
|
|
|
@ -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"
|
||||||
|
}
|
Before Width: | Height: | Size: 120 KiB After Width: | Height: | Size: 120 KiB |
Before Width: | Height: | Size: 1.7 MiB After Width: | Height: | Size: 1.7 MiB |
Before Width: | Height: | Size: 1.1 MiB After Width: | Height: | Size: 1.1 MiB |
Before Width: | Height: | Size: 1.1 MiB After Width: | Height: | Size: 1.1 MiB |
|
@ -61,7 +61,7 @@ class JpgBin:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
while(self.continue_process):
|
while(self.continue_process):
|
||||||
self.findAllMarker()
|
self.findAllMarkers()
|
||||||
self.getMoreBytes()
|
self.getMoreBytes()
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
@ -70,7 +70,7 @@ class JpgBin:
|
||||||
#
|
#
|
||||||
def genHash(self, file_h, hash_h):
|
def genHash(self, file_h, hash_h):
|
||||||
self.hh = hash_h
|
self.hh = hash_h
|
||||||
self.processFile(file_h)
|
#self.processFile(file_h)
|
||||||
|
|
||||||
while(self.continue_process):
|
while(self.continue_process):
|
||||||
if (self.findMarker(self.makers['SOS'])):
|
if (self.findMarker(self.makers['SOS'])):
|
||||||
|
@ -120,7 +120,7 @@ class JpgBin:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#
|
#
|
||||||
def findAllMarker(self):
|
def findAllMarkers(self):
|
||||||
(word_b,) = struct.unpack('>H', self.data_buf[self.data_idx:self.data_idx+2])
|
(word_b,) = struct.unpack('>H', self.data_buf[self.data_idx:self.data_idx+2])
|
||||||
hex_str = word_b.to_bytes(2, 'big').hex()
|
hex_str = word_b.to_bytes(2, 'big').hex()
|
||||||
# RST 0xD(n) (n==0..7)
|
# RST 0xD(n) (n==0..7)
|
||||||
|
|
|
@ -12,9 +12,14 @@ class JpgTools:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
#
|
||||||
|
# process a jpg file, read only
|
||||||
|
#
|
||||||
def getJpgBin(self, fname):
|
def getJpgBin(self, fname):
|
||||||
self.processFile(fname)
|
self.processFile(fname)
|
||||||
|
|
||||||
|
#
|
||||||
|
# process a jpg file, create new jpg with crypto keys
|
||||||
#
|
#
|
||||||
def jpgHash(self):
|
def jpgHash(self):
|
||||||
self.fh = open(fname, "rb")
|
self.fh = open(fname, "rb")
|
||||||
|
|
|
@ -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
|
|
|
@ -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")
|
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
#
|
#
|
||||||
# Test Signature Class
|
# 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 =)'
|
msg = b'Hieee, this is a test =)'
|
||||||
|
|
||||||
|
|