Finalize v1.33
This commit is contained in:
parent
a3004f091e
commit
08c9974917
|
@ -2,7 +2,7 @@ package main
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
Picocrypt v1.32
|
Picocrypt v1.33
|
||||||
Copyright (c) Evan Su
|
Copyright (c) Evan Su
|
||||||
Released under a GNU GPL v3 License
|
Released under a GNU GPL v3 License
|
||||||
https://github.com/HACKERALERT/Picocrypt
|
https://github.com/HACKERALERT/Picocrypt
|
||||||
|
@ -58,7 +58,7 @@ var TRANSPARENT = color.RGBA{0x00, 0x00, 0x00, 0x00}
|
||||||
|
|
||||||
// Generic variables
|
// Generic variables
|
||||||
var window *giu.MasterWindow
|
var window *giu.MasterWindow
|
||||||
var version = "v1.32"
|
var version = "v1.33"
|
||||||
var dpi float32
|
var dpi float32
|
||||||
var mode string
|
var mode string
|
||||||
var working bool
|
var working bool
|
||||||
|
@ -476,6 +476,11 @@ func draw() {
|
||||||
}
|
}
|
||||||
return giu.InputTextFlagsNone
|
return giu.InputTextFlagsNone
|
||||||
}()),
|
}()),
|
||||||
|
giu.Custom(func() {
|
||||||
|
if !commentsDisabled {
|
||||||
|
giu.Tooltip("Note: comments are not encrypted!").Build()
|
||||||
|
}
|
||||||
|
}),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
giu.Style().SetDisabled((len(keyfiles) == 0 && password == "") || (mode == "encrypt" && password != cpassword)).To(
|
giu.Style().SetDisabled((len(keyfiles) == 0 && password == "") || (mode == "encrypt" && password != cpassword)).To(
|
||||||
|
@ -1466,17 +1471,34 @@ func work() {
|
||||||
popupStatus = "Reading keyfiles..."
|
popupStatus = "Reading keyfiles..."
|
||||||
giu.Update()
|
giu.Update()
|
||||||
|
|
||||||
|
var keyfileTotal int64
|
||||||
|
for _, path := range keyfiles {
|
||||||
|
stat, _ := os.Stat(path)
|
||||||
|
keyfileTotal += stat.Size()
|
||||||
|
}
|
||||||
|
|
||||||
if keyfileOrdered { // If order matters, hash progressively
|
if keyfileOrdered { // If order matters, hash progressively
|
||||||
var tmp = sha3.New256()
|
var tmp = sha3.New256()
|
||||||
|
var keyfileDone int
|
||||||
|
|
||||||
// For each keyfile...
|
// For each keyfile...
|
||||||
for _, path := range keyfiles {
|
for _, path := range keyfiles {
|
||||||
fin, _ := os.Open(path)
|
fin, _ := os.Open(path)
|
||||||
stat, _ := os.Stat(path)
|
for { // Read in chunks of 1 MiB
|
||||||
data := make([]byte, stat.Size())
|
data := make([]byte, MiB)
|
||||||
fin.Read(data) // Read the keyfile
|
size, err := fin.Read(data)
|
||||||
|
if err != nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
data = data[:size]
|
||||||
|
tmp.Write(data) // Hash the data
|
||||||
|
|
||||||
|
// Update progress
|
||||||
|
keyfileDone += size
|
||||||
|
progress = float32(keyfileDone) / float32(keyfileTotal)
|
||||||
|
giu.Update()
|
||||||
|
}
|
||||||
fin.Close()
|
fin.Close()
|
||||||
tmp.Write(data) // Hash the data
|
|
||||||
}
|
}
|
||||||
keyfileKey = tmp.Sum(nil) // Get the SHA3-256
|
keyfileKey = tmp.Sum(nil) // Get the SHA3-256
|
||||||
|
|
||||||
|
@ -1485,17 +1507,29 @@ func work() {
|
||||||
tmp.Write(keyfileKey)
|
tmp.Write(keyfileKey)
|
||||||
keyfileHash = tmp.Sum(nil)
|
keyfileHash = tmp.Sum(nil)
|
||||||
} else { // If order doesn't matter, hash individually and combine
|
} else { // If order doesn't matter, hash individually and combine
|
||||||
|
var keyfileDone int
|
||||||
|
|
||||||
|
// For each keyfile...
|
||||||
for _, path := range keyfiles {
|
for _, path := range keyfiles {
|
||||||
fin, _ := os.Open(path)
|
fin, _ := os.Open(path)
|
||||||
stat, _ := os.Stat(path)
|
tmp := sha3.New256()
|
||||||
data := make([]byte, stat.Size())
|
for { // Read in chunks of 1 MiB
|
||||||
fin.Read(data) // Read the keyfile
|
data := make([]byte, MiB)
|
||||||
|
size, err := fin.Read(data)
|
||||||
|
if err != nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
data = data[:size]
|
||||||
|
tmp.Write(data) // Hash the data
|
||||||
|
|
||||||
|
// Update progress
|
||||||
|
keyfileDone += size
|
||||||
|
progress = float32(keyfileDone) / float32(keyfileTotal)
|
||||||
|
giu.Update()
|
||||||
|
}
|
||||||
fin.Close()
|
fin.Close()
|
||||||
|
|
||||||
// Get the SHA3-256
|
sum := tmp.Sum(nil) // Get the SHA3-256
|
||||||
tmp := sha3.New256()
|
|
||||||
tmp.Write(data)
|
|
||||||
sum := tmp.Sum(nil)
|
|
||||||
|
|
||||||
// XOR keyfile hash with 'keyfileKey'
|
// XOR keyfile hash with 'keyfileKey'
|
||||||
if keyfileKey == nil {
|
if keyfileKey == nil {
|
||||||
|
@ -1571,6 +1605,19 @@ func work() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(keyfiles) > 0 || keyfile {
|
if len(keyfiles) > 0 || keyfile {
|
||||||
|
// Prevent an even number of duplicate keyfiles
|
||||||
|
if bytes.Equal(keyfileKey, make([]byte, 32)) {
|
||||||
|
mainStatus = "Duplicate keyfiles detected."
|
||||||
|
mainStatusColor = RED
|
||||||
|
fin.Close()
|
||||||
|
if len(allFiles) > 1 || len(onlyFolders) > 0 || compress {
|
||||||
|
os.Remove(inputFile)
|
||||||
|
}
|
||||||
|
fout.Close()
|
||||||
|
os.Remove(fout.Name())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// XOR the encryption key with the keyfile key
|
// XOR the encryption key with the keyfile key
|
||||||
tmp := key
|
tmp := key
|
||||||
key = make([]byte, 32)
|
key = make([]byte, 32)
|
||||||
|
|
Loading…
Reference in New Issue