Fix scaling issue

This commit is contained in:
Evan Su 2022-08-11 21:41:36 -04:00 committed by GitHub
parent 5c835d74fa
commit 98afbfbe02
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 23 additions and 13 deletions

View File

@ -28,8 +28,10 @@ import (
"os" "os"
"path/filepath" "path/filepath"
"regexp" "regexp"
"runtime"
"strconv" "strconv"
"strings" "strings"
"syscall"
"time" "time"
"github.com/HACKERALERT/clipboard" "github.com/HACKERALERT/clipboard"
@ -565,6 +567,7 @@ func draw() {
if file == "" || err != nil { if file == "" || err != nil {
return return
} }
file = strings.Split(file, ".")[0]
// Add the correct extensions // Add the correct extensions
if mode == "encrypt" { if mode == "encrypt" {
@ -895,7 +898,7 @@ func work() {
// Cryptography values // Cryptography values
var salt []byte // Argon2 salt, 16 bytes var salt []byte // Argon2 salt, 16 bytes
var hkdfSalt []byte // HKDF-SHA3 salt, 32 bytes var hkdfSalt []byte // HKDF-SHA3 salt, 32 bytes
var serpentSalt []byte // Serpent salt, 16 bytes var serpentIV []byte // Serpent IV, 16 bytes
var nonce []byte // 24-byte XChaCha20 nonce var nonce []byte // 24-byte XChaCha20 nonce
var keyHash []byte // SHA3-512 hash of encryption key var keyHash []byte // SHA3-512 hash of encryption key
var keyHashRef []byte // Same as 'keyHash', but used for comparison var keyHashRef []byte // Same as 'keyHash', but used for comparison
@ -1106,7 +1109,7 @@ func work() {
// Set up cryptographic values // Set up cryptographic values
salt = make([]byte, 16) salt = make([]byte, 16)
hkdfSalt = make([]byte, 32) hkdfSalt = make([]byte, 32)
serpentSalt = make([]byte, 16) serpentIV = make([]byte, 16)
nonce = make([]byte, 24) nonce = make([]byte, 24)
// Write the program version to file // Write the program version to file
@ -1146,13 +1149,13 @@ func work() {
// Fill values with Go's CSPRNG // Fill values with Go's CSPRNG
rand.Read(salt) rand.Read(salt)
rand.Read(hkdfSalt) rand.Read(hkdfSalt)
rand.Read(serpentSalt) rand.Read(serpentIV)
rand.Read(nonce) rand.Read(nonce)
// Encode values with Reed-Solomon and write to file // Encode values with Reed-Solomon and write to file
_, errs[4] = fout.Write(rsEncode(rs16, salt)) _, errs[4] = fout.Write(rsEncode(rs16, salt))
_, errs[5] = fout.Write(rsEncode(rs32, hkdfSalt)) _, errs[5] = fout.Write(rsEncode(rs32, hkdfSalt))
_, errs[6] = fout.Write(rsEncode(rs16, serpentSalt)) _, errs[6] = fout.Write(rsEncode(rs16, serpentIV))
_, errs[7] = fout.Write(rsEncode(rs24, nonce)) _, errs[7] = fout.Write(rsEncode(rs24, nonce))
// Write placeholders for future use // Write placeholders for future use
@ -1204,9 +1207,9 @@ func work() {
fin.Read(hkdfSalt) fin.Read(hkdfSalt)
hkdfSalt, errs[4] = rsDecode(rs32, hkdfSalt) hkdfSalt, errs[4] = rsDecode(rs32, hkdfSalt)
serpentSalt = make([]byte, 48) serpentIV = make([]byte, 48)
fin.Read(serpentSalt) fin.Read(serpentIV)
serpentSalt, errs[5] = rsDecode(rs16, serpentSalt) serpentIV, errs[5] = rsDecode(rs16, serpentIV)
nonce = make([]byte, 72) nonce = make([]byte, 72)
fin.Read(nonce) fin.Read(nonce)
@ -1383,11 +1386,11 @@ func work() {
mac, _ = blake2b.New512(subkey) // Keyed BLAKE2b mac, _ = blake2b.New512(subkey) // Keyed BLAKE2b
} }
// Generate another subkey for use as Serpent's salt // Generate another subkey for use as Serpent's key
serpentKey := make([]byte, 32) serpentKey := make([]byte, 32)
hkdf.Read(serpentKey) hkdf.Read(serpentKey)
s, _ := serpent.NewCipher(serpentKey) s, _ := serpent.NewCipher(serpentKey)
serpent := cipher.NewCTR(s, serpentSalt) serpent := cipher.NewCTR(s, serpentIV)
// Start the main encryption process // Start the main encryption process
canCancel = true canCancel = true
@ -1551,7 +1554,7 @@ func work() {
} }
giu.Update() giu.Update()
// Change values after 60 GiB to prevent overflow // Change nonce/IV after 60 GiB to prevent overflow
if counter >= 60*GiB { if counter >= 60*GiB {
// ChaCha20 // ChaCha20
nonce = make([]byte, 24) nonce = make([]byte, 24)
@ -1559,9 +1562,9 @@ func work() {
chacha, _ = chacha20.NewUnauthenticatedCipher(key, nonce) chacha, _ = chacha20.NewUnauthenticatedCipher(key, nonce)
// Serpent // Serpent
serpentSalt = make([]byte, 16) serpentIV = make([]byte, 16)
hkdf.Read(serpentSalt) hkdf.Read(serpentIV)
serpent = cipher.NewCTR(s, serpentSalt) serpent = cipher.NewCTR(s, serpentIV)
// Reset counter to 0 // Reset counter to 0
counter = 0 counter = 0
@ -1967,6 +1970,13 @@ func sizeify(size int64) string {
} }
func main() { func main() {
// Set DPI awareness to system aware (value of 1)
if runtime.GOOS == "windows" {
shcore := syscall.NewLazyDLL("Shcore.dll")
shproc := shcore.NewProc("SetProcessDpiAwareness")
shproc.Call(uintptr(1))
}
// Create the main window // Create the main window
window = giu.NewMasterWindow("Picocrypt", 318, 479, giu.MasterWindowFlagsNotResizable) window = giu.NewMasterWindow("Picocrypt", 318, 479, giu.MasterWindowFlagsNotResizable)