payload almost done
This commit is contained in:
1 parent
77bfcba5b1
commit
09d0f237d5
16 files changed
+690
-118
No files matched your search
@@ -0,0 +1,48 @@
|
||||
package payload
|
||||
|
||||
import (
|
||||
"crypto/cipher"
|
||||
"crypto/des"
|
||||
"github.com/didiercrunch/ecrypto/helper"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func getAnyBlock() cipher.Block {
|
||||
block, err := des.NewTripleDESCipher(helper.Range(24))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return block
|
||||
}
|
||||
|
||||
func TestGetEncryptorStreamError(t *testing.T) {
|
||||
var foo BlockMode = "some_shit"
|
||||
if _, err := foo.GetEncryptorStream(); err == nil {
|
||||
t.Error("should have an error here")
|
||||
} else if err.Error() != "BlockMode 'some_shit' is not available" {
|
||||
t.Error("bad error message")
|
||||
}
|
||||
}
|
||||
|
||||
func TestOFB(t *testing.T) {
|
||||
_, err := OFB.GetEncryptorStream()
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCreateIV(t *testing.T) {
|
||||
block := getAnyBlock()
|
||||
if iv, err := createIV(block, helper.NewMockRandomReader()); err != nil {
|
||||
t.Error(err)
|
||||
} else if len(iv) != block.BlockSize() {
|
||||
t.Error("bad iv length")
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetCipherStream(t *testing.T) {
|
||||
block := getAnyBlock()
|
||||
if _, _, err := OFB.GetCipherStream(block, helper.NewMockRandomReader()); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user