Skip to content

Commit

Permalink
Added Functions V
Browse files Browse the repository at this point in the history
  • Loading branch information
pedroalbanese authored Nov 17, 2023
1 parent 9db55d1 commit 7472e76
Showing 1 changed file with 44 additions and 49 deletions.
93 changes: 44 additions & 49 deletions cmd/edgetk/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,21 +253,23 @@ Key Derivation Functions:
argon2 (phs/kdf) makwa (phs)
Message Athentication Codes:
hmac cmac gmac pmac
vmac poly1305 zuc128/eia128 zuc256/eia256
gost chaskey siphash xoodyak
chaskey hmac siphash64 xoodyak
cmac pmac skein zuc128/eia128
gmac poly1305 vmac zuc256/eia256
gost siphash
Message Digests:
blake2b256 keccak512 rmd256 sha3-512
blake2b512 lsh224 rmd320 siphash
blake2s128 (MAC) lsh256 sha224 siphash64
blake2s256 lsh384 sha256 (default) skein256
blake3 lsh512 sha384 skein512
cubehash lsh512-256 sha512 sm3
gost94 md4 [obsolete] sha512-256 streebog256
groestl md5 [obsolete] sha3-224 streebog512
jh rmd128 sha3-256 whirlpool
keccak256 rmd160 sha3-384 xoodyak`)
blake2b256 jh rmd160 sha3-384
blake2b512 keccak256 rmd256 sha3-512
blake2s128 (MAC) keccak512 rmd320 siphash
blake2s256 lsh224 sha1 [obsolete] siphash64
blake3 lsh256 sha224 skein256
cubehash lsh384 sha256 (default) skein512
gost94 lsh512 sha384 sm3
groestl lsh512-256 sha512 streebog256
haraka256 md4 [obsolete] sha512-256 streebog512
haraka512 md5 [obsolete] sha3-224 whirlpool
has160 rmd128 sha3-256 xoodyak`)
os.Exit(3)
}

Expand Down Expand Up @@ -625,6 +627,10 @@ Subcommands:
*length = 256
}

if *mac == "skein" && *length == 0 {
*length = 256
}

if *cph == "3des" && *pkey != "keygen" && *length != 192 && *crypt != "" {
*length = 192
}
Expand Down Expand Up @@ -658,7 +664,7 @@ Subcommands:
}

if strings.ToUpper(*alg) == "RSA" && *pkey == "keygen" && *length == 0 {
*length = 2048
*length = 3072
}

if strings.ToUpper(*alg) == "MAKWA" && *length == 0 {
Expand Down Expand Up @@ -2194,24 +2200,7 @@ Subcommands:
if *alg == "sphincs" && *pkey == "verify" {
verifySignature(inputfile)
}
/*
var maxPlainTextSizeInBits int
if *md == "haraka" || *md == "haraka256" || *md == "haraka512" {
if *md == "haraka512" {
maxPlainTextSizeInBits = 512
} else {
maxPlainTextSizeInBits = 256
}
plainTextBytes, err := ioutil.ReadAll(inputfile)
if err != nil {
log.Fatal(err)
}
plainTextSizeInBits := len(plainTextBytes) * 8
if plainTextSizeInBits > maxPlainTextSizeInBits {
println("Alert: The plain text exceeds 256 bits!")
}
}
*/

if *digest && (*md == "haraka" || *md == "haraka256") {
xkey := new([32]byte)
gkey := new([32]byte)
Expand All @@ -2236,7 +2225,7 @@ Subcommands:
log.Fatal(err)
}
if len(b)*8 > 512 {
fmt.Fprintf(os.Stderr, "Alert: The plain text exceeds 256 bits!\n")
fmt.Fprintf(os.Stderr, "Alert: The plain text exceeds 512 bits!\n")
}
copy(xkey[:], b)
haraka.Haraka512(gkey, xkey)
Expand Down Expand Up @@ -2839,7 +2828,7 @@ Subcommands:

if *mac == "skein" {
var err error
h := skeincipher.NewMAC(32, []byte(*key))
h := skeincipher.NewMAC(uint64(*length/8), []byte(*key))
if _, err = io.Copy(h, inputfile); err != nil {
log.Fatal(err)
}
Expand Down Expand Up @@ -3189,6 +3178,26 @@ Subcommands:
if err != nil {
log.Fatal(err)
}
} else if *cph == "threefish512" {
var tweak []byte
tweak = make([]byte, 16)
if *info != "" {
tweak = []byte(*info)
}
c, err = threefish.New512([]byte(*key), tweak)
if err != nil {
log.Fatal(err)
}
} else if *cph == "threefish1024" {
var tweak []byte
tweak = make([]byte, 16)
if *info != "" {
tweak = []byte(*info)
}
c, err = threefish.New1024([]byte(*key), tweak)
if err != nil {
log.Fatal(err)
}
}
if err != nil {
log.Fatal(err)
Expand Down Expand Up @@ -5052,21 +5061,7 @@ Subcommands:
}
os.Exit(0)
}
/*
if *pkey == "keygen" && strings.ToUpper(*alg) == "RSA" {
bar := pb.StartNew(*length)
go func() {
GenerateRsaKey(*length)
os.Exit(0)
}()
for i := 0; i < *length; i++ {
time.Sleep(time.Millisecond * 3)
bar.Increment()
}
select {}
os.Exit(0)
}
*/

if *pkey == "keygen" && strings.ToUpper(*alg) == "RSA" {
GenerateRsaKey(*length)
os.Exit(0)
Expand Down

0 comments on commit 7472e76

Please sign in to comment.