]> git.lizzy.rs Git - go-anidb.git/blobdiff - udp/aes_test.go
anidb: Add missing loop 'break's to EpisodeByEID
[go-anidb.git] / udp / aes_test.go
index b3d09f79b34a9c8f905e588d2f4a9f7705b01ba9..ddd7c6a8e7102c0a46d72f7514a0a939857f1b14 100755 (executable)
@@ -1,10 +1,41 @@
-package udp
+package udpapi
 
 import (
+       "math/rand"
+       "reflect"
        "testing"
 )
 
+func TestECB(T *testing.T) {
+       T.Parallel()
+
+       rnd := rand.New(rand.NewSource(31415))
+
+       salt := make([]byte, rnd.Intn(64))
+       for i := range salt {
+               salt[i] = byte(rnd.Intn(255))
+       }
+       plain := make([]byte, 1200+rnd.Intn(200))
+       for i := range plain {
+               plain[i] = byte(rnd.Intn(255))
+       }
+
+       ecbState := newECBState("agaa", salt)
+
+       T.Log("Length of plaintext:", len(plain))
+       cipher := ecbState.Encrypt(plain)
+       T.Log("Length of ciphertext:", len(cipher))
+       plain2 := ecbState.Decrypt(cipher)
+       T.Log("Length of roundtrip plaintext:", len(plain2))
+
+       if !reflect.DeepEqual(plain, plain2) {
+               T.Error("Encoding roundtrip result doesn't match plaintext")
+       }
+}
+
 func TestPKCS7(T *testing.T) {
+       T.Parallel()
+
        blockSize := byte(4)
        vec := [][2]string{
                [2]string{"testing", "testing\x01"},