summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortb <>2018-08-28 18:25:33 +0000
committertb <>2018-08-28 18:25:33 +0000
commitb6220631528c7c26f70cbdc98066b7bfb5565498 (patch)
tree4650ab6da722b9b98a327d074bdbdff0d0ed6837 /src
parentcfa3143bb2b75cb11f87b2c18d88b74bf4570539 (diff)
downloadopenbsd-b6220631528c7c26f70cbdc98066b7bfb5565498.tar.gz
openbsd-b6220631528c7c26f70cbdc98066b7bfb5565498.tar.bz2
openbsd-b6220631528c7c26f70cbdc98066b7bfb5565498.zip
remove some extra parens and fix some other formatting issues
pointed out by gofmt (thanks anton)
Diffstat (limited to 'src')
-rw-r--r--src/regress/lib/libcrypto/wycheproof/wycheproof.go34
1 files changed, 17 insertions, 17 deletions
diff --git a/src/regress/lib/libcrypto/wycheproof/wycheproof.go b/src/regress/lib/libcrypto/wycheproof/wycheproof.go
index 0cb0ddf65f..2f1ef5d716 100644
--- a/src/regress/lib/libcrypto/wycheproof/wycheproof.go
+++ b/src/regress/lib/libcrypto/wycheproof/wycheproof.go
@@ -1,4 +1,4 @@
1/* $OpenBSD: wycheproof.go,v 1.29 2018/08/28 17:45:50 tb Exp $ */ 1/* $OpenBSD: wycheproof.go,v 1.30 2018/08/28 18:25:33 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2018 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2018 Joel Sing <jsing@openbsd.org>
4 * Copyright (c) 2018 Theo Buehler <tb@openbsd.org> 4 * Copyright (c) 2018 Theo Buehler <tb@openbsd.org>
@@ -104,7 +104,7 @@ type wycheproofTestGroupChaCha20Poly1305 struct {
104} 104}
105 105
106type wycheproofTestChaCha20Poly1305 struct { 106type wycheproofTestChaCha20Poly1305 struct {
107 TCID int `json:"tcId"` 107 TCID int `json:"tcId"`
108 Comment string `json:"comment"` 108 Comment string `json:"comment"`
109 Key string `json:"key"` 109 Key string `json:"key"`
110 IV string `json:"iv"` 110 IV string `json:"iv"`
@@ -112,7 +112,7 @@ type wycheproofTestChaCha20Poly1305 struct {
112 Msg string `json:"msg"` 112 Msg string `json:"msg"`
113 CT string `json:"ct"` 113 CT string `json:"ct"`
114 Tag string `json:"tag"` 114 Tag string `json:"tag"`
115 Result string `json:"result"` 115 Result string `json:"result"`
116 Flags []string `json:"flags"` 116 Flags []string `json:"flags"`
117} 117}
118 118
@@ -340,16 +340,16 @@ func runAesCbcPkcs5Test(ctx *C.EVP_CIPHER_CTX, wt *wycheproofTestAesCbcPkcs5) bo
340 340
341 keyLen, ivLen, ctLen, msgLen := len(key), len(iv), len(ct), len(msg) 341 keyLen, ivLen, ctLen, msgLen := len(key), len(iv), len(ct), len(msg)
342 342
343 if (keyLen == 0) { 343 if keyLen == 0 {
344 key = append(key, 0) 344 key = append(key, 0)
345 } 345 }
346 if (ivLen == 0) { 346 if ivLen == 0 {
347 iv = append(iv, 0) 347 iv = append(iv, 0)
348 } 348 }
349 if (ctLen == 0) { 349 if ctLen == 0 {
350 ct = append(ct, 0) 350 ct = append(ct, 0)
351 } 351 }
352 if (msgLen == 0) { 352 if msgLen == 0 {
353 msg = append(msg, 0) 353 msg = append(msg, 0)
354 } 354 }
355 355
@@ -412,7 +412,7 @@ func checkAesCcm(ctx *C.EVP_CIPHER_CTX, doEncrypt int, key []byte, keyLen int, i
412 412
413 ret = C.EVP_CIPHER_CTX_ctrl(ctx, C.EVP_CTRL_CCM_SET_IVLEN, C.int(ivLen), nil) 413 ret = C.EVP_CIPHER_CTX_ctrl(ctx, C.EVP_CTRL_CCM_SET_IVLEN, C.int(ivLen), nil)
414 if ret != 1 { 414 if ret != 1 {
415 if (wt.Comment == "Nonce is too long" || wt.Comment == "Invalid nonce size") { 415 if wt.Comment == "Nonce is too long" || wt.Comment == "Invalid nonce size" {
416 return true 416 return true
417 } 417 }
418 fmt.Printf("FAIL: Test case %d (%q) [%v] - setting IV len to %d failed. got %d, want %v\n", wt.TCID, wt.Comment, action, ivLen, ret, wt.Result) 418 fmt.Printf("FAIL: Test case %d (%q) [%v] - setting IV len to %d failed. got %d, want %v\n", wt.TCID, wt.Comment, action, ivLen, ret, wt.Result)
@@ -421,7 +421,7 @@ func checkAesCcm(ctx *C.EVP_CIPHER_CTX, doEncrypt int, key []byte, keyLen int, i
421 421
422 ret = C.EVP_CIPHER_CTX_ctrl(ctx, C.EVP_CTRL_CCM_SET_TAG, C.int(tagLen), setTag) 422 ret = C.EVP_CIPHER_CTX_ctrl(ctx, C.EVP_CTRL_CCM_SET_TAG, C.int(tagLen), setTag)
423 if ret != 1 { 423 if ret != 1 {
424 if (wt.Comment == "Invalid tag size") { 424 if wt.Comment == "Invalid tag size" {
425 return true 425 return true
426 } 426 }
427 fmt.Printf("FAIL: Test case %d (%q) [%v] - setting tag length to %d failed. got %d, want %v\n", wt.TCID, wt.Comment, action, tagLen, ret, wt.Result) 427 fmt.Printf("FAIL: Test case %d (%q) [%v] - setting tag length to %d failed. got %d, want %v\n", wt.TCID, wt.Comment, action, tagLen, ret, wt.Result)
@@ -582,18 +582,18 @@ func checkChaCha20Poly1305Open(ctx *C.EVP_AEAD_CTX, iv []byte, ivLen int, aad []
582 return false 582 return false
583 } 583 }
584 584
585 if (openedMsgLen != C.size_t(msgLen)) { 585 if openedMsgLen != C.size_t(msgLen) {
586 fmt.Printf("FAIL: Test case %d (%q) - open length mismatch: got %d, want %d\n", wt.TCID, wt.Comment, openedMsgLen, msgLen) 586 fmt.Printf("FAIL: Test case %d (%q) - open length mismatch: got %d, want %d\n", wt.TCID, wt.Comment, openedMsgLen, msgLen)
587 return false 587 return false
588 } 588 }
589 589
590 openedMsg := opened[0:openedMsgLen] 590 openedMsg := opened[0:openedMsgLen]
591 if (msgLen == 0) { 591 if msgLen == 0 {
592 msg = nil 592 msg = nil
593 } 593 }
594 594
595 success := false 595 success := false
596 if (bytes.Equal(openedMsg, msg)) || wt.Result == "invalid" { 596 if bytes.Equal(openedMsg, msg) || wt.Result == "invalid" {
597 success = true 597 success = true
598 } else { 598 } else {
599 fmt.Printf("FAIL: Test case %d (%q) - msg match: %t; want %v\n", wt.TCID, wt.Comment, bytes.Equal(openedMsg, msg), wt.Result) 599 fmt.Printf("FAIL: Test case %d (%q) - msg match: %t; want %v\n", wt.TCID, wt.Comment, bytes.Equal(openedMsg, msg), wt.Result)
@@ -614,16 +614,16 @@ func checkChaCha20Poly1305Seal(ctx *C.EVP_AEAD_CTX, iv []byte, ivLen int, aad []
614 return false 614 return false
615 } 615 }
616 616
617 if (sealedLen != C.size_t(maxOutLen)) { 617 if sealedLen != C.size_t(maxOutLen) {
618 fmt.Printf("FAIL: Test case %d (%q) - seal length mismatch: got %d, want %d\n", wt.TCID, wt.Comment, sealedLen, maxOutLen) 618 fmt.Printf("FAIL: Test case %d (%q) - seal length mismatch: got %d, want %d\n", wt.TCID, wt.Comment, sealedLen, maxOutLen)
619 return false 619 return false
620 } 620 }
621 621
622 sealedCt := sealed[0:msgLen] 622 sealedCt := sealed[0:msgLen]
623 sealedTag := sealed[msgLen: maxOutLen] 623 sealedTag := sealed[msgLen:maxOutLen]
624 624
625 success := false 625 success := false
626 if (bytes.Equal(sealedCt, ct) && bytes.Equal(sealedTag, tag)) || wt.Result == "invalid" { 626 if bytes.Equal(sealedCt, ct) && bytes.Equal(sealedTag, tag) || wt.Result == "invalid" {
627 success = true 627 success = true
628 } else { 628 } else {
629 fmt.Printf("FAIL: Test case %d (%q) - EVP_AEAD_CTX_seal() = %d, ct match: %t, tag match: %t; want %v\n", wt.TCID, wt.Comment, int(sealRet), bytes.Equal(sealedCt, ct), bytes.Equal(sealedTag, tag), wt.Result) 629 fmt.Printf("FAIL: Test case %d (%q) - EVP_AEAD_CTX_seal() = %d, ct match: %t, tag match: %t; want %v\n", wt.TCID, wt.Comment, int(sealRet), bytes.Equal(sealedCt, ct), bytes.Equal(sealedTag, tag), wt.Result)
@@ -806,7 +806,7 @@ func runDSATestGroup(wtg *wycheproofTestGroupDSA) bool {
806 der = append(der, 0) 806 der = append(der, 0)
807 } 807 }
808 808
809 Cder := (*C.uchar)(C.malloc((C.ulong)(derLen))) 809 Cder := (*C.uchar)(C.malloc(C.ulong(derLen)))
810 if Cder == nil { 810 if Cder == nil {
811 log.Fatal("malloc failed") 811 log.Fatal("malloc failed")
812 } 812 }
@@ -818,7 +818,7 @@ func runDSATestGroup(wtg *wycheproofTestGroupDSA) bool {
818 C.free(unsafe.Pointer(Cder)) 818 C.free(unsafe.Pointer(Cder))
819 819
820 820
821 keyPEM := C.CString(wtg.KeyPEM); 821 keyPEM := C.CString(wtg.KeyPEM)
822 bio := C.BIO_new_mem_buf(unsafe.Pointer(keyPEM), C.int(len(wtg.KeyPEM))) 822 bio := C.BIO_new_mem_buf(unsafe.Pointer(keyPEM), C.int(len(wtg.KeyPEM)))
823 if bio == nil { 823 if bio == nil {
824 log.Fatal("BIO_new_mem_buf failed") 824 log.Fatal("BIO_new_mem_buf failed")