mirror of
https://github.com/HACKERALERT/Picocrypt.git
synced 2025-01-04 21:58:23 +00:00
Reed-Solomon fully working now
This commit is contained in:
parent
63554a0ba5
commit
7abaac4352
1 changed files with 34 additions and 11 deletions
|
@ -127,7 +127,7 @@ var shredding = "Ready."
|
||||||
var password string
|
var password string
|
||||||
var cPassword string // Confirm password text entry string variable
|
var cPassword string // Confirm password text entry string variable
|
||||||
var keyfilePath string
|
var keyfilePath string
|
||||||
var keyfileLabel = "Use a keyfile (experimental)"
|
var keyfileLabel = "Use a keyfile (Beta)"
|
||||||
var metadata string
|
var metadata string
|
||||||
var shredTemp bool
|
var shredTemp bool
|
||||||
var paranoid bool
|
var paranoid bool
|
||||||
|
@ -381,7 +381,7 @@ func startUI(){
|
||||||
giu.Checkbox("Fast mode (slightly less secure, not as durable)",&fast).Build()
|
giu.Checkbox("Fast mode (slightly less secure, not as durable)",&fast).Build()
|
||||||
giu.Checkbox("Paranoid mode (extremely secure, but slower)",¶noid).Build()
|
giu.Checkbox("Paranoid mode (extremely secure, but slower)",¶noid).Build()
|
||||||
giu.Row(
|
giu.Row(
|
||||||
giu.Checkbox("Encode with Reed-Solomon to prevent corruption",&reedsolo),
|
giu.Checkbox("Encode with Reed-Solomon to prevent corruption (slow)",&reedsolo),
|
||||||
giu.Button("?").Size(24,25).OnClick(func(){
|
giu.Button("?").Size(24,25).OnClick(func(){
|
||||||
browser.OpenURL("https://bit.ly/3A2V7LR")
|
browser.OpenURL("https://bit.ly/3A2V7LR")
|
||||||
}),
|
}),
|
||||||
|
@ -705,7 +705,7 @@ func onDrop(names []string){
|
||||||
fin.Read(flags)
|
fin.Read(flags)
|
||||||
flags,err = rsDecode(rs5,flags)
|
flags,err = rsDecode(rs5,flags)
|
||||||
if err!=nil{
|
if err!=nil{
|
||||||
_status = "File is corrupt and cannot be decrypted."
|
_status = "Input file is corrupt and cannot be decrypted."
|
||||||
_status_color = color.RGBA{0xff,0x00,0x00,255}
|
_status_color = color.RGBA{0xff,0x00,0x00,255}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -801,6 +801,7 @@ func work(){
|
||||||
status = "Starting..."
|
status = "Starting..."
|
||||||
// Set some variables
|
// Set some variables
|
||||||
working = true
|
working = true
|
||||||
|
padded := false
|
||||||
//headerBroken := false
|
//headerBroken := false
|
||||||
//reedsoloFixed := 0
|
//reedsoloFixed := 0
|
||||||
//reedsoloErrors := 0
|
//reedsoloErrors := 0
|
||||||
|
@ -911,6 +912,9 @@ func work(){
|
||||||
|
|
||||||
stat,_ := os.Stat(inputFile)
|
stat,_ := os.Stat(inputFile)
|
||||||
total := stat.Size()
|
total := stat.Size()
|
||||||
|
if mode=="decrypt"{
|
||||||
|
total -= 789
|
||||||
|
}
|
||||||
|
|
||||||
// XChaCha20's max message size is 256 GiB
|
// XChaCha20's max message size is 256 GiB
|
||||||
if total>256*1073741824{
|
if total>256*1073741824{
|
||||||
|
@ -970,6 +974,10 @@ func work(){
|
||||||
if reedsolo{
|
if reedsolo{
|
||||||
flags[3] = 1
|
flags[3] = 1
|
||||||
}
|
}
|
||||||
|
fmt.Println(total,total%1048576>=1048448)
|
||||||
|
if total%1048576>=1048448{
|
||||||
|
flags[4] = 1
|
||||||
|
}
|
||||||
//fmt.Println("flags:",flags)
|
//fmt.Println("flags:",flags)
|
||||||
flags = rsEncode(rs5,flags)
|
flags = rsEncode(rs5,flags)
|
||||||
fout.Write(flags)
|
fout.Write(flags)
|
||||||
|
@ -1036,6 +1044,7 @@ func work(){
|
||||||
paranoid = flags[1]==1
|
paranoid = flags[1]==1
|
||||||
keyfile = flags[2]==1
|
keyfile = flags[2]==1
|
||||||
reedsolo = flags[3]==1
|
reedsolo = flags[3]==1
|
||||||
|
padded = flags[4]==1
|
||||||
|
|
||||||
salt = make([]byte,48)
|
salt = make([]byte,48)
|
||||||
fin.Read(salt)
|
fin.Read(salt)
|
||||||
|
@ -1070,7 +1079,7 @@ func work(){
|
||||||
if keep{
|
if keep{
|
||||||
kept = true
|
kept = true
|
||||||
}else{
|
}else{
|
||||||
_status = "The header is corrupt and the file cannot be decrypted."
|
_status = "The header is corrupt and the input file cannot be decrypted."
|
||||||
_status_color = color.RGBA{0xff,0x00,0x00,255}
|
_status_color = color.RGBA{0xff,0x00,0x00,255}
|
||||||
fin.Close()
|
fin.Close()
|
||||||
return
|
return
|
||||||
|
@ -1258,6 +1267,7 @@ func work(){
|
||||||
//fmt.Println(data[:10])
|
//fmt.Println(data[:10])
|
||||||
}
|
}
|
||||||
chacha20.XORKeyStream(_data,data)
|
chacha20.XORKeyStream(_data,data)
|
||||||
|
mac.Write(_data)
|
||||||
if reedsolo{
|
if reedsolo{
|
||||||
copy(data,_data)
|
copy(data,_data)
|
||||||
_data = nil
|
_data = nil
|
||||||
|
@ -1279,15 +1289,14 @@ func work(){
|
||||||
_data = append(_data,rsEncode(rs128,pad(tmp))...)
|
_data = append(_data,rsEncode(rs128,pad(tmp))...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mac.Write(_data)
|
|
||||||
}else{
|
}else{
|
||||||
mac.Write(data)
|
|
||||||
if reedsolo{
|
if reedsolo{
|
||||||
copy(_data,data)
|
copy(_data,data)
|
||||||
//_data = append(_data,data...)
|
//_data = append(_data,data...)
|
||||||
data = nil
|
data = nil
|
||||||
fmt.Println(len(_data),len(data))
|
fmt.Println(len(_data),len(data))
|
||||||
if len(_data)==1114112{
|
if len(_data)==1114112{
|
||||||
|
fmt.Println(done,total,padded)
|
||||||
for i:=0;i<1114112;i+=136{
|
for i:=0;i<1114112;i+=136{
|
||||||
tmp := _data[i:i+136]
|
tmp := _data[i:i+136]
|
||||||
tmp,err = rsDecode(rs128,tmp)
|
tmp,err = rsDecode(rs128,tmp)
|
||||||
|
@ -1303,6 +1312,9 @@ func work(){
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if i==1113976&&done+1114112>=int(total)&&padded{
|
||||||
|
tmp = unpad(tmp)
|
||||||
|
}
|
||||||
data = append(data,tmp...)
|
data = append(data,tmp...)
|
||||||
//fmt.Println(len(data))
|
//fmt.Println(len(data))
|
||||||
}
|
}
|
||||||
|
@ -1345,14 +1357,13 @@ func work(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tmp = unpad(tmp)
|
tmp = unpad(tmp)
|
||||||
/*for _,j := range tmp{
|
fmt.Println(len(tmp))
|
||||||
data = append(data,j)
|
|
||||||
}*/
|
|
||||||
data = append(data,tmp...)
|
data = append(data,tmp...)
|
||||||
}
|
}
|
||||||
fmt.Println("data outside loop",len(data))
|
fmt.Println("data outside loop",len(data))
|
||||||
_data = make([]byte,len(data))
|
_data = make([]byte,len(data))
|
||||||
}
|
}
|
||||||
|
mac.Write(data)
|
||||||
fmt.Println("datac",len(data))
|
fmt.Println("datac",len(data))
|
||||||
chacha20.XORKeyStream(_data,data)
|
chacha20.XORKeyStream(_data,data)
|
||||||
if paranoid{
|
if paranoid{
|
||||||
|
@ -1500,7 +1511,7 @@ func work(){
|
||||||
|
|
||||||
// If user chose to keep a corrupted/modified file, let them know
|
// If user chose to keep a corrupted/modified file, let them know
|
||||||
if kept{
|
if kept{
|
||||||
_status = "The input is corrupted and/or modified. Please be careful."
|
_status = "The input file is corrupted and/or modified. Please be careful."
|
||||||
_status_color = color.RGBA{0xff,0xff,0x00,255}
|
_status_color = color.RGBA{0xff,0xff,0x00,255}
|
||||||
}else{
|
}else{
|
||||||
_status = "Completed."
|
_status = "Completed."
|
||||||
|
@ -1516,7 +1527,7 @@ func work(){
|
||||||
|
|
||||||
// This function is run if an issue occurs during decryption
|
// This function is run if an issue occurs during decryption
|
||||||
func broken(){
|
func broken(){
|
||||||
_status = "The file is either corrupted or intentionally modified."
|
_status = "The input file is either corrupted or intentionally modified."
|
||||||
_status_color = color.RGBA{0xff,0x00,0x00,255}
|
_status_color = color.RGBA{0xff,0x00,0x00,255}
|
||||||
if recombine{
|
if recombine{
|
||||||
os.Remove(inputFile)
|
os.Remove(inputFile)
|
||||||
|
@ -1536,6 +1547,13 @@ func generateChecksums(file string){
|
||||||
cs_sha3_256 = ""
|
cs_sha3_256 = ""
|
||||||
cs_blake2b = ""
|
cs_blake2b = ""
|
||||||
cs_blake2s = ""
|
cs_blake2s = ""
|
||||||
|
md5_color = color.RGBA{0x10,0x10,0x10,255}
|
||||||
|
sha1_color = color.RGBA{0x10,0x10,0x10,255}
|
||||||
|
sha256_color = color.RGBA{0x10,0x10,0x10,255}
|
||||||
|
sha3_256_color = color.RGBA{0x10,0x10,0x10,255}
|
||||||
|
blake2b_color = color.RGBA{0x10,0x10,0x10,255}
|
||||||
|
blake2s_color = color.RGBA{0x10,0x10,0x10,255}
|
||||||
|
cs_validate = ""
|
||||||
|
|
||||||
if md5_selected{
|
if md5_selected{
|
||||||
cs_md5 = "Calculating..."
|
cs_md5 = "Calculating..."
|
||||||
|
@ -1618,6 +1636,8 @@ func generateChecksums(file string){
|
||||||
if blake2s_selected{
|
if blake2s_selected{
|
||||||
cs_blake2s = hex.EncodeToString(crc_blake2s.Sum(nil))
|
cs_blake2s = hex.EncodeToString(crc_blake2s.Sum(nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fin.Close()
|
||||||
giu.Update()
|
giu.Update()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1819,6 +1839,9 @@ func rsDecode(rs *infectious.FEC,data []byte) ([]byte,error){
|
||||||
}
|
}
|
||||||
res,err := rs.Decode(nil,tmp)
|
res,err := rs.Decode(nil,tmp)
|
||||||
if err!=nil{
|
if err!=nil{
|
||||||
|
if rs.Total()==136{
|
||||||
|
return data[:128],err
|
||||||
|
}
|
||||||
return data[:rs.Total()/3],err
|
return data[:rs.Total()/3],err
|
||||||
}
|
}
|
||||||
return res,nil
|
return res,nil
|
||||||
|
|
Loading…
Reference in a new issue