Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(3010)

Unified Diff: src/pkg/crypto/des/des_test.go

Issue 5625045: code review 5625045: crypto/...: more fixes for bug 2841 (Closed)
Patch Set: diff -r ab8a2146f8f1 https://go.googlecode.com/hg/ Created 13 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/pkg/crypto/des/cipher.go ('k') | src/pkg/crypto/dsa/dsa.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pkg/crypto/des/des_test.go
===================================================================
--- a/src/pkg/crypto/des/des_test.go
+++ b/src/pkg/crypto/des/des_test.go
@@ -1260,11 +1260,19 @@
[]byte{0x63, 0xfa, 0xc0, 0xd0, 0x34, 0xd9, 0xf7, 0x93}},
}
+func newCipher(key []byte) *desCipher {
+ c, err := NewCipher(key)
+ if err != nil {
+ panic("NewCipher failed: " + err.Error())
+ }
+ return c.(*desCipher)
+}
+
// Use the known weak keys to test DES implementation
func TestWeakKeys(t *testing.T) {
for i, tt := range weakKeyTests {
var encrypt = func(in []byte) (out []byte) {
- c, _ := NewCipher(tt.key)
+ c := newCipher(tt.key)
out = make([]byte, len(in))
encryptBlock(c.subkeys[:], out, in)
return
@@ -1285,7 +1293,7 @@
func TestSemiWeakKeyPairs(t *testing.T) {
for i, tt := range semiWeakKeyTests {
var encrypt = func(key, in []byte) (out []byte) {
- c, _ := NewCipher(key)
+ c := newCipher(key)
out = make([]byte, len(in))
encryptBlock(c.subkeys[:], out, in)
return
@@ -1305,7 +1313,7 @@
func TestDESEncryptBlock(t *testing.T) {
for i, tt := range encryptDESTests {
- c, _ := NewCipher(tt.key)
+ c := newCipher(tt.key)
out := make([]byte, len(tt.in))
encryptBlock(c.subkeys[:], out, tt.in)
@@ -1317,7 +1325,7 @@
func TestDESDecryptBlock(t *testing.T) {
for i, tt := range encryptDESTests {
- c, _ := NewCipher(tt.key)
+ c := newCipher(tt.key)
plain := make([]byte, len(tt.in))
decryptBlock(c.subkeys[:], plain, tt.out)
« no previous file with comments | « src/pkg/crypto/des/cipher.go ('k') | src/pkg/crypto/dsa/dsa.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b