summaryrefslogtreecommitdiffstats
path: root/internal/cryptokit/cryptokit_test.go
diff options
context:
space:
mode:
authorGab Virebent <gabriel1@virebent.art>2026-08-23 00:26:27 +0200
committerGab Virebent <gabriel1@virebent.art>2026-08-23 00:26:27 +0200
commitbdb8a02bbb3dc0d7c39f5b3ec451abb68e9d093d (patch)
tree796d246f9874641717b5e81a72989961e65a9b9f /internal/cryptokit/cryptokit_test.go
parentc1decadb590c4d79d92bcc4df7772119a5c91244 (diff)
downloadaegis-bdb8a02bbb3dc0d7c39f5b3ec451abb68e9d093d.tar.gz
aegis-bdb8a02bbb3dc0d7c39f5b3ec451abb68e9d093d.tar.xz
aegis-bdb8a02bbb3dc0d7c39f5b3ec451abb68e9d093d.zip
Simplify Usenet posting to signing onlyHEADmain
Diffstat (limited to 'internal/cryptokit/cryptokit_test.go')
-rw-r--r--internal/cryptokit/cryptokit_test.go109
1 files changed, 0 insertions, 109 deletions
diff --git a/internal/cryptokit/cryptokit_test.go b/internal/cryptokit/cryptokit_test.go
index 928120e..cc771c2 100644
--- a/internal/cryptokit/cryptokit_test.go
+++ b/internal/cryptokit/cryptokit_test.go
@@ -1,18 +1,10 @@
package cryptokit
import (
- "bytes"
"crypto/ed25519"
"crypto/rand"
- "crypto/rsa"
"encoding/base64"
- "encoding/pem"
- "os"
- "os/exec"
"testing"
-
- "filippo.io/age"
- "golang.org/x/crypto/ssh"
)
func TestEd25519SignVerifyAcceptsSeedEncoding(t *testing.T) {
@@ -53,104 +45,3 @@ func TestEd25519PublicKeyAndFingerprint(t *testing.T) {
t.Fatalf("unexpected fingerprint %q", fingerprint)
}
}
-
-func TestAgeRoundTrip(t *testing.T) {
- identity, err := age.GenerateX25519Identity()
- if err != nil {
- t.Fatal(err)
- }
- ciphertext, err := EncryptAge([]byte("age test"), identity.Recipient().String())
- if err != nil {
- t.Fatal(err)
- }
- plaintext, err := DecryptAge(ciphertext, identity.String())
- if err != nil {
- t.Fatal(err)
- }
- if string(plaintext) != "age test" {
- t.Fatalf("unexpected plaintext %q", plaintext)
- }
-}
-
-func TestAgeSSHCompatibility(t *testing.T) {
- testKey := func(private any) {
- signer, err := ssh.NewSignerFromKey(private)
- if err != nil {
- t.Fatal(err)
- }
- privatePEM, err := ssh.MarshalPrivateKey(private, "")
- if err != nil {
- t.Fatal(err)
- }
- ciphertext, err := EncryptAge([]byte("age SSH test"), string(ssh.MarshalAuthorizedKey(signer.PublicKey())))
- if err != nil {
- t.Fatal(err)
- }
- plaintext, err := DecryptAge(ciphertext, string(pem.EncodeToMemory(privatePEM)))
- if err != nil {
- t.Fatal(err)
- }
- if string(plaintext) != "age SSH test" {
- t.Fatalf("unexpected plaintext %q", plaintext)
- }
- }
- _, edPrivate, err := ed25519.GenerateKey(rand.Reader)
- if err != nil {
- t.Fatal(err)
- }
- testKey(edPrivate)
- rsaPrivate, err := rsa.GenerateKey(rand.Reader, 2048)
- if err != nil {
- t.Fatal(err)
- }
- testKey(rsaPrivate)
-}
-
-func TestOpenPGPRoundTripWithUserKeyMaterial(t *testing.T) {
- gpg, err := exec.LookPath("gpg")
- if err != nil {
- t.Skip("gpg is not installed")
- }
- home := t.TempDir()
- if err := os.Chmod(home, 0o700); err != nil {
- t.Fatal(err)
- }
- run := func(args []string, input []byte) ([]byte, error) {
- cmd := exec.Command(gpg, append([]string{"--batch", "--no-tty", "--no-options", "--homedir", home}, args...)...)
- cmd.Stdin = bytes.NewReader(input)
- return cmd.Output()
- }
- if _, err := run([]string{"--pinentry-mode", "loopback", "--passphrase", "", "--quick-generate-key", "Aegis Test <aegis@example.invalid>", "rsa2048", "sign", "1d"}, nil); err != nil {
- t.Skipf("gpg cannot create an ephemeral test key: %v", err)
- }
- if _, err := run([]string{"--pinentry-mode", "loopback", "--passphrase", "", "--quick-add-key", "aegis@example.invalid", "rsa2048", "encrypt", "1d"}, nil); err != nil {
- t.Skipf("gpg cannot create an ephemeral encryption subkey: %v", err)
- }
- publicKey, err := run([]string{"--armor", "--export", "aegis@example.invalid"}, nil)
- if err != nil {
- t.Fatal(err)
- }
- privateKey, err := run([]string{"--armor", "--export-secret-keys", "aegis@example.invalid"}, nil)
- if err != nil {
- t.Fatal(err)
- }
- message := []byte("OpenPGP compatibility test")
- signature, err := SignOpenPGPDetached(message, string(privateKey))
- if err != nil {
- t.Fatal(err)
- }
- if err := VerifyOpenPGPDetached(message, signature, string(publicKey)); err != nil {
- t.Fatal(err)
- }
- ciphertext, err := EncryptOpenPGP(message, string(publicKey), string(privateKey))
- if err != nil {
- t.Fatal(err)
- }
- plaintext, err := DecryptOpenPGP([]byte(ciphertext), string(privateKey))
- if err != nil {
- t.Fatal(err)
- }
- if string(plaintext) != string(message) {
- t.Fatalf("unexpected plaintext %q", plaintext)
- }
-}