-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"},