aere-quantum/crypto-inventory/test/fixturi/go/crypto.go

31 lines
1.1 KiB
Go

// Fixtura: Go. In Go un import nefolosit nu compileaza, deci importul e dovada de folosire.
package fixturi
import (
"crypto/ecdsa"
"crypto/elliptic"
"crypto/hmac"
"crypto/md5"
"crypto/mlkem"
"crypto/rand"
"crypto/rsa"
"crypto/sha1"
"crypto/sha256" // EXPECT: SHA-256 | quantum-safe
"crypto/tls"
_ "crypto/sha512" // EXPECT: SHA-512 | quantum-safe
)
func Exemple(data []byte) {
k, _ := rsa.GenerateKey(rand.Reader, 3072) // EXPECT: RSA-3072 | quantum-vulnerable
e, _ := ecdsa.GenerateKey(elliptic.P256(), rand.Reader) // EXPECT: ECDSA-secp256r1 | quantum-vulnerable
s := md5.Sum(data) // EXPECT: MD5 | weak-now
m := hmac.New(sha1.New, data) // EXPECT: HMAC-SHA-1 | weak-now
dk, _ := mlkem.GenerateKey768() // EXPECT: ML-KEM-768 | quantum-safe
cfg := &tls.Config{
MinVersion: tls.VersionTLS12, // EXPECT: TLSv1.2 | quantum-vulnerable
CurvePreferences: []tls.CurveID{tls.X25519MLKEM768, tls.CurveP256}, // EXPECT: X25519MLKEM768 | quantum-safe ; ECDH-secp256r1 | quantum-vulnerable
}
f := sha256.New
_, _, _, _, _, _, _ = k, e, s, m, dk, cfg, f
}